Index: trunk/tools/ToolserverI18N/TsIntuition.php |
— | — | @@ -772,21 +772,22 @@ |
773 | 773 | * |
774 | 774 | * @return boolean |
775 | 775 | */ |
776 | | - public function setCookie( $name, $val, $lifetime = 2592000 /* 30 days */, $track = true ) { |
| 776 | + public function setCookie( $key, $val, $lifetime = 2592000 /* 30 days */, $track = TSINT_COOKIE_TRACK ) { |
777 | 777 | // Validate cookie name |
778 | | - $name = $this->getCookieName( $name ); |
| 778 | + $name = $this->getCookieName( $key ); |
779 | 779 | if ( !$name ) { |
780 | 780 | return false; |
781 | 781 | } |
| 782 | + |
782 | 783 | $val = strval( $val ); |
783 | 784 | $lifetime = intval( $lifetime ); |
784 | 785 | $expire = time() + $lifetime; |
785 | 786 | |
786 | 787 | // Set a 30-day domain-wide cookie |
787 | | - setcookie( $name, $val, $expire, '/', '.toolserver.org' ); |
| 788 | + setcookie( $name, $val, $expire, '/' ); |
788 | 789 | |
789 | 790 | // In order to keep track of the expiration date, we set another cookie |
790 | | - if ( $track ) { |
| 791 | + if ( $track === TSINT_COOKIE_TRACK ) { |
791 | 792 | $this->setExpiryTrackerCookie( $lifetime ); |
792 | 793 | } |
793 | 794 | |
— | — | @@ -798,8 +799,8 @@ |
799 | 800 | * In order to keep track of the expiration date, we set an additional cookie. |
800 | 801 | */ |
801 | 802 | private function setExpiryTrackerCookie( $lifetime ) { |
802 | | - $expire = time() + intval( $lifetime ); |
803 | | - setcookie( $this->getCookieName( 'track-expire' ), $expire, $expire, '/', '.toolserver.org' ); |
| 803 | + $val = time() + $lifetime; |
| 804 | + $this->setCookie( 'track-expire', $val, $lifetime, TSINT_COOKIE_NOTRACK ); |
804 | 805 | return true; |
805 | 806 | } |
806 | 807 | |
— | — | @@ -807,8 +808,11 @@ |
808 | 809 | * Renew all cookies |
809 | 810 | */ |
810 | 811 | public function renewCookies( $lifetime = 2592000 /* 30 days */ ) { |
811 | | - foreach( $this->getCookieNames() as $name ) { |
812 | | - $this->setCookie( $name, $_COOKIE[$name], $lifetime, false ); |
| 812 | + foreach( $this->getCookieNames() as $key => $name ) { |
| 813 | + if ( $key === 'track-expire' ) { |
| 814 | + continue; |
| 815 | + } |
| 816 | + $this->setCookie( $key, $_COOKIE[$name], $lifetime, TSINT_COOKIE_NOTRACK ); |
813 | 817 | } |
814 | 818 | $this->setExpiryTrackerCookie( $lifetime ); |
815 | 819 | return true; |
— | — | @@ -821,8 +825,8 @@ |
822 | 826 | */ |
823 | 827 | public function wipeCookies() { |
824 | 828 | $week = 7 * 24 * 3600; |
825 | | - foreach( $this->getCookieNames() as $name ) { |
826 | | - setcookie( $name, '', time()-$week, '/', '.toolserver.org' ); |
| 829 | + foreach( $this->getCookieNames() as $key => $name ) { |
| 830 | + $this->setCookie( $key, '', 0-$week, TSINT_COOKIE_NOTRACK ); |
827 | 831 | unset( $_COOKIE[$name] ); |
828 | 832 | } |
829 | 833 | return true; |
Index: trunk/tools/ToolserverI18N/public_html/index.php |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | break; |
150 | 150 | case 3: |
151 | 151 | $Tool->addOut( |
152 | | - _( 'renewcookies-success', array( 'variables' => array( '30 ' . _g( 'days' ) ) ) ), |
| 152 | + _( 'renewcookies-success', array( 'variables' => array( '30 ' . _g( 'days', array( 'parsemag' => true, 'variables' => array( 30 ) ) ) ) ) ), |
153 | 153 | 'div', |
154 | 154 | array( 'class' => 'msg ns success' ) |
155 | 155 | ); |
— | — | @@ -167,23 +167,27 @@ |
168 | 168 | // 29+ days |
169 | 169 | if ( $lifetime > 29*24*3600 ) { |
170 | 170 | $class = 'perfect'; |
171 | | - $time = floor( $lifetime/3600/24/7 ) . '+ ' . _g( 'weeks', array( 'parsemag' => true ) ); |
| 171 | + $number = floor( $lifetime/3600/24/7 ); |
| 172 | + $time = $number . '+ ' . _g( 'weeks', array( 'parsemag' => true, 'variables' => array( $number ) ) ); |
172 | 173 | |
173 | 174 | // 10+ days |
174 | 175 | } elseif ( $lifetime > 10*24*3600 ) { |
175 | 176 | $class = 'good'; |
176 | | - $time = floor( $lifetime/3600/24 ) . '+ ' . _g( 'days', array( 'parsemag' => true ) ); |
| 177 | + $number = floor( $lifetime/3600/24 ); |
| 178 | + $time = $number . '+ ' . _g( 'days', array( 'parsemag' => true, 'variables' => array( $number ) ) ); |
177 | 179 | |
178 | 180 | // 1+ day |
179 | 181 | } elseif ( $lifetime > 24*3600 ) { |
180 | 182 | $class = 'bad'; |
181 | | - $time = floor( $lifetime/3600/24 ) . '+ ' . _g( 'days', array( 'parsemag' => true ) ); |
| 183 | + $number = floor( $lifetime/3600/24 ); |
| 184 | + $time = $number . '+ ' . _g( 'days', array( 'parsemag' => true, 'variables' => array( $number ) ) ); |
182 | 185 | $after = $renew; |
183 | 186 | |
184 | 187 | // Less than a day |
185 | 188 | } else { |
186 | 189 | $class = 'worst'; |
187 | | - $time = '<' . ceil( $lifetime/3600 ) . ' ' . _g( 'hours', array( 'parsemag' => true ) ); |
| 190 | + $number = ceil( $lifetime/3600 ); |
| 191 | + $time = '<' . $number . '+ ' . _g( 'hours', array( 'parsemag' => true, 'variables' => array( $number ) ) ); |
188 | 192 | $after = $renew; |
189 | 193 | |
190 | 194 | } |
— | — | @@ -204,7 +208,7 @@ |
205 | 209 | . $after |
206 | 210 | . '</div></fieldset></form></div><!-- #tab-currentsettings -->' |
207 | 211 | ); |
208 | | - $toolSettings['tabs']['#tab-currentsettings'] = _('tab-overview'); |
| 212 | + $toolSettings['tabs']['#tab-currentsettings'] = _( 'tab-overview' ); |
209 | 213 | |
210 | 214 | |
211 | 215 | } |
Index: trunk/tools/ToolserverI18N/Defines.php |
— | — | @@ -13,3 +13,6 @@ |
14 | 14 | define( 'TSINT_HELP_ALL', true ); |
15 | 15 | define( 'TSINT_HELP_NONE', false ); |
16 | 16 | define( 'TSINT_HELP_CURRENT', null ); |
| 17 | + |
| 18 | +define( 'TSINT_COOKIE_TRACK', true ); |
| 19 | +define( 'TSINT_COOKIE_NOTRACK', true ); |