@@ -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', |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | 'db_get_version' => 'smf_db_get_version', |
| 33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
| 34 | 35 | ); |
| 35 | -} |
|
| 36 | + } |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
| 74 | 76 | )); |
| 75 | 77 | |
| 76 | 78 | // Old school or no school? |
| 77 | - if ($request) |
|
| 78 | - return $request; |
|
| 79 | + if ($request) { |
|
| 80 | + return $request; |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | foreach ($create as $k => $l) |
| 100 | 103 | { |
| 101 | 104 | // Get the name of the auto_increment column. |
| 102 | - if (strpos($l, 'auto_increment')) |
|
| 103 | - $auto_inc = trim($l); |
|
| 105 | + if (strpos($l, 'auto_increment')) { |
|
| 106 | + $auto_inc = trim($l); |
|
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // For the engine type, see if we can work out what it is. |
| 106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
| 108 | 112 | // Extract the engine type. |
| 109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
| 110 | 114 | |
| 111 | - if (!empty($match[1])) |
|
| 112 | - $engine = $match[1]; |
|
| 115 | + if (!empty($match[1])) { |
|
| 116 | + $engine = $match[1]; |
|
| 117 | + } |
|
| 113 | 118 | |
| 114 | - if (!empty($match[2])) |
|
| 115 | - $engine = $match[2]; |
|
| 119 | + if (!empty($match[2])) { |
|
| 120 | + $engine = $match[2]; |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | - if (!empty($match[5])) |
|
| 118 | - $charset = $match[5]; |
|
| 123 | + if (!empty($match[5])) { |
|
| 124 | + $charset = $match[5]; |
|
| 125 | + } |
|
| 119 | 126 | |
| 120 | - if (!empty($match[7])) |
|
| 121 | - $collate = $match[7]; |
|
| 127 | + if (!empty($match[7])) { |
|
| 128 | + $collate = $match[7]; |
|
| 129 | + } |
|
| 122 | 130 | } |
| 123 | 131 | |
| 124 | 132 | // Skip everything but keys... |
| 125 | - if (strpos($l, 'KEY') === false) |
|
| 126 | - unset($create[$k]); |
|
| 133 | + if (strpos($l, 'KEY') === false) { |
|
| 134 | + unset($create[$k]); |
|
| 135 | + } |
|
| 127 | 136 | } |
| 128 | 137 | |
| 129 | - if (!empty($create)) |
|
| 130 | - $create = '( |
|
| 138 | + if (!empty($create)) { |
|
| 139 | + $create = '( |
|
| 131 | 140 | ' . implode(' |
| 132 | 141 | ', $create) . ')'; |
| 133 | - else |
|
| 134 | - $create = ''; |
|
| 142 | + } else { |
|
| 143 | + $create = ''; |
|
| 144 | + } |
|
| 135 | 145 | |
| 136 | 146 | $request = $smcFunc['db_query']('', ' |
| 137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
| 150 | 160 | |
| 151 | 161 | if ($auto_inc != '') |
| 152 | 162 | { |
| 153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
| 154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
| 163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
| 164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
| 165 | + } |
|
| 155 | 166 | |
| 156 | 167 | $smcFunc['db_query']('', ' |
| 157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
| 195 | 206 | 'table' => $table, |
| 196 | 207 | ) |
| 197 | 208 | ); |
| 198 | - if (!$request) |
|
| 199 | - return -1; |
|
| 209 | + if (!$request) { |
|
| 210 | + return -1; |
|
| 211 | + } |
|
| 200 | 212 | |
| 201 | 213 | // How much left? |
| 202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
| 239 | 251 | ) |
| 240 | 252 | ); |
| 241 | 253 | $tables = array(); |
| 242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 243 | - $tables[] = $row[0]; |
|
| 254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 255 | + $tables[] = $row[0]; |
|
| 256 | + } |
|
| 244 | 257 | $smcFunc['db_free_result']($request); |
| 245 | 258 | |
| 246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
| 284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
| 285 | 298 | { |
| 286 | 299 | // Make a special case of auto-timestamp. |
| 287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
| 288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
| 301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 302 | + } |
|
| 289 | 303 | // Text shouldn't have a default. |
| 290 | 304 | elseif ($row['Default'] !== null) |
| 291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
| 320 | 334 | $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'] . '`'; |
| 321 | 335 | |
| 322 | 336 | // Is this the first column in the index? |
| 323 | - if (empty($indexes[$row['Key_name']])) |
|
| 324 | - $indexes[$row['Key_name']] = array(); |
|
| 337 | + if (empty($indexes[$row['Key_name']])) { |
|
| 338 | + $indexes[$row['Key_name']] = array(); |
|
| 339 | + } |
|
| 325 | 340 | |
| 326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
| 327 | - if (!empty($row['Sub_part'])) |
|
| 328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 329 | - else |
|
| 330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 342 | + if (!empty($row['Sub_part'])) { |
|
| 343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 344 | + } else { |
|
| 345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 346 | + } |
|
| 331 | 347 | } |
| 332 | 348 | $smcFunc['db_free_result']($result); |
| 333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
| 365 | 381 | { |
| 366 | 382 | static $ver; |
| 367 | 383 | |
| 368 | - if (!empty($ver)) |
|
| 369 | - return $ver; |
|
| 384 | + if (!empty($ver)) { |
|
| 385 | + return $ver; |
|
| 386 | + } |
|
| 370 | 387 | |
| 371 | 388 | global $smcFunc; |
| 372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
| 391 | 408 | global $smcFunc; |
| 392 | 409 | static $db_type; |
| 393 | 410 | |
| 394 | - if (!empty($db_type)) |
|
| 395 | - return $db_type; |
|
| 411 | + if (!empty($db_type)) { |
|
| 412 | + return $db_type; |
|
| 413 | + } |
|
| 396 | 414 | |
| 397 | 415 | $request = $smcFunc['db_query']('', |
| 398 | 416 | 'SELECT VARIABLE_VALUE |
@@ -408,13 +426,15 @@ discard block |
||
| 408 | 426 | // Skip these if we don't have a comment. |
| 409 | 427 | if (!empty($comment)) |
| 410 | 428 | { |
| 411 | - if (stripos($comment, 'percona') !== false) |
|
| 412 | - return 'Percona'; |
|
| 413 | - if (stripos($comment, 'mariadb') !== false) |
|
| 414 | - return 'MariaDB'; |
|
| 429 | + if (stripos($comment, 'percona') !== false) { |
|
| 430 | + return 'Percona'; |
|
| 431 | + } |
|
| 432 | + if (stripos($comment, 'mariadb') !== false) { |
|
| 433 | + return 'MariaDB'; |
|
| 434 | + } |
|
| 435 | + } else { |
|
| 436 | + return 'fail'; |
|
| 415 | 437 | } |
| 416 | - else |
|
| 417 | - return 'fail'; |
|
| 418 | 438 | |
| 419 | 439 | return 'MySQL'; |
| 420 | 440 | } |
@@ -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', |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | 'db_get_version' => 'smf_db_get_version', |
| 33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
| 34 | 35 | ); |
| 35 | -} |
|
| 36 | + } |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Backup $table to $backup_table. |
@@ -48,13 +50,14 @@ discard block |
||
| 48 | 50 | |
| 49 | 51 | // Do we need to drop it first? |
| 50 | 52 | $tables = smf_db_list_tables(false, $backup_table); |
| 51 | - if (!empty($tables)) |
|
| 52 | - $smcFunc['db_query']('', ' |
|
| 53 | + if (!empty($tables)) { |
|
| 54 | + $smcFunc['db_query']('', ' |
|
| 53 | 55 | DROP TABLE {raw:backup_table}', |
| 54 | 56 | array( |
| 55 | 57 | 'backup_table' => $backup_table, |
| 56 | 58 | ) |
| 57 | 59 | ); |
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | /** |
| 60 | 63 | * @todo Should we create backups of sequences as well? |
@@ -117,8 +120,9 @@ discard block |
||
| 117 | 120 | ) |
| 118 | 121 | ); |
| 119 | 122 | |
| 120 | - if (!$request) |
|
| 121 | - return -1; |
|
| 123 | + if (!$request) { |
|
| 124 | + return -1; |
|
| 125 | + } |
|
| 122 | 126 | |
| 123 | 127 | $request = $smcFunc['db_query']('', ' |
| 124 | 128 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -136,11 +140,12 @@ discard block |
||
| 136 | 140 | $row = $smcFunc['db_fetch_assoc']($request); |
| 137 | 141 | $smcFunc['db_free_result']($request); |
| 138 | 142 | |
| 139 | - if (isset($row['size'])) |
|
| 140 | - return ($old_size - $row['size']) / 1024; |
|
| 141 | - else |
|
| 142 | - return 0; |
|
| 143 | -} |
|
| 143 | + if (isset($row['size'])) { |
|
| 144 | + return ($old_size - $row['size']) / 1024; |
|
| 145 | + } else { |
|
| 146 | + return 0; |
|
| 147 | + } |
|
| 148 | + } |
|
| 144 | 149 | |
| 145 | 150 | /** |
| 146 | 151 | * This function lists all tables in the database. |
@@ -167,8 +172,9 @@ discard block |
||
| 167 | 172 | ); |
| 168 | 173 | |
| 169 | 174 | $tables = array(); |
| 170 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 171 | - $tables[] = $row[0]; |
|
| 175 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 176 | + $tables[] = $row[0]; |
|
| 177 | + } |
|
| 172 | 178 | $smcFunc['db_free_result']($request); |
| 173 | 179 | |
| 174 | 180 | return $tables; |
@@ -209,12 +215,14 @@ discard block |
||
| 209 | 215 | ); |
| 210 | 216 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 211 | 217 | { |
| 212 | - if ($row['data_type'] == 'character varying') |
|
| 213 | - $row['data_type'] = 'varchar'; |
|
| 214 | - elseif ($row['data_type'] == 'character') |
|
| 215 | - $row['data_type'] = 'char'; |
|
| 216 | - if ($row['character_maximum_length']) |
|
| 217 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
| 218 | + if ($row['data_type'] == 'character varying') { |
|
| 219 | + $row['data_type'] = 'varchar'; |
|
| 220 | + } elseif ($row['data_type'] == 'character') { |
|
| 221 | + $row['data_type'] = 'char'; |
|
| 222 | + } |
|
| 223 | + if ($row['character_maximum_length']) { |
|
| 224 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
| 225 | + } |
|
| 218 | 226 | |
| 219 | 227 | // Make the CREATE for this column. |
| 220 | 228 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -265,13 +273,14 @@ discard block |
||
| 265 | 273 | { |
| 266 | 274 | if ($row['is_primary']) |
| 267 | 275 | { |
| 268 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
| 269 | - continue; |
|
| 276 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
| 277 | + continue; |
|
| 278 | + } |
|
| 270 | 279 | |
| 271 | 280 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
| 281 | + } else { |
|
| 282 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
| 272 | 283 | } |
| 273 | - else |
|
| 274 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
| 275 | 284 | } |
| 276 | 285 | $smcFunc['db_free_result']($result); |
| 277 | 286 | |
@@ -290,8 +299,9 @@ discard block |
||
| 290 | 299 | global $db_connection; |
| 291 | 300 | static $ver; |
| 292 | 301 | |
| 293 | - if(!empty($ver)) |
|
| 294 | - return $ver; |
|
| 302 | + if(!empty($ver)) { |
|
| 303 | + return $ver; |
|
| 304 | + } |
|
| 295 | 305 | |
| 296 | 306 | $ver = pg_version($db_connection)['server']; |
| 297 | 307 | |
@@ -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 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_vendor'](); |
@@ -75,24 +75,31 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | 77 | $memcache_version = '???'; |
| 78 | - if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) |
|
| 79 | - $memcache_version = $cacheAPI->getVersion(); |
|
| 78 | + if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) { |
|
| 79 | + $memcache_version = $cacheAPI->getVersion(); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | // Check to see if we have any accelerators installed... |
| 82 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 83 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 85 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 86 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 87 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 88 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 89 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 83 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 84 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 85 | + } |
|
| 86 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 87 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 88 | + } |
|
| 89 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 90 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 91 | + } |
|
| 92 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 93 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | - if (in_array('php', $checkFor)) |
|
| 92 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 96 | + if (in_array('php', $checkFor)) { |
|
| 97 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | - if (in_array('server', $checkFor)) |
|
| 95 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 100 | + if (in_array('server', $checkFor)) { |
|
| 101 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 102 | + } |
|
| 96 | 103 | |
| 97 | 104 | return $versions; |
| 98 | 105 | } |
@@ -132,11 +139,13 @@ discard block |
||
| 132 | 139 | fclose($fp); |
| 133 | 140 | |
| 134 | 141 | // The comment looks rougly like... that. |
| 135 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 136 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 142 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 143 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 144 | + } |
|
| 137 | 145 | // Not found! This is bad. |
| 138 | - else |
|
| 139 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 146 | + else { |
|
| 147 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 148 | + } |
|
| 140 | 149 | } |
| 141 | 150 | |
| 142 | 151 | // Do the paid subscriptions handler? |
@@ -147,11 +156,13 @@ discard block |
||
| 147 | 156 | fclose($fp); |
| 148 | 157 | |
| 149 | 158 | // Found it? |
| 150 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 151 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 159 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 160 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 161 | + } |
|
| 152 | 162 | // If we haven't how do we all get paid? |
| 153 | - else |
|
| 154 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 163 | + else { |
|
| 164 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 165 | + } |
|
| 155 | 166 | } |
| 156 | 167 | |
| 157 | 168 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -166,11 +177,13 @@ discard block |
||
| 166 | 177 | fclose($fp); |
| 167 | 178 | |
| 168 | 179 | // Look for the version comment in the file header. |
| 169 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 170 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 180 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 181 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 182 | + } |
|
| 171 | 183 | // It wasn't found, but the file was... show a '??'. |
| 172 | - else |
|
| 173 | - $version_info['file_versions'][$entry] = '??'; |
|
| 184 | + else { |
|
| 185 | + $version_info['file_versions'][$entry] = '??'; |
|
| 186 | + } |
|
| 174 | 187 | } |
| 175 | 188 | } |
| 176 | 189 | $sources_dir->close(); |
@@ -189,11 +202,13 @@ discard block |
||
| 189 | 202 | fclose($fp); |
| 190 | 203 | |
| 191 | 204 | // Look for the version comment in the file header. |
| 192 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 193 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 205 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 206 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 207 | + } |
|
| 194 | 208 | // It wasn't found, but the file was... show a '??'. |
| 195 | - else |
|
| 196 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 209 | + else { |
|
| 210 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 211 | + } |
|
| 197 | 212 | } |
| 198 | 213 | } |
| 199 | 214 | $tasks_dir->close(); |
@@ -201,8 +216,9 @@ discard block |
||
| 201 | 216 | |
| 202 | 217 | // Load all the files in the default template directory - and the current theme if applicable. |
| 203 | 218 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 204 | - if ($settings['theme_id'] != 1) |
|
| 205 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 219 | + if ($settings['theme_id'] != 1) { |
|
| 220 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 221 | + } |
|
| 206 | 222 | |
| 207 | 223 | foreach ($directories as $type => $dirname) |
| 208 | 224 | { |
@@ -217,11 +233,13 @@ discard block |
||
| 217 | 233 | fclose($fp); |
| 218 | 234 | |
| 219 | 235 | // Look for the version comment in the file header. |
| 220 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 221 | - $version_info[$type][$entry] = $match[1]; |
|
| 236 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 237 | + $version_info[$type][$entry] = $match[1]; |
|
| 238 | + } |
|
| 222 | 239 | // It wasn't found, but the file was... show a '??'. |
| 223 | - else |
|
| 224 | - $version_info[$type][$entry] = '??'; |
|
| 240 | + else { |
|
| 241 | + $version_info[$type][$entry] = '??'; |
|
| 242 | + } |
|
| 225 | 243 | } |
| 226 | 244 | } |
| 227 | 245 | $this_dir->close(); |
@@ -242,11 +260,13 @@ discard block |
||
| 242 | 260 | list ($name, $language) = explode('.', $entry); |
| 243 | 261 | |
| 244 | 262 | // Look for the version comment in the file header. |
| 245 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 246 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 263 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 264 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 265 | + } |
|
| 247 | 266 | // It wasn't found, but the file was... show a '??'. |
| 248 | - else |
|
| 249 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 267 | + else { |
|
| 268 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 269 | + } |
|
| 250 | 270 | } |
| 251 | 271 | } |
| 252 | 272 | $this_dir->close(); |
@@ -261,8 +281,9 @@ discard block |
||
| 261 | 281 | ksort($version_info['tasks_versions']); |
| 262 | 282 | |
| 263 | 283 | // For languages sort each language too. |
| 264 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 265 | - ksort($version_info['default_language_versions'][$language]); |
|
| 284 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 285 | + ksort($version_info['default_language_versions'][$language]); |
|
| 286 | + } |
|
| 266 | 287 | } |
| 267 | 288 | return $version_info; |
| 268 | 289 | } |
@@ -304,27 +325,31 @@ discard block |
||
| 304 | 325 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 305 | 326 | |
| 306 | 327 | // Break it up based on \r or \n, and then clean out extra characters. |
| 307 | - if (strpos($settingsArray, "\n") !== false) |
|
| 308 | - $settingsArray = explode("\n", $settingsArray); |
|
| 309 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 310 | - $settingsArray = explode("\r", $settingsArray); |
|
| 311 | - else |
|
| 312 | - return; |
|
| 328 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 329 | + $settingsArray = explode("\n", $settingsArray); |
|
| 330 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 331 | + $settingsArray = explode("\r", $settingsArray); |
|
| 332 | + } else { |
|
| 333 | + return; |
|
| 334 | + } |
|
| 313 | 335 | |
| 314 | 336 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 315 | - if (count($settingsArray) < 10) |
|
| 316 | - return; |
|
| 337 | + if (count($settingsArray) < 10) { |
|
| 338 | + return; |
|
| 339 | + } |
|
| 317 | 340 | |
| 318 | 341 | // remove any /r's that made there way in here |
| 319 | - foreach ($settingsArray as $k => $dummy) |
|
| 320 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 342 | + foreach ($settingsArray as $k => $dummy) { |
|
| 343 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 344 | + } |
|
| 321 | 345 | |
| 322 | 346 | // go line by line and see whats changing |
| 323 | 347 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 324 | 348 | { |
| 325 | 349 | // Don't trim or bother with it if it's not a variable. |
| 326 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 327 | - continue; |
|
| 350 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 351 | + continue; |
|
| 352 | + } |
|
| 328 | 353 | |
| 329 | 354 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 330 | 355 | |
@@ -336,8 +361,7 @@ discard block |
||
| 336 | 361 | { |
| 337 | 362 | updateDbLastError($val); |
| 338 | 363 | unset($config_vars[$var]); |
| 339 | - } |
|
| 340 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 364 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 341 | 365 | { |
| 342 | 366 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 343 | 367 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -348,34 +372,39 @@ discard block |
||
| 348 | 372 | } |
| 349 | 373 | |
| 350 | 374 | // End of the file ... maybe |
| 351 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 352 | - $end = $i; |
|
| 375 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 376 | + $end = $i; |
|
| 377 | + } |
|
| 353 | 378 | } |
| 354 | 379 | |
| 355 | 380 | // This should never happen, but apparently it is happening. |
| 356 | - if (empty($end) || $end < 10) |
|
| 357 | - $end = count($settingsArray) - 1; |
|
| 381 | + if (empty($end) || $end < 10) { |
|
| 382 | + $end = count($settingsArray) - 1; |
|
| 383 | + } |
|
| 358 | 384 | |
| 359 | 385 | // Still more variables to go? Then lets add them at the end. |
| 360 | 386 | if (!empty($config_vars)) |
| 361 | 387 | { |
| 362 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 363 | - $settingsArray[$end++] = ''; |
|
| 364 | - else |
|
| 365 | - $end++; |
|
| 388 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 389 | + $settingsArray[$end++] = ''; |
|
| 390 | + } else { |
|
| 391 | + $end++; |
|
| 392 | + } |
|
| 366 | 393 | |
| 367 | 394 | // Add in any newly defined vars that were passed |
| 368 | - foreach ($config_vars as $var => $val) |
|
| 369 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 395 | + foreach ($config_vars as $var => $val) { |
|
| 396 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 397 | + } |
|
| 370 | 398 | |
| 371 | 399 | $settingsArray[$end] = '?' . '>'; |
| 400 | + } else { |
|
| 401 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 372 | 402 | } |
| 373 | - else |
|
| 374 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 375 | 403 | |
| 376 | 404 | // Sanity error checking: the file needs to be at least 12 lines. |
| 377 | - if (count($settingsArray) < 12) |
|
| 378 | - return; |
|
| 405 | + if (count($settingsArray) < 12) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 379 | 408 | |
| 380 | 409 | // Try to avoid a few pitfalls: |
| 381 | 410 | // - like a possible race condition, |
@@ -383,8 +412,9 @@ discard block |
||
| 383 | 412 | // |
| 384 | 413 | // Check before you act: if cache is enabled, we can do a simple write test |
| 385 | 414 | // to validate that we even write things on this filesystem. |
| 386 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 387 | - $cachedir = $boarddir . '/cache'; |
|
| 415 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 416 | + $cachedir = $boarddir . '/cache'; |
|
| 417 | + } |
|
| 388 | 418 | |
| 389 | 419 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 390 | 420 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
| 419 | 449 | // Well this is not good at all, lets see if we can save this |
| 420 | 450 | $context['settings_message'] = 'settings_error'; |
| 421 | 451 | |
| 422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 454 | + } |
|
| 424 | 455 | } |
| 425 | 456 | } |
| 426 | 457 | |
| 427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 429 | - if (function_exists('opcache_invalidate')) |
|
| 430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 431 | -} |
|
| 460 | + if (function_exists('opcache_invalidate')) { |
|
| 461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 462 | + } |
|
| 463 | + } |
|
| 432 | 464 | |
| 433 | 465 | /** |
| 434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
| 454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
| 455 | 487 | |
| 456 | 488 | // This must exist! |
| 457 | - if (!isset($context['admin_preferences'])) |
|
| 458 | - return false; |
|
| 489 | + if (!isset($context['admin_preferences'])) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 459 | 492 | |
| 460 | 493 | // This is what we'll be saving. |
| 461 | 494 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
| 519 | 552 | $emails_sent = array(); |
| 520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 521 | 554 | { |
| 522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 523 | - continue; |
|
| 555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 524 | 558 | |
| 525 | 559 | // Stick their particulars in the replacement data. |
| 526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
| 539 | 573 | $smcFunc['db_free_result']($request); |
| 540 | 574 | |
| 541 | 575 | // Any additional users we must email this to? |
| 542 | - if (!empty($additional_recipients)) |
|
| 543 | - foreach ($additional_recipients as $recipient) |
|
| 576 | + if (!empty($additional_recipients)) { |
|
| 577 | + foreach ($additional_recipients as $recipient) |
|
| 544 | 578 | { |
| 545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
| 546 | 580 | continue; |
| 581 | + } |
|
| 547 | 582 | |
| 548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
| 549 | 584 | $replacements['REALNAME'] = $recipient['name']; |