@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | { |
10 | 10 | /* Setup Routine */ |
11 | 11 | $this->_path = PATH . 'data'; |
12 | - if(!is_dir($this->_path)) mkdir($this->_path); |
|
12 | + if (!is_dir($this->_path)) mkdir($this->_path); |
|
13 | 13 | $this->_file = $this->_path . DIRECTORY_SEPARATOR . 'vizhash.png'; |
14 | 14 | serversalt::setPath($this->_path); |
15 | 15 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | /* Tear Down Routine */ |
20 | 20 | chmod($this->_path, 0700); |
21 | - if(!@unlink($this->_file)) { |
|
21 | + if (!@unlink($this->_file)) { |
|
22 | 22 | throw new Exception('Error deleting file "' . $this->_file . '".'); |
23 | 23 | } |
24 | 24 | helper::rmdir($this->_path); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -error_reporting( E_ALL | E_STRICT ); |
|
2 | +error_reporting(E_ALL | E_STRICT); |
|
3 | 3 | |
4 | 4 | // change this, if your php files and data is outside of your webservers document root |
5 | 5 | if (!defined('PUBLIC_PATH')) define('PUBLIC_PATH', '..'); |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | { |
155 | 155 | $path .= DIRECTORY_SEPARATOR; |
156 | 156 | $dir = dir($path); |
157 | - while(false !== ($file = $dir->read())) { |
|
158 | - if($file != '.' && $file != '..') { |
|
159 | - if(is_dir($path . $file)) { |
|
157 | + while (false !== ($file = $dir->read())) { |
|
158 | + if ($file != '.' && $file != '..') { |
|
159 | + if (is_dir($path . $file)) { |
|
160 | 160 | self::rmdir($path . $file); |
161 | - } elseif(is_file($path . $file)) { |
|
162 | - if(!@unlink($path . $file)) { |
|
161 | + } elseif (is_file($path . $file)) { |
|
162 | + if (!@unlink($path . $file)) { |
|
163 | 163 | throw new Exception('Error deleting file "' . $path . $file . '".'); |
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | 168 | $dir->close(); |
169 | - if(!@rmdir($path)) { |
|
169 | + if (!@rmdir($path)) { |
|
170 | 170 | throw new Exception('Error deleting directory "' . $path . '".'); |
171 | 171 | } |
172 | 172 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $ini = fopen($pathToFile, 'a'); |
207 | 207 | foreach ($values as $section => $options) { |
208 | 208 | fwrite($ini, "[$section]" . PHP_EOL); |
209 | - foreach($options as $option => $setting) { |
|
209 | + foreach ($options as $option => $setting) { |
|
210 | 210 | if (is_null($setting)) { |
211 | 211 | continue; |
212 | 212 | } elseif (is_string($setting)) { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | i18n::loadTranslations(); |
32 | 32 | $this->assertEquals($this->_translations['en'], i18n::_('en'), 'browser language de'); |
33 | 33 | $this->assertEquals('0 Stunden', i18n::_('%d hours', 0), '0 hours in german'); |
34 | - $this->assertEquals('1 Stunde', i18n::_('%d hours', 1), '1 hour in german'); |
|
34 | + $this->assertEquals('1 Stunde', i18n::_('%d hours', 1), '1 hour in german'); |
|
35 | 35 | $this->assertEquals('2 Stunden', i18n::_('%d hours', 2), '2 hours in french'); |
36 | 36 | } |
37 | 37 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | i18n::loadTranslations(); |
42 | 42 | $this->assertEquals($this->_translations['en'], i18n::_('en'), 'browser language de'); |
43 | 43 | $this->assertEquals('0 Stunden', i18n::_('%d hours', 0), '0 hours in german'); |
44 | - $this->assertEquals('1 Stunde', i18n::_('%d hours', 1), '1 hour in german'); |
|
44 | + $this->assertEquals('1 Stunde', i18n::_('%d hours', 1), '1 hour in german'); |
|
45 | 45 | $this->assertEquals('2 Stunden', i18n::_('%d hours', 2), '2 hours in french'); |
46 | 46 | } |
47 | 47 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr-CH,fr;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2'; |
51 | 51 | i18n::loadTranslations(); |
52 | 52 | $this->assertEquals('fr', i18n::_('en'), 'browser language fr'); |
53 | - $this->assertEquals('0 heure', i18n::_('%d hours', 0), '0 hours in french'); |
|
54 | - $this->assertEquals('1 heure', i18n::_('%d hours', 1), '1 hour in french'); |
|
53 | + $this->assertEquals('0 heure', i18n::_('%d hours', 0), '0 hours in french'); |
|
54 | + $this->assertEquals('1 heure', i18n::_('%d hours', 1), '1 hour in french'); |
|
55 | 55 | $this->assertEquals('2 heures', i18n::_('%d hours', 2), '2 hours in french'); |
56 | 56 | } |
57 | 57 |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | { |
14 | 14 | /* Setup Routine */ |
15 | 15 | $this->_path = PATH . 'data'; |
16 | - if(!is_dir($this->_path)) mkdir($this->_path); |
|
16 | + if (!is_dir($this->_path)) mkdir($this->_path); |
|
17 | 17 | serversalt::setPath($this->_path); |
18 | 18 | |
19 | 19 | $this->_otherPath = $this->_path . DIRECTORY_SEPARATOR . 'foo'; |
20 | 20 | |
21 | 21 | $this->_invalidPath = $this->_path . DIRECTORY_SEPARATOR . 'bar'; |
22 | - if(!is_dir($this->_invalidPath)) mkdir($this->_invalidPath); |
|
22 | + if (!is_dir($this->_invalidPath)) mkdir($this->_invalidPath); |
|
23 | 23 | $this->_invalidFile = $this->_invalidPath . DIRECTORY_SEPARATOR . 'salt.php'; |
24 | 24 | } |
25 | 25 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | function mcrypt_create_iv($int, $flag) |
44 | 44 | { |
45 | 45 | $randomSalt = ''; |
46 | - for($i = 0; $i < $int; ++$i) { |
|
46 | + for ($i = 0; $i < $int; ++$i) { |
|
47 | 47 | $randomSalt .= base_convert(mt_rand(), 10, 16); |
48 | 48 | } |
49 | 49 | // hex2bin requires an even length, pad if necessary |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | while (list($path, $setting) = each($test['conditions'])) { |
419 | 419 | if ($path == 'steps' && !in_array($step, $setting)) { |
420 | 420 | continue 2; |
421 | - } elseif($path != 'steps') { |
|
421 | + } elseif ($path != 'steps') { |
|
422 | 422 | list($section, $option) = explode('/', $path); |
423 | 423 | if ($fullOptions[$section][$option] !== $setting) { |
424 | 424 | continue 2; |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | private function _getFunction($step, $key, &$options, $preCode, $testCode) |
513 | 513 | { |
514 | 514 | if (count($testCode) == 0) { |
515 | - echo "skipping creation of test$step$key, no valid tests found for configuration: $options". PHP_EOL; |
|
515 | + echo "skipping creation of test$step$key, no valid tests found for configuration: $options" . PHP_EOL; |
|
516 | 516 | return ''; |
517 | 517 | } |
518 | 518 |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $response['deletetoken'], |
297 | 297 | 'outputs valid delete token' |
298 | 298 | ); |
299 | - $this->assertGreaterThanOrEqual($time + 300, $paste->meta->expire_date, 'time is set correctly'); |
|
299 | + $this->assertGreaterThanOrEqual($time+300, $paste->meta->expire_date, 'time is set correctly'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $response['deletetoken'], |
329 | 329 | 'outputs valid delete token' |
330 | 330 | ); |
331 | - $this->assertGreaterThanOrEqual($time + 300, $paste->meta->expire_date, 'time is set correctly'); |
|
331 | + $this->assertGreaterThanOrEqual($time+300, $paste->meta->expire_date, 'time is set correctly'); |
|
332 | 332 | $this->assertEquals(1, $paste->meta->opendiscussion, 'discussion is enabled'); |
333 | 333 | } |
334 | 334 |
@@ -115,15 +115,15 @@ |
||
115 | 115 | $tl = $GLOBALS['traffic_limiter']; |
116 | 116 | |
117 | 117 | // purge file of expired IPs to keep it small |
118 | - foreach($tl as $key => $time) |
|
118 | + foreach ($tl as $key => $time) |
|
119 | 119 | { |
120 | - if ($time + self::$_limit < $now) |
|
120 | + if ($time+self::$_limit < $now) |
|
121 | 121 | { |
122 | 122 | unset($tl[$key]); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if (array_key_exists($ip, $tl) && ($tl[$ip] + self::$_limit >= $now)) |
|
126 | + if (array_key_exists($ip, $tl) && ($tl[$ip]+self::$_limit >= $now)) |
|
127 | 127 | { |
128 | 128 | $result = false; |
129 | 129 | } else { |
@@ -89,38 +89,38 @@ discard block |
||
89 | 89 | if (!function_exists('gd_info')) return ''; |
90 | 90 | |
91 | 91 | // We hash the input string. |
92 | - $hash=hash('sha1',$text.$this->salt).hash('md5',$text.$this->salt); |
|
93 | - $hash=$hash.strrev($hash); # more data to make graphics |
|
92 | + $hash = hash('sha1', $text . $this->salt) . hash('md5', $text . $this->salt); |
|
93 | + $hash = $hash . strrev($hash); # more data to make graphics |
|
94 | 94 | |
95 | 95 | // We convert the hash into an array of integers. |
96 | - $this->VALUES=array(); |
|
97 | - for($i=0; $i<strlen($hash); $i=$i+2){ array_push($this->VALUES,hexdec(substr($hash,$i,2))); } |
|
98 | - $this->VALUES_INDEX=0; // to walk the array. |
|
96 | + $this->VALUES = array(); |
|
97 | + for ($i = 0; $i < strlen($hash); $i = $i+2) { array_push($this->VALUES, hexdec(substr($hash, $i, 2))); } |
|
98 | + $this->VALUES_INDEX = 0; // to walk the array. |
|
99 | 99 | |
100 | 100 | // Then use these integers to drive the creation of an image. |
101 | - $image = imagecreatetruecolor($this->width,$this->height); |
|
101 | + $image = imagecreatetruecolor($this->width, $this->height); |
|
102 | 102 | |
103 | - $r0 = $this->getInt();$r=$r0; |
|
104 | - $g0 = $this->getInt();$g=$g0; |
|
105 | - $b0 = $this->getInt();$b=$b0; |
|
103 | + $r0 = $this->getInt(); $r = $r0; |
|
104 | + $g0 = $this->getInt(); $g = $g0; |
|
105 | + $b0 = $this->getInt(); $b = $b0; |
|
106 | 106 | |
107 | 107 | // First, create an image with a specific gradient background. |
108 | - $op='v'; if (($this->getInt()%2)==0) { $op='h'; }; |
|
109 | - $image = $this->degrade($image,$op,array($r0,$g0,$b0),array(0,0,0)); |
|
108 | + $op = 'v'; if (($this->getInt() % 2) == 0) { $op = 'h'; }; |
|
109 | + $image = $this->degrade($image, $op, array($r0, $g0, $b0), array(0, 0, 0)); |
|
110 | 110 | |
111 | - for($i=0; $i<7; $i=$i+1) |
|
111 | + for ($i = 0; $i < 7; $i = $i+1) |
|
112 | 112 | { |
113 | - $action=$this->getInt(); |
|
114 | - $color = imagecolorallocate($image, $r,$g,$b); |
|
115 | - $r = ($r0 + $this->getInt()/25)%256; |
|
116 | - $g = ($g0 + $this->getInt()/25)%256; |
|
117 | - $b = ($b0 + $this->getInt()/25)%256; |
|
118 | - $r0=$r; $g0=$g; $b0=$b; |
|
119 | - $this->drawshape($image,$action,$color); |
|
113 | + $action = $this->getInt(); |
|
114 | + $color = imagecolorallocate($image, $r, $g, $b); |
|
115 | + $r = ($r0+$this->getInt() / 25) % 256; |
|
116 | + $g = ($g0+$this->getInt() / 25) % 256; |
|
117 | + $b = ($b0+$this->getInt() / 25) % 256; |
|
118 | + $r0 = $r; $g0 = $g; $b0 = $b; |
|
119 | + $this->drawshape($image, $action, $color); |
|
120 | 120 | } |
121 | 121 | |
122 | - $color = imagecolorallocate($image,$this->getInt(),$this->getInt(),$this->getInt()); |
|
123 | - $this->drawshape($image,$this->getInt(),$color); |
|
122 | + $color = imagecolorallocate($image, $this->getInt(), $this->getInt(), $this->getInt()); |
|
123 | + $this->drawshape($image, $this->getInt(), $color); |
|
124 | 124 | ob_start(); |
125 | 125 | imagepng($image); |
126 | 126 | $imagedata = ob_get_contents(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | private function getInt() |
140 | 140 | { |
141 | - $v= $this->VALUES[$this->VALUES_INDEX]; |
|
141 | + $v = $this->VALUES[$this->VALUES_INDEX]; |
|
142 | 142 | $this->VALUES_INDEX++; |
143 | 143 | $this->VALUES_INDEX %= count($this->VALUES); // Warp around the array |
144 | 144 | return $v; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | private function getX() |
154 | 154 | { |
155 | - return $this->width*$this->getInt()/256; |
|
155 | + return $this->width * $this->getInt() / 256; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | private function getY() |
165 | 165 | { |
166 | - return $this->height*$this->getInt()/256; |
|
166 | + return $this->height * $this->getInt() / 256; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -179,22 +179,22 @@ discard block |
||
179 | 179 | * @param array $color2 |
180 | 180 | * @return resource |
181 | 181 | */ |
182 | - private function degrade($img,$direction,$color1,$color2) |
|
182 | + private function degrade($img, $direction, $color1, $color2) |
|
183 | 183 | { |
184 | - if($direction=='h') { $size = imagesx($img); $sizeinv = imagesy($img); } |
|
185 | - else { $size = imagesy($img); $sizeinv = imagesx($img);} |
|
184 | + if ($direction == 'h') { $size = imagesx($img); $sizeinv = imagesy($img); } |
|
185 | + else { $size = imagesy($img); $sizeinv = imagesx($img); } |
|
186 | 186 | $diffs = array( |
187 | - (($color2[0]-$color1[0])/$size), |
|
188 | - (($color2[1]-$color1[1])/$size), |
|
189 | - (($color2[2]-$color1[2])/$size) |
|
187 | + (($color2[0]-$color1[0]) / $size), |
|
188 | + (($color2[1]-$color1[1]) / $size), |
|
189 | + (($color2[2]-$color1[2]) / $size) |
|
190 | 190 | ); |
191 | - for($i=0;$i<$size;$i++) |
|
191 | + for ($i = 0; $i < $size; $i++) |
|
192 | 192 | { |
193 | - $r = $color1[0]+($diffs[0]*$i); |
|
194 | - $g = $color1[1]+($diffs[1]*$i); |
|
195 | - $b = $color1[2]+($diffs[2]*$i); |
|
196 | - if($direction=='h') { imageline($img,$i,0,$i,$sizeinv,imagecolorallocate($img,$r,$g,$b)); } |
|
197 | - else { imageline($img,0,$i,$sizeinv,$i,imagecolorallocate($img,$r,$g,$b)); } |
|
193 | + $r = $color1[0]+($diffs[0] * $i); |
|
194 | + $g = $color1[1]+($diffs[1] * $i); |
|
195 | + $b = $color1[2]+($diffs[2] * $i); |
|
196 | + if ($direction == 'h') { imageline($img, $i, 0, $i, $sizeinv, imagecolorallocate($img, $r, $g, $b)); } |
|
197 | + else { imageline($img, 0, $i, $sizeinv, $i, imagecolorallocate($img, $r, $g, $b)); } |
|
198 | 198 | } |
199 | 199 | return $img; |
200 | 200 | } |
@@ -208,24 +208,24 @@ discard block |
||
208 | 208 | * @param int $color |
209 | 209 | * @return void |
210 | 210 | */ |
211 | - private function drawshape($image,$action,$color) |
|
211 | + private function drawshape($image, $action, $color) |
|
212 | 212 | { |
213 | - switch($action%7) |
|
213 | + switch ($action % 7) |
|
214 | 214 | { |
215 | 215 | case 0: |
216 | - ImageFilledRectangle ($image,$this->getX(),$this->getY(),$this->getX(),$this->getY(),$color); |
|
216 | + ImageFilledRectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color); |
|
217 | 217 | break; |
218 | 218 | case 1: |
219 | 219 | case 2: |
220 | - ImageFilledEllipse ($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color); |
|
220 | + ImageFilledEllipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color); |
|
221 | 221 | break; |
222 | 222 | case 3: |
223 | - $points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(),$this->getX(), $this->getY()); |
|
224 | - ImageFilledPolygon ($image, $points, 4, $color); |
|
223 | + $points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY()); |
|
224 | + ImageFilledPolygon($image, $points, 4, $color); |
|
225 | 225 | break; |
226 | 226 | default: |
227 | - $start=$this->getInt()*360/256; $end=$start+$this->getInt()*180/256; |
|
228 | - ImageFilledArc ($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(),$start,$end,$color,IMG_ARC_PIE); |
|
227 | + $start = $this->getInt() * 360 / 256; $end = $start+$this->getInt() * 180 / 256; |
|
228 | + ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | throw new Exception(zerobin::GENERIC_ERROR, 63); |
39 | 39 | } |
40 | 40 | // We kindly provide the remaining time before expiration (in seconds) |
41 | - $this->_data->meta->remaining_time = $this->_data->meta->expire_date - time(); |
|
41 | + $this->_data->meta->remaining_time = $this->_data->meta->expire_date-time(); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // set formatter for for the view. |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | // using getKey() to ensure a default value is present |
218 | 218 | $expire = $this->_conf->getKey($this->_conf->getKey('default', 'expire'), 'expire_options'); |
219 | 219 | } |
220 | - if ($expire > 0) $this->_data->meta->expire_date = time() + $expire; |
|
220 | + if ($expire > 0) $this->_data->meta->expire_date = time()+$expire; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |