@@ -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 |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * @version 2.1 Beta 4 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('SMF')) |
|
| 20 | +if (!defined('SMF')) { |
|
| 21 | 21 | die('No direct access...'); |
| 22 | +} |
|
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | $parsed_url = parse_url($boardurl); |
| 40 | 41 | |
| 41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | // @todo Set the session cookie path? |
| 45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
| 47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
| 48 | 50 | { |
| 49 | 51 | // Attempt to end the already-started session. |
| 50 | - if (ini_get('session.auto_start') == 1) |
|
| 51 | - session_write_close(); |
|
| 52 | + if (ini_get('session.auto_start') == 1) { |
|
| 53 | + session_write_close(); |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -63,23 +66,26 @@ discard block |
||
| 63 | 66 | if (!empty($modSettings['databaseSession_enable'])) |
| 64 | 67 | { |
| 65 | 68 | @ini_set('session.serialize_handler', 'php_serialize'); |
| 66 | - if (ini_get('session.serialize_handler') != 'php_serialize') |
|
| 67 | - @ini_set('session.serialize_handler', 'php'); |
|
| 69 | + if (ini_get('session.serialize_handler') != 'php_serialize') { |
|
| 70 | + @ini_set('session.serialize_handler', 'php'); |
|
| 71 | + } |
|
| 68 | 72 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
| 69 | 73 | @ini_set('session.gc_probability', '1'); |
| 74 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
| 75 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 70 | 76 | } |
| 71 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
| 72 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 73 | 77 | |
| 74 | 78 | // Use cache setting sessions? |
| 75 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
| 76 | - call_integration_hook('integrate_session_handlers'); |
|
| 79 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
| 80 | + call_integration_hook('integrate_session_handlers'); |
|
| 81 | + } |
|
| 77 | 82 | |
| 78 | 83 | session_start(); |
| 79 | 84 | |
| 80 | 85 | // Change it so the cache settings are a little looser than default. |
| 81 | - if (!empty($modSettings['databaseSession_loose'])) |
|
| 82 | - header('cache-control: private'); |
|
| 86 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
| 87 | + header('cache-control: private'); |
|
| 88 | + } |
|
| 83 | 89 | } |
| 84 | 90 | |
| 85 | 91 | // Set the randomly generated code. |
@@ -125,8 +131,9 @@ discard block |
||
| 125 | 131 | { |
| 126 | 132 | global $smcFunc; |
| 127 | 133 | |
| 128 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 129 | - return ''; |
|
| 134 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 135 | + return ''; |
|
| 136 | + } |
|
| 130 | 137 | |
| 131 | 138 | // Look for it in the database. |
| 132 | 139 | $result = $smcFunc['db_query']('', ' |
@@ -155,8 +162,9 @@ discard block |
||
| 155 | 162 | { |
| 156 | 163 | global $smcFunc, $db_connection, $db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_persist, $db_port; |
| 157 | 164 | |
| 158 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 159 | - return false; |
|
| 165 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 166 | + return false; |
|
| 167 | + } |
|
| 160 | 168 | |
| 161 | 169 | // php < 7.0 need this |
| 162 | 170 | if (empty($db_connection)) |
@@ -164,8 +172,9 @@ discard block |
||
| 164 | 172 | $db_options = array(); |
| 165 | 173 | |
| 166 | 174 | // Add in the port if needed |
| 167 | - if (!empty($db_port)) |
|
| 168 | - $db_options['port'] = $db_port; |
|
| 175 | + if (!empty($db_port)) { |
|
| 176 | + $db_options['port'] = $db_port; |
|
| 177 | + } |
|
| 169 | 178 | $options = array_merge($db_options, array('persist' => $db_persist, 'dont_select_db' => SMF == 'SSI')); |
| 170 | 179 | |
| 171 | 180 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
@@ -184,13 +193,14 @@ discard block |
||
| 184 | 193 | ); |
| 185 | 194 | |
| 186 | 195 | // If that didn't work, try inserting a new one. |
| 187 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 188 | - $smcFunc['db_insert']('ignore', |
|
| 196 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 197 | + $smcFunc['db_insert']('ignore', |
|
| 189 | 198 | '{db_prefix}sessions', |
| 190 | 199 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
| 191 | 200 | array($session_id, $data, time()), |
| 192 | 201 | array('session_id') |
| 193 | 202 | ); |
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
| 196 | 206 | } |
@@ -205,8 +215,9 @@ discard block |
||
| 205 | 215 | { |
| 206 | 216 | global $smcFunc; |
| 207 | 217 | |
| 208 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 209 | - return false; |
|
| 218 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 210 | 221 | |
| 211 | 222 | // Just delete the row... |
| 212 | 223 | $smcFunc['db_query']('', ' |
@@ -232,8 +243,9 @@ discard block |
||
| 232 | 243 | global $modSettings, $smcFunc; |
| 233 | 244 | |
| 234 | 245 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
| 235 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
| 236 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 246 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
| 247 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 248 | + } |
|
| 237 | 249 | |
| 238 | 250 | // Clean up after yerself ;). |
| 239 | 251 | $smcFunc['db_query']('', ' |
@@ -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 ($value == 'on' || $value == 'true') |
|
| 425 | - return true; |
|
| 426 | - else |
|
| 427 | - return false; |
|
| 428 | -} |
|
| 444 | + if ($value == 'on' || $value == 'true') { |
|
| 445 | + return true; |
|
| 446 | + } else { |
|
| 447 | + return false; |
|
| 448 | + } |
|
| 449 | + } |
|
| 429 | 450 | |
| 430 | 451 | ?> |
| 431 | 452 | \ 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']); |
@@ -70,26 +70,31 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function checkRequest() |
| 72 | 72 | { |
| 73 | - if (!$this->enabled) |
|
| 74 | - return false; |
|
| 73 | + if (!$this->enabled) { |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | // Try to create the image cache directory if it doesn't exist |
| 77 | - if (!file_exists($this->cache)) |
|
| 78 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
| 78 | + if (!file_exists($this->cache)) { |
|
| 79 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
| 79 | 80 | return false; |
| 81 | + } |
|
| 80 | 82 | |
| 81 | - if (empty($_GET['hash']) || empty($_GET['request']) || ($_GET['request'] === "http:") || ($_GET['request'] === "https:")) |
|
| 82 | - return false; |
|
| 83 | + if (empty($_GET['hash']) || empty($_GET['request']) || ($_GET['request'] === "http:") || ($_GET['request'] === "https:")) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | $hash = $_GET['hash']; |
| 85 | 88 | $request = $_GET['request']; |
| 86 | 89 | |
| 87 | - if (md5($request . $this->secret) != $hash) |
|
| 88 | - return false; |
|
| 90 | + if (md5($request . $this->secret) != $hash) { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 89 | 93 | |
| 90 | 94 | // Attempt to cache the request if it doesn't exist |
| 91 | - if (!$this->isCached($request)) |
|
| 92 | - return $this->cacheImage($request); |
|
| 95 | + if (!$this->isCached($request)) { |
|
| 96 | + return $this->cacheImage($request); |
|
| 97 | + } |
|
| 93 | 98 | |
| 94 | 99 | return true; |
| 95 | 100 | } |
@@ -126,8 +131,9 @@ discard block |
||
| 126 | 131 | if (!$cached || time() - $cached['time'] > ($this->maxDays * 86400)) |
| 127 | 132 | { |
| 128 | 133 | @unlink($cached_file); |
| 129 | - if ($this->checkRequest()) |
|
| 130 | - $this->serve(); |
|
| 134 | + if ($this->checkRequest()) { |
|
| 135 | + $this->serve(); |
|
| 136 | + } |
|
| 131 | 137 | $this::redirectexit($request); |
| 132 | 138 | } |
| 133 | 139 | |
@@ -140,8 +146,9 @@ discard block |
||
| 140 | 146 | |
| 141 | 147 | // Make sure we're serving an image |
| 142 | 148 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
| 143 | - if ($contentParts[0] != 'image') |
|
| 144 | - exit; |
|
| 149 | + if ($contentParts[0] != 'image') { |
|
| 150 | + exit; |
|
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $max_age = $time - $cached['time'] + (5 * 86400); |
| 147 | 154 | header('content-type: ' . $cached['content_type']); |
@@ -200,12 +207,14 @@ discard block |
||
| 200 | 207 | |
| 201 | 208 | // Make sure the url is returning an image |
| 202 | 209 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
| 203 | - if ($contentParts[0] != 'image') |
|
| 204 | - return -1; |
|
| 210 | + if ($contentParts[0] != 'image') { |
|
| 211 | + return -1; |
|
| 212 | + } |
|
| 205 | 213 | |
| 206 | 214 | // Validate the filesize |
| 207 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
| 208 | - return 0; |
|
| 215 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
| 216 | + return 0; |
|
| 217 | + } |
|
| 209 | 218 | |
| 210 | 219 | $time = $this->getTime(); |
| 211 | 220 | |