@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -140,7 +140,7 @@ |
||
140 | 140 | $max_age = $time - $cached['time'] + (5 * 86400); |
141 | 141 | header('content-type: ' . $cached['content_type']); |
142 | 142 | header('content-length: ' . $cached['size']); |
143 | - header('cache-control: public, max-age=' . $max_age ); |
|
143 | + header('cache-control: public, max-age=' . $max_age); |
|
144 | 144 | header('last-modified: ' . gmdate('D, d M Y H:i:s', $cached['time']) . ' GMT'); |
145 | 145 | header('etag: ' . $eTag); |
146 | 146 | echo base64_decode($cached['body']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | define('SMF', 'proxy'); |
18 | +} |
|
18 | 19 | |
19 | 20 | global $proxyhousekeeping; |
20 | 21 | |
@@ -68,33 +69,38 @@ discard block |
||
68 | 69 | */ |
69 | 70 | public function checkRequest() |
70 | 71 | { |
71 | - if (!$this->enabled) |
|
72 | - return false; |
|
72 | + if (!$this->enabled) { |
|
73 | + return false; |
|
74 | + } |
|
73 | 75 | |
74 | 76 | // Try to create the image cache directory if it doesn't exist |
75 | - if (!file_exists($this->cache)) |
|
76 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
77 | + if (!file_exists($this->cache)) { |
|
78 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
77 | 79 | return false; |
80 | + } |
|
78 | 81 | |
79 | 82 | // Basic sanity check |
80 | 83 | $_GET['request'] = validate_iri($_GET['request']); |
81 | 84 | |
82 | 85 | // We aren't going anywhere without these |
83 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
84 | - return false; |
|
86 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
87 | + return false; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | $hash = $_GET['hash']; |
87 | 91 | $request = $_GET['request']; |
88 | 92 | |
89 | - if (md5($request . $this->secret) != $hash) |
|
90 | - return false; |
|
93 | + if (md5($request . $this->secret) != $hash) { |
|
94 | + return false; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | // Ensure any non-ASCII characters in the URL are encoded correctly |
93 | 98 | $request = iri_to_url($request); |
94 | 99 | |
95 | 100 | // Attempt to cache the request if it doesn't exist |
96 | - if (!$this->isCached($request)) |
|
97 | - return $this->cacheImage($request); |
|
101 | + if (!$this->isCached($request)) { |
|
102 | + return $this->cacheImage($request); |
|
103 | + } |
|
98 | 104 | |
99 | 105 | return true; |
100 | 106 | } |
@@ -131,8 +137,9 @@ discard block |
||
131 | 137 | if (!$cached || $time - $cached['time'] > ($this->maxDays * 86400)) |
132 | 138 | { |
133 | 139 | @unlink($cached_file); |
134 | - if ($this->checkRequest()) |
|
135 | - $this->serve(); |
|
140 | + if ($this->checkRequest()) { |
|
141 | + $this->serve(); |
|
142 | + } |
|
136 | 143 | $this::redirectexit($request); |
137 | 144 | } |
138 | 145 | |
@@ -145,8 +152,9 @@ discard block |
||
145 | 152 | |
146 | 153 | // Make sure we're serving an image |
147 | 154 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
148 | - if ($contentParts[0] != 'image') |
|
149 | - exit; |
|
155 | + if ($contentParts[0] != 'image') { |
|
156 | + exit; |
|
157 | + } |
|
150 | 158 | |
151 | 159 | $max_age = $time - $cached['time'] + (5 * 86400); |
152 | 160 | header('content-type: ' . $cached['content_type']); |
@@ -196,25 +204,29 @@ discard block |
||
196 | 204 | $image = fetch_web_data($request); |
197 | 205 | |
198 | 206 | // Looks like nobody was home |
199 | - if (empty($image)) |
|
200 | - return -1; |
|
207 | + if (empty($image)) { |
|
208 | + return -1; |
|
209 | + } |
|
201 | 210 | |
202 | 211 | // What kind of file did they give us? |
203 | 212 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
204 | 213 | $mime_type = finfo_buffer($finfo, $image); |
205 | 214 | |
206 | 215 | // SVG needs a little extra care |
207 | - if ($ext == 'svg' && $mime_type == 'text/plain') |
|
208 | - $mime_type = 'image/svg+xml'; |
|
216 | + if ($ext == 'svg' && $mime_type == 'text/plain') { |
|
217 | + $mime_type = 'image/svg+xml'; |
|
218 | + } |
|
209 | 219 | |
210 | 220 | // Make sure the url is returning an image |
211 | - if (strpos($mime_type, 'image/') !== 0) |
|
212 | - return -1; |
|
221 | + if (strpos($mime_type, 'image/') !== 0) { |
|
222 | + return -1; |
|
223 | + } |
|
213 | 224 | |
214 | 225 | // Validate the filesize |
215 | 226 | $size = strlen($image); |
216 | - if ($size > ($this->maxSize * 1024)) |
|
217 | - return 0; |
|
227 | + if ($size > ($this->maxSize * 1024)) { |
|
228 | + return 0; |
|
229 | + } |
|
218 | 230 | |
219 | 231 | // Cache it for later |
220 | 232 | return file_put_contents($dest, json_encode(array( |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | 'db_allow_persistent' => 'smf_db_allow_persistent', |
35 | 36 | ); |
36 | -} |
|
37 | + } |
|
38 | + } |
|
37 | 39 | |
38 | 40 | /** |
39 | 41 | * Backup $table to $backup_table. |
@@ -75,8 +77,9 @@ discard block |
||
75 | 77 | )); |
76 | 78 | |
77 | 79 | // Old school or no school? |
78 | - if ($request) |
|
79 | - return $request; |
|
80 | + if ($request) { |
|
81 | + return $request; |
|
82 | + } |
|
80 | 83 | } |
81 | 84 | |
82 | 85 | // At this point, the quick method failed. |
@@ -100,8 +103,9 @@ discard block |
||
100 | 103 | foreach ($create as $k => $l) |
101 | 104 | { |
102 | 105 | // Get the name of the auto_increment column. |
103 | - if (strpos($l, 'auto_increment')) |
|
104 | - $auto_inc = trim($l); |
|
106 | + if (strpos($l, 'auto_increment')) { |
|
107 | + $auto_inc = trim($l); |
|
108 | + } |
|
105 | 109 | |
106 | 110 | // For the engine type, see if we can work out what it is. |
107 | 111 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -109,30 +113,36 @@ discard block |
||
109 | 113 | // Extract the engine type. |
110 | 114 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
111 | 115 | |
112 | - if (!empty($match[1])) |
|
113 | - $engine = $match[1]; |
|
116 | + if (!empty($match[1])) { |
|
117 | + $engine = $match[1]; |
|
118 | + } |
|
114 | 119 | |
115 | - if (!empty($match[2])) |
|
116 | - $engine = $match[2]; |
|
120 | + if (!empty($match[2])) { |
|
121 | + $engine = $match[2]; |
|
122 | + } |
|
117 | 123 | |
118 | - if (!empty($match[5])) |
|
119 | - $charset = $match[5]; |
|
124 | + if (!empty($match[5])) { |
|
125 | + $charset = $match[5]; |
|
126 | + } |
|
120 | 127 | |
121 | - if (!empty($match[7])) |
|
122 | - $collate = $match[7]; |
|
128 | + if (!empty($match[7])) { |
|
129 | + $collate = $match[7]; |
|
130 | + } |
|
123 | 131 | } |
124 | 132 | |
125 | 133 | // Skip everything but keys... |
126 | - if (strpos($l, 'KEY') === false) |
|
127 | - unset($create[$k]); |
|
134 | + if (strpos($l, 'KEY') === false) { |
|
135 | + unset($create[$k]); |
|
136 | + } |
|
128 | 137 | } |
129 | 138 | |
130 | - if (!empty($create)) |
|
131 | - $create = '( |
|
139 | + if (!empty($create)) { |
|
140 | + $create = '( |
|
132 | 141 | ' . implode(' |
133 | 142 | ', $create) . ')'; |
134 | - else |
|
135 | - $create = ''; |
|
143 | + } else { |
|
144 | + $create = ''; |
|
145 | + } |
|
136 | 146 | |
137 | 147 | $request = $smcFunc['db_query']('', ' |
138 | 148 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -151,8 +161,9 @@ discard block |
||
151 | 161 | |
152 | 162 | if ($auto_inc != '') |
153 | 163 | { |
154 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
155 | - $auto_inc = substr($auto_inc, 0, -1); |
|
164 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
165 | + $auto_inc = substr($auto_inc, 0, -1); |
|
166 | + } |
|
156 | 167 | |
157 | 168 | $smcFunc['db_query']('', ' |
158 | 169 | ALTER TABLE {raw:backup_table} |
@@ -196,8 +207,9 @@ discard block |
||
196 | 207 | 'table' => $table, |
197 | 208 | ) |
198 | 209 | ); |
199 | - if (!$request) |
|
200 | - return -1; |
|
210 | + if (!$request) { |
|
211 | + return -1; |
|
212 | + } |
|
201 | 213 | |
202 | 214 | // How much left? |
203 | 215 | $request = $smcFunc['db_query']('', ' |
@@ -240,8 +252,9 @@ discard block |
||
240 | 252 | ) |
241 | 253 | ); |
242 | 254 | $tables = array(); |
243 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
244 | - $tables[] = $row[0]; |
|
255 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
256 | + $tables[] = $row[0]; |
|
257 | + } |
|
245 | 258 | $smcFunc['db_free_result']($request); |
246 | 259 | |
247 | 260 | return $tables; |
@@ -285,8 +298,9 @@ discard block |
||
285 | 298 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
286 | 299 | { |
287 | 300 | // Make a special case of auto-timestamp. |
288 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
289 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
301 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
302 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
303 | + } |
|
290 | 304 | // Text shouldn't have a default. |
291 | 305 | elseif ($row['Default'] !== null) |
292 | 306 | { |
@@ -321,14 +335,16 @@ discard block |
||
321 | 335 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
322 | 336 | |
323 | 337 | // Is this the first column in the index? |
324 | - if (empty($indexes[$row['Key_name']])) |
|
325 | - $indexes[$row['Key_name']] = array(); |
|
338 | + if (empty($indexes[$row['Key_name']])) { |
|
339 | + $indexes[$row['Key_name']] = array(); |
|
340 | + } |
|
326 | 341 | |
327 | 342 | // A sub part, like only indexing 15 characters of a varchar. |
328 | - if (!empty($row['Sub_part'])) |
|
329 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
330 | - else |
|
331 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
343 | + if (!empty($row['Sub_part'])) { |
|
344 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
345 | + } else { |
|
346 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
347 | + } |
|
332 | 348 | } |
333 | 349 | $smcFunc['db_free_result']($result); |
334 | 350 | |
@@ -366,8 +382,9 @@ discard block |
||
366 | 382 | { |
367 | 383 | static $ver; |
368 | 384 | |
369 | - if (!empty($ver)) |
|
370 | - return $ver; |
|
385 | + if (!empty($ver)) { |
|
386 | + return $ver; |
|
387 | + } |
|
371 | 388 | |
372 | 389 | global $smcFunc; |
373 | 390 | |
@@ -392,8 +409,9 @@ discard block |
||
392 | 409 | global $smcFunc; |
393 | 410 | static $db_type; |
394 | 411 | |
395 | - if (!empty($db_type)) |
|
396 | - return $db_type; |
|
412 | + if (!empty($db_type)) { |
|
413 | + return $db_type; |
|
414 | + } |
|
397 | 415 | |
398 | 416 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
399 | 417 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -402,13 +420,15 @@ discard block |
||
402 | 420 | // Skip these if we don't have a comment. |
403 | 421 | if (!empty($comment)) |
404 | 422 | { |
405 | - if (stripos($comment, 'percona') !== false) |
|
406 | - return 'Percona'; |
|
407 | - if (stripos($comment, 'mariadb') !== false) |
|
408 | - return 'MariaDB'; |
|
423 | + if (stripos($comment, 'percona') !== false) { |
|
424 | + return 'Percona'; |
|
425 | + } |
|
426 | + if (stripos($comment, 'mariadb') !== false) { |
|
427 | + return 'MariaDB'; |
|
428 | + } |
|
429 | + } else { |
|
430 | + return 'fail'; |
|
409 | 431 | } |
410 | - else |
|
411 | - return 'fail'; |
|
412 | 432 | |
413 | 433 | return 'MySQL'; |
414 | 434 | } |
@@ -421,10 +441,11 @@ discard block |
||
421 | 441 | function smf_db_allow_persistent() |
422 | 442 | { |
423 | 443 | $value = ini_get('mysqli.allow_persistent'); |
424 | - if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') |
|
425 | - return true; |
|
426 | - else |
|
427 | - return false; |
|
428 | -} |
|
444 | + if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') { |
|
445 | + return true; |
|
446 | + } else { |
|
447 | + return false; |
|
448 | + } |
|
449 | + } |
|
429 | 450 | |
430 | 451 | ?> |
431 | 452 | \ No newline at end of file |