@@ -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(privatebin::GENERIC_ERROR, 64); |
|
30 | + if ($this->_data === false) { |
|
31 | + throw new Exception(privatebin::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 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | array_key_exists('dir', $options) |
43 | 43 | ) self::$_dir = $options['dir'] . DIRECTORY_SEPARATOR; |
44 | 44 | // if needed initialize the singleton |
45 | - if(!(self::$_instance instanceof privatebin_data)) { |
|
45 | + if (!(self::$_instance instanceof privatebin_data)) { |
|
46 | 46 | self::$_instance = new self; |
47 | 47 | self::_init(); |
48 | 48 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function read($pasteid) |
76 | 76 | { |
77 | - if(!$this->exists($pasteid)) return false; |
|
77 | + if (!$this->exists($pasteid)) return false; |
|
78 | 78 | $paste = json_decode( |
79 | 79 | file_get_contents(self::_dataid2path($pasteid) . $pasteid) |
80 | 80 | ); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $dir = dir($discdir); |
112 | 112 | while (false !== ($filename = $dir->read())) |
113 | 113 | { |
114 | - if (is_file($discdir.$filename)) @unlink($discdir.$filename); |
|
114 | + if (is_file($discdir . $filename)) @unlink($discdir . $filename); |
|
115 | 115 | } |
116 | 116 | $dir->close(); |
117 | 117 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | file_put_contents( |
228 | 228 | self::$_dir . '.htaccess', |
229 | 229 | 'Allow from none' . PHP_EOL . |
230 | - 'Deny from all'. PHP_EOL |
|
230 | + 'Deny from all' . PHP_EOL |
|
231 | 231 | ); |
232 | 232 | } |
233 | 233 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | private static function _dataid2path($dataid) |
251 | 251 | { |
252 | - return self::$_dir . substr($dataid,0,2) . '/' . substr($dataid,2,2) . '/'; |
|
252 | + return self::$_dir . substr($dataid, 0, 2) . '/' . substr($dataid, 2, 2) . '/'; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public static function getInstance($options = null) |
64 | 64 | { |
65 | 65 | // if needed initialize the singleton |
66 | - if(!(self::$_instance instanceof privatebin_db)) { |
|
66 | + if (!(self::$_instance instanceof privatebin_db)) { |
|
67 | 67 | self::$_instance = new self; |
68 | 68 | } |
69 | 69 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | if ( |
153 | 153 | array_key_exists($pasteid, self::$_cache) |
154 | 154 | ) { |
155 | - if(false !== self::$_cache[$pasteid]) { |
|
155 | + if (false !== self::$_cache[$pasteid]) { |
|
156 | 156 | return false; |
157 | 157 | } else { |
158 | 158 | unset(self::$_cache[$pasteid]); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | array($pasteid), true |
224 | 224 | ); |
225 | 225 | |
226 | - if(false !== $paste) { |
|
226 | + if (false !== $paste) { |
|
227 | 227 | // create object |
228 | 228 | self::$_cache[$pasteid] = new stdClass; |
229 | 229 | self::$_cache[$pasteid]->data = $paste['data']; |
@@ -421,8 +421,7 @@ discard block |
||
421 | 421 | $statement = self::$_db->prepare($sql); |
422 | 422 | $statement->execute($params); |
423 | 423 | $result = $firstOnly ? |
424 | - $statement->fetch(PDO::FETCH_ASSOC) : |
|
425 | - $statement->fetchAll(PDO::FETCH_ASSOC); |
|
424 | + $statement->fetch(PDO::FETCH_ASSOC) : $statement->fetchAll(PDO::FETCH_ASSOC); |
|
426 | 425 | $statement->closeCursor(); |
427 | 426 | return $result; |
428 | 427 | } |
@@ -438,7 +437,7 @@ discard block |
||
438 | 437 | */ |
439 | 438 | private static function _getTableQuery($type) |
440 | 439 | { |
441 | - switch($type) |
|
440 | + switch ($type) |
|
442 | 441 | { |
443 | 442 | case 'ibm': |
444 | 443 | $sql = 'SELECT tabname FROM SYSCAT.TABLES '; |