@@ -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); |
@@ -9,7 +9,9 @@ |
||
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)) { |
|
13 | + mkdir($this->_path); |
|
14 | + } |
|
13 | 15 | $this->_file = $this->_path . DIRECTORY_SEPARATOR . 'vizhash.png'; |
14 | 16 | serversalt::setPath($this->_path); |
15 | 17 | } |
@@ -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)) { |
@@ -2,10 +2,18 @@ discard block |
||
2 | 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 | -if (!defined('PUBLIC_PATH')) define('PUBLIC_PATH', '..'); |
|
6 | -if (!defined('PATH')) define('PATH', '..' . DIRECTORY_SEPARATOR); |
|
7 | -if (!defined('CONF')) define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'); |
|
8 | -if (!is_file(CONF)) copy(CONF . '.sample', CONF); |
|
5 | +if (!defined('PUBLIC_PATH')) { |
|
6 | + define('PUBLIC_PATH', '..'); |
|
7 | +} |
|
8 | +if (!defined('PATH')) { |
|
9 | + define('PATH', '..' . DIRECTORY_SEPARATOR); |
|
10 | +} |
|
11 | +if (!defined('CONF')) { |
|
12 | + define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'); |
|
13 | +} |
|
14 | +if (!is_file(CONF)) { |
|
15 | + copy(CONF . '.sample', CONF); |
|
16 | +} |
|
9 | 17 | |
10 | 18 | require PATH . 'lib/auto.php'; |
11 | 19 | |
@@ -100,8 +108,9 @@ discard block |
||
100 | 108 | $example = self::getPaste(); |
101 | 109 | // the JSON shouldn't contain the salt |
102 | 110 | unset($example['meta']['salt']); |
103 | - if (count($meta)) |
|
104 | - $example['meta'] = $meta; |
|
111 | + if (count($meta)) { |
|
112 | + $example['meta'] = $meta; |
|
113 | + } |
|
105 | 114 | $example['comments'] = array(); |
106 | 115 | $example['comment_count'] = 0; |
107 | 116 | $example['comment_offset'] = 0; |
@@ -178,8 +187,9 @@ discard block |
||
178 | 187 | */ |
179 | 188 | public static function confBackup() |
180 | 189 | { |
181 | - if (!is_file(CONF . '.bak') && is_file(CONF)) |
|
182 | - rename(CONF, CONF . '.bak'); |
|
190 | + if (!is_file(CONF . '.bak') && is_file(CONF)) { |
|
191 | + rename(CONF, CONF . '.bak'); |
|
192 | + } |
|
183 | 193 | } |
184 | 194 | |
185 | 195 | /** |
@@ -189,8 +199,9 @@ discard block |
||
189 | 199 | */ |
190 | 200 | public static function confRestore() |
191 | 201 | { |
192 | - if (is_file(CONF . '.bak')) |
|
193 | - rename(CONF . '.bak', CONF); |
|
202 | + if (is_file(CONF . '.bak')) { |
|
203 | + rename(CONF . '.bak', CONF); |
|
204 | + } |
|
194 | 205 | } |
195 | 206 | |
196 | 207 | /** |
@@ -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 |
@@ -13,13 +13,17 @@ 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)) { |
|
17 | + mkdir($this->_path); |
|
18 | + } |
|
17 | 19 | serversalt::setPath($this->_path); |
18 | 20 | |
19 | 21 | $this->_otherPath = $this->_path . DIRECTORY_SEPARATOR . 'foo'; |
20 | 22 | |
21 | 23 | $this->_invalidPath = $this->_path . DIRECTORY_SEPARATOR . 'bar'; |
22 | - if(!is_dir($this->_invalidPath)) mkdir($this->_invalidPath); |
|
24 | + if(!is_dir($this->_invalidPath)) { |
|
25 | + mkdir($this->_invalidPath); |
|
26 | + } |
|
23 | 27 | $this->_invalidFile = $this->_invalidPath . DIRECTORY_SEPARATOR . 'salt.php'; |
24 | 28 | } |
25 | 29 | |
@@ -39,7 +43,9 @@ discard block |
||
39 | 43 | // mcrypt mock |
40 | 44 | if (!function_exists('mcrypt_create_iv')) |
41 | 45 | { |
42 | - if (!defined('MCRYPT_DEV_URANDOM')) define('MCRYPT_DEV_URANDOM', 1); |
|
46 | + if (!defined('MCRYPT_DEV_URANDOM')) { |
|
47 | + define('MCRYPT_DEV_URANDOM', 1); |
|
48 | + } |
|
43 | 49 | function mcrypt_create_iv($int, $flag) |
44 | 50 | { |
45 | 51 | $randomSalt = ''; |
@@ -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 |
@@ -22,8 +22,9 @@ |
||
22 | 22 | $_POST = array(); |
23 | 23 | $_GET = array(); |
24 | 24 | $_SERVER = array(); |
25 | - if ($this->_model->exists(helper::getPasteId())) |
|
26 | - $this->_model->delete(helper::getPasteId()); |
|
25 | + if ($this->_model->exists(helper::getPasteId())) { |
|
26 | + $this->_model->delete(helper::getPasteId()); |
|
27 | + } |
|
27 | 28 | helper::confRestore(); |
28 | 29 | } |
29 | 30 |
@@ -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 { |
@@ -95,7 +95,9 @@ |
||
95 | 95 | public static function canPass() |
96 | 96 | { |
97 | 97 | // disable limits if set to less then 1 |
98 | - if (self::$_limit < 1) return true; |
|
98 | + if (self::$_limit < 1) { |
|
99 | + return true; |
|
100 | + } |
|
99 | 101 | |
100 | 102 | $ip = hash_hmac('sha256', self::getIp(), serversalt::get()); |
101 | 103 |
@@ -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 | } |
@@ -86,7 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function generate($text) |
88 | 88 | { |
89 | - if (!function_exists('gd_info')) return ''; |
|
89 | + if (!function_exists('gd_info')) { |
|
90 | + return ''; |
|
91 | + } |
|
90 | 92 | |
91 | 93 | // We hash the input string. |
92 | 94 | $hash=hash('sha1',$text.$this->salt).hash('md5',$text.$this->salt); |
@@ -181,8 +183,7 @@ discard block |
||
181 | 183 | */ |
182 | 184 | private function degrade($img,$direction,$color1,$color2) |
183 | 185 | { |
184 | - if($direction=='h') { $size = imagesx($img); $sizeinv = imagesy($img); } |
|
185 | - else { $size = imagesy($img); $sizeinv = imagesx($img);} |
|
186 | + if($direction=='h') { $size = imagesx($img); $sizeinv = imagesy($img); } else { $size = imagesy($img); $sizeinv = imagesx($img);} |
|
186 | 187 | $diffs = array( |
187 | 188 | (($color2[0]-$color1[0])/$size), |
188 | 189 | (($color2[1]-$color1[1])/$size), |
@@ -193,8 +194,7 @@ discard block |
||
193 | 194 | $r = $color1[0]+($diffs[0]*$i); |
194 | 195 | $g = $color1[1]+($diffs[1]*$i); |
195 | 196 | $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)); } |
|
197 | + if($direction=='h') { imageline($img,$i,0,$i,$sizeinv,imagecolorallocate($img,$r,$g,$b)); } else { imageline($img,0,$i,$sizeinv,$i,imagecolorallocate($img,$r,$g,$b)); } |
|
198 | 198 | } |
199 | 199 | return $img; |
200 | 200 | } |
@@ -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 | /** |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | public function get() |
28 | 28 | { |
29 | 29 | $this->_data = $this->_store->read($this->getId()); |
30 | - if ($this->_data === false) throw new Exception(zerobin::GENERIC_ERROR, 64); |
|
30 | + if ($this->_data === false) { |
|
31 | + throw new Exception(zerobin::GENERIC_ERROR, 64); |
|
32 | + } |
|
31 | 33 | |
32 | 34 | // check if paste has expired and delete it if neccessary. |
33 | 35 | if (property_exists($this->_data->meta, 'expire_date')) |
@@ -48,8 +50,7 @@ discard block |
||
48 | 50 | if (property_exists($this->_data->meta, 'syntaxcoloring') && $this->_data->meta->syntaxcoloring === true) |
49 | 51 | { |
50 | 52 | $this->_data->meta->formatter = 'syntaxhighlighting'; |
51 | - } |
|
52 | - else |
|
53 | + } else |
|
53 | 54 | { |
54 | 55 | $this->_data->meta->formatter = $this->_conf->getKey('defaultformatter'); |
55 | 56 | } |
@@ -77,8 +78,9 @@ discard block |
||
77 | 78 | public function store() |
78 | 79 | { |
79 | 80 | // Check for improbable collision. |
80 | - if ($this->exists()) |
|
81 | - throw new Exception('You are unlucky. Try again.', 75); |
|
81 | + if ($this->exists()) { |
|
82 | + throw new Exception('You are unlucky. Try again.', 75); |
|
83 | + } |
|
82 | 84 | |
83 | 85 | $this->_data->meta->postdate = time(); |
84 | 86 | $this->_data->meta->salt = serversalt::generate(); |
@@ -89,7 +91,9 @@ discard block |
||
89 | 91 | $this->getId(), |
90 | 92 | json_decode(json_encode($this->_data), true) |
91 | 93 | ) === false |
92 | - ) throw new Exception('Error saving paste. Sorry.', 76); |
|
94 | + ) { |
|
95 | + throw new Exception('Error saving paste. Sorry.', 76); |
|
96 | + } |
|
93 | 97 | } |
94 | 98 | |
95 | 99 | /** |
@@ -133,7 +137,9 @@ discard block |
||
133 | 137 | $comment = new model_comment($this->_conf, $this->_store); |
134 | 138 | $comment->setPaste($this); |
135 | 139 | $comment->setParentId($parentId); |
136 | - if ($commentId !== null) $comment->setId($commentId); |
|
140 | + if ($commentId !== null) { |
|
141 | + $comment->setId($commentId); |
|
142 | + } |
|
137 | 143 | return $comment; |
138 | 144 | } |
139 | 145 | |
@@ -160,7 +166,9 @@ discard block |
||
160 | 166 | */ |
161 | 167 | public function getDeleteToken() |
162 | 168 | { |
163 | - if (!property_exists($this->_data->meta, 'salt')) $this->get(); |
|
169 | + if (!property_exists($this->_data->meta, 'salt')) { |
|
170 | + $this->get(); |
|
171 | + } |
|
164 | 172 | return hash_hmac( |
165 | 173 | $this->_conf->getKey('zerobincompatibility') ? 'sha1' : 'sha256', |
166 | 174 | $this->getId(), |
@@ -178,8 +186,9 @@ discard block |
||
178 | 186 | */ |
179 | 187 | public function setAttachment($attachment) |
180 | 188 | { |
181 | - if (!$this->_conf->getKey('fileupload') || !sjcl::isValid($attachment)) |
|
182 | - throw new Exception('Invalid attachment.', 71); |
|
189 | + if (!$this->_conf->getKey('fileupload') || !sjcl::isValid($attachment)) { |
|
190 | + throw new Exception('Invalid attachment.', 71); |
|
191 | + } |
|
183 | 192 | $this->_data->meta->attachment = $attachment; |
184 | 193 | } |
185 | 194 | |
@@ -193,8 +202,9 @@ discard block |
||
193 | 202 | */ |
194 | 203 | public function setAttachmentName($attachmentname) |
195 | 204 | { |
196 | - if (!$this->_conf->getKey('fileupload') || !sjcl::isValid($attachmentname)) |
|
197 | - throw new Exception('Invalid attachment.', 72); |
|
205 | + if (!$this->_conf->getKey('fileupload') || !sjcl::isValid($attachmentname)) { |
|
206 | + throw new Exception('Invalid attachment.', 72); |
|
207 | + } |
|
198 | 208 | $this->_data->meta->attachmentname = $attachmentname; |
199 | 209 | } |
200 | 210 | |
@@ -211,13 +221,14 @@ discard block |
||
211 | 221 | if (array_key_exists($expiration, $expire_options)) |
212 | 222 | { |
213 | 223 | $expire = $expire_options[$expiration]; |
214 | - } |
|
215 | - else |
|
224 | + } else |
|
216 | 225 | { |
217 | 226 | // using getKey() to ensure a default value is present |
218 | 227 | $expire = $this->_conf->getKey($this->_conf->getKey('default', 'expire'), 'expire_options'); |
219 | 228 | } |
220 | - if ($expire > 0) $this->_data->meta->expire_date = time() + $expire; |
|
229 | + if ($expire > 0) { |
|
230 | + $this->_data->meta->expire_date = time() + $expire; |
|
231 | + } |
|
221 | 232 | } |
222 | 233 | |
223 | 234 | /** |
@@ -233,11 +244,11 @@ discard block |
||
233 | 244 | if ($burnafterreading === '0') |
234 | 245 | { |
235 | 246 | $this->_data->meta->burnafterreading = false; |
236 | - } |
|
237 | - else |
|
247 | + } else |
|
238 | 248 | { |
239 | - if ($burnafterreading !== '1') |
|
240 | - throw new Exception('Invalid data.', 73); |
|
249 | + if ($burnafterreading !== '1') { |
|
250 | + throw new Exception('Invalid data.', 73); |
|
251 | + } |
|
241 | 252 | $this->_data->meta->burnafterreading = true; |
242 | 253 | $this->_data->meta->opendiscussion = false; |
243 | 254 | } |
@@ -260,11 +271,11 @@ discard block |
||
260 | 271 | ) |
261 | 272 | { |
262 | 273 | $this->_data->meta->opendiscussion = false; |
263 | - } |
|
264 | - else |
|
274 | + } else |
|
265 | 275 | { |
266 | - if ($opendiscussion !== '1') |
|
267 | - throw new Exception('Invalid data.', 74); |
|
276 | + if ($opendiscussion !== '1') { |
|
277 | + throw new Exception('Invalid data.', 74); |
|
278 | + } |
|
268 | 279 | $this->_data->meta->opendiscussion = true; |
269 | 280 | } |
270 | 281 | } |
@@ -295,7 +306,9 @@ discard block |
||
295 | 306 | */ |
296 | 307 | public function isBurnafterreading() |
297 | 308 | { |
298 | - if (!property_exists($this->_data, 'data')) $this->get(); |
|
309 | + if (!property_exists($this->_data, 'data')) { |
|
310 | + $this->get(); |
|
311 | + } |
|
299 | 312 | return property_exists($this->_data->meta, 'burnafterreading') && |
300 | 313 | $this->_data->meta->burnafterreading === true; |
301 | 314 | } |
@@ -310,7 +323,9 @@ discard block |
||
310 | 323 | */ |
311 | 324 | public function isOpendiscussion() |
312 | 325 | { |
313 | - if (!property_exists($this->_data, 'data')) $this->get(); |
|
326 | + if (!property_exists($this->_data, 'data')) { |
|
327 | + $this->get(); |
|
328 | + } |
|
314 | 329 | return property_exists($this->_data->meta, 'opendiscussion') && |
315 | 330 | $this->_data->meta->opendiscussion === true; |
316 | 331 | } |