@@ -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 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -61,9 +62,11 @@ discard block |
||
| 61 | 62 | 'db_ping' => 'mysqli_ping', |
| 62 | 63 | 'db_fetch_all' => 'smf_db_fetch_all', |
| 63 | 64 | ); |
| 65 | + } |
|
| 64 | 66 | |
| 65 | - if (!empty($db_options['persist'])) |
|
| 66 | - $db_server = 'p:' . $db_server; |
|
| 67 | + if (!empty($db_options['persist'])) { |
|
| 68 | + $db_server = 'p:' . $db_server; |
|
| 69 | + } |
|
| 67 | 70 | |
| 68 | 71 | $connection = mysqli_init(); |
| 69 | 72 | |
@@ -72,24 +75,27 @@ discard block |
||
| 72 | 75 | $success = false; |
| 73 | 76 | |
| 74 | 77 | if ($connection) { |
| 75 | - if (!empty($db_options['port'])) |
|
| 76 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 77 | - else |
|
| 78 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 78 | + if (!empty($db_options['port'])) { |
|
| 79 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 80 | + } else { |
|
| 81 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 82 | + } |
|
| 79 | 83 | } |
| 80 | 84 | |
| 81 | 85 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 82 | 86 | if ($success === false) |
| 83 | 87 | { |
| 84 | - if (!empty($db_options['non_fatal'])) |
|
| 85 | - return null; |
|
| 86 | - else |
|
| 87 | - display_db_error(); |
|
| 88 | + if (!empty($db_options['non_fatal'])) { |
|
| 89 | + return null; |
|
| 90 | + } else { |
|
| 91 | + display_db_error(); |
|
| 92 | + } |
|
| 88 | 93 | } |
| 89 | 94 | |
| 90 | 95 | // Select the database, unless told not to |
| 91 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
| 92 | - display_db_error(); |
|
| 96 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
| 97 | + display_db_error(); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | 100 | $smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'', |
| 95 | 101 | array(), |
@@ -165,34 +171,42 @@ discard block |
||
| 165 | 171 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
| 166 | 172 | |
| 167 | 173 | list ($values, $connection) = $db_callback; |
| 168 | - if (!is_object($connection)) |
|
| 169 | - display_db_error(); |
|
| 174 | + if (!is_object($connection)) { |
|
| 175 | + display_db_error(); |
|
| 176 | + } |
|
| 170 | 177 | |
| 171 | - if ($matches[1] === 'db_prefix') |
|
| 172 | - return $db_prefix; |
|
| 178 | + if ($matches[1] === 'db_prefix') { |
|
| 179 | + return $db_prefix; |
|
| 180 | + } |
|
| 173 | 181 | |
| 174 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 175 | - return $user_info[$matches[1]]; |
|
| 182 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 183 | + return $user_info[$matches[1]]; |
|
| 184 | + } |
|
| 176 | 185 | |
| 177 | - if ($matches[1] === 'empty') |
|
| 178 | - return '\'\''; |
|
| 186 | + if ($matches[1] === 'empty') { |
|
| 187 | + return '\'\''; |
|
| 188 | + } |
|
| 179 | 189 | |
| 180 | - if (!isset($matches[2])) |
|
| 181 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 190 | + if (!isset($matches[2])) { |
|
| 191 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 192 | + } |
|
| 182 | 193 | |
| 183 | - if ($matches[1] === 'literal') |
|
| 184 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 194 | + if ($matches[1] === 'literal') { |
|
| 195 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 196 | + } |
|
| 185 | 197 | |
| 186 | - if (!isset($values[$matches[2]])) |
|
| 187 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 198 | + if (!isset($values[$matches[2]])) { |
|
| 199 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 200 | + } |
|
| 188 | 201 | |
| 189 | 202 | $replacement = $values[$matches[2]]; |
| 190 | 203 | |
| 191 | 204 | switch ($matches[1]) |
| 192 | 205 | { |
| 193 | 206 | case 'int': |
| 194 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 195 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 207 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 208 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 209 | + } |
|
| 196 | 210 | return (string) (int) $replacement; |
| 197 | 211 | break; |
| 198 | 212 | |
@@ -204,65 +218,73 @@ discard block |
||
| 204 | 218 | case 'array_int': |
| 205 | 219 | if (is_array($replacement)) |
| 206 | 220 | { |
| 207 | - if (empty($replacement)) |
|
| 208 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 221 | + if (empty($replacement)) { |
|
| 222 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 223 | + } |
|
| 209 | 224 | |
| 210 | 225 | foreach ($replacement as $key => $value) |
| 211 | 226 | { |
| 212 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 213 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 227 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 228 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 229 | + } |
|
| 214 | 230 | |
| 215 | 231 | $replacement[$key] = (string) (int) $value; |
| 216 | 232 | } |
| 217 | 233 | |
| 218 | 234 | return implode(', ', $replacement); |
| 235 | + } else { |
|
| 236 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 219 | 237 | } |
| 220 | - else |
|
| 221 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 222 | 238 | |
| 223 | 239 | break; |
| 224 | 240 | |
| 225 | 241 | case 'array_string': |
| 226 | 242 | if (is_array($replacement)) |
| 227 | 243 | { |
| 228 | - if (empty($replacement)) |
|
| 229 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 244 | + if (empty($replacement)) { |
|
| 245 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 246 | + } |
|
| 230 | 247 | |
| 231 | - foreach ($replacement as $key => $value) |
|
| 232 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 248 | + foreach ($replacement as $key => $value) { |
|
| 249 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 250 | + } |
|
| 233 | 251 | |
| 234 | 252 | return implode(', ', $replacement); |
| 253 | + } else { |
|
| 254 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 235 | 255 | } |
| 236 | - else |
|
| 237 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 238 | 256 | break; |
| 239 | 257 | |
| 240 | 258 | case 'date': |
| 241 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 242 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 243 | - else |
|
| 244 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 259 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 260 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 261 | + } else { |
|
| 262 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 263 | + } |
|
| 245 | 264 | break; |
| 246 | 265 | |
| 247 | 266 | case 'time': |
| 248 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 249 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 250 | - else |
|
| 251 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 267 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 268 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 269 | + } else { |
|
| 270 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 271 | + } |
|
| 252 | 272 | break; |
| 253 | 273 | |
| 254 | 274 | case 'datetime': |
| 255 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 256 | - return 'str_to_date('. |
|
| 275 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 276 | + return 'str_to_date('. |
|
| 257 | 277 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 258 | 278 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 259 | - else |
|
| 260 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 279 | + } else { |
|
| 280 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 281 | + } |
|
| 261 | 282 | break; |
| 262 | 283 | |
| 263 | 284 | case 'float': |
| 264 | - if (!is_numeric($replacement)) |
|
| 265 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 285 | + if (!is_numeric($replacement)) { |
|
| 286 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 287 | + } |
|
| 266 | 288 | return (string) (float) $replacement; |
| 267 | 289 | break; |
| 268 | 290 | |
@@ -276,32 +298,37 @@ discard block |
||
| 276 | 298 | break; |
| 277 | 299 | |
| 278 | 300 | case 'inet': |
| 279 | - if ($replacement == 'null' || $replacement == '') |
|
| 280 | - return 'null'; |
|
| 281 | - if (!isValidIP($replacement)) |
|
| 282 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 301 | + if ($replacement == 'null' || $replacement == '') { |
|
| 302 | + return 'null'; |
|
| 303 | + } |
|
| 304 | + if (!isValidIP($replacement)) { |
|
| 305 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 306 | + } |
|
| 283 | 307 | //we don't use the native support of mysql > 5.6.2 |
| 284 | 308 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 285 | 309 | |
| 286 | 310 | case 'array_inet': |
| 287 | 311 | if (is_array($replacement)) |
| 288 | 312 | { |
| 289 | - if (empty($replacement)) |
|
| 290 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 313 | + if (empty($replacement)) { |
|
| 314 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 315 | + } |
|
| 291 | 316 | |
| 292 | 317 | foreach ($replacement as $key => $value) |
| 293 | 318 | { |
| 294 | - if ($replacement == 'null' || $replacement == '') |
|
| 295 | - $replacement[$key] = 'null'; |
|
| 296 | - if (!isValidIP($value)) |
|
| 297 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 319 | + if ($replacement == 'null' || $replacement == '') { |
|
| 320 | + $replacement[$key] = 'null'; |
|
| 321 | + } |
|
| 322 | + if (!isValidIP($value)) { |
|
| 323 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 324 | + } |
|
| 298 | 325 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 299 | 326 | } |
| 300 | 327 | |
| 301 | 328 | return implode(', ', $replacement); |
| 329 | + } else { |
|
| 330 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 302 | 331 | } |
| 303 | - else |
|
| 304 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 305 | 332 | break; |
| 306 | 333 | |
| 307 | 334 | default: |
@@ -377,22 +404,25 @@ discard block |
||
| 377 | 404 | // Are we in SSI mode? If so try that username and password first |
| 378 | 405 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 379 | 406 | { |
| 380 | - if (empty($db_persist)) |
|
| 381 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 382 | - else |
|
| 383 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 407 | + if (empty($db_persist)) { |
|
| 408 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 409 | + } else { |
|
| 410 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 411 | + } |
|
| 384 | 412 | } |
| 385 | 413 | // Fall back to the regular username and password if need be |
| 386 | 414 | if (!$db_connection) |
| 387 | 415 | { |
| 388 | - if (empty($db_persist)) |
|
| 389 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 390 | - else |
|
| 391 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 416 | + if (empty($db_persist)) { |
|
| 417 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 418 | + } else { |
|
| 419 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 420 | + } |
|
| 392 | 421 | } |
| 393 | 422 | |
| 394 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 395 | - $db_connection = false; |
|
| 423 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 424 | + $db_connection = false; |
|
| 425 | + } |
|
| 396 | 426 | |
| 397 | 427 | $connection = $db_connection; |
| 398 | 428 | } |
@@ -400,18 +430,20 @@ discard block |
||
| 400 | 430 | // One more query.... |
| 401 | 431 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 402 | 432 | |
| 403 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 404 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 433 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 434 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 435 | + } |
|
| 405 | 436 | |
| 406 | 437 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 407 | 438 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 408 | 439 | { |
| 409 | 440 | // Add before LIMIT |
| 410 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 411 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 412 | - else |
|
| 413 | - // Append it. |
|
| 441 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 442 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 443 | + } else { |
|
| 444 | + // Append it. |
|
| 414 | 445 | $db_string .= "\n\t\t\tORDER BY null"; |
| 446 | + } |
|
| 415 | 447 | } |
| 416 | 448 | |
| 417 | 449 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -433,8 +465,9 @@ discard block |
||
| 433 | 465 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 434 | 466 | |
| 435 | 467 | // Initialize $db_cache if not already initialized. |
| 436 | - if (!isset($db_cache)) |
|
| 437 | - $db_cache = array(); |
|
| 468 | + if (!isset($db_cache)) { |
|
| 469 | + $db_cache = array(); |
|
| 470 | + } |
|
| 438 | 471 | |
| 439 | 472 | if (!empty($_SESSION['debug_redirect'])) |
| 440 | 473 | { |
@@ -460,17 +493,18 @@ discard block |
||
| 460 | 493 | while (true) |
| 461 | 494 | { |
| 462 | 495 | $pos = strpos($db_string, '\'', $pos + 1); |
| 463 | - if ($pos === false) |
|
| 464 | - break; |
|
| 496 | + if ($pos === false) { |
|
| 497 | + break; |
|
| 498 | + } |
|
| 465 | 499 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 466 | 500 | |
| 467 | 501 | while (true) |
| 468 | 502 | { |
| 469 | 503 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 470 | 504 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 471 | - if ($pos1 === false) |
|
| 472 | - break; |
|
| 473 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 505 | + if ($pos1 === false) { |
|
| 506 | + break; |
|
| 507 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 474 | 508 | { |
| 475 | 509 | $pos = $pos1; |
| 476 | 510 | break; |
@@ -486,29 +520,35 @@ discard block |
||
| 486 | 520 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 487 | 521 | |
| 488 | 522 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 489 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 490 | - $fail = true; |
|
| 523 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 524 | + $fail = true; |
|
| 525 | + } |
|
| 491 | 526 | // Trying to change passwords, slow us down, or something? |
| 492 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 493 | - $fail = true; |
|
| 494 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 495 | - $fail = true; |
|
| 527 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 528 | + $fail = true; |
|
| 529 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 530 | + $fail = true; |
|
| 531 | + } |
|
| 496 | 532 | |
| 497 | - if (!empty($fail) && function_exists('log_error')) |
|
| 498 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 533 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 534 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 535 | + } |
|
| 499 | 536 | } |
| 500 | 537 | |
| 501 | - if (empty($db_unbuffered)) |
|
| 502 | - $ret = @mysqli_query($connection, $db_string); |
|
| 503 | - else |
|
| 504 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 538 | + if (empty($db_unbuffered)) { |
|
| 539 | + $ret = @mysqli_query($connection, $db_string); |
|
| 540 | + } else { |
|
| 541 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 542 | + } |
|
| 505 | 543 | |
| 506 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 507 | - $ret = smf_db_error($db_string, $connection); |
|
| 544 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 545 | + $ret = smf_db_error($db_string, $connection); |
|
| 546 | + } |
|
| 508 | 547 | |
| 509 | 548 | // Debugging. |
| 510 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 511 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 549 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 550 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 551 | + } |
|
| 512 | 552 | |
| 513 | 553 | return $ret; |
| 514 | 554 | } |
@@ -555,12 +595,13 @@ discard block |
||
| 555 | 595 | // Decide which connection to use |
| 556 | 596 | $connection = $connection === null ? $db_connection : $connection; |
| 557 | 597 | |
| 558 | - if ($type == 'begin') |
|
| 559 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 560 | - elseif ($type == 'rollback') |
|
| 561 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 562 | - elseif ($type == 'commit') |
|
| 563 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 598 | + if ($type == 'begin') { |
|
| 599 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 600 | + } elseif ($type == 'rollback') { |
|
| 601 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 602 | + } elseif ($type == 'commit') { |
|
| 603 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 604 | + } |
|
| 564 | 605 | |
| 565 | 606 | return false; |
| 566 | 607 | } |
@@ -600,8 +641,9 @@ discard block |
||
| 600 | 641 | // 2013: Lost connection to server during query. |
| 601 | 642 | |
| 602 | 643 | // Log the error. |
| 603 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 604 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 644 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 645 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 646 | + } |
|
| 605 | 647 | |
| 606 | 648 | // Database error auto fixing ;). |
| 607 | 649 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -610,8 +652,9 @@ discard block |
||
| 610 | 652 | $old_cache = @$modSettings['cache_enable']; |
| 611 | 653 | $modSettings['cache_enable'] = '1'; |
| 612 | 654 | |
| 613 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 614 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 655 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 656 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 657 | + } |
|
| 615 | 658 | |
| 616 | 659 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 617 | 660 | { |
@@ -627,8 +670,9 @@ discard block |
||
| 627 | 670 | foreach ($tables as $table) |
| 628 | 671 | { |
| 629 | 672 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 630 | - if (trim($table) != '') |
|
| 631 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 673 | + if (trim($table) != '') { |
|
| 674 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 675 | + } |
|
| 632 | 676 | } |
| 633 | 677 | } |
| 634 | 678 | |
@@ -637,8 +681,9 @@ discard block |
||
| 637 | 681 | // Table crashed. Let's try to fix it. |
| 638 | 682 | elseif ($query_errno == 1016) |
| 639 | 683 | { |
| 640 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 641 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 684 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 685 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 686 | + } |
|
| 642 | 687 | } |
| 643 | 688 | // Indexes crashed. Should be easy to fix! |
| 644 | 689 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -657,13 +702,15 @@ discard block |
||
| 657 | 702 | |
| 658 | 703 | // Make a note of the REPAIR... |
| 659 | 704 | cache_put_data('db_last_error', time(), 600); |
| 660 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 661 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 705 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 706 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 707 | + } |
|
| 662 | 708 | |
| 663 | 709 | // Attempt to find and repair the broken table. |
| 664 | - foreach ($fix_tables as $table) |
|
| 665 | - $smcFunc['db_query']('', " |
|
| 710 | + foreach ($fix_tables as $table) { |
|
| 711 | + $smcFunc['db_query']('', " |
|
| 666 | 712 | REPAIR TABLE $table", false, false); |
| 713 | + } |
|
| 667 | 714 | |
| 668 | 715 | // And send off an email! |
| 669 | 716 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -672,11 +719,12 @@ discard block |
||
| 672 | 719 | |
| 673 | 720 | // Try the query again...? |
| 674 | 721 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 675 | - if ($ret !== false) |
|
| 676 | - return $ret; |
|
| 722 | + if ($ret !== false) { |
|
| 723 | + return $ret; |
|
| 724 | + } |
|
| 725 | + } else { |
|
| 726 | + $modSettings['cache_enable'] = $old_cache; |
|
| 677 | 727 | } |
| 678 | - else |
|
| 679 | - $modSettings['cache_enable'] = $old_cache; |
|
| 680 | 728 | |
| 681 | 729 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 682 | 730 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -686,22 +734,25 @@ discard block |
||
| 686 | 734 | // Are we in SSI mode? If so try that username and password first |
| 687 | 735 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 688 | 736 | { |
| 689 | - if (empty($db_persist)) |
|
| 690 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 691 | - else |
|
| 692 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 737 | + if (empty($db_persist)) { |
|
| 738 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 739 | + } else { |
|
| 740 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 741 | + } |
|
| 693 | 742 | } |
| 694 | 743 | // Fall back to the regular username and password if need be |
| 695 | 744 | if (!$db_connection) |
| 696 | 745 | { |
| 697 | - if (empty($db_persist)) |
|
| 698 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 699 | - else |
|
| 700 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 746 | + if (empty($db_persist)) { |
|
| 747 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 748 | + } else { |
|
| 749 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 750 | + } |
|
| 701 | 751 | } |
| 702 | 752 | |
| 703 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 704 | - $db_connection = false; |
|
| 753 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 754 | + $db_connection = false; |
|
| 755 | + } |
|
| 705 | 756 | } |
| 706 | 757 | |
| 707 | 758 | if ($db_connection) |
@@ -712,24 +763,27 @@ discard block |
||
| 712 | 763 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 713 | 764 | |
| 714 | 765 | $new_errno = mysqli_errno($db_connection); |
| 715 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 716 | - break; |
|
| 766 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 767 | + break; |
|
| 768 | + } |
|
| 717 | 769 | } |
| 718 | 770 | |
| 719 | 771 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 720 | - if ($ret !== false) |
|
| 721 | - return $ret; |
|
| 772 | + if ($ret !== false) { |
|
| 773 | + return $ret; |
|
| 774 | + } |
|
| 722 | 775 | } |
| 723 | 776 | } |
| 724 | 777 | // Are they out of space, perhaps? |
| 725 | 778 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 726 | 779 | { |
| 727 | - if (!isset($txt)) |
|
| 728 | - $query_error .= ' - check database storage space.'; |
|
| 729 | - else |
|
| 780 | + if (!isset($txt)) { |
|
| 781 | + $query_error .= ' - check database storage space.'; |
|
| 782 | + } else |
|
| 730 | 783 | { |
| 731 | - if (!isset($txt['mysql_error_space'])) |
|
| 732 | - loadLanguage('Errors'); |
|
| 784 | + if (!isset($txt['mysql_error_space'])) { |
|
| 785 | + loadLanguage('Errors'); |
|
| 786 | + } |
|
| 733 | 787 | |
| 734 | 788 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 735 | 789 | } |
@@ -737,15 +791,17 @@ discard block |
||
| 737 | 791 | } |
| 738 | 792 | |
| 739 | 793 | // Nothing's defined yet... just die with it. |
| 740 | - if (empty($context) || empty($txt)) |
|
| 741 | - die($query_error); |
|
| 794 | + if (empty($context) || empty($txt)) { |
|
| 795 | + die($query_error); |
|
| 796 | + } |
|
| 742 | 797 | |
| 743 | 798 | // Show an error message, if possible. |
| 744 | 799 | $context['error_title'] = $txt['database_error']; |
| 745 | - if (allowedTo('admin_forum')) |
|
| 746 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 747 | - else |
|
| 748 | - $context['error_message'] = $txt['try_again']; |
|
| 800 | + if (allowedTo('admin_forum')) { |
|
| 801 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 802 | + } else { |
|
| 803 | + $context['error_message'] = $txt['try_again']; |
|
| 804 | + } |
|
| 749 | 805 | |
| 750 | 806 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 751 | 807 | { |
@@ -777,8 +833,9 @@ discard block |
||
| 777 | 833 | $return_var = null; |
| 778 | 834 | |
| 779 | 835 | // With nothing to insert, simply return. |
| 780 | - if (empty($data)) |
|
| 781 | - return; |
|
| 836 | + if (empty($data)) { |
|
| 837 | + return; |
|
| 838 | + } |
|
| 782 | 839 | |
| 783 | 840 | // Replace the prefix holder with the actual prefix. |
| 784 | 841 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -788,23 +845,26 @@ discard block |
||
| 788 | 845 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
| 789 | 846 | { |
| 790 | 847 | $with_returning = true; |
| 791 | - if ($returnmode == 2) |
|
| 792 | - $return_var = array(); |
|
| 848 | + if ($returnmode == 2) { |
|
| 849 | + $return_var = array(); |
|
| 850 | + } |
|
| 793 | 851 | } |
| 794 | 852 | |
| 795 | 853 | // Inserting data as a single row can be done as a single array. |
| 796 | - if (!is_array($data[array_rand($data)])) |
|
| 797 | - $data = array($data); |
|
| 854 | + if (!is_array($data[array_rand($data)])) { |
|
| 855 | + $data = array($data); |
|
| 856 | + } |
|
| 798 | 857 | |
| 799 | 858 | // Create the mold for a single row insert. |
| 800 | 859 | $insertData = '('; |
| 801 | 860 | foreach ($columns as $columnName => $type) |
| 802 | 861 | { |
| 803 | 862 | // Are we restricting the length? |
| 804 | - if (strpos($type, 'string-') !== false) |
|
| 805 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 806 | - else |
|
| 807 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 863 | + if (strpos($type, 'string-') !== false) { |
|
| 864 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 865 | + } else { |
|
| 866 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 867 | + } |
|
| 808 | 868 | } |
| 809 | 869 | $insertData = substr($insertData, 0, -2) . ')'; |
| 810 | 870 | |
@@ -813,8 +873,9 @@ discard block |
||
| 813 | 873 | |
| 814 | 874 | // Here's where the variables are injected to the query. |
| 815 | 875 | $insertRows = array(); |
| 816 | - foreach ($data as $dataRow) |
|
| 817 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 876 | + foreach ($data as $dataRow) { |
|
| 877 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 878 | + } |
|
| 818 | 879 | |
| 819 | 880 | // Determine the method of insertion. |
| 820 | 881 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -833,8 +894,7 @@ discard block |
||
| 833 | 894 | ), |
| 834 | 895 | $connection |
| 835 | 896 | ); |
| 836 | - } |
|
| 837 | - else //special way for ignore method with returning |
|
| 897 | + } else //special way for ignore method with returning |
|
| 838 | 898 | { |
| 839 | 899 | $count = count($insertRows); |
| 840 | 900 | $ai = 0; |
@@ -854,19 +914,21 @@ discard block |
||
| 854 | 914 | ); |
| 855 | 915 | $new_id = $smcFunc['db_insert_id'](); |
| 856 | 916 | |
| 857 | - if ($last_id != $new_id) //the inserted value was new |
|
| 917 | + if ($last_id != $new_id) { |
|
| 918 | + //the inserted value was new |
|
| 858 | 919 | { |
| 859 | 920 | $ai = $new_id; |
| 860 | 921 | } |
| 861 | - else // the inserted value already exists we need to find the pk |
|
| 922 | + } else // the inserted value already exists we need to find the pk |
|
| 862 | 923 | { |
| 863 | 924 | $where_string = ''; |
| 864 | 925 | $count2 = count($indexed_columns); |
| 865 | 926 | for ($x = 0; $x < $count2; $x++) |
| 866 | 927 | { |
| 867 | 928 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
| 868 | - if (($x + 1) < $count2) |
|
| 869 | - $where_string += ' AND '; |
|
| 929 | + if (($x + 1) < $count2) { |
|
| 930 | + $where_string += ' AND '; |
|
| 931 | + } |
|
| 870 | 932 | } |
| 871 | 933 | |
| 872 | 934 | $request = $smcFunc['db_query']('',' |
@@ -882,25 +944,27 @@ discard block |
||
| 882 | 944 | } |
| 883 | 945 | } |
| 884 | 946 | |
| 885 | - if ($returnmode == 1) |
|
| 886 | - $return_var = $ai; |
|
| 887 | - else if ($returnmode == 2) |
|
| 888 | - $return_var[] = $ai; |
|
| 947 | + if ($returnmode == 1) { |
|
| 948 | + $return_var = $ai; |
|
| 949 | + } else if ($returnmode == 2) { |
|
| 950 | + $return_var[] = $ai; |
|
| 951 | + } |
|
| 889 | 952 | } |
| 890 | 953 | } |
| 891 | 954 | |
| 892 | 955 | |
| 893 | 956 | if ($with_returning) |
| 894 | 957 | { |
| 895 | - if ($returnmode == 1 && empty($return_var)) |
|
| 896 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 897 | - else if ($returnmode == 2 && empty($return_var)) |
|
| 958 | + if ($returnmode == 1 && empty($return_var)) { |
|
| 959 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 960 | + } else if ($returnmode == 2 && empty($return_var)) |
|
| 898 | 961 | { |
| 899 | 962 | $return_var = array(); |
| 900 | 963 | $count = count($insertRows); |
| 901 | 964 | $start = smf_db_insert_id($table, $keys[0]); |
| 902 | - for ($i = 0; $i < $count; $i++ ) |
|
| 903 | - $return_var[] = $start + $i; |
|
| 965 | + for ($i = 0; $i < $count; $i++ ) { |
|
| 966 | + $return_var[] = $start + $i; |
|
| 967 | + } |
|
| 904 | 968 | } |
| 905 | 969 | return $return_var; |
| 906 | 970 | } |
@@ -918,8 +982,9 @@ discard block |
||
| 918 | 982 | */ |
| 919 | 983 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 920 | 984 | { |
| 921 | - if (empty($log_message)) |
|
| 922 | - $log_message = $error_message; |
|
| 985 | + if (empty($log_message)) { |
|
| 986 | + $log_message = $error_message; |
|
| 987 | + } |
|
| 923 | 988 | |
| 924 | 989 | foreach (debug_backtrace() as $step) |
| 925 | 990 | { |
@@ -938,12 +1003,14 @@ discard block |
||
| 938 | 1003 | } |
| 939 | 1004 | |
| 940 | 1005 | // A special case - we want the file and line numbers for debugging. |
| 941 | - if ($error_type == 'return') |
|
| 942 | - return array($file, $line); |
|
| 1006 | + if ($error_type == 'return') { |
|
| 1007 | + return array($file, $line); |
|
| 1008 | + } |
|
| 943 | 1009 | |
| 944 | 1010 | // Is always a critical error. |
| 945 | - if (function_exists('log_error')) |
|
| 946 | - log_error($log_message, 'critical', $file, $line); |
|
| 1011 | + if (function_exists('log_error')) { |
|
| 1012 | + log_error($log_message, 'critical', $file, $line); |
|
| 1013 | + } |
|
| 947 | 1014 | |
| 948 | 1015 | if (function_exists('fatal_error')) |
| 949 | 1016 | { |
@@ -951,12 +1018,12 @@ discard block |
||
| 951 | 1018 | |
| 952 | 1019 | // Cannot continue... |
| 953 | 1020 | exit; |
| 1021 | + } elseif ($error_type) { |
|
| 1022 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 1023 | + } else { |
|
| 1024 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 1025 | + } |
|
| 954 | 1026 | } |
| 955 | - elseif ($error_type) |
|
| 956 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 957 | - else |
|
| 958 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 959 | -} |
|
| 960 | 1027 | |
| 961 | 1028 | /** |
| 962 | 1029 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -973,10 +1040,11 @@ discard block |
||
| 973 | 1040 | '\\' => '\\\\', |
| 974 | 1041 | ); |
| 975 | 1042 | |
| 976 | - if ($translate_human_wildcards) |
|
| 977 | - $replacements += array( |
|
| 1043 | + if ($translate_human_wildcards) { |
|
| 1044 | + $replacements += array( |
|
| 978 | 1045 | '*' => '%', |
| 979 | 1046 | ); |
| 1047 | + } |
|
| 980 | 1048 | |
| 981 | 1049 | return strtr($string, $replacements); |
| 982 | 1050 | } |
@@ -990,8 +1058,9 @@ discard block |
||
| 990 | 1058 | */ |
| 991 | 1059 | function smf_is_resource($result) |
| 992 | 1060 | { |
| 993 | - if ($result instanceof mysqli_result) |
|
| 994 | - return true; |
|
| 1061 | + if ($result instanceof mysqli_result) { |
|
| 1062 | + return true; |
|
| 1063 | + } |
|
| 995 | 1064 | |
| 996 | 1065 | return false; |
| 997 | 1066 | } |
@@ -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 | * This is the notoriously defunct package manager..... :/. |
@@ -57,10 +58,11 @@ discard block |
||
| 57 | 58 | ); |
| 58 | 59 | |
| 59 | 60 | // Work out exactly who it is we are calling. |
| 60 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 61 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 62 | - else |
|
| 63 | - $context['sub_action'] = 'browse'; |
|
| 61 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 62 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 63 | + } else { |
|
| 64 | + $context['sub_action'] = 'browse'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Set up some tabs... |
| 66 | 68 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -82,8 +84,9 @@ discard block |
||
| 82 | 84 | ), |
| 83 | 85 | ); |
| 84 | 86 | |
| 85 | - if ($context['sub_action'] == 'browse') |
|
| 86 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 87 | + if ($context['sub_action'] == 'browse') { |
|
| 88 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 89 | + } |
|
| 87 | 90 | |
| 88 | 91 | call_integration_hook('integrate_manage_packages', array(&$subActions)); |
| 89 | 92 | |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | global $boarddir, $txt, $context, $scripturl, $sourcedir, $packagesdir, $modSettings, $smcFunc, $settings; |
| 100 | 103 | |
| 101 | 104 | // You have to specify a file!! |
| 102 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 103 | - redirectexit('action=admin;area=packages'); |
|
| 105 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 106 | + redirectexit('action=admin;area=packages'); |
|
| 107 | + } |
|
| 104 | 108 | $context['filename'] = preg_replace('~[\.]+~', '.', $_REQUEST['package']); |
| 105 | 109 | |
| 106 | 110 | // Do we have an existing id, for uninstalls and the like. |
@@ -112,8 +116,9 @@ discard block |
||
| 112 | 116 | create_chmod_control(); |
| 113 | 117 | |
| 114 | 118 | // Make sure temp directory exists and is empty. |
| 115 | - if (file_exists($packagesdir . '/temp')) |
|
| 116 | - deltree($packagesdir . '/temp', false); |
|
| 119 | + if (file_exists($packagesdir . '/temp')) { |
|
| 120 | + deltree($packagesdir . '/temp', false); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | if (!mktree($packagesdir . '/temp', 0755)) |
| 119 | 124 | { |
@@ -124,8 +129,9 @@ discard block |
||
| 124 | 129 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'], 'crash_on_error' => true)); |
| 125 | 130 | |
| 126 | 131 | deltree($packagesdir . '/temp', false); |
| 127 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
| 128 | - fatal_lang_error('package_cant_download', false); |
|
| 132 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
| 133 | + fatal_lang_error('package_cant_download', false); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | 136 | } |
| 131 | 137 | |
@@ -151,25 +157,26 @@ discard block |
||
| 151 | 157 | { |
| 152 | 158 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 153 | 159 | |
| 154 | - if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 155 | - foreach ($context['extracted_files'] as $file) |
|
| 160 | + if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 161 | + foreach ($context['extracted_files'] as $file) |
|
| 156 | 162 | if (basename($file['filename']) == 'package-info.xml') |
| 157 | 163 | { |
| 158 | 164 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 165 | + } |
|
| 159 | 166 | break; |
| 160 | 167 | } |
| 161 | 168 | |
| 162 | - if (!isset($context['base_path'])) |
|
| 163 | - $context['base_path'] = ''; |
|
| 164 | - } |
|
| 165 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 169 | + if (!isset($context['base_path'])) { |
|
| 170 | + $context['base_path'] = ''; |
|
| 171 | + } |
|
| 172 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 166 | 173 | { |
| 167 | 174 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 168 | 175 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
| 169 | 176 | $context['base_path'] = ''; |
| 177 | + } else { |
|
| 178 | + fatal_lang_error('no_access', false); |
|
| 170 | 179 | } |
| 171 | - else |
|
| 172 | - fatal_lang_error('no_access', false); |
|
| 173 | 180 | |
| 174 | 181 | // Load up any custom themes we may want to install into... |
| 175 | 182 | $request = $smcFunc['db_query']('', ' |
@@ -185,15 +192,17 @@ discard block |
||
| 185 | 192 | ) |
| 186 | 193 | ); |
| 187 | 194 | $theme_paths = array(); |
| 188 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 189 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 196 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 197 | + } |
|
| 190 | 198 | $smcFunc['db_free_result']($request); |
| 191 | 199 | |
| 192 | 200 | // Get the package info... |
| 193 | 201 | $packageInfo = getPackageInfo($context['filename']); |
| 194 | 202 | |
| 195 | - if (!is_array($packageInfo)) |
|
| 196 | - fatal_lang_error($packageInfo); |
|
| 203 | + if (!is_array($packageInfo)) { |
|
| 204 | + fatal_lang_error($packageInfo); |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | $packageInfo['filename'] = $context['filename']; |
| 199 | 208 | $context['package_name'] = isset($packageInfo['name']) ? $packageInfo['name'] : $context['filename']; |
@@ -227,18 +236,19 @@ discard block |
||
| 227 | 236 | $smcFunc['db_free_result']($request); |
| 228 | 237 | |
| 229 | 238 | $context['database_changes'] = array(); |
| 230 | - if (isset($packageInfo['uninstall']['database'])) |
|
| 231 | - $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
| 232 | - elseif (!empty($db_changes)) |
|
| 239 | + if (isset($packageInfo['uninstall']['database'])) { |
|
| 240 | + $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
| 241 | + } elseif (!empty($db_changes)) |
|
| 233 | 242 | { |
| 234 | 243 | foreach ($db_changes as $change) |
| 235 | 244 | { |
| 236 | - if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) |
|
| 237 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
| 238 | - elseif (isset($txt['package_db_' . $change[0]])) |
|
| 239 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
| 240 | - else |
|
| 241 | - $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
| 245 | + if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) { |
|
| 246 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
| 247 | + } elseif (isset($txt['package_db_' . $change[0]])) { |
|
| 248 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
| 249 | + } else { |
|
| 250 | + $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
| 251 | + } |
|
| 242 | 252 | } |
| 243 | 253 | } |
| 244 | 254 | |
@@ -265,31 +275,33 @@ discard block |
||
| 265 | 275 | $context['themes_locked'] = true; |
| 266 | 276 | |
| 267 | 277 | // Only let them uninstall themes it was installed into. |
| 268 | - foreach ($theme_paths as $id => $data) |
|
| 269 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 278 | + foreach ($theme_paths as $id => $data) { |
|
| 279 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 270 | 280 | unset($theme_paths[$id]); |
| 271 | - } |
|
| 272 | - elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 281 | + } |
|
| 282 | + } elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 273 | 283 | { |
| 274 | 284 | // Look for an upgrade... |
| 275 | 285 | $actions = parsePackageInfo($packageInfo['xml'], true, 'upgrade', $old_version); |
| 276 | 286 | |
| 277 | 287 | // There was no upgrade.... |
| 278 | - if (empty($actions)) |
|
| 279 | - $context['is_installed'] = true; |
|
| 280 | - else |
|
| 288 | + if (empty($actions)) { |
|
| 289 | + $context['is_installed'] = true; |
|
| 290 | + } else |
|
| 281 | 291 | { |
| 282 | 292 | // Otherwise they can only upgrade themes from the first time around. |
| 283 | - foreach ($theme_paths as $id => $data) |
|
| 284 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 293 | + foreach ($theme_paths as $id => $data) { |
|
| 294 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 285 | 295 | unset($theme_paths[$id]); |
| 296 | + } |
|
| 286 | 297 | } |
| 298 | + } elseif (isset($old_version) && $old_version == $packageInfo['version']) { |
|
| 299 | + $context['is_installed'] = true; |
|
| 287 | 300 | } |
| 288 | - elseif (isset($old_version) && $old_version == $packageInfo['version']) |
|
| 289 | - $context['is_installed'] = true; |
|
| 290 | 301 | |
| 291 | - if (!isset($old_version) || $context['is_installed']) |
|
| 292 | - $actions = parsePackageInfo($packageInfo['xml'], true, 'install'); |
|
| 302 | + if (!isset($old_version) || $context['is_installed']) { |
|
| 303 | + $actions = parsePackageInfo($packageInfo['xml'], true, 'install'); |
|
| 304 | + } |
|
| 293 | 305 | |
| 294 | 306 | $context['actions'] = array(); |
| 295 | 307 | $context['ftp_needed'] = false; |
@@ -297,8 +309,9 @@ discard block |
||
| 297 | 309 | $chmod_files = array(); |
| 298 | 310 | |
| 299 | 311 | // no actions found, return so we can display an error |
| 300 | - if (empty($actions)) |
|
| 301 | - return; |
|
| 312 | + if (empty($actions)) { |
|
| 313 | + return; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | // This will hold data about anything that can be installed in other themes. |
| 304 | 317 | $themeFinds = array( |
@@ -317,14 +330,14 @@ discard block |
||
| 317 | 330 | { |
| 318 | 331 | $chmod_files[] = $action['filename']; |
| 319 | 332 | continue; |
| 320 | - } |
|
| 321 | - elseif ($action['type'] == 'readme' || $action['type'] == 'license') |
|
| 333 | + } elseif ($action['type'] == 'readme' || $action['type'] == 'license') |
|
| 322 | 334 | { |
| 323 | 335 | $type = 'package_' . $action['type']; |
| 324 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 325 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r")); |
|
| 326 | - elseif (file_exists($action['filename'])) |
|
| 327 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 336 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 337 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r")); |
|
| 338 | + } elseif (file_exists($action['filename'])) { |
|
| 339 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 340 | + } |
|
| 328 | 341 | |
| 329 | 342 | if (!empty($action['parse_bbc'])) |
| 330 | 343 | { |
@@ -332,24 +345,24 @@ discard block |
||
| 332 | 345 | $context[$type] = preg_replace('~\[[/]?html\]~i', '', $context[$type]); |
| 333 | 346 | preparsecode($context[$type]); |
| 334 | 347 | $context[$type] = parse_bbc($context[$type]); |
| 348 | + } else { |
|
| 349 | + $context[$type] = nl2br($context[$type]); |
|
| 335 | 350 | } |
| 336 | - else |
|
| 337 | - $context[$type] = nl2br($context[$type]); |
|
| 338 | 351 | |
| 339 | 352 | continue; |
| 340 | 353 | } |
| 341 | 354 | // Don't show redirects. |
| 342 | - elseif ($action['type'] == 'redirect') |
|
| 343 | - continue; |
|
| 344 | - elseif ($action['type'] == 'error') |
|
| 355 | + elseif ($action['type'] == 'redirect') { |
|
| 356 | + continue; |
|
| 357 | + } elseif ($action['type'] == 'error') |
|
| 345 | 358 | { |
| 346 | 359 | $context['has_failure'] = true; |
| 347 | - if (isset($action['error_msg']) && isset($action['error_var'])) |
|
| 348 | - $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']); |
|
| 349 | - elseif (isset($action['error_msg'])) |
|
| 350 | - $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg']; |
|
| 351 | - } |
|
| 352 | - elseif ($action['type'] == 'modification') |
|
| 360 | + if (isset($action['error_msg']) && isset($action['error_var'])) { |
|
| 361 | + $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']); |
|
| 362 | + } elseif (isset($action['error_msg'])) { |
|
| 363 | + $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg']; |
|
| 364 | + } |
|
| 365 | + } elseif ($action['type'] == 'modification') |
|
| 353 | 366 | { |
| 354 | 367 | if (!file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
| 355 | 368 | { |
@@ -361,52 +374,54 @@ discard block |
||
| 361 | 374 | 'description' => $txt['package_action_missing'], |
| 362 | 375 | 'failed' => true, |
| 363 | 376 | ); |
| 364 | - } |
|
| 365 | - else |
|
| 377 | + } else |
|
| 366 | 378 | { |
| 367 | 379 | |
| 368 | - if ($action['boardmod']) |
|
| 369 | - $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 370 | - else |
|
| 371 | - $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 380 | + if ($action['boardmod']) { |
|
| 381 | + $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 382 | + } else { |
|
| 383 | + $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 384 | + } |
|
| 372 | 385 | |
| 373 | - if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') |
|
| 374 | - $mod_actions[0]['filename'] = $action['filename']; |
|
| 386 | + if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') { |
|
| 387 | + $mod_actions[0]['filename'] = $action['filename']; |
|
| 388 | + } |
|
| 375 | 389 | |
| 376 | 390 | foreach ($mod_actions as $key => $mod_action) |
| 377 | 391 | { |
| 378 | 392 | // Lets get the last section of the file name. |
| 379 | - if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') |
|
| 380 | - $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 381 | - elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
|
| 382 | - $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 383 | - else |
|
| 384 | - $actual_filename = $key; |
|
| 385 | - |
|
| 386 | - if ($mod_action['type'] == 'opened') |
|
| 387 | - $failed = false; |
|
| 388 | - elseif ($mod_action['type'] == 'failure') |
|
| 393 | + if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') { |
|
| 394 | + $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 395 | + } elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) { |
|
| 396 | + $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 397 | + } else { |
|
| 398 | + $actual_filename = $key; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if ($mod_action['type'] == 'opened') { |
|
| 402 | + $failed = false; |
|
| 403 | + } elseif ($mod_action['type'] == 'failure') |
|
| 389 | 404 | { |
| 390 | - if (empty($mod_action['is_custom'])) |
|
| 391 | - $context['has_failure'] = true; |
|
| 405 | + if (empty($mod_action['is_custom'])) { |
|
| 406 | + $context['has_failure'] = true; |
|
| 407 | + } |
|
| 392 | 408 | $failed = true; |
| 393 | - } |
|
| 394 | - elseif ($mod_action['type'] == 'chmod') |
|
| 409 | + } elseif ($mod_action['type'] == 'chmod') |
|
| 395 | 410 | { |
| 396 | 411 | $chmod_files[] = $mod_action['filename']; |
| 397 | - } |
|
| 398 | - elseif ($mod_action['type'] == 'saved') |
|
| 412 | + } elseif ($mod_action['type'] == 'saved') |
|
| 399 | 413 | { |
| 400 | 414 | if (!empty($mod_action['is_custom'])) |
| 401 | 415 | { |
| 402 | - if (!isset($context['theme_actions'][$mod_action['is_custom']])) |
|
| 403 | - $context['theme_actions'][$mod_action['is_custom']] = array( |
|
| 416 | + if (!isset($context['theme_actions'][$mod_action['is_custom']])) { |
|
| 417 | + $context['theme_actions'][$mod_action['is_custom']] = array( |
|
| 404 | 418 | 'name' => $theme_paths[$mod_action['is_custom']]['name'], |
| 405 | 419 | 'actions' => array(), |
| 406 | 420 | 'has_failure' => $failed, |
| 407 | 421 | ); |
| 408 | - else |
|
| 409 | - $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed; |
|
| 422 | + } else { |
|
| 423 | + $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed; |
|
| 424 | + } |
|
| 410 | 425 | |
| 411 | 426 | $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename] = array( |
| 412 | 427 | 'type' => $txt['execute_modification'], |
@@ -414,8 +429,7 @@ discard block |
||
| 414 | 429 | 'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'], |
| 415 | 430 | 'failed' => $failed, |
| 416 | 431 | ); |
| 417 | - } |
|
| 418 | - elseif (!isset($context['actions'][$actual_filename])) |
|
| 432 | + } elseif (!isset($context['actions'][$actual_filename])) |
|
| 419 | 433 | { |
| 420 | 434 | $context['actions'][$actual_filename] = array( |
| 421 | 435 | 'type' => $txt['execute_modification'], |
@@ -423,22 +437,19 @@ discard block |
||
| 423 | 437 | 'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'], |
| 424 | 438 | 'failed' => $failed, |
| 425 | 439 | ); |
| 426 | - } |
|
| 427 | - else |
|
| 440 | + } else |
|
| 428 | 441 | { |
| 429 | 442 | $context['actions'][$actual_filename]['failed'] |= $failed; |
| 430 | 443 | $context['actions'][$actual_filename]['description'] = $context['actions'][$actual_filename]['failed'] ? $txt['package_action_failure'] : $txt['package_action_success']; |
| 431 | 444 | } |
| 432 | - } |
|
| 433 | - elseif ($mod_action['type'] == 'skipping') |
|
| 445 | + } elseif ($mod_action['type'] == 'skipping') |
|
| 434 | 446 | { |
| 435 | 447 | $context['actions'][$actual_filename] = array( |
| 436 | 448 | 'type' => $txt['execute_modification'], |
| 437 | 449 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 438 | 450 | 'description' => $txt['package_action_skipping'] |
| 439 | 451 | ); |
| 440 | - } |
|
| 441 | - elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom'])) |
|
| 452 | + } elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom'])) |
|
| 442 | 453 | { |
| 443 | 454 | $context['has_failure'] = true; |
| 444 | 455 | $context['actions'][$actual_filename] = array( |
@@ -447,32 +458,33 @@ discard block |
||
| 447 | 458 | 'description' => $txt['package_action_missing'], |
| 448 | 459 | 'failed' => true, |
| 449 | 460 | ); |
| 450 | - } |
|
| 451 | - elseif ($mod_action['type'] == 'error') |
|
| 452 | - $context['actions'][$actual_filename] = array( |
|
| 461 | + } elseif ($mod_action['type'] == 'error') { |
|
| 462 | + $context['actions'][$actual_filename] = array( |
|
| 453 | 463 | 'type' => $txt['execute_modification'], |
| 454 | 464 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 455 | 465 | 'description' => $txt['package_action_error'], |
| 456 | 466 | 'failed' => true, |
| 457 | 467 | ); |
| 468 | + } |
|
| 458 | 469 | } |
| 459 | 470 | |
| 460 | 471 | // We need to loop again just to get the operations down correctly. |
| 461 | 472 | foreach ($mod_actions as $operation_key => $mod_action) |
| 462 | 473 | { |
| 463 | 474 | // Lets get the last section of the file name. |
| 464 | - if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') |
|
| 465 | - $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 466 | - elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
|
| 467 | - $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 468 | - else |
|
| 469 | - $actual_filename = $key; |
|
| 475 | + if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') { |
|
| 476 | + $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 477 | + } elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) { |
|
| 478 | + $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 479 | + } else { |
|
| 480 | + $actual_filename = $key; |
|
| 481 | + } |
|
| 470 | 482 | |
| 471 | 483 | // We just need it for actual parse changes. |
| 472 | 484 | if (!in_array($mod_action['type'], array('error', 'result', 'opened', 'saved', 'end', 'missing', 'skipping', 'chmod'))) |
| 473 | 485 | { |
| 474 | - if (empty($mod_action['is_custom'])) |
|
| 475 | - $context['actions'][$actual_filename]['operations'][] = array( |
|
| 486 | + if (empty($mod_action['is_custom'])) { |
|
| 487 | + $context['actions'][$actual_filename]['operations'][] = array( |
|
| 476 | 488 | 'type' => $txt['execute_modification'], |
| 477 | 489 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 478 | 490 | 'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'], |
@@ -483,10 +495,11 @@ discard block |
||
| 483 | 495 | 'failed' => $mod_action['failed'], |
| 484 | 496 | 'ignore_failure' => !empty($mod_action['ignore_failure']), |
| 485 | 497 | ); |
| 498 | + } |
|
| 486 | 499 | |
| 487 | 500 | // Themes are under the saved type. |
| 488 | - if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) |
|
| 489 | - $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array( |
|
| 501 | + if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) { |
|
| 502 | + $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array( |
|
| 490 | 503 | 'type' => $txt['execute_modification'], |
| 491 | 504 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 492 | 505 | 'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'], |
@@ -497,59 +510,55 @@ discard block |
||
| 497 | 510 | 'failed' => $mod_action['failed'], |
| 498 | 511 | 'ignore_failure' => !empty($mod_action['ignore_failure']), |
| 499 | 512 | ); |
| 513 | + } |
|
| 500 | 514 | } |
| 501 | 515 | } |
| 502 | 516 | } |
| 503 | - } |
|
| 504 | - elseif ($action['type'] == 'code') |
|
| 517 | + } elseif ($action['type'] == 'code') |
|
| 505 | 518 | { |
| 506 | 519 | $thisAction = array( |
| 507 | 520 | 'type' => $txt['execute_code'], |
| 508 | 521 | 'action' => $smcFunc['htmlspecialchars']($action['filename']), |
| 509 | 522 | ); |
| 510 | - } |
|
| 511 | - elseif ($action['type'] == 'database') |
|
| 523 | + } elseif ($action['type'] == 'database') |
|
| 512 | 524 | { |
| 513 | 525 | $thisAction = array( |
| 514 | 526 | 'type' => $txt['execute_database_changes'], |
| 515 | 527 | 'action' => $smcFunc['htmlspecialchars']($action['filename']), |
| 516 | 528 | ); |
| 517 | - } |
|
| 518 | - elseif (in_array($action['type'], array('create-dir', 'create-file'))) |
|
| 529 | + } elseif (in_array($action['type'], array('create-dir', 'create-file'))) |
|
| 519 | 530 | { |
| 520 | 531 | $thisAction = array( |
| 521 | 532 | 'type' => $txt['package_create'] . ' ' . ($action['type'] == 'create-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 522 | 533 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 523 | 534 | ); |
| 524 | - } |
|
| 525 | - elseif ($action['type'] == 'hook') |
|
| 535 | + } elseif ($action['type'] == 'hook') |
|
| 526 | 536 | { |
| 527 | 537 | $action['description'] = !isset($action['hook'], $action['function']) ? $txt['package_action_failure'] : $txt['package_action_success']; |
| 528 | 538 | |
| 529 | - if (!isset($action['hook'], $action['function'])) |
|
| 530 | - $context['has_failure'] = true; |
|
| 539 | + if (!isset($action['hook'], $action['function'])) { |
|
| 540 | + $context['has_failure'] = true; |
|
| 541 | + } |
|
| 531 | 542 | |
| 532 | 543 | $thisAction = array( |
| 533 | 544 | 'type' => $action['reverse'] ? $txt['execute_hook_remove'] : $txt['execute_hook_add'], |
| 534 | 545 | 'action' => sprintf($txt['execute_hook_action' . ($action['reverse'] ? '_inverse' : '')], $smcFunc['htmlspecialchars']($action['hook'])), |
| 535 | 546 | ); |
| 536 | - } |
|
| 537 | - elseif ($action['type'] == 'credits') |
|
| 547 | + } elseif ($action['type'] == 'credits') |
|
| 538 | 548 | { |
| 539 | 549 | $thisAction = array( |
| 540 | 550 | 'type' => $txt['execute_credits_add'], |
| 541 | 551 | 'action' => sprintf($txt['execute_credits_action'], $smcFunc['htmlspecialchars']($action['title'])), |
| 542 | 552 | ); |
| 543 | - } |
|
| 544 | - elseif ($action['type'] == 'requires') |
|
| 553 | + } elseif ($action['type'] == 'requires') |
|
| 545 | 554 | { |
| 546 | 555 | $installed = false; |
| 547 | 556 | $version = true; |
| 548 | 557 | |
| 549 | 558 | // package missing required values? |
| 550 | - if (!isset($action['id'])) |
|
| 551 | - $context['has_failure'] = true; |
|
| 552 | - else |
|
| 559 | + if (!isset($action['id'])) { |
|
| 560 | + $context['has_failure'] = true; |
|
| 561 | + } else |
|
| 553 | 562 | { |
| 554 | 563 | // See if this dependancy is installed |
| 555 | 564 | $request = $smcFunc['db_query']('', ' |
@@ -565,8 +574,9 @@ discard block |
||
| 565 | 574 | ) |
| 566 | 575 | ); |
| 567 | 576 | $installed = ($smcFunc['db_num_rows']($request) !== 0); |
| 568 | - if ($installed) |
|
| 569 | - list ($version) = $smcFunc['db_fetch_row']($request); |
|
| 577 | + if ($installed) { |
|
| 578 | + list ($version) = $smcFunc['db_fetch_row']($request); |
|
| 579 | + } |
|
| 570 | 580 | $smcFunc['db_free_result']($request); |
| 571 | 581 | |
| 572 | 582 | // do a version level check (if requested) in the most basic way |
@@ -581,8 +591,7 @@ discard block |
||
| 581 | 591 | 'type' => $txt['package_requires'], |
| 582 | 592 | 'action' => $txt['package_check_for'] . ' ' . $action['id'] . (isset($action['version']) ? (' / ' . ($version ? $action['version'] : '<span class="error">' . $action['version'] . '</span>')) : ''), |
| 583 | 593 | ); |
| 584 | - } |
|
| 585 | - elseif (in_array($action['type'], array('require-dir', 'require-file'))) |
|
| 594 | + } elseif (in_array($action['type'], array('require-dir', 'require-file'))) |
|
| 586 | 595 | { |
| 587 | 596 | // Do this one... |
| 588 | 597 | $thisAction = array( |
@@ -596,26 +605,29 @@ discard block |
||
| 596 | 605 | // Is the action already stated? |
| 597 | 606 | $theme_action = !empty($action['theme_action']) && in_array($action['theme_action'], array('no', 'yes', 'auto')) ? $action['theme_action'] : 'auto'; |
| 598 | 607 | // If it's not auto do we think we have something we can act upon? |
| 599 | - if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
|
| 600 | - $theme_action = ''; |
|
| 608 | + if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) { |
|
| 609 | + $theme_action = ''; |
|
| 610 | + } |
|
| 601 | 611 | // ... or if it's auto do we even want to do anything? |
| 602 | - elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') |
|
| 603 | - $theme_action = ''; |
|
| 612 | + elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') { |
|
| 613 | + $theme_action = ''; |
|
| 614 | + } |
|
| 604 | 615 | |
| 605 | 616 | // So, we still want to do something? |
| 606 | - if ($theme_action != '') |
|
| 607 | - $themeFinds['candidates'][] = $action; |
|
| 617 | + if ($theme_action != '') { |
|
| 618 | + $themeFinds['candidates'][] = $action; |
|
| 619 | + } |
|
| 608 | 620 | // Otherwise is this is going into another theme record it. |
| 609 | - elseif ($matches[1] == 'themes_dir') |
|
| 610 | - $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 621 | + elseif ($matches[1] == 'themes_dir') { |
|
| 622 | + $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 623 | + } |
|
| 611 | 624 | } |
| 612 | - } |
|
| 613 | - elseif (in_array($action['type'], array('move-dir', 'move-file'))) |
|
| 614 | - $thisAction = array( |
|
| 625 | + } elseif (in_array($action['type'], array('move-dir', 'move-file'))) { |
|
| 626 | + $thisAction = array( |
|
| 615 | 627 | 'type' => $txt['package_move'] . ' ' . ($action['type'] == 'move-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 616 | 628 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['source'], array($boarddir => '.'))) . ' => ' . $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 617 | 629 | ); |
| 618 | - elseif (in_array($action['type'], array('remove-dir', 'remove-file'))) |
|
| 630 | + } elseif (in_array($action['type'], array('remove-dir', 'remove-file'))) |
|
| 619 | 631 | { |
| 620 | 632 | $thisAction = array( |
| 621 | 633 | 'type' => $txt['package_delete'] . ' ' . ($action['type'] == 'remove-dir' ? $txt['package_tree'] : $txt['package_file']), |
@@ -631,30 +643,36 @@ discard block |
||
| 631 | 643 | $action['unparsed_destination'] = $action['unparsed_filename']; |
| 632 | 644 | |
| 633 | 645 | // If it's not auto do we think we have something we can act upon? |
| 634 | - if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
|
| 635 | - $theme_action = ''; |
|
| 646 | + if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) { |
|
| 647 | + $theme_action = ''; |
|
| 648 | + } |
|
| 636 | 649 | // ... or if it's auto do we even want to do anything? |
| 637 | - elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') |
|
| 638 | - $theme_action = ''; |
|
| 650 | + elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') { |
|
| 651 | + $theme_action = ''; |
|
| 652 | + } |
|
| 639 | 653 | |
| 640 | 654 | // So, we still want to do something? |
| 641 | - if ($theme_action != '') |
|
| 642 | - $themeFinds['candidates'][] = $action; |
|
| 655 | + if ($theme_action != '') { |
|
| 656 | + $themeFinds['candidates'][] = $action; |
|
| 657 | + } |
|
| 643 | 658 | // Otherwise is this is going into another theme record it. |
| 644 | - elseif ($matches[1] == 'themes_dir') |
|
| 645 | - $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 659 | + elseif ($matches[1] == 'themes_dir') { |
|
| 660 | + $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 661 | + } |
|
| 646 | 662 | } |
| 647 | 663 | } |
| 648 | 664 | |
| 649 | - if (empty($thisAction)) |
|
| 650 | - continue; |
|
| 665 | + if (empty($thisAction)) { |
|
| 666 | + continue; |
|
| 667 | + } |
|
| 651 | 668 | |
| 652 | 669 | if (!in_array($action['type'], array('hook', 'credits'))) |
| 653 | 670 | { |
| 654 | - if ($context['uninstalling']) |
|
| 655 | - $file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 656 | - else |
|
| 657 | - $file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 671 | + if ($context['uninstalling']) { |
|
| 672 | + $file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 673 | + } else { |
|
| 674 | + $file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 675 | + } |
|
| 658 | 676 | } |
| 659 | 677 | |
| 660 | 678 | // Don't fail if a file/directory we're trying to create doesn't exist... |
@@ -669,8 +687,9 @@ discard block |
||
| 669 | 687 | } |
| 670 | 688 | |
| 671 | 689 | // @todo None given? |
| 672 | - if (empty($thisAction['description'])) |
|
| 673 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 690 | + if (empty($thisAction['description'])) { |
|
| 691 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 692 | + } |
|
| 674 | 693 | |
| 675 | 694 | $context['actions'][] = $thisAction; |
| 676 | 695 | } |
@@ -683,18 +702,21 @@ discard block |
||
| 683 | 702 | // Get the part of the file we'll be dealing with. |
| 684 | 703 | preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir)(\\|/)*(.+)*~i', $action_data['unparsed_destination'], $matches); |
| 685 | 704 | |
| 686 | - if ($matches[1] == 'imagesdir') |
|
| 687 | - $path = '/' . basename($settings['default_images_url']); |
|
| 688 | - elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir') |
|
| 689 | - $path = '/languages'; |
|
| 690 | - else |
|
| 691 | - $path = ''; |
|
| 705 | + if ($matches[1] == 'imagesdir') { |
|
| 706 | + $path = '/' . basename($settings['default_images_url']); |
|
| 707 | + } elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir') { |
|
| 708 | + $path = '/languages'; |
|
| 709 | + } else { |
|
| 710 | + $path = ''; |
|
| 711 | + } |
|
| 692 | 712 | |
| 693 | - if (!empty($matches[3])) |
|
| 694 | - $path .= $matches[3]; |
|
| 713 | + if (!empty($matches[3])) { |
|
| 714 | + $path .= $matches[3]; |
|
| 715 | + } |
|
| 695 | 716 | |
| 696 | - if (!$context['uninstalling']) |
|
| 697 | - $path .= '/' . basename($action_data['filename']); |
|
| 717 | + if (!$context['uninstalling']) { |
|
| 718 | + $path .= '/' . basename($action_data['filename']); |
|
| 719 | + } |
|
| 698 | 720 | |
| 699 | 721 | // Loop through each custom theme to note it's candidacy! |
| 700 | 722 | foreach ($theme_paths as $id => $theme_data) |
@@ -710,36 +732,40 @@ discard block |
||
| 710 | 732 | if (!mktree(dirname($real_path), false)) |
| 711 | 733 | { |
| 712 | 734 | $temp = dirname($real_path); |
| 713 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
| 714 | - $temp = dirname($temp); |
|
| 735 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
| 736 | + $temp = dirname($temp); |
|
| 737 | + } |
|
| 715 | 738 | $chmod_files[] = $temp; |
| 716 | 739 | } |
| 717 | 740 | |
| 718 | - if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) |
|
| 719 | - $chmod_files[] = $real_path; |
|
| 741 | + if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) { |
|
| 742 | + $chmod_files[] = $real_path; |
|
| 743 | + } |
|
| 720 | 744 | |
| 721 | - if (!isset($context['theme_actions'][$id])) |
|
| 722 | - $context['theme_actions'][$id] = array( |
|
| 745 | + if (!isset($context['theme_actions'][$id])) { |
|
| 746 | + $context['theme_actions'][$id] = array( |
|
| 723 | 747 | 'name' => $theme_data['name'], |
| 724 | 748 | 'actions' => array(), |
| 725 | 749 | ); |
| 750 | + } |
|
| 726 | 751 | |
| 727 | - if ($context['uninstalling']) |
|
| 728 | - $context['theme_actions'][$id]['actions'][] = array( |
|
| 752 | + if ($context['uninstalling']) { |
|
| 753 | + $context['theme_actions'][$id]['actions'][] = array( |
|
| 729 | 754 | 'type' => $txt['package_delete'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 730 | 755 | 'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')), |
| 731 | 756 | 'description' => '', |
| 732 | 757 | 'value' => base64_encode($smcFunc['json_encode'](array('type' => $action_data['type'], 'orig' => $action_data['filename'], 'future' => $real_path, 'id' => $id))), |
| 733 | 758 | 'not_mod' => true, |
| 734 | 759 | ); |
| 735 | - else |
|
| 736 | - $context['theme_actions'][$id]['actions'][] = array( |
|
| 760 | + } else { |
|
| 761 | + $context['theme_actions'][$id]['actions'][] = array( |
|
| 737 | 762 | 'type' => $txt['package_extract'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 738 | 763 | 'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')), |
| 739 | 764 | 'description' => '', |
| 740 | 765 | 'value' => base64_encode($smcFunc['json_encode'](array('type' => $action_data['type'], 'orig' => $action_data['destination'], 'future' => $real_path, 'id' => $id))), |
| 741 | 766 | 'not_mod' => true, |
| 742 | 767 | ); |
| 768 | + } |
|
| 743 | 769 | } |
| 744 | 770 | } |
| 745 | 771 | } |
@@ -749,8 +775,9 @@ discard block |
||
| 749 | 775 | // Trash the cache... which will also check permissions for us! |
| 750 | 776 | package_flush_cache(true); |
| 751 | 777 | |
| 752 | - if (file_exists($packagesdir . '/temp')) |
|
| 753 | - deltree($packagesdir . '/temp'); |
|
| 778 | + if (file_exists($packagesdir . '/temp')) { |
|
| 779 | + deltree($packagesdir . '/temp'); |
|
| 780 | + } |
|
| 754 | 781 | |
| 755 | 782 | if (!empty($chmod_files)) |
| 756 | 783 | { |
@@ -775,8 +802,9 @@ discard block |
||
| 775 | 802 | checkSession(); |
| 776 | 803 | |
| 777 | 804 | // If there's no file, what are we installing? |
| 778 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 779 | - redirectexit('action=admin;area=packages'); |
|
| 805 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 806 | + redirectexit('action=admin;area=packages'); |
|
| 807 | + } |
|
| 780 | 808 | $context['filename'] = $_REQUEST['package']; |
| 781 | 809 | |
| 782 | 810 | // If this is an uninstall, we'll have an id. |
@@ -797,51 +825,55 @@ discard block |
||
| 797 | 825 | |
| 798 | 826 | $context['sub_template'] = 'extract_package'; |
| 799 | 827 | |
| 800 | - if (!file_exists($packagesdir . '/' . $context['filename'])) |
|
| 801 | - fatal_lang_error('package_no_file', false); |
|
| 828 | + if (!file_exists($packagesdir . '/' . $context['filename'])) { |
|
| 829 | + fatal_lang_error('package_no_file', false); |
|
| 830 | + } |
|
| 802 | 831 | |
| 803 | 832 | // Load up the package FTP information? |
| 804 | 833 | create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'])); |
| 805 | 834 | |
| 806 | 835 | // Make sure temp directory exists and is empty! |
| 807 | - if (file_exists($packagesdir . '/temp')) |
|
| 808 | - deltree($packagesdir . '/temp', false); |
|
| 809 | - else |
|
| 810 | - mktree($packagesdir . '/temp', 0777); |
|
| 836 | + if (file_exists($packagesdir . '/temp')) { |
|
| 837 | + deltree($packagesdir . '/temp', false); |
|
| 838 | + } else { |
|
| 839 | + mktree($packagesdir . '/temp', 0777); |
|
| 840 | + } |
|
| 811 | 841 | |
| 812 | 842 | // Let the unpacker do the work. |
| 813 | 843 | if (is_file($packagesdir . '/' . $context['filename'])) |
| 814 | 844 | { |
| 815 | 845 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 816 | 846 | |
| 817 | - if (!file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 818 | - foreach ($context['extracted_files'] as $file) |
|
| 847 | + if (!file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 848 | + foreach ($context['extracted_files'] as $file) |
|
| 819 | 849 | if (basename($file['filename']) == 'package-info.xml') |
| 820 | 850 | { |
| 821 | 851 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 852 | + } |
|
| 822 | 853 | break; |
| 823 | 854 | } |
| 824 | 855 | |
| 825 | - if (!isset($context['base_path'])) |
|
| 826 | - $context['base_path'] = ''; |
|
| 827 | - } |
|
| 828 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 856 | + if (!isset($context['base_path'])) { |
|
| 857 | + $context['base_path'] = ''; |
|
| 858 | + } |
|
| 859 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 829 | 860 | { |
| 830 | 861 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 831 | 862 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
| 832 | 863 | $context['base_path'] = ''; |
| 864 | + } else { |
|
| 865 | + fatal_lang_error('no_access', false); |
|
| 833 | 866 | } |
| 834 | - else |
|
| 835 | - fatal_lang_error('no_access', false); |
|
| 836 | 867 | |
| 837 | 868 | // Are we installing this into any custom themes? |
| 838 | 869 | $custom_themes = array(1); |
| 839 | 870 | $known_themes = explode(',', $modSettings['knownThemes']); |
| 840 | 871 | if (!empty($_POST['custom_theme'])) |
| 841 | 872 | { |
| 842 | - foreach ($_POST['custom_theme'] as $tid) |
|
| 843 | - if (in_array($tid, $known_themes)) |
|
| 873 | + foreach ($_POST['custom_theme'] as $tid) { |
|
| 874 | + if (in_array($tid, $known_themes)) |
|
| 844 | 875 | $custom_themes[] = (int) $tid; |
| 876 | + } |
|
| 845 | 877 | } |
| 846 | 878 | |
| 847 | 879 | // Now load up the paths of the themes that we need to know about. |
@@ -858,8 +890,9 @@ discard block |
||
| 858 | 890 | ); |
| 859 | 891 | $theme_paths = array(); |
| 860 | 892 | $themes_installed = array(1); |
| 861 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 862 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 894 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 895 | + } |
|
| 863 | 896 | $smcFunc['db_free_result']($request); |
| 864 | 897 | |
| 865 | 898 | // Are there any theme copying that we want to take place? |
@@ -871,11 +904,13 @@ discard block |
||
| 871 | 904 | { |
| 872 | 905 | foreach ($_POST['theme_changes'] as $change) |
| 873 | 906 | { |
| 874 | - if (empty($change)) |
|
| 875 | - continue; |
|
| 907 | + if (empty($change)) { |
|
| 908 | + continue; |
|
| 909 | + } |
|
| 876 | 910 | $theme_data = $smcFunc['json_decode'](base64_decode($change), true); |
| 877 | - if (empty($theme_data['type'])) |
|
| 878 | - continue; |
|
| 911 | + if (empty($theme_data['type'])) { |
|
| 912 | + continue; |
|
| 913 | + } |
|
| 879 | 914 | |
| 880 | 915 | $themes_installed[] = $theme_data['id']; |
| 881 | 916 | $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; |
@@ -884,8 +919,9 @@ discard block |
||
| 884 | 919 | |
| 885 | 920 | // Get the package info... |
| 886 | 921 | $packageInfo = getPackageInfo($context['filename']); |
| 887 | - if (!is_array($packageInfo)) |
|
| 888 | - fatal_lang_error($packageInfo); |
|
| 922 | + if (!is_array($packageInfo)) { |
|
| 923 | + fatal_lang_error($packageInfo); |
|
| 924 | + } |
|
| 889 | 925 | |
| 890 | 926 | $packageInfo['filename'] = $context['filename']; |
| 891 | 927 | |
@@ -897,8 +933,9 @@ discard block |
||
| 897 | 933 | { |
| 898 | 934 | $_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$'); |
| 899 | 935 | $result = package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.')); |
| 900 | - if (!$result) |
|
| 901 | - fatal_lang_error('could_not_package_backup', false); |
|
| 936 | + if (!$result) { |
|
| 937 | + fatal_lang_error('could_not_package_backup', false); |
|
| 938 | + } |
|
| 902 | 939 | } |
| 903 | 940 | |
| 904 | 941 | // The mod isn't installed.... unless proven otherwise. |
@@ -938,35 +975,38 @@ discard block |
||
| 938 | 975 | $install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall'); |
| 939 | 976 | |
| 940 | 977 | // Gadzooks! There's no uninstaller at all!? |
| 941 | - if (empty($install_log)) |
|
| 942 | - fatal_lang_error('package_uninstall_cannot', false); |
|
| 978 | + if (empty($install_log)) { |
|
| 979 | + fatal_lang_error('package_uninstall_cannot', false); |
|
| 980 | + } |
|
| 943 | 981 | |
| 944 | 982 | // They can only uninstall from what it was originally installed into. |
| 945 | - foreach ($theme_paths as $id => $data) |
|
| 946 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 983 | + foreach ($theme_paths as $id => $data) { |
|
| 984 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 947 | 985 | unset($theme_paths[$id]); |
| 948 | - } |
|
| 949 | - elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 986 | + } |
|
| 987 | + } elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 950 | 988 | { |
| 951 | 989 | // Look for an upgrade... |
| 952 | 990 | $install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $old_version); |
| 953 | 991 | |
| 954 | 992 | // There was no upgrade.... |
| 955 | - if (empty($install_log)) |
|
| 956 | - $context['is_installed'] = true; |
|
| 957 | - else |
|
| 993 | + if (empty($install_log)) { |
|
| 994 | + $context['is_installed'] = true; |
|
| 995 | + } else |
|
| 958 | 996 | { |
| 959 | 997 | // Upgrade previous themes only! |
| 960 | - foreach ($theme_paths as $id => $data) |
|
| 961 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 998 | + foreach ($theme_paths as $id => $data) { |
|
| 999 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 962 | 1000 | unset($theme_paths[$id]); |
| 1001 | + } |
|
| 963 | 1002 | } |
| 1003 | + } elseif (isset($old_version) && $old_version == $packageInfo['version']) { |
|
| 1004 | + $context['is_installed'] = true; |
|
| 964 | 1005 | } |
| 965 | - elseif (isset($old_version) && $old_version == $packageInfo['version']) |
|
| 966 | - $context['is_installed'] = true; |
|
| 967 | 1006 | |
| 968 | - if (!isset($old_version) || $context['is_installed']) |
|
| 969 | - $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); |
|
| 1007 | + if (!isset($old_version) || $context['is_installed']) { |
|
| 1008 | + $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); |
|
| 1009 | + } |
|
| 970 | 1010 | |
| 971 | 1011 | $context['install_finished'] = false; |
| 972 | 1012 | |
@@ -983,37 +1023,39 @@ discard block |
||
| 983 | 1023 | |
| 984 | 1024 | if ($action['type'] == 'modification' && !empty($action['filename'])) |
| 985 | 1025 | { |
| 986 | - if ($action['boardmod']) |
|
| 987 | - $mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 988 | - else |
|
| 989 | - $mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1026 | + if ($action['boardmod']) { |
|
| 1027 | + $mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1028 | + } else { |
|
| 1029 | + $mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1030 | + } |
|
| 990 | 1031 | |
| 991 | 1032 | // Any errors worth noting? |
| 992 | 1033 | foreach ($mod_actions as $key => $modAction) |
| 993 | 1034 | { |
| 994 | - if ($modAction['type'] == 'failure') |
|
| 995 | - $failed_steps[] = array( |
|
| 1035 | + if ($modAction['type'] == 'failure') { |
|
| 1036 | + $failed_steps[] = array( |
|
| 996 | 1037 | 'file' => $modAction['filename'], |
| 997 | 1038 | 'large_step' => $failed_count, |
| 998 | 1039 | 'sub_step' => $key, |
| 999 | 1040 | 'theme' => 1, |
| 1000 | 1041 | ); |
| 1042 | + } |
|
| 1001 | 1043 | |
| 1002 | 1044 | // Gather the themes we installed into. |
| 1003 | - if (!empty($modAction['is_custom'])) |
|
| 1004 | - $themes_installed[] = $modAction['is_custom']; |
|
| 1045 | + if (!empty($modAction['is_custom'])) { |
|
| 1046 | + $themes_installed[] = $modAction['is_custom']; |
|
| 1047 | + } |
|
| 1005 | 1048 | } |
| 1006 | - } |
|
| 1007 | - elseif ($action['type'] == 'code' && !empty($action['filename'])) |
|
| 1049 | + } elseif ($action['type'] == 'code' && !empty($action['filename'])) |
|
| 1008 | 1050 | { |
| 1009 | 1051 | // This is just here as reference for what is available. |
| 1010 | 1052 | global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $forum_version, $smcFunc; |
| 1011 | 1053 | |
| 1012 | 1054 | // Now include the file and be done with it ;). |
| 1013 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 1014 | - require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1015 | - } |
|
| 1016 | - elseif ($action['type'] == 'credits') |
|
| 1055 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 1056 | + require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1057 | + } |
|
| 1058 | + } elseif ($action['type'] == 'credits') |
|
| 1017 | 1059 | { |
| 1018 | 1060 | // Time to build the billboard |
| 1019 | 1061 | $credits_tag = array( |
@@ -1023,13 +1065,13 @@ discard block |
||
| 1023 | 1065 | 'copyright' => $action['copyright'], |
| 1024 | 1066 | 'title' => $action['title'], |
| 1025 | 1067 | ); |
| 1026 | - } |
|
| 1027 | - elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) |
|
| 1068 | + } elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) |
|
| 1028 | 1069 | { |
| 1029 | - if ($action['reverse']) |
|
| 1030 | - remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1031 | - else |
|
| 1032 | - add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1070 | + if ($action['reverse']) { |
|
| 1071 | + remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1072 | + } else { |
|
| 1073 | + add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1074 | + } |
|
| 1033 | 1075 | } |
| 1034 | 1076 | // Only do the database changes on uninstall if requested. |
| 1035 | 1077 | elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes']))) |
@@ -1042,8 +1084,9 @@ discard block |
||
| 1042 | 1084 | db_extend('packages'); |
| 1043 | 1085 | |
| 1044 | 1086 | // Let the file work its magic ;) |
| 1045 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 1046 | - require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1087 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 1088 | + require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1089 | + } |
|
| 1047 | 1090 | } |
| 1048 | 1091 | // Handle a redirect... |
| 1049 | 1092 | elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) |
@@ -1125,8 +1168,9 @@ discard block |
||
| 1125 | 1168 | reloadSettings(); |
| 1126 | 1169 | |
| 1127 | 1170 | // Any db changes from older version? |
| 1128 | - if (!empty($old_db_changes)) |
|
| 1129 | - $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); |
|
| 1171 | + if (!empty($old_db_changes)) { |
|
| 1172 | + $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); |
|
| 1173 | + } |
|
| 1130 | 1174 | |
| 1131 | 1175 | // If there are some database changes we might want to remove then filter them out. |
| 1132 | 1176 | if (!empty($db_package_log)) |
@@ -1142,22 +1186,24 @@ discard block |
||
| 1142 | 1186 | */ |
| 1143 | 1187 | function sort_table_first($a, $b) |
| 1144 | 1188 | { |
| 1145 | - if ($a[0] == $b[0]) |
|
| 1146 | - return 0; |
|
| 1189 | + if ($a[0] == $b[0]) { |
|
| 1190 | + return 0; |
|
| 1191 | + } |
|
| 1147 | 1192 | return $a[0] == 'remove_table' ? -1 : 1; |
| 1148 | 1193 | } |
| 1149 | 1194 | usort($db_package_log, 'sort_table_first'); |
| 1150 | 1195 | foreach ($db_package_log as $k => $log) |
| 1151 | 1196 | { |
| 1152 | - if ($log[0] == 'remove_table') |
|
| 1153 | - $tables[] = $log[1]; |
|
| 1154 | - elseif (in_array($log[1], $tables)) |
|
| 1155 | - unset($db_package_log[$k]); |
|
| 1197 | + if ($log[0] == 'remove_table') { |
|
| 1198 | + $tables[] = $log[1]; |
|
| 1199 | + } elseif (in_array($log[1], $tables)) { |
|
| 1200 | + unset($db_package_log[$k]); |
|
| 1201 | + } |
|
| 1156 | 1202 | } |
| 1157 | 1203 | $db_changes = $smcFunc['json_encode']($db_package_log); |
| 1204 | + } else { |
|
| 1205 | + $db_changes = ''; |
|
| 1158 | 1206 | } |
| 1159 | - else |
|
| 1160 | - $db_changes = ''; |
|
| 1161 | 1207 | |
| 1162 | 1208 | // What themes did we actually install? |
| 1163 | 1209 | $themes_installed = array_unique($themes_installed); |
@@ -1206,18 +1252,20 @@ discard block |
||
| 1206 | 1252 | |
| 1207 | 1253 | foreach ($db_changes as $change) |
| 1208 | 1254 | { |
| 1209 | - if ($change[0] == 'remove_table' && isset($change[1])) |
|
| 1210 | - $smcFunc['db_drop_table']($change[1]); |
|
| 1211 | - elseif ($change[0] == 'remove_column' && isset($change[2])) |
|
| 1212 | - $smcFunc['db_remove_column']($change[1], $change[2]); |
|
| 1213 | - elseif ($change[0] == 'remove_index' && isset($change[2])) |
|
| 1214 | - $smcFunc['db_remove_index']($change[1], $change[2]); |
|
| 1255 | + if ($change[0] == 'remove_table' && isset($change[1])) { |
|
| 1256 | + $smcFunc['db_drop_table']($change[1]); |
|
| 1257 | + } elseif ($change[0] == 'remove_column' && isset($change[2])) { |
|
| 1258 | + $smcFunc['db_remove_column']($change[1], $change[2]); |
|
| 1259 | + } elseif ($change[0] == 'remove_index' && isset($change[2])) { |
|
| 1260 | + $smcFunc['db_remove_index']($change[1], $change[2]); |
|
| 1261 | + } |
|
| 1215 | 1262 | } |
| 1216 | 1263 | } |
| 1217 | 1264 | |
| 1218 | 1265 | // Clean house... get rid of the evidence ;). |
| 1219 | - if (file_exists($packagesdir . '/temp')) |
|
| 1220 | - deltree($packagesdir . '/temp'); |
|
| 1266 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1267 | + deltree($packagesdir . '/temp'); |
|
| 1268 | + } |
|
| 1221 | 1269 | |
| 1222 | 1270 | // Log what we just did. |
| 1223 | 1271 | logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $smcFunc['htmlspecialchars']($packageInfo['name']), 'version' => $smcFunc['htmlspecialchars']($packageInfo['version'])), 'admin'); |
@@ -1239,8 +1287,9 @@ discard block |
||
| 1239 | 1287 | require_once($sourcedir . '/Subs-Package.php'); |
| 1240 | 1288 | |
| 1241 | 1289 | // No package? Show him or her the door. |
| 1242 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 1243 | - redirectexit('action=admin;area=packages'); |
|
| 1290 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 1291 | + redirectexit('action=admin;area=packages'); |
|
| 1292 | + } |
|
| 1244 | 1293 | |
| 1245 | 1294 | $context['linktree'][] = array( |
| 1246 | 1295 | 'url' => $scripturl . '?action=admin;area=packages;sa=list;package=' . $_REQUEST['package'], |
@@ -1253,11 +1302,12 @@ discard block |
||
| 1253 | 1302 | $context['filename'] = $_REQUEST['package']; |
| 1254 | 1303 | |
| 1255 | 1304 | // Let the unpacker do the work. |
| 1256 | - if (is_file($packagesdir . '/' . $context['filename'])) |
|
| 1257 | - $context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null); |
|
| 1258 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1259 | - $context['files'] = listtree($packagesdir . '/' . $context['filename']); |
|
| 1260 | -} |
|
| 1305 | + if (is_file($packagesdir . '/' . $context['filename'])) { |
|
| 1306 | + $context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null); |
|
| 1307 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) { |
|
| 1308 | + $context['files'] = listtree($packagesdir . '/' . $context['filename']); |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1261 | 1311 | |
| 1262 | 1312 | /** |
| 1263 | 1313 | * Display one of the files in a package. |
@@ -1269,22 +1319,25 @@ discard block |
||
| 1269 | 1319 | require_once($sourcedir . '/Subs-Package.php'); |
| 1270 | 1320 | |
| 1271 | 1321 | // No package? Show him or her the door. |
| 1272 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 1273 | - redirectexit('action=admin;area=packages'); |
|
| 1322 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 1323 | + redirectexit('action=admin;area=packages'); |
|
| 1324 | + } |
|
| 1274 | 1325 | |
| 1275 | 1326 | // No file? Show him or her the door. |
| 1276 | - if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '') |
|
| 1277 | - redirectexit('action=admin;area=packages'); |
|
| 1327 | + if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '') { |
|
| 1328 | + redirectexit('action=admin;area=packages'); |
|
| 1329 | + } |
|
| 1278 | 1330 | |
| 1279 | 1331 | $_REQUEST['package'] = preg_replace('~[\.]+~', '.', strtr($_REQUEST['package'], array('/' => '_', '\\' => '_'))); |
| 1280 | 1332 | $_REQUEST['file'] = preg_replace('~[\.]+~', '.', $_REQUEST['file']); |
| 1281 | 1333 | |
| 1282 | 1334 | if (isset($_REQUEST['raw'])) |
| 1283 | 1335 | { |
| 1284 | - if (is_file($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1285 | - echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true); |
|
| 1286 | - elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1287 | - echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']); |
|
| 1336 | + if (is_file($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1337 | + echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true); |
|
| 1338 | + } elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1339 | + echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']); |
|
| 1340 | + } |
|
| 1288 | 1341 | |
| 1289 | 1342 | obExit(false); |
| 1290 | 1343 | } |
@@ -1301,17 +1354,19 @@ discard block |
||
| 1301 | 1354 | $context['filename'] = $_REQUEST['file']; |
| 1302 | 1355 | |
| 1303 | 1356 | // Let the unpacker do the work.... but make sure we handle images properly. |
| 1304 | - if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) |
|
| 1305 | - $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">'; |
|
| 1306 | - else |
|
| 1357 | + if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) { |
|
| 1358 | + $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">'; |
|
| 1359 | + } else |
|
| 1307 | 1360 | { |
| 1308 | - if (is_file($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1309 | - $context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true)); |
|
| 1310 | - elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1311 | - $context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file'])); |
|
| 1361 | + if (is_file($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1362 | + $context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true)); |
|
| 1363 | + } elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1364 | + $context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file'])); |
|
| 1365 | + } |
|
| 1312 | 1366 | |
| 1313 | - if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php') |
|
| 1314 | - $context['filedata'] = highlight_php_code($context['filedata']); |
|
| 1367 | + if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php') { |
|
| 1368 | + $context['filedata'] = highlight_php_code($context['filedata']); |
|
| 1369 | + } |
|
| 1315 | 1370 | } |
| 1316 | 1371 | } |
| 1317 | 1372 | |
@@ -1326,8 +1381,9 @@ discard block |
||
| 1326 | 1381 | checkSession('get'); |
| 1327 | 1382 | |
| 1328 | 1383 | // Ack, don't allow deletion of arbitrary files here, could become a security hole somehow! |
| 1329 | - if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups') |
|
| 1330 | - redirectexit('action=admin;area=packages;sa=browse'); |
|
| 1384 | + if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups') { |
|
| 1385 | + redirectexit('action=admin;area=packages;sa=browse'); |
|
| 1386 | + } |
|
| 1331 | 1387 | $_GET['package'] = preg_replace('~[\.]+~', '.', strtr($_GET['package'], array('/' => '_', '\\' => '_'))); |
| 1332 | 1388 | |
| 1333 | 1389 | // Can't delete what's not there. |
@@ -1335,9 +1391,9 @@ discard block |
||
| 1335 | 1391 | { |
| 1336 | 1392 | create_chmod_control(array($packagesdir . '/' . $_GET['package']), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=remove;package=' . $_GET['package'], 'crash_on_error' => true)); |
| 1337 | 1393 | |
| 1338 | - if (is_dir($packagesdir . '/' . $_GET['package'])) |
|
| 1339 | - deltree($packagesdir . '/' . $_GET['package']); |
|
| 1340 | - else |
|
| 1394 | + if (is_dir($packagesdir . '/' . $_GET['package'])) { |
|
| 1395 | + deltree($packagesdir . '/' . $_GET['package']); |
|
| 1396 | + } else |
|
| 1341 | 1397 | { |
| 1342 | 1398 | smf_chmod($packagesdir . '/' . $_GET['package'], 0777); |
| 1343 | 1399 | unlink($packagesdir . '/' . $_GET['package']); |
@@ -1385,8 +1441,9 @@ discard block |
||
| 1385 | 1441 | 'data' => array( |
| 1386 | 1442 | 'function' => function($package_md5) use ($type, &$context) |
| 1387 | 1443 | { |
| 1388 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1389 | - return $context['available_' . $type . ''][$package_md5]['sort_id']; |
|
| 1444 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1445 | + return $context['available_' . $type . ''][$package_md5]['sort_id']; |
|
| 1446 | + } |
|
| 1390 | 1447 | }, |
| 1391 | 1448 | ), |
| 1392 | 1449 | 'sort' => array( |
@@ -1402,8 +1459,9 @@ discard block |
||
| 1402 | 1459 | 'data' => array( |
| 1403 | 1460 | 'function' => function($package_md5) use ($type, &$context) |
| 1404 | 1461 | { |
| 1405 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1406 | - return $context['available_' . $type . ''][$package_md5]['name']; |
|
| 1462 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1463 | + return $context['available_' . $type . ''][$package_md5]['name']; |
|
| 1464 | + } |
|
| 1407 | 1465 | }, |
| 1408 | 1466 | ), |
| 1409 | 1467 | 'sort' => array( |
@@ -1418,8 +1476,9 @@ discard block |
||
| 1418 | 1476 | 'data' => array( |
| 1419 | 1477 | 'function' => function($package_md5) use ($type, &$context) |
| 1420 | 1478 | { |
| 1421 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1422 | - return $context['available_' . $type . ''][$package_md5]['version']; |
|
| 1479 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1480 | + return $context['available_' . $type . ''][$package_md5]['version']; |
|
| 1481 | + } |
|
| 1423 | 1482 | }, |
| 1424 | 1483 | ), |
| 1425 | 1484 | 'sort' => array( |
@@ -1434,8 +1493,9 @@ discard block |
||
| 1434 | 1493 | 'data' => array( |
| 1435 | 1494 | 'function' => function($package_md5) use ($type, $txt, &$context) |
| 1436 | 1495 | { |
| 1437 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1438 | - return !empty($context['available_' . $type . ''][$package_md5]['time_installed']) ? timeformat($context['available_' . $type . ''][$package_md5]['time_installed']) : $txt['not_applicable']; |
|
| 1496 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1497 | + return !empty($context['available_' . $type . ''][$package_md5]['time_installed']) ? timeformat($context['available_' . $type . ''][$package_md5]['time_installed']) : $txt['not_applicable']; |
|
| 1498 | + } |
|
| 1439 | 1499 | }, |
| 1440 | 1500 | 'class' => 'smalltext', |
| 1441 | 1501 | ), |
@@ -1451,28 +1511,30 @@ discard block |
||
| 1451 | 1511 | 'data' => array( |
| 1452 | 1512 | 'function' => function($package_md5) use ($type, &$context, $scripturl, $txt) |
| 1453 | 1513 | { |
| 1454 | - if (!isset($context['available_' . $type . ''][$package_md5])) |
|
| 1455 | - return ''; |
|
| 1514 | + if (!isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1515 | + return ''; |
|
| 1516 | + } |
|
| 1456 | 1517 | |
| 1457 | 1518 | // Rewrite shortcut |
| 1458 | 1519 | $package = $context['available_' . $type . ''][$package_md5]; |
| 1459 | 1520 | $return = ''; |
| 1460 | 1521 | |
| 1461 | - if ($package['can_uninstall']) |
|
| 1462 | - $return = ' |
|
| 1522 | + if ($package['can_uninstall']) { |
|
| 1523 | + $return = ' |
|
| 1463 | 1524 | <a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button">' . $txt['uninstall'] . '</a>'; |
| 1464 | - elseif ($package['can_emulate_uninstall']) |
|
| 1465 | - $return = ' |
|
| 1525 | + } elseif ($package['can_emulate_uninstall']) { |
|
| 1526 | + $return = ' |
|
| 1466 | 1527 | <a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;ve=' . $package['can_emulate_uninstall'] . ';package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button">' . $txt['package_emulate_uninstall'] . ' ' . $package['can_emulate_uninstall'] . '</a>'; |
| 1467 | - elseif ($package['can_upgrade']) |
|
| 1468 | - $return = ' |
|
| 1528 | + } elseif ($package['can_upgrade']) { |
|
| 1529 | + $return = ' |
|
| 1469 | 1530 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button">' . $txt['package_upgrade'] . '</a>'; |
| 1470 | - elseif ($package['can_install']) |
|
| 1471 | - $return = ' |
|
| 1531 | + } elseif ($package['can_install']) { |
|
| 1532 | + $return = ' |
|
| 1472 | 1533 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button">' . $txt['install_mod'] . '</a>'; |
| 1473 | - elseif ($package['can_emulate_install']) |
|
| 1474 | - $return = ' |
|
| 1534 | + } elseif ($package['can_emulate_install']) { |
|
| 1535 | + $return = ' |
|
| 1475 | 1536 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;ve=' . $package['can_emulate_install'] . ';package=' . $package['filename'] . '" class="button">' . $txt['package_emulate_install'] . ' ' . $package['can_emulate_install'] . '</a>'; |
| 1537 | + } |
|
| 1476 | 1538 | |
| 1477 | 1539 | return $return . ' |
| 1478 | 1540 | <a href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $package['filename'] . '" class="button">' . $txt['list_files'] . '</a> |
@@ -1537,12 +1599,14 @@ discard block |
||
| 1537 | 1599 | static $packages, $installed_mods; |
| 1538 | 1600 | |
| 1539 | 1601 | // Start things up |
| 1540 | - if (!isset($packages[$params])) |
|
| 1541 | - $packages[$params] = array(); |
|
| 1602 | + if (!isset($packages[$params])) { |
|
| 1603 | + $packages[$params] = array(); |
|
| 1604 | + } |
|
| 1542 | 1605 | |
| 1543 | 1606 | // We need the packages directory to be writable for this. |
| 1544 | - if (!@is_writable($packagesdir)) |
|
| 1545 | - create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
| 1607 | + if (!@is_writable($packagesdir)) { |
|
| 1608 | + create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
| 1609 | + } |
|
| 1546 | 1610 | |
| 1547 | 1611 | $the_version = strtr($forum_version, array('SMF ' => '')); |
| 1548 | 1612 | |
@@ -1550,41 +1614,44 @@ discard block |
||
| 1550 | 1614 | if (isset($_GET['version_emulate']) && strtr($_GET['version_emulate'], array('SMF ' => '')) == $the_version) |
| 1551 | 1615 | { |
| 1552 | 1616 | unset($_SESSION['version_emulate']); |
| 1553 | - } |
|
| 1554 | - elseif (isset($_GET['version_emulate'])) |
|
| 1617 | + } elseif (isset($_GET['version_emulate'])) |
|
| 1555 | 1618 | { |
| 1556 | - if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === $forum_version) && isset($_SESSION['version_emulate'])) |
|
| 1557 | - unset($_SESSION['version_emulate']); |
|
| 1558 | - elseif ($_GET['version_emulate'] !== 0) |
|
| 1559 | - $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => '')); |
|
| 1619 | + if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === $forum_version) && isset($_SESSION['version_emulate'])) { |
|
| 1620 | + unset($_SESSION['version_emulate']); |
|
| 1621 | + } elseif ($_GET['version_emulate'] !== 0) { |
|
| 1622 | + $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => '')); |
|
| 1623 | + } |
|
| 1560 | 1624 | } |
| 1561 | 1625 | if (!empty($_SESSION['version_emulate'])) |
| 1562 | 1626 | { |
| 1563 | 1627 | $context['forum_version'] = 'SMF ' . $_SESSION['version_emulate']; |
| 1564 | 1628 | $the_version = $_SESSION['version_emulate']; |
| 1565 | 1629 | } |
| 1566 | - if (isset($_SESSION['single_version_emulate'])) |
|
| 1567 | - unset($_SESSION['single_version_emulate']); |
|
| 1630 | + if (isset($_SESSION['single_version_emulate'])) { |
|
| 1631 | + unset($_SESSION['single_version_emulate']); |
|
| 1632 | + } |
|
| 1568 | 1633 | |
| 1569 | 1634 | if (empty($installed_mods)) |
| 1570 | 1635 | { |
| 1571 | 1636 | $instmods = loadInstalledPackages(); |
| 1572 | 1637 | $installed_mods = array(); |
| 1573 | 1638 | // Look through the list of installed mods... |
| 1574 | - foreach ($instmods as $installed_mod) |
|
| 1575 | - $installed_mods[$installed_mod['package_id']] = array( |
|
| 1639 | + foreach ($instmods as $installed_mod) { |
|
| 1640 | + $installed_mods[$installed_mod['package_id']] = array( |
|
| 1576 | 1641 | 'id' => $installed_mod['id'], |
| 1577 | 1642 | 'version' => $installed_mod['version'], |
| 1578 | 1643 | 'time_installed' => $installed_mod['time_installed'], |
| 1579 | 1644 | ); |
| 1645 | + } |
|
| 1580 | 1646 | |
| 1581 | 1647 | // Get a list of all the ids installed, so the latest packages won't include already installed ones. |
| 1582 | 1648 | $context['installed_mods'] = array_keys($installed_mods); |
| 1583 | 1649 | } |
| 1584 | 1650 | |
| 1585 | - if (empty($packages)) |
|
| 1586 | - foreach ($context['modification_types'] as $type) |
|
| 1651 | + if (empty($packages)) { |
|
| 1652 | + foreach ($context['modification_types'] as $type) |
|
| 1587 | 1653 | $packages[$type] = array(); |
| 1654 | + } |
|
| 1588 | 1655 | |
| 1589 | 1656 | if ($dir = @opendir($packagesdir)) |
| 1590 | 1657 | { |
@@ -1600,50 +1667,56 @@ discard block |
||
| 1600 | 1667 | |
| 1601 | 1668 | while ($package = readdir($dir)) |
| 1602 | 1669 | { |
| 1603 | - if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
| 1604 | - continue; |
|
| 1670 | + if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
| 1671 | + continue; |
|
| 1672 | + } |
|
| 1605 | 1673 | |
| 1606 | 1674 | $skip = false; |
| 1607 | - foreach ($context['modification_types'] as $type) |
|
| 1608 | - if (isset($context['available_' . $type][md5($package)])) |
|
| 1675 | + foreach ($context['modification_types'] as $type) { |
|
| 1676 | + if (isset($context['available_' . $type][md5($package)])) |
|
| 1609 | 1677 | $skip = true; |
| 1678 | + } |
|
| 1610 | 1679 | |
| 1611 | - if ($skip) |
|
| 1612 | - continue; |
|
| 1680 | + if ($skip) { |
|
| 1681 | + continue; |
|
| 1682 | + } |
|
| 1613 | 1683 | |
| 1614 | 1684 | // Skip directories or files that are named the same. |
| 1615 | 1685 | if (is_dir($packagesdir . '/' . $package)) |
| 1616 | 1686 | { |
| 1617 | - if (in_array($package, $dirs)) |
|
| 1618 | - continue; |
|
| 1687 | + if (in_array($package, $dirs)) { |
|
| 1688 | + continue; |
|
| 1689 | + } |
|
| 1619 | 1690 | $dirs[] = $package; |
| 1620 | - } |
|
| 1621 | - elseif (substr(strtolower($package), -7) == '.tar.gz') |
|
| 1691 | + } elseif (substr(strtolower($package), -7) == '.tar.gz') |
|
| 1622 | 1692 | { |
| 1623 | - if (in_array(substr($package, 0, -7), $dirs)) |
|
| 1624 | - continue; |
|
| 1693 | + if (in_array(substr($package, 0, -7), $dirs)) { |
|
| 1694 | + continue; |
|
| 1695 | + } |
|
| 1625 | 1696 | $dirs[] = substr($package, 0, -7); |
| 1626 | - } |
|
| 1627 | - elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') |
|
| 1697 | + } elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') |
|
| 1628 | 1698 | { |
| 1629 | - if (in_array(substr($package, 0, -4), $dirs)) |
|
| 1630 | - continue; |
|
| 1699 | + if (in_array(substr($package, 0, -4), $dirs)) { |
|
| 1700 | + continue; |
|
| 1701 | + } |
|
| 1631 | 1702 | $dirs[] = substr($package, 0, -4); |
| 1632 | 1703 | } |
| 1633 | 1704 | |
| 1634 | 1705 | $packageInfo = getPackageInfo($package); |
| 1635 | - if (!is_array($packageInfo)) |
|
| 1636 | - continue; |
|
| 1706 | + if (!is_array($packageInfo)) { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1637 | 1709 | |
| 1638 | 1710 | if (!empty($packageInfo)) |
| 1639 | 1711 | { |
| 1640 | 1712 | $packageInfo['installed_id'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['id'] : 0; |
| 1641 | 1713 | $packageInfo['time_installed'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['time_installed'] : 0; |
| 1642 | 1714 | |
| 1643 | - if (!isset($sort_id[$packageInfo['type']])) |
|
| 1644 | - $packageInfo['sort_id'] = $sort_id['unknown']; |
|
| 1645 | - else |
|
| 1646 | - $packageInfo['sort_id'] = $sort_id[$packageInfo['type']]; |
|
| 1715 | + if (!isset($sort_id[$packageInfo['type']])) { |
|
| 1716 | + $packageInfo['sort_id'] = $sort_id['unknown']; |
|
| 1717 | + } else { |
|
| 1718 | + $packageInfo['sort_id'] = $sort_id[$packageInfo['type']]; |
|
| 1719 | + } |
|
| 1647 | 1720 | |
| 1648 | 1721 | $packageInfo['is_installed'] = isset($installed_mods[$packageInfo['id']]); |
| 1649 | 1722 | $packageInfo['is_current'] = $packageInfo['is_installed'] && ($installed_mods[$packageInfo['id']]['version'] == $packageInfo['version']); |
@@ -1692,10 +1765,11 @@ discard block |
||
| 1692 | 1765 | foreach ($upgrades as $upgrade) |
| 1693 | 1766 | { |
| 1694 | 1767 | // Even if it is for this SMF, is it for the installed version of the mod? |
| 1695 | - if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) |
|
| 1696 | - if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
| 1768 | + if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) { |
|
| 1769 | + if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
| 1697 | 1770 | { |
| 1698 | 1771 | $packageInfo['can_upgrade'] = true; |
| 1772 | + } |
|
| 1699 | 1773 | break; |
| 1700 | 1774 | } |
| 1701 | 1775 | } |
@@ -1772,10 +1846,11 @@ discard block |
||
| 1772 | 1846 | |
| 1773 | 1847 | if (isset($_GET['type']) && $_GET['type'] == $params) |
| 1774 | 1848 | { |
| 1775 | - if (isset($_GET['desc'])) |
|
| 1776 | - krsort($packages[$params]); |
|
| 1777 | - else |
|
| 1778 | - ksort($packages[$params]); |
|
| 1849 | + if (isset($_GET['desc'])) { |
|
| 1850 | + krsort($packages[$params]); |
|
| 1851 | + } else { |
|
| 1852 | + ksort($packages[$params]); |
|
| 1853 | + } |
|
| 1779 | 1854 | } |
| 1780 | 1855 | |
| 1781 | 1856 | return $packages[$params]; |
@@ -1804,10 +1879,11 @@ discard block |
||
| 1804 | 1879 | redirectexit('action=admin;area=packages;sa=options'); |
| 1805 | 1880 | } |
| 1806 | 1881 | |
| 1807 | - if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match)) |
|
| 1808 | - $default_username = $match[1]; |
|
| 1809 | - else |
|
| 1810 | - $default_username = ''; |
|
| 1882 | + if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match)) { |
|
| 1883 | + $default_username = $match[1]; |
|
| 1884 | + } else { |
|
| 1885 | + $default_username = ''; |
|
| 1886 | + } |
|
| 1811 | 1887 | |
| 1812 | 1888 | $context['page_title'] = $txt['package_settings']; |
| 1813 | 1889 | $context['sub_template'] = 'install_options'; |
@@ -1836,8 +1912,9 @@ discard block |
||
| 1836 | 1912 | isAllowedTo('admin_forum'); |
| 1837 | 1913 | |
| 1838 | 1914 | // We need to know the operation key for the search and replace, mod file looking at, is it a board mod? |
| 1839 | - if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key'])) |
|
| 1840 | - fatal_lang_error('operation_invalid', 'general'); |
|
| 1915 | + if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key'])) { |
|
| 1916 | + fatal_lang_error('operation_invalid', 'general'); |
|
| 1917 | + } |
|
| 1841 | 1918 | |
| 1842 | 1919 | // Load the required file. |
| 1843 | 1920 | require_once($sourcedir . '/Subs-Package.php'); |
@@ -1853,18 +1930,19 @@ discard block |
||
| 1853 | 1930 | { |
| 1854 | 1931 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 1855 | 1932 | |
| 1856 | - if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 1857 | - foreach ($context['extracted_files'] as $file) |
|
| 1933 | + if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 1934 | + foreach ($context['extracted_files'] as $file) |
|
| 1858 | 1935 | if (basename($file['filename']) == 'package-info.xml') |
| 1859 | 1936 | { |
| 1860 | 1937 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 1938 | + } |
|
| 1861 | 1939 | break; |
| 1862 | 1940 | } |
| 1863 | 1941 | |
| 1864 | - if (!isset($context['base_path'])) |
|
| 1865 | - $context['base_path'] = ''; |
|
| 1866 | - } |
|
| 1867 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1942 | + if (!isset($context['base_path'])) { |
|
| 1943 | + $context['base_path'] = ''; |
|
| 1944 | + } |
|
| 1945 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1868 | 1946 | { |
| 1869 | 1947 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 1870 | 1948 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
@@ -1885,8 +1963,9 @@ discard block |
||
| 1885 | 1963 | ) |
| 1886 | 1964 | ); |
| 1887 | 1965 | $theme_paths = array(); |
| 1888 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1889 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1967 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1968 | + } |
|
| 1890 | 1969 | $smcFunc['db_free_result']($request); |
| 1891 | 1970 | |
| 1892 | 1971 | // If we're viewing uninstall operations, only consider themes that |
@@ -1911,19 +1990,21 @@ discard block |
||
| 1911 | 1990 | list ($old_themes) = $smcFunc['db_fetch_row']($request); |
| 1912 | 1991 | $old_themes = explode(',', $old_themes); |
| 1913 | 1992 | |
| 1914 | - foreach ($theme_paths as $id => $data) |
|
| 1915 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 1993 | + foreach ($theme_paths as $id => $data) { |
|
| 1994 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 1916 | 1995 | unset($theme_paths[$id]); |
| 1996 | + } |
|
| 1917 | 1997 | } |
| 1918 | 1998 | $smcFunc['db_free_result']($request); |
| 1919 | 1999 | } |
| 1920 | 2000 | } |
| 1921 | 2001 | |
| 1922 | 2002 | // Boardmod? |
| 1923 | - if (isset($_REQUEST['boardmod'])) |
|
| 1924 | - $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 1925 | - else |
|
| 1926 | - $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2003 | + if (isset($_REQUEST['boardmod'])) { |
|
| 2004 | + $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2005 | + } else { |
|
| 2006 | + $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2007 | + } |
|
| 1927 | 2008 | |
| 1928 | 2009 | // Ok lets get the content of the file. |
| 1929 | 2010 | $context['operations'] = array( |
@@ -1979,9 +2060,9 @@ discard block |
||
| 1979 | 2060 | 'path' => $detect_path, |
| 1980 | 2061 | 'form_elements_only' => true, |
| 1981 | 2062 | ); |
| 2063 | + } else { |
|
| 2064 | + $context['ftp_connected'] = true; |
|
| 1982 | 2065 | } |
| 1983 | - else |
|
| 1984 | - $context['ftp_connected'] = true; |
|
| 1985 | 2066 | |
| 1986 | 2067 | // Define the template. |
| 1987 | 2068 | $context['page_title'] = $txt['package_file_perms']; |
@@ -2094,18 +2175,19 @@ discard block |
||
| 2094 | 2175 | { |
| 2095 | 2176 | unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']); |
| 2096 | 2177 | |
| 2097 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 2098 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 2178 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 2179 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 2180 | + } |
|
| 2099 | 2181 | |
| 2100 | 2182 | // @todo Should we suggest non-current directories be read only? |
| 2101 | - foreach ($modSettings['attachmentUploadDir'] as $dir) |
|
| 2102 | - $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
| 2183 | + foreach ($modSettings['attachmentUploadDir'] as $dir) { |
|
| 2184 | + $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
| 2103 | 2185 | 'type' => 'dir', |
| 2104 | 2186 | 'writable_on' => 'restrictive', |
| 2105 | 2187 | ); |
| 2188 | + } |
|
| 2106 | 2189 | |
| 2107 | - } |
|
| 2108 | - elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) |
|
| 2190 | + } elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) |
|
| 2109 | 2191 | { |
| 2110 | 2192 | unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']); |
| 2111 | 2193 | $context['file_tree'][strtr($modSettings['attachmentUploadDir'], array('\\' => '/'))] = array( |
@@ -2155,8 +2237,8 @@ discard block |
||
| 2155 | 2237 | ); |
| 2156 | 2238 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2157 | 2239 | { |
| 2158 | - if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) |
|
| 2159 | - $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array( |
|
| 2240 | + if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) { |
|
| 2241 | + $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array( |
|
| 2160 | 2242 | 'type' => 'dir_recursive', |
| 2161 | 2243 | 'list_contents' => true, |
| 2162 | 2244 | 'contents' => array( |
@@ -2166,7 +2248,7 @@ discard block |
||
| 2166 | 2248 | ), |
| 2167 | 2249 | ), |
| 2168 | 2250 | ); |
| 2169 | - else |
|
| 2251 | + } else |
|
| 2170 | 2252 | { |
| 2171 | 2253 | $context['file_tree'][strtr($row['value'], array('\\' => '/'))] = array( |
| 2172 | 2254 | 'type' => 'dir_recursive', |
@@ -2183,28 +2265,33 @@ discard block |
||
| 2183 | 2265 | $smcFunc['db_free_result']($request); |
| 2184 | 2266 | |
| 2185 | 2267 | // If we're submitting then let's move on to another function to keep things cleaner.. |
| 2186 | - if (isset($_POST['action_changes'])) |
|
| 2187 | - return PackagePermissionsAction(); |
|
| 2268 | + if (isset($_POST['action_changes'])) { |
|
| 2269 | + return PackagePermissionsAction(); |
|
| 2270 | + } |
|
| 2188 | 2271 | |
| 2189 | 2272 | $context['look_for'] = array(); |
| 2190 | 2273 | // Are we looking for a particular tree - normally an expansion? |
| 2191 | - if (!empty($_REQUEST['find'])) |
|
| 2192 | - $context['look_for'][] = base64_decode($_REQUEST['find']); |
|
| 2274 | + if (!empty($_REQUEST['find'])) { |
|
| 2275 | + $context['look_for'][] = base64_decode($_REQUEST['find']); |
|
| 2276 | + } |
|
| 2193 | 2277 | // Only that tree? |
| 2194 | 2278 | $context['only_find'] = isset($_GET['xml']) && !empty($_REQUEST['onlyfind']) ? $_REQUEST['onlyfind'] : ''; |
| 2195 | - if ($context['only_find']) |
|
| 2196 | - $context['look_for'][] = $context['only_find']; |
|
| 2279 | + if ($context['only_find']) { |
|
| 2280 | + $context['look_for'][] = $context['only_find']; |
|
| 2281 | + } |
|
| 2197 | 2282 | |
| 2198 | 2283 | // Have we got a load of back-catalogue trees to expand from a submit etc? |
| 2199 | 2284 | if (!empty($_GET['back_look'])) |
| 2200 | 2285 | { |
| 2201 | 2286 | $potententialTrees = $smcFunc['json_decode'](base64_decode($_GET['back_look']), true); |
| 2202 | - foreach ($potententialTrees as $tree) |
|
| 2203 | - $context['look_for'][] = $tree; |
|
| 2287 | + foreach ($potententialTrees as $tree) { |
|
| 2288 | + $context['look_for'][] = $tree; |
|
| 2289 | + } |
|
| 2204 | 2290 | } |
| 2205 | 2291 | // ... maybe posted? |
| 2206 | - if (!empty($_POST['back_look'])) |
|
| 2207 | - $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']); |
|
| 2292 | + if (!empty($_POST['back_look'])) { |
|
| 2293 | + $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']); |
|
| 2294 | + } |
|
| 2208 | 2295 | |
| 2209 | 2296 | $context['back_look_data'] = base64_encode($smcFunc['json_encode'](array_slice($context['look_for'], 0, 15))); |
| 2210 | 2297 | |
@@ -2243,9 +2330,9 @@ discard block |
||
| 2243 | 2330 | 'chmod' => @is_writable($path), |
| 2244 | 2331 | 'perms' => @fileperms($path), |
| 2245 | 2332 | ); |
| 2333 | + } else { |
|
| 2334 | + unset($context['file_tree'][$path]); |
|
| 2246 | 2335 | } |
| 2247 | - else |
|
| 2248 | - unset($context['file_tree'][$path]); |
|
| 2249 | 2336 | } |
| 2250 | 2337 | |
| 2251 | 2338 | // Is this actually xml? |
@@ -2269,22 +2356,25 @@ discard block |
||
| 2269 | 2356 | global $context; |
| 2270 | 2357 | |
| 2271 | 2358 | $isLikelyPath = false; |
| 2272 | - foreach ($context['look_for'] as $possiblePath) |
|
| 2273 | - if (substr($possiblePath, 0, strlen($path)) == $path) |
|
| 2359 | + foreach ($context['look_for'] as $possiblePath) { |
|
| 2360 | + if (substr($possiblePath, 0, strlen($path)) == $path) |
|
| 2274 | 2361 | $isLikelyPath = true; |
| 2362 | + } |
|
| 2275 | 2363 | |
| 2276 | 2364 | // Is this where we stop? |
| 2277 | - if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) |
|
| 2278 | - return; |
|
| 2279 | - elseif ($level > $context['default_level'] && !$isLikelyPath) |
|
| 2280 | - return; |
|
| 2365 | + if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) { |
|
| 2366 | + return; |
|
| 2367 | + } elseif ($level > $context['default_level'] && !$isLikelyPath) { |
|
| 2368 | + return; |
|
| 2369 | + } |
|
| 2281 | 2370 | |
| 2282 | 2371 | // Are we actually interested in saving this data? |
| 2283 | 2372 | $save_data = empty($context['only_find']) || $context['only_find'] == $path; |
| 2284 | 2373 | |
| 2285 | 2374 | // @todo Shouldn't happen - but better error message? |
| 2286 | - if (!is_dir($path)) |
|
| 2287 | - fatal_lang_error('no_access', false); |
|
| 2375 | + if (!is_dir($path)) { |
|
| 2376 | + fatal_lang_error('no_access', false); |
|
| 2377 | + } |
|
| 2288 | 2378 | |
| 2289 | 2379 | // This is where we put stuff we've found for sorting. |
| 2290 | 2380 | $foundData = array( |
@@ -2299,11 +2389,13 @@ discard block |
||
| 2299 | 2389 | if (is_file($path . '/' . $entry)) |
| 2300 | 2390 | { |
| 2301 | 2391 | // Are we listing PHP files in this directory? |
| 2302 | - if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php') |
|
| 2303 | - $foundData['files'][$entry] = true; |
|
| 2392 | + if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php') { |
|
| 2393 | + $foundData['files'][$entry] = true; |
|
| 2394 | + } |
|
| 2304 | 2395 | // A file we were looking for. |
| 2305 | - elseif ($save_data && isset($data['contents'][$entry])) |
|
| 2306 | - $foundData['files'][$entry] = true; |
|
| 2396 | + elseif ($save_data && isset($data['contents'][$entry])) { |
|
| 2397 | + $foundData['files'][$entry] = true; |
|
| 2398 | + } |
|
| 2307 | 2399 | } |
| 2308 | 2400 | // It's a directory - we're interested one way or another, probably... |
| 2309 | 2401 | elseif ($entry != '.' && $entry != '..') |
@@ -2311,32 +2403,36 @@ discard block |
||
| 2311 | 2403 | // Going further? |
| 2312 | 2404 | if ((!empty($data['type']) && $data['type'] == 'dir_recursive') || (isset($data['contents'][$entry]) && (!empty($data['contents'][$entry]['list_contents']) || (!empty($data['contents'][$entry]['type']) && $data['contents'][$entry]['type'] == 'dir_recursive')))) |
| 2313 | 2405 | { |
| 2314 | - if (!isset($data['contents'][$entry])) |
|
| 2315 | - $foundData['folders'][$entry] = 'dir_recursive'; |
|
| 2316 | - else |
|
| 2317 | - $foundData['folders'][$entry] = true; |
|
| 2406 | + if (!isset($data['contents'][$entry])) { |
|
| 2407 | + $foundData['folders'][$entry] = 'dir_recursive'; |
|
| 2408 | + } else { |
|
| 2409 | + $foundData['folders'][$entry] = true; |
|
| 2410 | + } |
|
| 2318 | 2411 | |
| 2319 | 2412 | // If this wasn't expected inherit the recusiveness... |
| 2320 | - if (!isset($data['contents'][$entry])) |
|
| 2321 | - // We need to do this as we will be going all recursive. |
|
| 2413 | + if (!isset($data['contents'][$entry])) { |
|
| 2414 | + // We need to do this as we will be going all recursive. |
|
| 2322 | 2415 | $data['contents'][$entry] = array( |
| 2323 | 2416 | 'type' => 'dir_recursive', |
| 2324 | 2417 | ); |
| 2418 | + } |
|
| 2325 | 2419 | |
| 2326 | 2420 | // Actually do the recursive stuff... |
| 2327 | 2421 | fetchPerms__recursive($path . '/' . $entry, $data['contents'][$entry], $level + 1); |
| 2328 | 2422 | } |
| 2329 | 2423 | // Maybe it is a folder we are not descending into. |
| 2330 | - elseif (isset($data['contents'][$entry])) |
|
| 2331 | - $foundData['folders'][$entry] = true; |
|
| 2424 | + elseif (isset($data['contents'][$entry])) { |
|
| 2425 | + $foundData['folders'][$entry] = true; |
|
| 2426 | + } |
|
| 2332 | 2427 | // Otherwise we stop here. |
| 2333 | 2428 | } |
| 2334 | 2429 | } |
| 2335 | 2430 | closedir($dh); |
| 2336 | 2431 | |
| 2337 | 2432 | // Nothing to see here? |
| 2338 | - if (!$save_data) |
|
| 2339 | - return; |
|
| 2433 | + if (!$save_data) { |
|
| 2434 | + return; |
|
| 2435 | + } |
|
| 2340 | 2436 | |
| 2341 | 2437 | // Now actually add the data, starting with the folders. |
| 2342 | 2438 | ksort($foundData['folders']); |
@@ -2348,8 +2444,9 @@ discard block |
||
| 2348 | 2444 | 'perms' => @fileperms($path . '/' . $folder), |
| 2349 | 2445 | ), |
| 2350 | 2446 | ); |
| 2351 | - if ($type !== true) |
|
| 2352 | - $additional_data['type'] = $type; |
|
| 2447 | + if ($type !== true) { |
|
| 2448 | + $additional_data['type'] = $type; |
|
| 2449 | + } |
|
| 2353 | 2450 | |
| 2354 | 2451 | // If there's an offset ignore any folders in XML mode. |
| 2355 | 2452 | if (isset($_GET['xml']) && $context['file_offset'] == 0) |
@@ -2368,13 +2465,13 @@ discard block |
||
| 2368 | 2465 | ), |
| 2369 | 2466 | 'value' => $folder, |
| 2370 | 2467 | ); |
| 2371 | - } |
|
| 2372 | - elseif (!isset($_GET['xml'])) |
|
| 2468 | + } elseif (!isset($_GET['xml'])) |
|
| 2373 | 2469 | { |
| 2374 | - if (isset($data['contents'][$folder])) |
|
| 2375 | - $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
| 2376 | - else |
|
| 2377 | - $data['contents'][$folder] = $additional_data; |
|
| 2470 | + if (isset($data['contents'][$folder])) { |
|
| 2471 | + $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
| 2472 | + } else { |
|
| 2473 | + $data['contents'][$folder] = $additional_data; |
|
| 2474 | + } |
|
| 2378 | 2475 | } |
| 2379 | 2476 | } |
| 2380 | 2477 | |
@@ -2386,11 +2483,13 @@ discard block |
||
| 2386 | 2483 | $counter++; |
| 2387 | 2484 | |
| 2388 | 2485 | // Have we reached our offset? |
| 2389 | - if ($context['file_offset'] > $counter) |
|
| 2390 | - continue; |
|
| 2486 | + if ($context['file_offset'] > $counter) { |
|
| 2487 | + continue; |
|
| 2488 | + } |
|
| 2391 | 2489 | // Gone too far? |
| 2392 | - if ($counter > ($context['file_offset'] + $context['file_limit'])) |
|
| 2393 | - continue; |
|
| 2490 | + if ($counter > ($context['file_offset'] + $context['file_limit'])) { |
|
| 2491 | + continue; |
|
| 2492 | + } |
|
| 2394 | 2493 | |
| 2395 | 2494 | $additional_data = array( |
| 2396 | 2495 | 'perms' => array( |
@@ -2416,13 +2515,13 @@ discard block |
||
| 2416 | 2515 | ), |
| 2417 | 2516 | 'value' => $file, |
| 2418 | 2517 | ); |
| 2419 | - } |
|
| 2420 | - elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
|
| 2518 | + } elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
|
| 2421 | 2519 | { |
| 2422 | - if (isset($data['contents'][$file])) |
|
| 2423 | - $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
| 2424 | - else |
|
| 2425 | - $data['contents'][$file] = $additional_data; |
|
| 2520 | + if (isset($data['contents'][$file])) { |
|
| 2521 | + $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
| 2522 | + } else { |
|
| 2523 | + $data['contents'][$file] = $additional_data; |
|
| 2524 | + } |
|
| 2426 | 2525 | } |
| 2427 | 2526 | } |
| 2428 | 2527 | } |
@@ -2444,8 +2543,9 @@ discard block |
||
| 2444 | 2543 | $context['back_look_data'] = isset($_POST['back_look']) ? $_POST['back_look'] : array(); |
| 2445 | 2544 | |
| 2446 | 2545 | // Skipping use of FTP? |
| 2447 | - if (empty($package_ftp)) |
|
| 2448 | - $context['skip_ftp'] = true; |
|
| 2546 | + if (empty($package_ftp)) { |
|
| 2547 | + $context['skip_ftp'] = true; |
|
| 2548 | + } |
|
| 2449 | 2549 | |
| 2450 | 2550 | // We'll start off in a good place, security. Make sure that if we're dealing with individual files that they seem in the right place. |
| 2451 | 2551 | if ($context['method'] == 'individual') |
@@ -2455,8 +2555,9 @@ discard block |
||
| 2455 | 2555 | $context['custom_value'] = (int) $_POST['custom_value']; |
| 2456 | 2556 | |
| 2457 | 2557 | // Continuing? |
| 2458 | - if (isset($_POST['toProcess'])) |
|
| 2459 | - $_POST['permStatus'] = $smcFunc['json_decode'](base64_decode($_POST['toProcess']), true); |
|
| 2558 | + if (isset($_POST['toProcess'])) { |
|
| 2559 | + $_POST['permStatus'] = $smcFunc['json_decode'](base64_decode($_POST['toProcess']), true); |
|
| 2560 | + } |
|
| 2460 | 2561 | |
| 2461 | 2562 | if (isset($_POST['permStatus'])) |
| 2462 | 2563 | { |
@@ -2465,22 +2566,27 @@ discard block |
||
| 2465 | 2566 | foreach ($_POST['permStatus'] as $path => $status) |
| 2466 | 2567 | { |
| 2467 | 2568 | // Nothing to see here? |
| 2468 | - if ($status == 'no_change') |
|
| 2469 | - continue; |
|
| 2569 | + if ($status == 'no_change') { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2470 | 2572 | $legal = false; |
| 2471 | - foreach ($legal_roots as $root) |
|
| 2472 | - if (substr($path, 0, strlen($root)) == $root) |
|
| 2573 | + foreach ($legal_roots as $root) { |
|
| 2574 | + if (substr($path, 0, strlen($root)) == $root) |
|
| 2473 | 2575 | $legal = true; |
| 2576 | + } |
|
| 2474 | 2577 | |
| 2475 | - if (!$legal) |
|
| 2476 | - continue; |
|
| 2578 | + if (!$legal) { |
|
| 2579 | + continue; |
|
| 2580 | + } |
|
| 2477 | 2581 | |
| 2478 | 2582 | // Check it exists. |
| 2479 | - if (!file_exists($path)) |
|
| 2480 | - continue; |
|
| 2583 | + if (!file_exists($path)) { |
|
| 2584 | + continue; |
|
| 2585 | + } |
|
| 2481 | 2586 | |
| 2482 | - if ($status == 'custom') |
|
| 2483 | - $validate_custom = true; |
|
| 2587 | + if ($status == 'custom') { |
|
| 2588 | + $validate_custom = true; |
|
| 2589 | + } |
|
| 2484 | 2590 | |
| 2485 | 2591 | // Now add it. |
| 2486 | 2592 | $context['to_process'][$path] = $status; |
@@ -2490,17 +2596,20 @@ discard block |
||
| 2490 | 2596 | // Make sure the chmod status is valid? |
| 2491 | 2597 | if ($validate_custom) |
| 2492 | 2598 | { |
| 2493 | - if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false) |
|
| 2494 | - fatal_error($txt['chmod_value_invalid']); |
|
| 2599 | + if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false) { |
|
| 2600 | + fatal_error($txt['chmod_value_invalid']); |
|
| 2601 | + } |
|
| 2495 | 2602 | } |
| 2496 | 2603 | |
| 2497 | 2604 | // Nothing to do? |
| 2498 | - if (empty($context['to_process'])) |
|
| 2499 | - redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode($smcFunc['json_encode']($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2605 | + if (empty($context['to_process'])) { |
|
| 2606 | + redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode($smcFunc['json_encode']($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2607 | + } |
|
| 2500 | 2608 | } |
| 2501 | 2609 | // Should never get here, |
| 2502 | - else |
|
| 2503 | - fatal_lang_error('no_access', false); |
|
| 2610 | + else { |
|
| 2611 | + fatal_lang_error('no_access', false); |
|
| 2612 | + } |
|
| 2504 | 2613 | |
| 2505 | 2614 | // Setup the custom value. |
| 2506 | 2615 | $custom_value = octdec('0' . $context['custom_value']); |
@@ -2508,18 +2617,18 @@ discard block |
||
| 2508 | 2617 | // Start processing items. |
| 2509 | 2618 | foreach ($context['to_process'] as $path => $status) |
| 2510 | 2619 | { |
| 2511 | - if (in_array($status, array('execute', 'writable', 'read'))) |
|
| 2512 | - package_chmod($path, $status); |
|
| 2513 | - elseif ($status == 'custom' && !empty($custom_value)) |
|
| 2620 | + if (in_array($status, array('execute', 'writable', 'read'))) { |
|
| 2621 | + package_chmod($path, $status); |
|
| 2622 | + } elseif ($status == 'custom' && !empty($custom_value)) |
|
| 2514 | 2623 | { |
| 2515 | 2624 | // Use FTP if we have it. |
| 2516 | 2625 | if (!empty($package_ftp) && !empty($_SESSION['pack_ftp'])) |
| 2517 | 2626 | { |
| 2518 | 2627 | $ftp_file = strtr($path, array($_SESSION['pack_ftp']['root'] => '')); |
| 2519 | 2628 | $package_ftp->chmod($ftp_file, $custom_value); |
| 2629 | + } else { |
|
| 2630 | + smf_chmod($path, $custom_value); |
|
| 2520 | 2631 | } |
| 2521 | - else |
|
| 2522 | - smf_chmod($path, $custom_value); |
|
| 2523 | 2632 | } |
| 2524 | 2633 | |
| 2525 | 2634 | // This fish is fried... |
@@ -2603,23 +2712,27 @@ discard block |
||
| 2603 | 2712 | { |
| 2604 | 2713 | global $context; |
| 2605 | 2714 | |
| 2606 | - if (!empty($data['writable_on'])) |
|
| 2607 | - if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive') |
|
| 2715 | + if (!empty($data['writable_on'])) { |
|
| 2716 | + if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive') |
|
| 2608 | 2717 | $context['special_files'][$path] = 1; |
| 2718 | + } |
|
| 2609 | 2719 | |
| 2610 | - if (!empty($data['contents'])) |
|
| 2611 | - foreach ($data['contents'] as $name => $contents) |
|
| 2720 | + if (!empty($data['contents'])) { |
|
| 2721 | + foreach ($data['contents'] as $name => $contents) |
|
| 2612 | 2722 | build_special_files__recursive($path . '/' . $name, $contents); |
| 2723 | + } |
|
| 2613 | 2724 | } |
| 2614 | 2725 | |
| 2615 | - foreach ($context['file_tree'] as $path => $data) |
|
| 2616 | - build_special_files__recursive($path, $data); |
|
| 2726 | + foreach ($context['file_tree'] as $path => $data) { |
|
| 2727 | + build_special_files__recursive($path, $data); |
|
| 2728 | + } |
|
| 2617 | 2729 | } |
| 2618 | 2730 | // Free doesn't need special files. |
| 2619 | - elseif ($context['predefined_type'] == 'free') |
|
| 2620 | - $context['special_files'] = array(); |
|
| 2621 | - else |
|
| 2622 | - $context['special_files'] = $smcFunc['json_decode'](base64_decode($_POST['specialFiles']), true); |
|
| 2731 | + elseif ($context['predefined_type'] == 'free') { |
|
| 2732 | + $context['special_files'] = array(); |
|
| 2733 | + } else { |
|
| 2734 | + $context['special_files'] = $smcFunc['json_decode'](base64_decode($_POST['specialFiles']), true); |
|
| 2735 | + } |
|
| 2623 | 2736 | |
| 2624 | 2737 | // Now we definitely know where we are, we need to go through again doing the chmod! |
| 2625 | 2738 | foreach ($context['directory_list'] as $path => $dummy) |
@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -34,8 +35,8 @@ discard block |
||
| 34 | 35 | global $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // Map some database specific functions, only do this once. |
| 37 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 38 | - $smcFunc += array( |
|
| 38 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 39 | + $smcFunc += array( |
|
| 39 | 40 | 'db_query' => 'smf_db_query', |
| 40 | 41 | 'db_quote' => 'smf_db_quote', |
| 41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -62,11 +63,13 @@ discard block |
||
| 62 | 63 | 'db_ping' => 'pg_ping', |
| 63 | 64 | 'db_fetch_all' => 'smf_db_fetch_all', |
| 64 | 65 | ); |
| 66 | + } |
|
| 65 | 67 | |
| 66 | - if (!empty($db_options['persist'])) |
|
| 67 | - $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 68 | - else |
|
| 69 | - $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 68 | + if (!empty($db_options['persist'])) { |
|
| 69 | + $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 70 | + } else { |
|
| 71 | + $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 72 | 75 | if (!$connection) |
@@ -74,8 +77,7 @@ discard block |
||
| 74 | 77 | if (!empty($db_options['non_fatal'])) |
| 75 | 78 | { |
| 76 | 79 | return null; |
| 77 | - } |
|
| 78 | - else |
|
| 80 | + } else |
|
| 79 | 81 | { |
| 80 | 82 | display_db_error(); |
| 81 | 83 | } |
@@ -126,31 +128,38 @@ discard block |
||
| 126 | 128 | |
| 127 | 129 | list ($values, $connection) = $db_callback; |
| 128 | 130 | |
| 129 | - if ($matches[1] === 'db_prefix') |
|
| 130 | - return $db_prefix; |
|
| 131 | + if ($matches[1] === 'db_prefix') { |
|
| 132 | + return $db_prefix; |
|
| 133 | + } |
|
| 131 | 134 | |
| 132 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 133 | - return $user_info[$matches[1]]; |
|
| 135 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 136 | + return $user_info[$matches[1]]; |
|
| 137 | + } |
|
| 134 | 138 | |
| 135 | - if ($matches[1] === 'empty') |
|
| 136 | - return '\'\''; |
|
| 139 | + if ($matches[1] === 'empty') { |
|
| 140 | + return '\'\''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | - if (!isset($matches[2])) |
|
| 139 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 143 | + if (!isset($matches[2])) { |
|
| 144 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 145 | + } |
|
| 140 | 146 | |
| 141 | - if ($matches[1] === 'literal') |
|
| 142 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
| 147 | + if ($matches[1] === 'literal') { |
|
| 148 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
| 149 | + } |
|
| 143 | 150 | |
| 144 | - if (!isset($values[$matches[2]])) |
|
| 145 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 151 | + if (!isset($values[$matches[2]])) { |
|
| 152 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 153 | + } |
|
| 146 | 154 | |
| 147 | 155 | $replacement = $values[$matches[2]]; |
| 148 | 156 | |
| 149 | 157 | switch ($matches[1]) |
| 150 | 158 | { |
| 151 | 159 | case 'int': |
| 152 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 153 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 160 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 161 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 162 | + } |
|
| 154 | 163 | return (string) (int) $replacement; |
| 155 | 164 | break; |
| 156 | 165 | |
@@ -162,65 +171,73 @@ discard block |
||
| 162 | 171 | case 'array_int': |
| 163 | 172 | if (is_array($replacement)) |
| 164 | 173 | { |
| 165 | - if (empty($replacement)) |
|
| 166 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 174 | + if (empty($replacement)) { |
|
| 175 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 176 | + } |
|
| 167 | 177 | |
| 168 | 178 | foreach ($replacement as $key => $value) |
| 169 | 179 | { |
| 170 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 171 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 180 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 181 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 182 | + } |
|
| 172 | 183 | |
| 173 | 184 | $replacement[$key] = (string) (int) $value; |
| 174 | 185 | } |
| 175 | 186 | |
| 176 | 187 | return implode(', ', $replacement); |
| 188 | + } else { |
|
| 189 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 177 | 190 | } |
| 178 | - else |
|
| 179 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 180 | 191 | |
| 181 | 192 | break; |
| 182 | 193 | |
| 183 | 194 | case 'array_string': |
| 184 | 195 | if (is_array($replacement)) |
| 185 | 196 | { |
| 186 | - if (empty($replacement)) |
|
| 187 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 197 | + if (empty($replacement)) { |
|
| 198 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 199 | + } |
|
| 188 | 200 | |
| 189 | - foreach ($replacement as $key => $value) |
|
| 190 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
| 201 | + foreach ($replacement as $key => $value) { |
|
| 202 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
| 203 | + } |
|
| 191 | 204 | |
| 192 | 205 | return implode(', ', $replacement); |
| 206 | + } else { |
|
| 207 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 193 | 208 | } |
| 194 | - else |
|
| 195 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 196 | 209 | break; |
| 197 | 210 | |
| 198 | 211 | case 'date': |
| 199 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 200 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 201 | - else |
|
| 202 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 212 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 213 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 214 | + } else { |
|
| 215 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 216 | + } |
|
| 203 | 217 | break; |
| 204 | 218 | |
| 205 | 219 | case 'time': |
| 206 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 207 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 208 | - else |
|
| 209 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 220 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 221 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 222 | + } else { |
|
| 223 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 224 | + } |
|
| 210 | 225 | break; |
| 211 | 226 | |
| 212 | 227 | case 'datetime': |
| 213 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 214 | - return 'to_timestamp('. |
|
| 228 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 229 | + return 'to_timestamp('. |
|
| 215 | 230 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 216 | 231 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
| 217 | - else |
|
| 218 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 232 | + } else { |
|
| 233 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 234 | + } |
|
| 219 | 235 | break; |
| 220 | 236 | |
| 221 | 237 | case 'float': |
| 222 | - if (!is_numeric($replacement)) |
|
| 223 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 238 | + if (!is_numeric($replacement)) { |
|
| 239 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 240 | + } |
|
| 224 | 241 | return (string) (float) $replacement; |
| 225 | 242 | break; |
| 226 | 243 | |
@@ -233,31 +250,36 @@ discard block |
||
| 233 | 250 | break; |
| 234 | 251 | |
| 235 | 252 | case 'inet': |
| 236 | - if ($replacement == 'null' || $replacement == '') |
|
| 237 | - return 'null'; |
|
| 238 | - if (inet_pton($replacement) === false) |
|
| 239 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 253 | + if ($replacement == 'null' || $replacement == '') { |
|
| 254 | + return 'null'; |
|
| 255 | + } |
|
| 256 | + if (inet_pton($replacement) === false) { |
|
| 257 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 258 | + } |
|
| 240 | 259 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
| 241 | 260 | |
| 242 | 261 | case 'array_inet': |
| 243 | 262 | if (is_array($replacement)) |
| 244 | 263 | { |
| 245 | - if (empty($replacement)) |
|
| 246 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 264 | + if (empty($replacement)) { |
|
| 265 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 266 | + } |
|
| 247 | 267 | |
| 248 | 268 | foreach ($replacement as $key => $value) |
| 249 | 269 | { |
| 250 | - if ($replacement == 'null' || $replacement == '') |
|
| 251 | - $replacement[$key] = 'null'; |
|
| 252 | - if (!isValidIP($value)) |
|
| 253 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 270 | + if ($replacement == 'null' || $replacement == '') { |
|
| 271 | + $replacement[$key] = 'null'; |
|
| 272 | + } |
|
| 273 | + if (!isValidIP($value)) { |
|
| 274 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 275 | + } |
|
| 254 | 276 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
| 255 | 277 | } |
| 256 | 278 | |
| 257 | 279 | return implode(', ', $replacement); |
| 280 | + } else { |
|
| 281 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 258 | 282 | } |
| 259 | - else |
|
| 260 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 261 | 283 | break; |
| 262 | 284 | |
| 263 | 285 | default: |
@@ -351,14 +373,16 @@ discard block |
||
| 351 | 373 | ), |
| 352 | 374 | ); |
| 353 | 375 | |
| 354 | - if (isset($replacements[$identifier])) |
|
| 355 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 376 | + if (isset($replacements[$identifier])) { |
|
| 377 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 378 | + } |
|
| 356 | 379 | |
| 357 | 380 | // Limits need to be a little different. |
| 358 | 381 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
| 359 | 382 | |
| 360 | - if (trim($db_string) == '') |
|
| 361 | - return false; |
|
| 383 | + if (trim($db_string) == '') { |
|
| 384 | + return false; |
|
| 385 | + } |
|
| 362 | 386 | |
| 363 | 387 | // Comments that are allowed in a query are preg_removed. |
| 364 | 388 | static $allowed_comments_from = array( |
@@ -378,8 +402,9 @@ discard block |
||
| 378 | 402 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 379 | 403 | $db_replace_result = 0; |
| 380 | 404 | |
| 381 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 382 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 405 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 406 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 407 | + } |
|
| 383 | 408 | |
| 384 | 409 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
| 385 | 410 | { |
@@ -400,8 +425,9 @@ discard block |
||
| 400 | 425 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 401 | 426 | |
| 402 | 427 | // Initialize $db_cache if not already initialized. |
| 403 | - if (!isset($db_cache)) |
|
| 404 | - $db_cache = array(); |
|
| 428 | + if (!isset($db_cache)) { |
|
| 429 | + $db_cache = array(); |
|
| 430 | + } |
|
| 405 | 431 | |
| 406 | 432 | if (!empty($_SESSION['debug_redirect'])) |
| 407 | 433 | { |
@@ -427,17 +453,18 @@ discard block |
||
| 427 | 453 | while (true) |
| 428 | 454 | { |
| 429 | 455 | $pos = strpos($db_string, '\'', $pos + 1); |
| 430 | - if ($pos === false) |
|
| 431 | - break; |
|
| 456 | + if ($pos === false) { |
|
| 457 | + break; |
|
| 458 | + } |
|
| 432 | 459 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 433 | 460 | |
| 434 | 461 | while (true) |
| 435 | 462 | { |
| 436 | 463 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 437 | 464 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 438 | - if ($pos1 === false) |
|
| 439 | - break; |
|
| 440 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 465 | + if ($pos1 === false) { |
|
| 466 | + break; |
|
| 467 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 441 | 468 | { |
| 442 | 469 | $pos = $pos1; |
| 443 | 470 | break; |
@@ -453,16 +480,19 @@ discard block |
||
| 453 | 480 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 454 | 481 | |
| 455 | 482 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 456 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 457 | - $fail = true; |
|
| 483 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 484 | + $fail = true; |
|
| 485 | + } |
|
| 458 | 486 | // Trying to change passwords, slow us down, or something? |
| 459 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 460 | - $fail = true; |
|
| 461 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 462 | - $fail = true; |
|
| 487 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 488 | + $fail = true; |
|
| 489 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 490 | + $fail = true; |
|
| 491 | + } |
|
| 463 | 492 | |
| 464 | - if (!empty($fail) && function_exists('log_error')) |
|
| 465 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 493 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 494 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 495 | + } |
|
| 466 | 496 | } |
| 467 | 497 | |
| 468 | 498 | // Set optimize stuff |
@@ -481,18 +511,21 @@ discard block |
||
| 481 | 511 | |
| 482 | 512 | $db_string = $query_hints_set . $db_string; |
| 483 | 513 | |
| 484 | - if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') |
|
| 485 | - $db_cache[$db_count]['q'] = "\t\t" . $db_string; |
|
| 514 | + if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') { |
|
| 515 | + $db_cache[$db_count]['q'] = "\t\t" . $db_string; |
|
| 516 | + } |
|
| 486 | 517 | } |
| 487 | 518 | |
| 488 | 519 | $db_last_result = @pg_query($connection, $db_string); |
| 489 | 520 | |
| 490 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
| 491 | - $db_last_result = smf_db_error($db_string, $connection); |
|
| 521 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
| 522 | + $db_last_result = smf_db_error($db_string, $connection); |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | // Debugging. |
| 494 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 495 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 526 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 527 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 528 | + } |
|
| 496 | 529 | |
| 497 | 530 | return $db_last_result; |
| 498 | 531 | } |
@@ -505,10 +538,11 @@ discard block |
||
| 505 | 538 | { |
| 506 | 539 | global $db_last_result, $db_replace_result; |
| 507 | 540 | |
| 508 | - if ($db_replace_result) |
|
| 509 | - return $db_replace_result; |
|
| 510 | - elseif ($result === null && !$db_last_result) |
|
| 511 | - return 0; |
|
| 541 | + if ($db_replace_result) { |
|
| 542 | + return $db_replace_result; |
|
| 543 | + } elseif ($result === null && !$db_last_result) { |
|
| 544 | + return 0; |
|
| 545 | + } |
|
| 512 | 546 | |
| 513 | 547 | return pg_affected_rows($result === null ? $db_last_result : $result); |
| 514 | 548 | } |
@@ -532,8 +566,9 @@ discard block |
||
| 532 | 566 | array( |
| 533 | 567 | ) |
| 534 | 568 | ); |
| 535 | - if (!$request) |
|
| 536 | - return false; |
|
| 569 | + if (!$request) { |
|
| 570 | + return false; |
|
| 571 | + } |
|
| 537 | 572 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
| 538 | 573 | $smcFunc['db_free_result']($request); |
| 539 | 574 | |
@@ -554,12 +589,13 @@ discard block |
||
| 554 | 589 | // Decide which connection to use |
| 555 | 590 | $connection = $connection === null ? $db_connection : $connection; |
| 556 | 591 | |
| 557 | - if ($type == 'begin') |
|
| 558 | - return @pg_query($connection, 'BEGIN'); |
|
| 559 | - elseif ($type == 'rollback') |
|
| 560 | - return @pg_query($connection, 'ROLLBACK'); |
|
| 561 | - elseif ($type == 'commit') |
|
| 562 | - return @pg_query($connection, 'COMMIT'); |
|
| 592 | + if ($type == 'begin') { |
|
| 593 | + return @pg_query($connection, 'BEGIN'); |
|
| 594 | + } elseif ($type == 'rollback') { |
|
| 595 | + return @pg_query($connection, 'ROLLBACK'); |
|
| 596 | + } elseif ($type == 'commit') { |
|
| 597 | + return @pg_query($connection, 'COMMIT'); |
|
| 598 | + } |
|
| 563 | 599 | |
| 564 | 600 | return false; |
| 565 | 601 | } |
@@ -587,19 +623,22 @@ discard block |
||
| 587 | 623 | $query_error = @pg_last_error($connection); |
| 588 | 624 | |
| 589 | 625 | // Log the error. |
| 590 | - if (function_exists('log_error')) |
|
| 591 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
| 626 | + if (function_exists('log_error')) { |
|
| 627 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
| 628 | + } |
|
| 592 | 629 | |
| 593 | 630 | // Nothing's defined yet... just die with it. |
| 594 | - if (empty($context) || empty($txt)) |
|
| 595 | - die($query_error); |
|
| 631 | + if (empty($context) || empty($txt)) { |
|
| 632 | + die($query_error); |
|
| 633 | + } |
|
| 596 | 634 | |
| 597 | 635 | // Show an error message, if possible. |
| 598 | 636 | $context['error_title'] = $txt['database_error']; |
| 599 | - if (allowedTo('admin_forum')) |
|
| 600 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 601 | - else |
|
| 602 | - $context['error_message'] = $txt['try_again']; |
|
| 637 | + if (allowedTo('admin_forum')) { |
|
| 638 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 639 | + } else { |
|
| 640 | + $context['error_message'] = $txt['try_again']; |
|
| 641 | + } |
|
| 603 | 642 | |
| 604 | 643 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 605 | 644 | { |
@@ -621,12 +660,14 @@ discard block |
||
| 621 | 660 | { |
| 622 | 661 | global $db_row_count; |
| 623 | 662 | |
| 624 | - if ($counter !== false) |
|
| 625 | - return pg_fetch_row($request, $counter); |
|
| 663 | + if ($counter !== false) { |
|
| 664 | + return pg_fetch_row($request, $counter); |
|
| 665 | + } |
|
| 626 | 666 | |
| 627 | 667 | // Reset the row counter... |
| 628 | - if (!isset($db_row_count[(int) $request])) |
|
| 629 | - $db_row_count[(int) $request] = 0; |
|
| 668 | + if (!isset($db_row_count[(int) $request])) { |
|
| 669 | + $db_row_count[(int) $request] = 0; |
|
| 670 | + } |
|
| 630 | 671 | |
| 631 | 672 | // Return the right row. |
| 632 | 673 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -643,12 +684,14 @@ discard block |
||
| 643 | 684 | { |
| 644 | 685 | global $db_row_count; |
| 645 | 686 | |
| 646 | - if ($counter !== false) |
|
| 647 | - return pg_fetch_assoc($request, $counter); |
|
| 687 | + if ($counter !== false) { |
|
| 688 | + return pg_fetch_assoc($request, $counter); |
|
| 689 | + } |
|
| 648 | 690 | |
| 649 | 691 | // Reset the row counter... |
| 650 | - if (!isset($db_row_count[(int) $request])) |
|
| 651 | - $db_row_count[(int) $request] = 0; |
|
| 692 | + if (!isset($db_row_count[(int) $request])) { |
|
| 693 | + $db_row_count[(int) $request] = 0; |
|
| 694 | + } |
|
| 652 | 695 | |
| 653 | 696 | // Return the right row. |
| 654 | 697 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -701,11 +744,13 @@ discard block |
||
| 701 | 744 | |
| 702 | 745 | $replace = ''; |
| 703 | 746 | |
| 704 | - if (empty($data)) |
|
| 705 | - return; |
|
| 747 | + if (empty($data)) { |
|
| 748 | + return; |
|
| 749 | + } |
|
| 706 | 750 | |
| 707 | - if (!is_array($data[array_rand($data)])) |
|
| 708 | - $data = array($data); |
|
| 751 | + if (!is_array($data[array_rand($data)])) { |
|
| 752 | + $data = array($data); |
|
| 753 | + } |
|
| 709 | 754 | |
| 710 | 755 | // Replace the prefix holder with the actual prefix. |
| 711 | 756 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -724,11 +769,13 @@ discard block |
||
| 724 | 769 | //pg 9.5 got replace support |
| 725 | 770 | $pg_version = $smcFunc['db_get_version'](); |
| 726 | 771 | // if we got a Beta Version |
| 727 | - if (stripos($pg_version, 'beta') !== false) |
|
| 728 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
| 772 | + if (stripos($pg_version, 'beta') !== false) { |
|
| 773 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
| 774 | + } |
|
| 729 | 775 | // or RC |
| 730 | - if (stripos($pg_version, 'rc') !== false) |
|
| 731 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
| 776 | + if (stripos($pg_version, 'rc') !== false) { |
|
| 777 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
| 778 | + } |
|
| 732 | 779 | |
| 733 | 780 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
| 734 | 781 | } |
@@ -747,8 +794,7 @@ discard block |
||
| 747 | 794 | $key_str .= ($count_pk > 0 ? ',' : ''); |
| 748 | 795 | $key_str .= $columnName; |
| 749 | 796 | $count_pk++; |
| 750 | - } |
|
| 751 | - else //normal field |
|
| 797 | + } else //normal field |
|
| 752 | 798 | { |
| 753 | 799 | $col_str .= ($count > 0 ? ',' : ''); |
| 754 | 800 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
@@ -756,20 +802,21 @@ discard block |
||
| 756 | 802 | } |
| 757 | 803 | } |
| 758 | 804 | $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
| 759 | - } |
|
| 760 | - else |
|
| 805 | + } else |
|
| 761 | 806 | { |
| 762 | 807 | foreach ($columns as $columnName => $type) |
| 763 | 808 | { |
| 764 | 809 | // Are we restricting the length? |
| 765 | - if (strpos($type, 'string-') !== false) |
|
| 766 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
| 767 | - else |
|
| 768 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
| 810 | + if (strpos($type, 'string-') !== false) { |
|
| 811 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
| 812 | + } else { |
|
| 813 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
| 814 | + } |
|
| 769 | 815 | |
| 770 | 816 | // A key? That's what we were looking for. |
| 771 | - if (in_array($columnName, $keys)) |
|
| 772 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
| 817 | + if (in_array($columnName, $keys)) { |
|
| 818 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
| 819 | + } |
|
| 773 | 820 | $count++; |
| 774 | 821 | } |
| 775 | 822 | |
@@ -805,10 +852,11 @@ discard block |
||
| 805 | 852 | foreach ($columns as $columnName => $type) |
| 806 | 853 | { |
| 807 | 854 | // Are we restricting the length? |
| 808 | - if (strpos($type, 'string-') !== false) |
|
| 809 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 810 | - else |
|
| 811 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 855 | + if (strpos($type, 'string-') !== false) { |
|
| 856 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 857 | + } else { |
|
| 858 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 859 | + } |
|
| 812 | 860 | } |
| 813 | 861 | $insertData = substr($insertData, 0, -2) . ')'; |
| 814 | 862 | |
@@ -817,8 +865,9 @@ discard block |
||
| 817 | 865 | |
| 818 | 866 | // Here's where the variables are injected to the query. |
| 819 | 867 | $insertRows = array(); |
| 820 | - foreach ($data as $dataRow) |
|
| 821 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 868 | + foreach ($data as $dataRow) { |
|
| 869 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 870 | + } |
|
| 822 | 871 | |
| 823 | 872 | // Do the insert. |
| 824 | 873 | $request = $smcFunc['db_query']('', ' |
@@ -835,19 +884,21 @@ discard block |
||
| 835 | 884 | |
| 836 | 885 | if ($with_returning && $request !== false) |
| 837 | 886 | { |
| 838 | - if ($returnmode === 2) |
|
| 839 | - $return_var = array(); |
|
| 887 | + if ($returnmode === 2) { |
|
| 888 | + $return_var = array(); |
|
| 889 | + } |
|
| 840 | 890 | |
| 841 | 891 | while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
| 842 | 892 | { |
| 843 | - if (is_numeric($row[0])) // try to emulate mysql limitation |
|
| 893 | + if (is_numeric($row[0])) { |
|
| 894 | + // try to emulate mysql limitation |
|
| 844 | 895 | { |
| 845 | 896 | if ($returnmode === 1) |
| 846 | 897 | $return_var = $row[0]; |
| 847 | - elseif ($returnmode === 2) |
|
| 848 | - $return_var[] = $row[0]; |
|
| 849 | - } |
|
| 850 | - else |
|
| 898 | + } elseif ($returnmode === 2) { |
|
| 899 | + $return_var[] = $row[0]; |
|
| 900 | + } |
|
| 901 | + } else |
|
| 851 | 902 | { |
| 852 | 903 | $with_returning = false; |
| 853 | 904 | trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR); |
@@ -856,9 +907,10 @@ discard block |
||
| 856 | 907 | } |
| 857 | 908 | } |
| 858 | 909 | |
| 859 | - if ($with_returning && !empty($return_var)) |
|
| 860 | - return $return_var; |
|
| 861 | -} |
|
| 910 | + if ($with_returning && !empty($return_var)) { |
|
| 911 | + return $return_var; |
|
| 912 | + } |
|
| 913 | + } |
|
| 862 | 914 | |
| 863 | 915 | /** |
| 864 | 916 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -895,8 +947,9 @@ discard block |
||
| 895 | 947 | */ |
| 896 | 948 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 897 | 949 | { |
| 898 | - if (empty($log_message)) |
|
| 899 | - $log_message = $error_message; |
|
| 950 | + if (empty($log_message)) { |
|
| 951 | + $log_message = $error_message; |
|
| 952 | + } |
|
| 900 | 953 | |
| 901 | 954 | foreach (debug_backtrace() as $step) |
| 902 | 955 | { |
@@ -915,12 +968,14 @@ discard block |
||
| 915 | 968 | } |
| 916 | 969 | |
| 917 | 970 | // A special case - we want the file and line numbers for debugging. |
| 918 | - if ($error_type == 'return') |
|
| 919 | - return array($file, $line); |
|
| 971 | + if ($error_type == 'return') { |
|
| 972 | + return array($file, $line); |
|
| 973 | + } |
|
| 920 | 974 | |
| 921 | 975 | // Is always a critical error. |
| 922 | - if (function_exists('log_error')) |
|
| 923 | - log_error($log_message, 'critical', $file, $line); |
|
| 976 | + if (function_exists('log_error')) { |
|
| 977 | + log_error($log_message, 'critical', $file, $line); |
|
| 978 | + } |
|
| 924 | 979 | |
| 925 | 980 | if (function_exists('fatal_error')) |
| 926 | 981 | { |
@@ -928,12 +983,12 @@ discard block |
||
| 928 | 983 | |
| 929 | 984 | // Cannot continue... |
| 930 | 985 | exit; |
| 986 | + } elseif ($error_type) { |
|
| 987 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 988 | + } else { |
|
| 989 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 990 | + } |
|
| 931 | 991 | } |
| 932 | - elseif ($error_type) |
|
| 933 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 934 | - else |
|
| 935 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 936 | -} |
|
| 937 | 992 | |
| 938 | 993 | /** |
| 939 | 994 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -950,10 +1005,11 @@ discard block |
||
| 950 | 1005 | '\\' => '\\\\', |
| 951 | 1006 | ); |
| 952 | 1007 | |
| 953 | - if ($translate_human_wildcards) |
|
| 954 | - $replacements += array( |
|
| 1008 | + if ($translate_human_wildcards) { |
|
| 1009 | + $replacements += array( |
|
| 955 | 1010 | '*' => '%', |
| 956 | 1011 | ); |
| 1012 | + } |
|
| 957 | 1013 | |
| 958 | 1014 | return strtr($string, $replacements); |
| 959 | 1015 | } |
@@ -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 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
| 24 | 25 | global $time_start, $smcFunc; |
| 25 | 26 | |
| 26 | 27 | // Special case for doing the mail queue. |
| 27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
| 28 | - ReduceMailQueue(); |
|
| 29 | - else |
|
| 28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
| 29 | + ReduceMailQueue(); |
|
| 30 | + } else |
|
| 30 | 31 | { |
| 31 | 32 | $task_string = ''; |
| 32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | // How long in seconds it the gap? |
| 55 | 56 | $duration = $row['time_regularity']; |
| 56 | - if ($row['time_unit'] == 'm') |
|
| 57 | - $duration *= 60; |
|
| 58 | - elseif ($row['time_unit'] == 'h') |
|
| 59 | - $duration *= 3600; |
|
| 60 | - elseif ($row['time_unit'] == 'd') |
|
| 61 | - $duration *= 86400; |
|
| 62 | - elseif ($row['time_unit'] == 'w') |
|
| 63 | - $duration *= 604800; |
|
| 57 | + if ($row['time_unit'] == 'm') { |
|
| 58 | + $duration *= 60; |
|
| 59 | + } elseif ($row['time_unit'] == 'h') { |
|
| 60 | + $duration *= 3600; |
|
| 61 | + } elseif ($row['time_unit'] == 'd') { |
|
| 62 | + $duration *= 86400; |
|
| 63 | + } elseif ($row['time_unit'] == 'w') { |
|
| 64 | + $duration *= 604800; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // If we were really late running this task actually skip the next one. |
| 66 | - if (time() + ($duration / 2) > $next_time) |
|
| 67 | - $next_time += $duration; |
|
| 68 | + if (time() + ($duration / 2) > $next_time) { |
|
| 69 | + $next_time += $duration; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Update it now, so no others run this! |
| 70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
| 81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
| 82 | 85 | |
| 83 | 86 | // What kind of task are we handling? |
| 84 | - if (!empty($row['callable'])) |
|
| 85 | - $task_string = $row['callable']; |
|
| 87 | + if (!empty($row['callable'])) { |
|
| 88 | + $task_string = $row['callable']; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | // Default SMF task or old mods? |
| 88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 89 | - $task_string = 'scheduled_' . $row['task']; |
|
| 92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 93 | + $task_string = 'scheduled_' . $row['task']; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // One last resource, the task name. |
| 92 | - elseif (!empty($row['task'])) |
|
| 93 | - $task_string = $row['task']; |
|
| 97 | + elseif (!empty($row['task'])) { |
|
| 98 | + $task_string = $row['task']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
| 96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
| 101 | 107 | $callable_task = call_helper($task_string, true); |
| 102 | 108 | |
| 103 | 109 | // Perform the task. |
| 104 | - if (!empty($callable_task)) |
|
| 105 | - $completed = call_user_func($callable_task); |
|
| 106 | - |
|
| 107 | - else |
|
| 108 | - $completed = false; |
|
| 110 | + if (!empty($callable_task)) { |
|
| 111 | + $completed = call_user_func($callable_task); |
|
| 112 | + } else { |
|
| 113 | + $completed = false; |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | // Log that we did it ;) |
| 111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
| 138 | 144 | ) |
| 139 | 145 | ); |
| 140 | 146 | // No new task scheduled yet? |
| 141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 142 | - $nextEvent = time() + 86400; |
|
| 143 | - else |
|
| 144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 148 | + $nextEvent = time() + 86400; |
|
| 149 | + } else { |
|
| 150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 151 | + } |
|
| 145 | 152 | $smcFunc['db_free_result']($request); |
| 146 | 153 | |
| 147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | 157 | // Shall we return? |
| 151 | - if (!isset($_GET['scheduled'])) |
|
| 152 | - return true; |
|
| 158 | + if (!isset($_GET['scheduled'])) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | // Finally, send some stuff... |
| 155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
| 181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 182 | 190 | { |
| 183 | 191 | // If this is no longer around we'll ignore it. |
| 184 | - if (empty($row['id_topic'])) |
|
| 185 | - continue; |
|
| 192 | + if (empty($row['id_topic'])) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 186 | 195 | |
| 187 | 196 | // What type is it? |
| 188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
| 189 | - $type = 'topic'; |
|
| 190 | - elseif ($row['id_attach']) |
|
| 191 | - $type = 'attach'; |
|
| 192 | - else |
|
| 193 | - $type = 'msg'; |
|
| 197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
| 198 | + $type = 'topic'; |
|
| 199 | + } elseif ($row['id_attach']) { |
|
| 200 | + $type = 'attach'; |
|
| 201 | + } else { |
|
| 202 | + $type = 'msg'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | // Add it to the array otherwise. |
| 196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
| 211 | 221 | ); |
| 212 | 222 | |
| 213 | 223 | // If nothing quit now. |
| 214 | - if (empty($notices)) |
|
| 215 | - return true; |
|
| 224 | + if (empty($notices)) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 216 | 227 | |
| 217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
| 218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
| 231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 232 | 243 | { |
| 233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
| 234 | - if ($row['id_group'] < 2) |
|
| 235 | - continue; |
|
| 245 | + if ($row['id_group'] < 2) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
| 238 | 250 | |
| 239 | 251 | // Anyone who can access has to be considered. |
| 240 | - if ($row['add_deny']) |
|
| 241 | - $addGroups[] = $row['id_group']; |
|
| 252 | + if ($row['add_deny']) { |
|
| 253 | + $addGroups[] = $row['id_group']; |
|
| 254 | + } |
|
| 242 | 255 | } |
| 243 | 256 | $smcFunc['db_free_result']($request); |
| 244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | if (!empty($row['mod_prefs'])) |
| 284 | 297 | { |
| 285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
| 286 | - if (!($pref_binary & 4)) |
|
| 287 | - continue; |
|
| 299 | + if (!($pref_binary & 4)) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | |
| 290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
| 309 | 323 | $emailbody = ''; |
| 310 | 324 | |
| 311 | 325 | // Load the language file as required. |
| 312 | - if (empty($current_language) || $current_language != $member['language']) |
|
| 313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
| 327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | // Loop through each notice... |
| 316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
| 318 | 333 | $access = false; |
| 319 | 334 | |
| 320 | 335 | // Can they mod in this board? |
| 321 | - if (isset($mods[$id][$board])) |
|
| 322 | - $access = true; |
|
| 336 | + if (isset($mods[$id][$board])) { |
|
| 337 | + $access = true; |
|
| 338 | + } |
|
| 323 | 339 | |
| 324 | 340 | // Do the group check... |
| 325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
| 326 | 342 | { |
| 327 | 343 | // They can access?! |
| 328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
| 329 | - $access = true; |
|
| 344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
| 345 | + $access = true; |
|
| 346 | + } |
|
| 330 | 347 | |
| 331 | 348 | // If they have deny rights don't consider them! |
| 332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
| 333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
| 350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 334 | 351 | $access = false; |
| 352 | + } |
|
| 335 | 353 | } |
| 336 | 354 | |
| 337 | 355 | // Finally, fix it for admins! |
| 338 | - if (in_array(1, $member['groups'])) |
|
| 339 | - $access = true; |
|
| 356 | + if (in_array(1, $member['groups'])) { |
|
| 357 | + $access = true; |
|
| 358 | + } |
|
| 340 | 359 | |
| 341 | 360 | // If they can't access it then give it a break! |
| 342 | - if (!$access) |
|
| 343 | - continue; |
|
| 361 | + if (!$access) { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 344 | 364 | |
| 345 | 365 | foreach ($notice as $type => $items) |
| 346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
| 348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
| 349 | 369 | '------------------------------------------------------' . "\n"; |
| 350 | 370 | |
| 351 | - foreach ($items as $item) |
|
| 352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 371 | + foreach ($items as $item) { |
|
| 372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 373 | + } |
|
| 353 | 374 | |
| 354 | 375 | $emailbody .= "\n"; |
| 355 | 376 | } |
| 356 | 377 | } |
| 357 | 378 | |
| 358 | - if ($emailbody == '') |
|
| 359 | - continue; |
|
| 379 | + if ($emailbody == '') { |
|
| 380 | + continue; |
|
| 381 | + } |
|
| 360 | 382 | |
| 361 | 383 | $replacements = array( |
| 362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
| 397 | 419 | ) |
| 398 | 420 | ); |
| 399 | 421 | $members = array(); |
| 400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 401 | - $members[$row['id_member']] = $row['warning']; |
|
| 422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 423 | + $members[$row['id_member']] = $row['warning']; |
|
| 424 | + } |
|
| 402 | 425 | $smcFunc['db_free_result']($request); |
| 403 | 426 | |
| 404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
| 420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 421 | 444 | { |
| 422 | 445 | // More than 24 hours ago? |
| 423 | - if ($row['last_warning'] <= time() - 86400) |
|
| 424 | - $member_changes[] = array( |
|
| 446 | + if ($row['last_warning'] <= time() - 86400) { |
|
| 447 | + $member_changes[] = array( |
|
| 425 | 448 | 'id' => $row['id_recipient'], |
| 426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
| 427 | 450 | ); |
| 451 | + } |
|
| 428 | 452 | } |
| 429 | 453 | $smcFunc['db_free_result']($request); |
| 430 | 454 | |
| 431 | 455 | // Have some members to change? |
| 432 | - if (!empty($member_changes)) |
|
| 433 | - foreach ($member_changes as $change) |
|
| 456 | + if (!empty($member_changes)) { |
|
| 457 | + foreach ($member_changes as $change) |
|
| 434 | 458 | $smcFunc['db_query']('', ' |
| 435 | 459 | UPDATE {db_prefix}members |
| 436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
| 440 | 464 | 'id_member' => $change['id'], |
| 441 | 465 | ) |
| 442 | 466 | ); |
| 467 | + } |
|
| 443 | 468 | } |
| 444 | 469 | } |
| 445 | 470 | |
@@ -506,15 +531,17 @@ discard block |
||
| 506 | 531 | |
| 507 | 532 | // Store this useful data! |
| 508 | 533 | $boards[$row['id_board']] = $row['id_board']; |
| 509 | - if ($row['id_topic']) |
|
| 510 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 511 | - else |
|
| 512 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 534 | + if ($row['id_topic']) { |
|
| 535 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 536 | + } else { |
|
| 537 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 538 | + } |
|
| 513 | 539 | } |
| 514 | 540 | $smcFunc['db_free_result']($request); |
| 515 | 541 | |
| 516 | - if (empty($boards)) |
|
| 517 | - return true; |
|
| 542 | + if (empty($boards)) { |
|
| 543 | + return true; |
|
| 544 | + } |
|
| 518 | 545 | |
| 519 | 546 | // Just get the board names. |
| 520 | 547 | $request = $smcFunc['db_query']('', ' |
@@ -526,12 +553,14 @@ discard block |
||
| 526 | 553 | ) |
| 527 | 554 | ); |
| 528 | 555 | $boards = array(); |
| 529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 530 | - $boards[$row['id_board']] = $row['name']; |
|
| 556 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 557 | + $boards[$row['id_board']] = $row['name']; |
|
| 558 | + } |
|
| 531 | 559 | $smcFunc['db_free_result']($request); |
| 532 | 560 | |
| 533 | - if (empty($boards)) |
|
| 534 | - return true; |
|
| 561 | + if (empty($boards)) { |
|
| 562 | + return true; |
|
| 563 | + } |
|
| 535 | 564 | |
| 536 | 565 | // Get the actual topics... |
| 537 | 566 | $request = $smcFunc['db_query']('', ' |
@@ -551,52 +580,57 @@ discard block |
||
| 551 | 580 | $types = array(); |
| 552 | 581 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 553 | 582 | { |
| 554 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
| 555 | - $types[$row['note_type']][$row['id_board']] = array( |
|
| 583 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
| 584 | + $types[$row['note_type']][$row['id_board']] = array( |
|
| 556 | 585 | 'lines' => array(), |
| 557 | 586 | 'name' => $row['board_name'], |
| 558 | 587 | 'id' => $row['id_board'], |
| 559 | 588 | ); |
| 589 | + } |
|
| 560 | 590 | |
| 561 | 591 | if ($row['note_type'] == 'reply') |
| 562 | 592 | { |
| 563 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 564 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 565 | - else |
|
| 566 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 593 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 594 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 595 | + } else { |
|
| 596 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 567 | 597 | 'id' => $row['id_topic'], |
| 568 | 598 | 'subject' => un_htmlspecialchars($row['subject']), |
| 569 | 599 | 'count' => 1, |
| 570 | 600 | ); |
| 571 | - } |
|
| 572 | - elseif ($row['note_type'] == 'topic') |
|
| 601 | + } |
|
| 602 | + } elseif ($row['note_type'] == 'topic') |
|
| 573 | 603 | { |
| 574 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 575 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 604 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 605 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 576 | 606 | 'id' => $row['id_topic'], |
| 577 | 607 | 'subject' => un_htmlspecialchars($row['subject']), |
| 578 | 608 | ); |
| 579 | - } |
|
| 580 | - else |
|
| 609 | + } |
|
| 610 | + } else |
|
| 581 | 611 | { |
| 582 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 583 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 612 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 613 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 584 | 614 | 'id' => $row['id_topic'], |
| 585 | 615 | 'subject' => un_htmlspecialchars($row['subject']), |
| 586 | 616 | 'starter' => $row['id_member_started'], |
| 587 | 617 | ); |
| 618 | + } |
|
| 588 | 619 | } |
| 589 | 620 | |
| 590 | 621 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
| 591 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
| 592 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 593 | - if (!empty($notify['boards'][$row['id_board']])) |
|
| 594 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 622 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
| 623 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 624 | + } |
|
| 625 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
| 626 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 627 | + } |
|
| 595 | 628 | } |
| 596 | 629 | $smcFunc['db_free_result']($request); |
| 597 | 630 | |
| 598 | - if (empty($types)) |
|
| 599 | - return true; |
|
| 631 | + if (empty($types)) { |
|
| 632 | + return true; |
|
| 633 | + } |
|
| 600 | 634 | |
| 601 | 635 | // Let's load all the languages into a cache thingy. |
| 602 | 636 | $langtxt = array(); |
@@ -637,8 +671,9 @@ discard block |
||
| 637 | 671 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
| 638 | 672 | |
| 639 | 673 | // Did they not elect to choose this? |
| 640 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
| 641 | - continue; |
|
| 674 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 642 | 677 | |
| 643 | 678 | // Right character set! |
| 644 | 679 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -654,39 +689,43 @@ discard block |
||
| 654 | 689 | if (isset($types['topic'])) |
| 655 | 690 | { |
| 656 | 691 | $titled = false; |
| 657 | - foreach ($types['topic'] as $id => $board) |
|
| 658 | - foreach ($board['lines'] as $topic) |
|
| 692 | + foreach ($types['topic'] as $id => $board) { |
|
| 693 | + foreach ($board['lines'] as $topic) |
|
| 659 | 694 | if (in_array($mid, $topic['members'])) |
| 660 | 695 | { |
| 661 | 696 | if (!$titled) |
| 662 | 697 | { |
| 663 | 698 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
| 699 | + } |
|
| 664 | 700 | $titled = true; |
| 665 | 701 | } |
| 666 | 702 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
| 667 | 703 | } |
| 668 | - if ($titled) |
|
| 669 | - $email['body'] .= "\n"; |
|
| 704 | + if ($titled) { |
|
| 705 | + $email['body'] .= "\n"; |
|
| 706 | + } |
|
| 670 | 707 | } |
| 671 | 708 | |
| 672 | 709 | // What about replies? |
| 673 | 710 | if (isset($types['reply'])) |
| 674 | 711 | { |
| 675 | 712 | $titled = false; |
| 676 | - foreach ($types['reply'] as $id => $board) |
|
| 677 | - foreach ($board['lines'] as $topic) |
|
| 713 | + foreach ($types['reply'] as $id => $board) { |
|
| 714 | + foreach ($board['lines'] as $topic) |
|
| 678 | 715 | if (in_array($mid, $topic['members'])) |
| 679 | 716 | { |
| 680 | 717 | if (!$titled) |
| 681 | 718 | { |
| 682 | 719 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
| 720 | + } |
|
| 683 | 721 | $titled = true; |
| 684 | 722 | } |
| 685 | 723 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
| 686 | 724 | } |
| 687 | 725 | |
| 688 | - if ($titled) |
|
| 689 | - $email['body'] .= "\n"; |
|
| 726 | + if ($titled) { |
|
| 727 | + $email['body'] .= "\n"; |
|
| 728 | + } |
|
| 690 | 729 | } |
| 691 | 730 | |
| 692 | 731 | // Finally, moderation actions! |
@@ -695,24 +734,27 @@ discard block |
||
| 695 | 734 | $titled = false; |
| 696 | 735 | foreach ($types as $note_type => $type) |
| 697 | 736 | { |
| 698 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
| 699 | - continue; |
|
| 737 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 700 | 740 | |
| 701 | - foreach ($type as $id => $board) |
|
| 702 | - foreach ($board['lines'] as $topic) |
|
| 741 | + foreach ($type as $id => $board) { |
|
| 742 | + foreach ($board['lines'] as $topic) |
|
| 703 | 743 | if (in_array($mid, $topic['members'])) |
| 704 | 744 | { |
| 705 | 745 | if (!$titled) |
| 706 | 746 | { |
| 707 | 747 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
| 748 | + } |
|
| 708 | 749 | $titled = true; |
| 709 | 750 | } |
| 710 | 751 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
| 711 | 752 | } |
| 712 | 753 | } |
| 713 | 754 | } |
| 714 | - if ($titled) |
|
| 715 | - $email['body'] .= "\n"; |
|
| 755 | + if ($titled) { |
|
| 756 | + $email['body'] .= "\n"; |
|
| 757 | + } |
|
| 716 | 758 | |
| 717 | 759 | // Then just say our goodbyes! |
| 718 | 760 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -740,8 +782,7 @@ discard block |
||
| 740 | 782 | 'not_daily' => 0, |
| 741 | 783 | ) |
| 742 | 784 | ); |
| 743 | - } |
|
| 744 | - else |
|
| 785 | + } else |
|
| 745 | 786 | { |
| 746 | 787 | // Clear any only weekly ones, and stop us from sending daily again. |
| 747 | 788 | $smcFunc['db_query']('', ' |
@@ -803,16 +844,19 @@ discard block |
||
| 803 | 844 | global $modSettings, $smcFunc, $sourcedir; |
| 804 | 845 | |
| 805 | 846 | // Are we intending another script to be sending out the queue? |
| 806 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
| 807 | - return false; |
|
| 847 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
| 848 | + return false; |
|
| 849 | + } |
|
| 808 | 850 | |
| 809 | 851 | // By default send 5 at once. |
| 810 | - if (!$number) |
|
| 811 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 852 | + if (!$number) { |
|
| 853 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 854 | + } |
|
| 812 | 855 | |
| 813 | 856 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
| 814 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
| 815 | - return false; |
|
| 857 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
| 858 | + return false; |
|
| 859 | + } |
|
| 816 | 860 | |
| 817 | 861 | // By default move the next sending on by 10 seconds, and require an affected row. |
| 818 | 862 | if (!$override_limit) |
@@ -829,8 +873,9 @@ discard block |
||
| 829 | 873 | 'last_send' => $modSettings['mail_next_send'], |
| 830 | 874 | ) |
| 831 | 875 | ); |
| 832 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 833 | - return false; |
|
| 876 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 877 | + return false; |
|
| 878 | + } |
|
| 834 | 879 | $modSettings['mail_next_send'] = time() + $delay; |
| 835 | 880 | } |
| 836 | 881 | |
@@ -851,8 +896,9 @@ discard block |
||
| 851 | 896 | $mn += $number; |
| 852 | 897 | } |
| 853 | 898 | // No more I'm afraid, return! |
| 854 | - else |
|
| 855 | - return false; |
|
| 899 | + else { |
|
| 900 | + return false; |
|
| 901 | + } |
|
| 856 | 902 | |
| 857 | 903 | // Reflect that we're about to send some, do it now to be safe. |
| 858 | 904 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -887,14 +933,15 @@ discard block |
||
| 887 | 933 | $smcFunc['db_free_result']($request); |
| 888 | 934 | |
| 889 | 935 | // Delete, delete, delete!!! |
| 890 | - if (!empty($ids)) |
|
| 891 | - $smcFunc['db_query']('', ' |
|
| 936 | + if (!empty($ids)) { |
|
| 937 | + $smcFunc['db_query']('', ' |
|
| 892 | 938 | DELETE FROM {db_prefix}mail_queue |
| 893 | 939 | WHERE id_mail IN ({array_int:mail_list})', |
| 894 | 940 | array( |
| 895 | 941 | 'mail_list' => $ids, |
| 896 | 942 | ) |
| 897 | 943 | ); |
| 944 | + } |
|
| 898 | 945 | |
| 899 | 946 | // Don't believe we have any left? |
| 900 | 947 | if (count($ids) < $number) |
@@ -912,11 +959,13 @@ discard block |
||
| 912 | 959 | ); |
| 913 | 960 | } |
| 914 | 961 | |
| 915 | - if (empty($ids)) |
|
| 916 | - return false; |
|
| 962 | + if (empty($ids)) { |
|
| 963 | + return false; |
|
| 964 | + } |
|
| 917 | 965 | |
| 918 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
| 919 | - require_once($sourcedir . '/Subs-Post.php'); |
|
| 966 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
| 967 | + require_once($sourcedir . '/Subs-Post.php'); |
|
| 968 | + } |
|
| 920 | 969 | |
| 921 | 970 | // Send each email, yea! |
| 922 | 971 | $failed_emails = array(); |
@@ -936,15 +985,17 @@ discard block |
||
| 936 | 985 | |
| 937 | 986 | // Try to stop a timeout, this would be bad... |
| 938 | 987 | @set_time_limit(300); |
| 939 | - if (function_exists('apache_reset_timeout')) |
|
| 940 | - @apache_reset_timeout(); |
|
| 988 | + if (function_exists('apache_reset_timeout')) { |
|
| 989 | + @apache_reset_timeout(); |
|
| 990 | + } |
|
| 991 | + } else { |
|
| 992 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 941 | 993 | } |
| 942 | - else |
|
| 943 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 944 | 994 | |
| 945 | 995 | // Hopefully it sent? |
| 946 | - if (!$result) |
|
| 947 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 996 | + if (!$result) { |
|
| 997 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 998 | + } |
|
| 948 | 999 | } |
| 949 | 1000 | |
| 950 | 1001 | // Any emails that didn't send? |
@@ -959,8 +1010,8 @@ discard block |
||
| 959 | 1010 | ); |
| 960 | 1011 | |
| 961 | 1012 | // If we have failed to many times, tell mail to wait a bit and try again. |
| 962 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
| 963 | - $smcFunc['db_query']('', ' |
|
| 1013 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
| 1014 | + $smcFunc['db_query']('', ' |
|
| 964 | 1015 | UPDATE {db_prefix}settings |
| 965 | 1016 | SET value = {string:next_mail_send} |
| 966 | 1017 | WHERE variable = {literal:mail_next_send} |
@@ -969,6 +1020,7 @@ discard block |
||
| 969 | 1020 | 'next_mail_send' => time() + 60, |
| 970 | 1021 | 'last_send' => $modSettings['mail_next_send'], |
| 971 | 1022 | )); |
| 1023 | + } |
|
| 972 | 1024 | |
| 973 | 1025 | // Add our email back to the queue, manually. |
| 974 | 1026 | $smcFunc['db_insert']('insert', |
@@ -981,8 +1033,8 @@ discard block |
||
| 981 | 1033 | return false; |
| 982 | 1034 | } |
| 983 | 1035 | // We where unable to send the email, clear our failed attempts. |
| 984 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
| 985 | - $smcFunc['db_query']('', ' |
|
| 1036 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
| 1037 | + $smcFunc['db_query']('', ' |
|
| 986 | 1038 | UPDATE {db_prefix}settings |
| 987 | 1039 | SET value = {string:zero} |
| 988 | 1040 | WHERE variable = {string:mail_failed_attempts}', |
@@ -990,6 +1042,7 @@ discard block |
||
| 990 | 1042 | 'zero' => '0', |
| 991 | 1043 | 'mail_failed_attempts' => 'mail_failed_attempts', |
| 992 | 1044 | )); |
| 1045 | + } |
|
| 993 | 1046 | |
| 994 | 1047 | // Had something to send... |
| 995 | 1048 | return true; |
@@ -1006,16 +1059,18 @@ discard block |
||
| 1006 | 1059 | global $modSettings, $smcFunc; |
| 1007 | 1060 | |
| 1008 | 1061 | $task_query = ''; |
| 1009 | - if (!is_array($tasks)) |
|
| 1010 | - $tasks = array($tasks); |
|
| 1062 | + if (!is_array($tasks)) { |
|
| 1063 | + $tasks = array($tasks); |
|
| 1064 | + } |
|
| 1011 | 1065 | |
| 1012 | 1066 | // Actually have something passed? |
| 1013 | 1067 | if (!empty($tasks)) |
| 1014 | 1068 | { |
| 1015 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
| 1016 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1017 | - else |
|
| 1018 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1069 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
| 1070 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1071 | + } else { |
|
| 1072 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1073 | + } |
|
| 1019 | 1074 | } |
| 1020 | 1075 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
| 1021 | 1076 | |
@@ -1036,20 +1091,22 @@ discard block |
||
| 1036 | 1091 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
| 1037 | 1092 | |
| 1038 | 1093 | // Only bother moving the task if it's out of place or we're forcing it! |
| 1039 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
| 1040 | - $tasks[$row['id_task']] = $next_time; |
|
| 1041 | - else |
|
| 1042 | - $next_time = $row['next_time']; |
|
| 1094 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
| 1095 | + $tasks[$row['id_task']] = $next_time; |
|
| 1096 | + } else { |
|
| 1097 | + $next_time = $row['next_time']; |
|
| 1098 | + } |
|
| 1043 | 1099 | |
| 1044 | 1100 | // If this is sooner than the current next task, make this the next task. |
| 1045 | - if ($next_time < $nextTaskTime) |
|
| 1046 | - $nextTaskTime = $next_time; |
|
| 1101 | + if ($next_time < $nextTaskTime) { |
|
| 1102 | + $nextTaskTime = $next_time; |
|
| 1103 | + } |
|
| 1047 | 1104 | } |
| 1048 | 1105 | $smcFunc['db_free_result']($request); |
| 1049 | 1106 | |
| 1050 | 1107 | // Now make the changes! |
| 1051 | - foreach ($tasks as $id => $time) |
|
| 1052 | - $smcFunc['db_query']('', ' |
|
| 1108 | + foreach ($tasks as $id => $time) { |
|
| 1109 | + $smcFunc['db_query']('', ' |
|
| 1053 | 1110 | UPDATE {db_prefix}scheduled_tasks |
| 1054 | 1111 | SET next_time = {int:next_time} |
| 1055 | 1112 | WHERE id_task = {int:id_task}', |
@@ -1058,11 +1115,13 @@ discard block |
||
| 1058 | 1115 | 'id_task' => $id, |
| 1059 | 1116 | ) |
| 1060 | 1117 | ); |
| 1118 | + } |
|
| 1061 | 1119 | |
| 1062 | 1120 | // If the next task is now different update. |
| 1063 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
| 1064 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1065 | -} |
|
| 1121 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
| 1122 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1066 | 1125 | |
| 1067 | 1126 | /** |
| 1068 | 1127 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1075,8 +1134,9 @@ discard block |
||
| 1075 | 1134 | function next_time($regularity, $unit, $offset) |
| 1076 | 1135 | { |
| 1077 | 1136 | // Just in case! |
| 1078 | - if ($regularity == 0) |
|
| 1079 | - $regularity = 2; |
|
| 1137 | + if ($regularity == 0) { |
|
| 1138 | + $regularity = 2; |
|
| 1139 | + } |
|
| 1080 | 1140 | |
| 1081 | 1141 | $curMin = date('i', time()); |
| 1082 | 1142 | |
@@ -1086,15 +1146,16 @@ discard block |
||
| 1086 | 1146 | $off = date('i', $offset); |
| 1087 | 1147 | |
| 1088 | 1148 | // If it's now just pretend it ain't, |
| 1089 | - if ($off == $curMin) |
|
| 1090 | - $next_time = time() + $regularity; |
|
| 1091 | - else |
|
| 1149 | + if ($off == $curMin) { |
|
| 1150 | + $next_time = time() + $regularity; |
|
| 1151 | + } else |
|
| 1092 | 1152 | { |
| 1093 | 1153 | // Make sure that the offset is always in the past. |
| 1094 | 1154 | $off = $off > $curMin ? $off - 60 : $off; |
| 1095 | 1155 | |
| 1096 | - while ($off <= $curMin) |
|
| 1097 | - $off += $regularity; |
|
| 1156 | + while ($off <= $curMin) { |
|
| 1157 | + $off += $regularity; |
|
| 1158 | + } |
|
| 1098 | 1159 | |
| 1099 | 1160 | // Now we know when the time should be! |
| 1100 | 1161 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1114,11 +1175,13 @@ discard block |
||
| 1114 | 1175 | // Default we'll jump in hours. |
| 1115 | 1176 | $applyOffset = 3600; |
| 1116 | 1177 | // 24 hours = 1 day. |
| 1117 | - if ($unit == 'd') |
|
| 1118 | - $applyOffset = 86400; |
|
| 1178 | + if ($unit == 'd') { |
|
| 1179 | + $applyOffset = 86400; |
|
| 1180 | + } |
|
| 1119 | 1181 | // Otherwise a week. |
| 1120 | - if ($unit == 'w') |
|
| 1121 | - $applyOffset = 604800; |
|
| 1182 | + if ($unit == 'w') { |
|
| 1183 | + $applyOffset = 604800; |
|
| 1184 | + } |
|
| 1122 | 1185 | |
| 1123 | 1186 | $applyOffset *= $regularity; |
| 1124 | 1187 | |
@@ -1155,8 +1218,9 @@ discard block |
||
| 1155 | 1218 | $settings[$row['variable']] = $row['value']; |
| 1156 | 1219 | |
| 1157 | 1220 | // Is this the default theme? |
| 1158 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
| 1159 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1221 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
| 1222 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1223 | + } |
|
| 1160 | 1224 | } |
| 1161 | 1225 | $smcFunc['db_free_result']($result); |
| 1162 | 1226 | |
@@ -1166,12 +1230,14 @@ discard block |
||
| 1166 | 1230 | $settings['template_dirs'] = array($settings['theme_dir']); |
| 1167 | 1231 | |
| 1168 | 1232 | // Based on theme (if there is one). |
| 1169 | - if (!empty($settings['base_theme_dir'])) |
|
| 1170 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1233 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1234 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1235 | + } |
|
| 1171 | 1236 | |
| 1172 | 1237 | // Lastly the default theme. |
| 1173 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1174 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1238 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1239 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1240 | + } |
|
| 1175 | 1241 | } |
| 1176 | 1242 | |
| 1177 | 1243 | // Assume we want this. |
@@ -1318,8 +1384,9 @@ discard block |
||
| 1318 | 1384 | // Ok should we prune the logs? |
| 1319 | 1385 | if (!empty($modSettings['pruningOptions'])) |
| 1320 | 1386 | { |
| 1321 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
| 1322 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1387 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
| 1388 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1389 | + } |
|
| 1323 | 1390 | |
| 1324 | 1391 | if (!empty($modSettings['pruneErrorLog'])) |
| 1325 | 1392 | { |
@@ -1385,8 +1452,9 @@ discard block |
||
| 1385 | 1452 | ) |
| 1386 | 1453 | ); |
| 1387 | 1454 | |
| 1388 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
| 1389 | - $reports[] = $row[0]; |
|
| 1455 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
| 1456 | + $reports[] = $row[0]; |
|
| 1457 | + } |
|
| 1390 | 1458 | |
| 1391 | 1459 | $smcFunc['db_free_result']($result); |
| 1392 | 1460 | |
@@ -1548,8 +1616,9 @@ discard block |
||
| 1548 | 1616 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
| 1549 | 1617 | |
| 1550 | 1618 | // Send the actual email. |
| 1551 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
| 1552 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1619 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
| 1620 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1621 | + } |
|
| 1553 | 1622 | |
| 1554 | 1623 | if ($notifyPrefs[$row['id_member']] & 0x01) |
| 1555 | 1624 | { |
@@ -1572,18 +1641,19 @@ discard block |
||
| 1572 | 1641 | } |
| 1573 | 1642 | |
| 1574 | 1643 | // Insert the alerts if any |
| 1575 | - if (!empty($alert_rows)) |
|
| 1576 | - $smcFunc['db_insert']('', |
|
| 1644 | + if (!empty($alert_rows)) { |
|
| 1645 | + $smcFunc['db_insert']('', |
|
| 1577 | 1646 | '{db_prefix}user_alerts', |
| 1578 | 1647 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 1579 | 1648 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 1580 | 1649 | $alert_rows, |
| 1581 | 1650 | array() |
| 1582 | 1651 | ); |
| 1652 | + } |
|
| 1583 | 1653 | |
| 1584 | 1654 | // Mark the reminder as sent. |
| 1585 | - if (!empty($subs_reminded)) |
|
| 1586 | - $smcFunc['db_query']('', ' |
|
| 1655 | + if (!empty($subs_reminded)) { |
|
| 1656 | + $smcFunc['db_query']('', ' |
|
| 1587 | 1657 | UPDATE {db_prefix}log_subscribed |
| 1588 | 1658 | SET reminder_sent = {int:reminder_sent} |
| 1589 | 1659 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1592,6 +1662,7 @@ discard block |
||
| 1592 | 1662 | 'reminder_sent' => 1, |
| 1593 | 1663 | ) |
| 1594 | 1664 | ); |
| 1665 | + } |
|
| 1595 | 1666 | |
| 1596 | 1667 | return true; |
| 1597 | 1668 | } |
@@ -1607,13 +1678,13 @@ discard block |
||
| 1607 | 1678 | // We need to know where this thing is going. |
| 1608 | 1679 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1609 | 1680 | { |
| 1610 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 1611 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 1681 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 1682 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 1683 | + } |
|
| 1612 | 1684 | |
| 1613 | 1685 | // Just use the current path for temp files. |
| 1614 | 1686 | $attach_dirs = $modSettings['attachmentUploadDir']; |
| 1615 | - } |
|
| 1616 | - else |
|
| 1687 | + } else |
|
| 1617 | 1688 | { |
| 1618 | 1689 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
| 1619 | 1690 | } |
@@ -1632,14 +1703,16 @@ discard block |
||
| 1632 | 1703 | |
| 1633 | 1704 | while ($file = readdir($dir)) |
| 1634 | 1705 | { |
| 1635 | - if ($file == '.' || $file == '..') |
|
| 1636 | - continue; |
|
| 1706 | + if ($file == '.' || $file == '..') { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1637 | 1709 | |
| 1638 | 1710 | if (strpos($file, 'post_tmp_') !== false) |
| 1639 | 1711 | { |
| 1640 | 1712 | // Temp file is more than 5 hours old! |
| 1641 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1642 | - @unlink($attach_dir . '/' . $file); |
|
| 1713 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1714 | + @unlink($attach_dir . '/' . $file); |
|
| 1715 | + } |
|
| 1643 | 1716 | } |
| 1644 | 1717 | } |
| 1645 | 1718 | closedir($dir); |
@@ -1672,8 +1745,9 @@ discard block |
||
| 1672 | 1745 | ) |
| 1673 | 1746 | ); |
| 1674 | 1747 | |
| 1675 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1676 | - $topics[] = $row[0]; |
|
| 1748 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1749 | + $topics[] = $row[0]; |
|
| 1750 | + } |
|
| 1677 | 1751 | $smcFunc['db_free_result']($request); |
| 1678 | 1752 | |
| 1679 | 1753 | // Zap, your gone |
@@ -1693,8 +1767,9 @@ discard block |
||
| 1693 | 1767 | { |
| 1694 | 1768 | global $smcFunc, $sourcedir, $modSettings; |
| 1695 | 1769 | |
| 1696 | - if (empty($modSettings['drafts_keep_days'])) |
|
| 1697 | - return true; |
|
| 1770 | + if (empty($modSettings['drafts_keep_days'])) { |
|
| 1771 | + return true; |
|
| 1772 | + } |
|
| 1698 | 1773 | |
| 1699 | 1774 | // init |
| 1700 | 1775 | $drafts = array(); |
@@ -1712,8 +1787,9 @@ discard block |
||
| 1712 | 1787 | ) |
| 1713 | 1788 | ); |
| 1714 | 1789 | |
| 1715 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1716 | - $drafts[] = (int) $row[0]; |
|
| 1790 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1791 | + $drafts[] = (int) $row[0]; |
|
| 1792 | + } |
|
| 1717 | 1793 | $smcFunc['db_free_result']($request); |
| 1718 | 1794 | |
| 1719 | 1795 | // If we have old one, remove them |
@@ -32,16 +32,18 @@ discard block |
||
| 32 | 32 | ob_start(); |
| 33 | 33 | |
| 34 | 34 | // Do some cleaning, just in case. |
| 35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 36 | 36 | if (isset($GLOBALS[$variable])) |
| 37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 38 | +} |
|
| 38 | 39 | |
| 39 | 40 | // Load the settings... |
| 40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 41 | 42 | |
| 42 | 43 | // Make absolutely sure the cache directory is defined. |
| 43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 44 | 45 | $cachedir = $boarddir . '/cache'; |
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | // Without those we can't go anywhere |
| 47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | require_once($sourcedir . '/Load.php'); |
| 52 | 54 | |
| 53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 54 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 55 | 57 | display_maintenance_message(); |
| 58 | +} |
|
| 56 | 59 | |
| 57 | 60 | // Create a variable to store some SMF specific functions in. |
| 58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | cleanRequest(); |
| 68 | 71 | |
| 69 | 72 | // Seed the random generator. |
| 70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 71 | 74 | smf_seed_generator(); |
| 75 | +} |
|
| 72 | 76 | |
| 73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
| 88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 89 | 93 | { |
| 90 | 94 | // If zlib is being used, turn off output compression. |
| 91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 93 | - else |
|
| 95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 97 | + } else |
|
| 94 | 98 | { |
| 95 | 99 | ob_end_clean(); |
| 96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
| 182 | 186 | loadPermissions(); |
| 183 | 187 | |
| 184 | 188 | // Attachments don't require the entire theme to be loaded. |
| 185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 186 | - detectBrowser(); |
|
| 189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 190 | + detectBrowser(); |
|
| 191 | + } |
|
| 187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 188 | - else |
|
| 189 | - loadTheme(); |
|
| 193 | + else { |
|
| 194 | + loadTheme(); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | // Check if the user should be disallowed access. |
| 192 | 198 | is_not_banned(); |
| 193 | 199 | |
| 194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 196 | - fatal_lang_error('not_a_topic', false); |
|
| 201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 202 | + fatal_lang_error('not_a_topic', false); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | writeLog(); |
| 205 | 212 | |
| 206 | 213 | // Track forum statistics and hits...? |
| 207 | - if (!empty($modSettings['hitStats'])) |
|
| 208 | - trackStats(array('hits' => '+')); |
|
| 214 | + if (!empty($modSettings['hitStats'])) { |
|
| 215 | + trackStats(array('hits' => '+')); |
|
| 216 | + } |
|
| 209 | 217 | } |
| 210 | 218 | unset($no_stat_actions); |
| 211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
| 219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 220 | 228 | } |
| 221 | 229 | // Don't even try it, sonny. |
| 222 | - else |
|
| 223 | - return 'InMaintenance'; |
|
| 230 | + else { |
|
| 231 | + return 'InMaintenance'; |
|
| 232 | + } |
|
| 224 | 233 | } |
| 225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
| 226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 227 | - return 'KickGuest'; |
|
| 228 | - elseif (empty($_REQUEST['action'])) |
|
| 235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 236 | + return 'KickGuest'; |
|
| 237 | + } elseif (empty($_REQUEST['action'])) |
|
| 229 | 238 | { |
| 230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
| 239 | 248 | |
| 240 | 249 | $call = call_helper($defaultAction, true); |
| 241 | 250 | |
| 242 | - if (!empty($call)) |
|
| 243 | - return $call; |
|
| 251 | + if (!empty($call)) { |
|
| 252 | + return $call; |
|
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | |
| 371 | 381 | $call = call_helper($fallbackAction, true); |
| 372 | 382 | |
| 373 | - if (!empty($call)) |
|
| 374 | - return $call; |
|
| 383 | + if (!empty($call)) { |
|
| 384 | + return $call; |
|
| 385 | + } |
|
| 375 | 386 | } |
| 376 | 387 | |
| 377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // Otherwise, it was set - so let's go to that action. |
| 385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
| 386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
| 397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 398 | + } |
|
| 387 | 399 | |
| 388 | 400 | // Do the right thing. |
| 389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |
@@ -64,9 +64,10 @@ discard block |
||
| 64 | 64 | <strong>', $txt['administrators'], ':</strong> |
| 65 | 65 | ', implode(', ', $context['administrators']); |
| 66 | 66 | // If we have lots of admins... don't show them all. |
| 67 | - if (!empty($context['more_admins_link'])) |
|
| 68 | - echo ' |
|
| 67 | + if (!empty($context['more_admins_link'])) { |
|
| 68 | + echo ' |
|
| 69 | 69 | (', $context['more_admins_link'], ')'; |
| 70 | + } |
|
| 70 | 71 | |
| 71 | 72 | echo ' |
| 72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
| 83 | 84 | foreach ($area['areas'] as $item_id => $item) |
| 84 | 85 | { |
| 85 | 86 | // No point showing the 'home' page here, we're already on it! |
| 86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
| 87 | - continue; |
|
| 87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
| 90 | - if (!empty($item['icon_file'])) |
|
| 91 | - echo ' |
|
| 92 | + if (!empty($item['icon_file'])) { |
|
| 93 | + echo ' |
|
| 92 | 94 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
| 93 | - else |
|
| 94 | - echo ' |
|
| 95 | + } else { |
|
| 96 | + echo ' |
|
| 95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
| 98 | + } |
|
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
| 103 | 106 | </div>'; |
| 104 | 107 | |
| 105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
| 106 | - if (empty($modSettings['disable_smf_js'])) |
|
| 107 | - echo ' |
|
| 109 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 110 | + echo ' |
|
| 108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
| 109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 113 | + } |
|
| 110 | 114 | |
| 111 | 115 | // This sets the announcements and current versions themselves ;). |
| 112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
| 185 | 189 | <em>', $version['version'], '</em>'; |
| 186 | 190 | |
| 187 | 191 | // more details for this item, show them a link |
| 188 | - if ($context['can_admin'] && isset($version['more'])) |
|
| 189 | - echo |
|
| 192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
| 193 | + echo |
|
| 190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
| 195 | + } |
|
| 191 | 196 | echo ' |
| 192 | 197 | <br>'; |
| 193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
| 218 | 223 | |
| 219 | 224 | foreach ($context['credits'] as $section) |
| 220 | 225 | { |
| 221 | - if (isset($section['pretext'])) |
|
| 222 | - echo ' |
|
| 226 | + if (isset($section['pretext'])) { |
|
| 227 | + echo ' |
|
| 223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
| 229 | + } |
|
| 224 | 230 | |
| 225 | 231 | echo ' |
| 226 | 232 | <dl>'; |
| 227 | 233 | |
| 228 | 234 | foreach ($section['groups'] as $group) |
| 229 | 235 | { |
| 230 | - if (isset($group['title'])) |
|
| 231 | - echo ' |
|
| 236 | + if (isset($group['title'])) { |
|
| 237 | + echo ' |
|
| 232 | 238 | <dt> |
| 233 | 239 | <strong>', $group['title'], ':</strong> |
| 234 | 240 | </dt>'; |
| 241 | + } |
|
| 235 | 242 | |
| 236 | 243 | echo ' |
| 237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
| 240 | 247 | echo ' |
| 241 | 248 | </dl>'; |
| 242 | 249 | |
| 243 | - if (isset($section['posttext'])) |
|
| 244 | - echo ' |
|
| 250 | + if (isset($section['posttext'])) { |
|
| 251 | + echo ' |
|
| 245 | 252 | <hr> |
| 246 | 253 | <p>', $section['posttext'], '</p>'; |
| 254 | + } |
|
| 247 | 255 | } |
| 248 | 256 | |
| 249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
| 259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
| 260 | 268 | |
| 261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
| 262 | - foreach ($context['current_versions'] as $variable => $version) |
|
| 263 | - echo ' |
|
| 270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
| 271 | + echo ' |
|
| 264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
| 273 | + } |
|
| 265 | 274 | |
| 266 | 275 | // Now we just have to include the script and wait ;). |
| 267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
| 358 | 367 | <tbody>'; |
| 359 | 368 | |
| 360 | 369 | // Loop through every source file displaying its version - using javascript. |
| 361 | - foreach ($context['file_versions'] as $filename => $version) |
|
| 362 | - echo ' |
|
| 370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
| 371 | + echo ' |
|
| 363 | 372 | <tr class="windowbg"> |
| 364 | 373 | <td class="half_table"> |
| 365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
| 371 | 380 | <em id="currentSources', $filename, '">??</em> |
| 372 | 381 | </td> |
| 373 | 382 | </tr>'; |
| 383 | + } |
|
| 374 | 384 | |
| 375 | 385 | // Default template files. |
| 376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
| 396 | 406 | <table id="Default" class="table_grid"> |
| 397 | 407 | <tbody>'; |
| 398 | 408 | |
| 399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
| 400 | - echo ' |
|
| 409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
| 410 | + echo ' |
|
| 401 | 411 | <tr class="windowbg"> |
| 402 | 412 | <td class="half_table"> |
| 403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
| 409 | 419 | <em id="currentDefault', $filename, '">??</em> |
| 410 | 420 | </td> |
| 411 | 421 | </tr>'; |
| 422 | + } |
|
| 412 | 423 | |
| 413 | 424 | // Now the language files... |
| 414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
| 436 | 447 | |
| 437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
| 438 | 449 | { |
| 439 | - foreach ($files as $filename => $version) |
|
| 440 | - echo ' |
|
| 450 | + foreach ($files as $filename => $version) { |
|
| 451 | + echo ' |
|
| 441 | 452 | <tr class="windowbg"> |
| 442 | 453 | <td class="half_table"> |
| 443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
| 449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
| 450 | 461 | </td> |
| 451 | 462 | </tr>'; |
| 463 | + } |
|
| 452 | 464 | } |
| 453 | 465 | |
| 454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
| 478 | 490 | <table id="Templates" class="table_grid"> |
| 479 | 491 | <tbody>'; |
| 480 | 492 | |
| 481 | - foreach ($context['template_versions'] as $filename => $version) |
|
| 482 | - echo ' |
|
| 493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
| 494 | + echo ' |
|
| 483 | 495 | <tr class="windowbg"> |
| 484 | 496 | <td class="half_table"> |
| 485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
| 491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
| 492 | 504 | </td> |
| 493 | 505 | </tr>'; |
| 506 | + } |
|
| 494 | 507 | |
| 495 | 508 | echo ' |
| 496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
| 520 | 533 | <table id="Tasks" class="table_grid"> |
| 521 | 534 | <tbody>'; |
| 522 | 535 | |
| 523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
| 524 | - echo ' |
|
| 536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
| 537 | + echo ' |
|
| 525 | 538 | <tr class="windowbg"> |
| 526 | 539 | <td class="half_table"> |
| 527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
| 533 | 546 | <em id="currentTasks', $filename, '">??</em> |
| 534 | 547 | </td> |
| 535 | 548 | </tr>'; |
| 549 | + } |
|
| 536 | 550 | |
| 537 | 551 | echo ' |
| 538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
| 574 | 588 | { |
| 575 | 589 | global $context, $scripturl, $txt, $modSettings; |
| 576 | 590 | |
| 577 | - if (!empty($context['saved_successful'])) |
|
| 578 | - echo ' |
|
| 591 | + if (!empty($context['saved_successful'])) { |
|
| 592 | + echo ' |
|
| 579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 594 | + } |
|
| 580 | 595 | |
| 581 | 596 | // First section is for adding/removing words from the censored list. |
| 582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
| 591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
| 592 | 607 | |
| 593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
| 594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
| 595 | - echo ' |
|
| 609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
| 610 | + echo ' |
|
| 596 | 611 | <div class="block"> |
| 597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
| 598 | 613 | </div>'; |
| 614 | + } |
|
| 599 | 615 | |
| 600 | 616 | // Now provide a way to censor more words. |
| 601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
| 669 | 685 | <div class="windowbg2 noup"> |
| 670 | 686 | ', $txt['not_done_reason']; |
| 671 | 687 | |
| 672 | - if (!empty($context['continue_percent'])) |
|
| 673 | - echo ' |
|
| 688 | + if (!empty($context['continue_percent'])) { |
|
| 689 | + echo ' |
|
| 674 | 690 | <div class="progress_bar"> |
| 675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
| 676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
| 677 | 693 | </div>'; |
| 694 | + } |
|
| 678 | 695 | |
| 679 | - if (!empty($context['substep_enabled'])) |
|
| 680 | - echo ' |
|
| 696 | + if (!empty($context['substep_enabled'])) { |
|
| 697 | + echo ' |
|
| 681 | 698 | <div class="progress_bar"> |
| 682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
| 683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
| 684 | 701 | </div>'; |
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | echo ' |
| 687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
| 716 | 734 | { |
| 717 | 735 | global $context, $txt, $scripturl; |
| 718 | 736 | |
| 719 | - if (!empty($context['saved_successful'])) |
|
| 720 | - echo ' |
|
| 737 | + if (!empty($context['saved_successful'])) { |
|
| 738 | + echo ' |
|
| 721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 722 | - elseif (!empty($context['saved_failed'])) |
|
| 723 | - echo ' |
|
| 740 | + } elseif (!empty($context['saved_failed'])) { |
|
| 741 | + echo ' |
|
| 724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
| 743 | + } |
|
| 725 | 744 | |
| 726 | - if (!empty($context['settings_pre_javascript'])) |
|
| 727 | - echo ' |
|
| 745 | + if (!empty($context['settings_pre_javascript'])) { |
|
| 746 | + echo ' |
|
| 728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
| 748 | + } |
|
| 729 | 749 | |
| 730 | - if (!empty($context['settings_insert_above'])) |
|
| 731 | - echo $context['settings_insert_above']; |
|
| 750 | + if (!empty($context['settings_insert_above'])) { |
|
| 751 | + echo $context['settings_insert_above']; |
|
| 752 | + } |
|
| 732 | 753 | |
| 733 | 754 | echo ' |
| 734 | 755 | <div id="admincenter"> |
| 735 | 756 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
| 736 | 757 | |
| 737 | 758 | // Is there a custom title? |
| 738 | - if (isset($context['settings_title'])) |
|
| 739 | - echo ' |
|
| 759 | + if (isset($context['settings_title'])) { |
|
| 760 | + echo ' |
|
| 740 | 761 | <div class="cat_bar"> |
| 741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
| 742 | 763 | </div>'; |
| 764 | + } |
|
| 743 | 765 | |
| 744 | 766 | // Have we got a message to display? |
| 745 | - if (!empty($context['settings_message'])) |
|
| 746 | - echo ' |
|
| 767 | + if (!empty($context['settings_message'])) { |
|
| 768 | + echo ' |
|
| 747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
| 770 | + } |
|
| 748 | 771 | |
| 749 | 772 | // Now actually loop through all the variables. |
| 750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
| 797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
| 798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
| 799 | 822 | { |
| 800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
| 801 | - call_user_func('template_callback_' . $config_var['name']); |
|
| 823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
| 824 | + call_user_func('template_callback_' . $config_var['name']); |
|
| 825 | + } |
|
| 802 | 826 | |
| 803 | 827 | continue; |
| 804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
| 828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
| 829 | 853 | |
| 830 | 854 | // Show the [?] button. |
| 831 | - if ($config_var['help']) |
|
| 832 | - echo ' |
|
| 855 | + if ($config_var['help']) { |
|
| 856 | + echo ' |
|
| 833 | 857 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
| 858 | + } |
|
| 834 | 859 | |
| 835 | 860 | echo ' |
| 836 | 861 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -839,22 +864,25 @@ discard block |
||
| 839 | 864 | $config_var['preinput']; |
| 840 | 865 | |
| 841 | 866 | // Show a check box. |
| 842 | - if ($config_var['type'] == 'check') |
|
| 843 | - echo ' |
|
| 867 | + if ($config_var['type'] == 'check') { |
|
| 868 | + echo ' |
|
| 844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
| 870 | + } |
|
| 845 | 871 | // Escape (via htmlspecialchars.) the text box. |
| 846 | - elseif ($config_var['type'] == 'password') |
|
| 847 | - echo ' |
|
| 872 | + elseif ($config_var['type'] == 'password') { |
|
| 873 | + echo ' |
|
| 848 | 874 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
| 849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 876 | + } |
|
| 850 | 877 | // Show a selection box. |
| 851 | 878 | elseif ($config_var['type'] == 'select') |
| 852 | 879 | { |
| 853 | 880 | echo ' |
| 854 | 881 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 855 | - foreach ($config_var['data'] as $option) |
|
| 856 | - echo ' |
|
| 882 | + foreach ($config_var['data'] as $option) { |
|
| 883 | + echo ' |
|
| 857 | 884 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
| 885 | + } |
|
| 858 | 886 | echo ' |
| 859 | 887 | </select>'; |
| 860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
| 868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
| 869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
| 870 | 898 | { |
| 871 | - if (!$first) |
|
| 872 | - echo ' |
|
| 899 | + if (!$first) { |
|
| 900 | + echo ' |
|
| 873 | 901 | <hr>'; |
| 902 | + } |
|
| 874 | 903 | echo ' |
| 875 | 904 | <strong>', $cat['name'], '</strong> |
| 876 | 905 | <ul>'; |
| 877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
| 878 | - echo ' |
|
| 906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
| 907 | + echo ' |
|
| 879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
| 909 | + } |
|
| 880 | 910 | |
| 881 | 911 | echo ' |
| 882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
| 886 | 916 | </fieldset>'; |
| 887 | 917 | } |
| 888 | 918 | // Text area? |
| 889 | - elseif ($config_var['type'] == 'large_text') |
|
| 890 | - echo ' |
|
| 919 | + elseif ($config_var['type'] == 'large_text') { |
|
| 920 | + echo ' |
|
| 891 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
| 922 | + } |
|
| 892 | 923 | // Permission group? |
| 893 | - elseif ($config_var['type'] == 'permissions') |
|
| 894 | - theme_inline_permissions($config_var['name']); |
|
| 924 | + elseif ($config_var['type'] == 'permissions') { |
|
| 925 | + theme_inline_permissions($config_var['name']); |
|
| 926 | + } |
|
| 895 | 927 | // BBC selection? |
| 896 | 928 | elseif ($config_var['type'] == 'bbc') |
| 897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
| 902 | 934 | |
| 903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
| 904 | 936 | { |
| 905 | - foreach ($bbcColumn as $bbcTag) |
|
| 906 | - echo ' |
|
| 937 | + foreach ($bbcColumn as $bbcTag) { |
|
| 938 | + echo ' |
|
| 907 | 939 | <li class="list_bbc floatleft"> |
| 908 | 940 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
| 909 | 941 | </li>'; |
| 942 | + } |
|
| 910 | 943 | } |
| 911 | 944 | echo ' </ul> |
| 912 | 945 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
| 913 | 946 | </fieldset>'; |
| 914 | 947 | } |
| 915 | 948 | // A simple message? |
| 916 | - elseif ($config_var['type'] == 'var_message') |
|
| 917 | - echo ' |
|
| 949 | + elseif ($config_var['type'] == 'var_message') { |
|
| 950 | + echo ' |
|
| 918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
| 952 | + } |
|
| 919 | 953 | // Assume it must be a text box |
| 920 | 954 | else |
| 921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
| 940 | 974 | ' . $config_var['postinput'] : '', |
| 941 | 975 | '</dd>'; |
| 942 | 976 | } |
| 943 | - } |
|
| 944 | - |
|
| 945 | - else |
|
| 977 | + } else |
|
| 946 | 978 | { |
| 947 | 979 | // Just show a separator. |
| 948 | - if ($config_var == '') |
|
| 949 | - echo ' |
|
| 980 | + if ($config_var == '') { |
|
| 981 | + echo ' |
|
| 950 | 982 | </dl> |
| 951 | 983 | <hr> |
| 952 | 984 | <dl class="settings">'; |
| 953 | - else |
|
| 954 | - echo ' |
|
| 985 | + } else { |
|
| 986 | + echo ' |
|
| 955 | 987 | <dd> |
| 956 | 988 | <strong>' . $config_var . '</strong> |
| 957 | 989 | </dd>'; |
| 990 | + } |
|
| 958 | 991 | } |
| 959 | 992 | } |
| 960 | 993 | |
| 961 | - if ($is_open) |
|
| 962 | - echo ' |
|
| 994 | + if ($is_open) { |
|
| 995 | + echo ' |
|
| 963 | 996 | </dl>'; |
| 997 | + } |
|
| 964 | 998 | |
| 965 | - if (empty($context['settings_save_dont_show'])) |
|
| 966 | - echo ' |
|
| 999 | + if (empty($context['settings_save_dont_show'])) { |
|
| 1000 | + echo ' |
|
| 967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
| 1002 | + } |
|
| 968 | 1003 | |
| 969 | - if ($is_open) |
|
| 970 | - echo ' |
|
| 1004 | + if ($is_open) { |
|
| 1005 | + echo ' |
|
| 971 | 1006 | </div>'; |
| 1007 | + } |
|
| 972 | 1008 | |
| 973 | 1009 | |
| 974 | 1010 | // At least one token has to be used! |
| 975 | - if (isset($context['admin-ssc_token'])) |
|
| 976 | - echo ' |
|
| 1011 | + if (isset($context['admin-ssc_token'])) { |
|
| 1012 | + echo ' |
|
| 977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
| 1014 | + } |
|
| 978 | 1015 | |
| 979 | - if (isset($context['admin-dbsc_token'])) |
|
| 980 | - echo ' |
|
| 1016 | + if (isset($context['admin-dbsc_token'])) { |
|
| 1017 | + echo ' |
|
| 981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
| 1019 | + } |
|
| 982 | 1020 | |
| 983 | - if (isset($context['admin-mp_token'])) |
|
| 984 | - echo ' |
|
| 1021 | + if (isset($context['admin-mp_token'])) { |
|
| 1022 | + echo ' |
|
| 985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
| 1024 | + } |
|
| 986 | 1025 | |
| 987 | 1026 | echo ' |
| 988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 989 | 1028 | </form> |
| 990 | 1029 | </div>'; |
| 991 | 1030 | |
| 992 | - if (!empty($context['settings_post_javascript'])) |
|
| 993 | - echo ' |
|
| 1031 | + if (!empty($context['settings_post_javascript'])) { |
|
| 1032 | + echo ' |
|
| 994 | 1033 | <script> |
| 995 | 1034 | ', $context['settings_post_javascript'], ' |
| 996 | 1035 | </script>'; |
| 1036 | + } |
|
| 997 | 1037 | |
| 998 | - if (!empty($context['settings_insert_below'])) |
|
| 999 | - echo $context['settings_insert_below']; |
|
| 1038 | + if (!empty($context['settings_insert_below'])) { |
|
| 1039 | + echo $context['settings_insert_below']; |
|
| 1040 | + } |
|
| 1000 | 1041 | |
| 1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
| 1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
| 1019 | 1060 | { |
| 1020 | 1061 | global $context, $txt; |
| 1021 | 1062 | |
| 1022 | - if (!empty($context['saved_successful'])) |
|
| 1023 | - echo ' |
|
| 1063 | + if (!empty($context['saved_successful'])) { |
|
| 1064 | + echo ' |
|
| 1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1066 | + } |
|
| 1025 | 1067 | |
| 1026 | 1068 | // Standard fields. |
| 1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
| 1053 | 1095 | if (isset($_GET['msg'])) |
| 1054 | 1096 | { |
| 1055 | 1097 | loadLanguage('Errors'); |
| 1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
| 1057 | - echo ' |
|
| 1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
| 1099 | + echo ' |
|
| 1058 | 1100 | <div class="errorbox">', |
| 1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
| 1060 | 1102 | </div>'; |
| 1103 | + } |
|
| 1061 | 1104 | } |
| 1062 | 1105 | |
| 1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
| 1123 | 1166 | <dd> |
| 1124 | 1167 | <select name="placement" id="placement">'; |
| 1125 | 1168 | |
| 1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
| 1127 | - echo ' |
|
| 1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
| 1170 | + echo ' |
|
| 1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
| 1172 | + } |
|
| 1129 | 1173 | |
| 1130 | 1174 | echo ' |
| 1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
| 1148 | 1192 | </dt> |
| 1149 | 1193 | <dd> |
| 1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
| 1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
| 1152 | - echo ' |
|
| 1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
| 1196 | + echo ' |
|
| 1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
| 1198 | + } |
|
| 1154 | 1199 | |
| 1155 | 1200 | echo ' |
| 1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
| 1251 | 1296 | </fieldset> |
| 1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
| 1253 | 1298 | |
| 1254 | - if ($context['fid']) |
|
| 1255 | - echo ' |
|
| 1299 | + if ($context['fid']) { |
|
| 1300 | + echo ' |
|
| 1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
| 1302 | + } |
|
| 1257 | 1303 | |
| 1258 | 1304 | echo ' |
| 1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
| 1296 | 1342 | { |
| 1297 | 1343 | echo ' |
| 1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
| 1299 | - } |
|
| 1300 | - else |
|
| 1345 | + } else |
|
| 1301 | 1346 | { |
| 1302 | 1347 | echo ' |
| 1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
| 1323 | 1368 | <li> |
| 1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
| 1325 | 1370 | |
| 1326 | - if ($result['help']) |
|
| 1327 | - echo ' |
|
| 1371 | + if ($result['help']) { |
|
| 1372 | + echo ' |
|
| 1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
| 1374 | + } |
|
| 1329 | 1375 | |
| 1330 | 1376 | echo ' |
| 1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
| 1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
| 1366 | 1412 | </dd>'; |
| 1367 | 1413 | |
| 1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1370 | 1416 | { |
| 1371 | 1417 | $question = $context['question_answers'][$q_id]; |
| 1418 | + } |
|
| 1372 | 1419 | echo ' |
| 1373 | 1420 | <dt> |
| 1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="verification_question"> |
| 1375 | 1422 | </dt> |
| 1376 | 1423 | <dd>'; |
| 1377 | - foreach ($question['answers'] as $answer) |
|
| 1378 | - echo ' |
|
| 1424 | + foreach ($question['answers'] as $answer) { |
|
| 1425 | + echo ' |
|
| 1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
| 1427 | + } |
|
| 1380 | 1428 | |
| 1381 | 1429 | echo ' |
| 1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
| 1415 | 1463 | ', $txt['errors_found'], ': |
| 1416 | 1464 | <ul>'; |
| 1417 | 1465 | |
| 1418 | - foreach ($context['repair_errors'] as $error) |
|
| 1419 | - echo ' |
|
| 1466 | + foreach ($context['repair_errors'] as $error) { |
|
| 1467 | + echo ' |
|
| 1420 | 1468 | <li> |
| 1421 | 1469 | ', $error, ' |
| 1422 | 1470 | </li>'; |
| 1471 | + } |
|
| 1423 | 1472 | |
| 1424 | 1473 | echo ' |
| 1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
| 1429 | 1478 | <p class="padding"> |
| 1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
| 1431 | 1480 | </p>'; |
| 1432 | - } |
|
| 1433 | - else |
|
| 1434 | - echo ' |
|
| 1481 | + } else { |
|
| 1482 | + echo ' |
|
| 1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
| 1436 | 1484 | <p class="padding"> |
| 1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
| 1438 | 1486 | </p>'; |
| 1487 | + } |
|
| 1439 | 1488 | |
| 1440 | - } |
|
| 1441 | - else |
|
| 1489 | + } else |
|
| 1442 | 1490 | { |
| 1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
| 1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
| 1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
| 1452 | 1500 | </form>'; |
| 1453 | - } |
|
| 1454 | - else |
|
| 1501 | + } else |
|
| 1455 | 1502 | { |
| 1456 | 1503 | echo ' |
| 1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
| 1603 | 1650 | function template_admin_quick_search() |
| 1604 | 1651 | { |
| 1605 | 1652 | global $context, $txt; |
| 1606 | - if ($context['user']['is_admin']) |
|
| 1607 | - echo ' |
|
| 1653 | + if ($context['user']['is_admin']) { |
|
| 1654 | + echo ' |
|
| 1608 | 1655 | <span class="floatright admin_search"> |
| 1609 | 1656 | <span class="generic_icons filter centericon"></span> |
| 1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';"> |
@@ -1615,6 +1662,7 @@ discard block |
||
| 1615 | 1662 | </select> |
| 1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
| 1617 | 1664 | </span>'; |
| 1618 | -} |
|
| 1665 | + } |
|
| 1666 | + } |
|
| 1619 | 1667 | |
| 1620 | 1668 | ?> |
| 1621 | 1669 | \ No newline at end of file |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -197,8 +204,9 @@ discard block |
||
| 197 | 204 | 'db_error_skip' => true, |
| 198 | 205 | ) |
| 199 | 206 | ); |
| 200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 201 | - $modSettings[$row['variable']] = $row['value']; |
|
| 207 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 208 | + $modSettings[$row['variable']] = $row['value']; |
|
| 209 | + } |
|
| 202 | 210 | $smcFunc['db_free_result']($request); |
| 203 | 211 | } |
| 204 | 212 | |
@@ -208,10 +216,12 @@ discard block |
||
| 208 | 216 | $modSettings['theme_url'] = 'Themes/default'; |
| 209 | 217 | $modSettings['images_url'] = 'Themes/default/images'; |
| 210 | 218 | } |
| 211 | -if (!isset($settings['default_theme_url'])) |
|
| 219 | +if (!isset($settings['default_theme_url'])) { |
|
| 212 | 220 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 213 | -if (!isset($settings['default_theme_dir'])) |
|
| 221 | +} |
|
| 222 | +if (!isset($settings['default_theme_dir'])) { |
|
| 214 | 223 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 224 | +} |
|
| 215 | 225 | |
| 216 | 226 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 217 | 227 | // Default title... |
@@ -229,13 +239,15 @@ discard block |
||
| 229 | 239 | $support_js = $upcontext['upgrade_status']['js']; |
| 230 | 240 | |
| 231 | 241 | // Only set this if the upgrader status says so. |
| 232 | - if (empty($is_debug)) |
|
| 233 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 242 | + if (empty($is_debug)) { |
|
| 243 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // Load the language. |
| 236 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 237 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 238 | -} |
|
| 247 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 248 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | + } |
|
| 250 | + } |
|
| 239 | 251 | // Set the defaults. |
| 240 | 252 | else |
| 241 | 253 | { |
@@ -253,15 +265,18 @@ discard block |
||
| 253 | 265 | } |
| 254 | 266 | |
| 255 | 267 | // If this isn't the first stage see whether they are logging in and resuming. |
| 256 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 268 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 257 | 269 | checkLogin(); |
| 270 | +} |
|
| 258 | 271 | |
| 259 | -if ($command_line) |
|
| 272 | +if ($command_line) { |
|
| 260 | 273 | cmdStep0(); |
| 274 | +} |
|
| 261 | 275 | |
| 262 | 276 | // Don't error if we're using xml. |
| 263 | -if (isset($_GET['xml'])) |
|
| 277 | +if (isset($_GET['xml'])) { |
|
| 264 | 278 | $upcontext['return_error'] = true; |
| 279 | +} |
|
| 265 | 280 | |
| 266 | 281 | // Loop through all the steps doing each one as required. |
| 267 | 282 | $upcontext['overall_percent'] = 0; |
@@ -282,9 +297,9 @@ discard block |
||
| 282 | 297 | } |
| 283 | 298 | |
| 284 | 299 | // Call the step and if it returns false that means pause! |
| 285 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 286 | - break; |
|
| 287 | - elseif (function_exists($step[2])) { |
|
| 300 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 301 | + break; |
|
| 302 | + } elseif (function_exists($step[2])) { |
|
| 288 | 303 | //Start each new step with this unset, so the 'normal' template is called first |
| 289 | 304 | unset($_GET['xml']); |
| 290 | 305 | //Clear out warnings at the start of each step |
@@ -330,17 +345,18 @@ discard block |
||
| 330 | 345 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 331 | 346 | if (!empty($command_line)) |
| 332 | 347 | { |
| 333 | - if (function_exists('debug_print_backtrace')) |
|
| 334 | - debug_print_backtrace(); |
|
| 348 | + if (function_exists('debug_print_backtrace')) { |
|
| 349 | + debug_print_backtrace(); |
|
| 350 | + } |
|
| 335 | 351 | |
| 336 | 352 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 337 | 353 | flush(); |
| 338 | 354 | die(); |
| 339 | 355 | } |
| 340 | 356 | |
| 341 | - if (!isset($_GET['xml'])) |
|
| 342 | - template_upgrade_above(); |
|
| 343 | - else |
|
| 357 | + if (!isset($_GET['xml'])) { |
|
| 358 | + template_upgrade_above(); |
|
| 359 | + } else |
|
| 344 | 360 | { |
| 345 | 361 | header('Content-Type: text/xml; charset=UTF-8'); |
| 346 | 362 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -362,25 +378,29 @@ discard block |
||
| 362 | 378 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 363 | 379 | |
| 364 | 380 | // Custom stuff to pass back? |
| 365 | - if (!empty($upcontext['query_string'])) |
|
| 366 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 381 | + if (!empty($upcontext['query_string'])) { |
|
| 382 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | // Call the appropriate subtemplate |
| 369 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 370 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 371 | - else |
|
| 372 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 386 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 387 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 388 | + } else { |
|
| 389 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 390 | + } |
|
| 373 | 391 | } |
| 374 | 392 | |
| 375 | 393 | // Was there an error? |
| 376 | - if (!empty($upcontext['forced_error_message'])) |
|
| 377 | - echo $upcontext['forced_error_message']; |
|
| 394 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 395 | + echo $upcontext['forced_error_message']; |
|
| 396 | + } |
|
| 378 | 397 | |
| 379 | 398 | // Show the footer. |
| 380 | - if (!isset($_GET['xml'])) |
|
| 381 | - template_upgrade_below(); |
|
| 382 | - else |
|
| 383 | - template_xml_below(); |
|
| 399 | + if (!isset($_GET['xml'])) { |
|
| 400 | + template_upgrade_below(); |
|
| 401 | + } else { |
|
| 402 | + template_xml_below(); |
|
| 403 | + } |
|
| 384 | 404 | } |
| 385 | 405 | |
| 386 | 406 | |
@@ -392,15 +412,19 @@ discard block |
||
| 392 | 412 | $seconds = intval($active % 60); |
| 393 | 413 | |
| 394 | 414 | $totalTime = ''; |
| 395 | - if ($hours > 0) |
|
| 396 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 397 | - if ($minutes > 0) |
|
| 398 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 399 | - if ($seconds > 0) |
|
| 400 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 415 | + if ($hours > 0) { |
|
| 416 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 417 | + } |
|
| 418 | + if ($minutes > 0) { |
|
| 419 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 420 | + } |
|
| 421 | + if ($seconds > 0) { |
|
| 422 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 423 | + } |
|
| 401 | 424 | |
| 402 | - if (!empty($totalTime)) |
|
| 403 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 425 | + if (!empty($totalTime)) { |
|
| 426 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 427 | + } |
|
| 404 | 428 | } |
| 405 | 429 | |
| 406 | 430 | // Bang - gone! |
@@ -413,8 +437,9 @@ discard block |
||
| 413 | 437 | global $upgradeurl, $upcontext, $command_line; |
| 414 | 438 | |
| 415 | 439 | // Command line users can't be redirected. |
| 416 | - if ($command_line) |
|
| 417 | - upgradeExit(true); |
|
| 440 | + if ($command_line) { |
|
| 441 | + upgradeExit(true); |
|
| 442 | + } |
|
| 418 | 443 | |
| 419 | 444 | // Are we providing the core info? |
| 420 | 445 | if ($addForm) |
@@ -440,12 +465,14 @@ discard block |
||
| 440 | 465 | define('SMF', 1); |
| 441 | 466 | |
| 442 | 467 | // Start the session. |
| 443 | - if (@ini_get('session.save_handler') == 'user') |
|
| 444 | - @ini_set('session.save_handler', 'files'); |
|
| 468 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 469 | + @ini_set('session.save_handler', 'files'); |
|
| 470 | + } |
|
| 445 | 471 | @session_start(); |
| 446 | 472 | |
| 447 | - if (empty($smcFunc)) |
|
| 448 | - $smcFunc = array(); |
|
| 473 | + if (empty($smcFunc)) { |
|
| 474 | + $smcFunc = array(); |
|
| 475 | + } |
|
| 449 | 476 | |
| 450 | 477 | // We need this for authentication and some upgrade code |
| 451 | 478 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -472,24 +499,27 @@ discard block |
||
| 472 | 499 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 473 | 500 | |
| 474 | 501 | // Make the connection... |
| 475 | - if (empty($db_connection)) |
|
| 476 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 477 | - else |
|
| 478 | - // If we've returned here, ping/reconnect to be safe |
|
| 502 | + if (empty($db_connection)) { |
|
| 503 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 504 | + } else { |
|
| 505 | + // If we've returned here, ping/reconnect to be safe |
|
| 479 | 506 | $smcFunc['db_ping']($db_connection); |
| 507 | + } |
|
| 480 | 508 | |
| 481 | 509 | // Oh dear god!! |
| 482 | - if ($db_connection === null) |
|
| 483 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 510 | + if ($db_connection === null) { |
|
| 511 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 512 | + } |
|
| 484 | 513 | |
| 485 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 486 | - $smcFunc['db_query']('', ' |
|
| 514 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 515 | + $smcFunc['db_query']('', ' |
|
| 487 | 516 | SET NAMES {string:db_character_set}', |
| 488 | 517 | array( |
| 489 | 518 | 'db_error_skip' => true, |
| 490 | 519 | 'db_character_set' => $db_character_set, |
| 491 | 520 | ) |
| 492 | 521 | ); |
| 522 | + } |
|
| 493 | 523 | |
| 494 | 524 | // Load the modSettings data... |
| 495 | 525 | $request = $smcFunc['db_query']('', ' |
@@ -500,11 +530,11 @@ discard block |
||
| 500 | 530 | ) |
| 501 | 531 | ); |
| 502 | 532 | $modSettings = array(); |
| 503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 504 | - $modSettings[$row['variable']] = $row['value']; |
|
| 533 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 534 | + $modSettings[$row['variable']] = $row['value']; |
|
| 535 | + } |
|
| 505 | 536 | $smcFunc['db_free_result']($request); |
| 506 | - } |
|
| 507 | - else |
|
| 537 | + } else |
|
| 508 | 538 | { |
| 509 | 539 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 510 | 540 | } |
@@ -518,9 +548,10 @@ discard block |
||
| 518 | 548 | cleanRequest(); |
| 519 | 549 | } |
| 520 | 550 | |
| 521 | - if (!isset($_GET['substep'])) |
|
| 522 | - $_GET['substep'] = 0; |
|
| 523 | -} |
|
| 551 | + if (!isset($_GET['substep'])) { |
|
| 552 | + $_GET['substep'] = 0; |
|
| 553 | + } |
|
| 554 | + } |
|
| 524 | 555 | |
| 525 | 556 | function initialize_inputs() |
| 526 | 557 | { |
@@ -550,8 +581,9 @@ discard block |
||
| 550 | 581 | $dh = opendir(dirname(__FILE__)); |
| 551 | 582 | while ($file = readdir($dh)) |
| 552 | 583 | { |
| 553 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 554 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 584 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 585 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 586 | + } |
|
| 555 | 587 | } |
| 556 | 588 | closedir($dh); |
| 557 | 589 | |
@@ -580,8 +612,9 @@ discard block |
||
| 580 | 612 | $temp = 'upgrade_php?step'; |
| 581 | 613 | while (strlen($temp) > 4) |
| 582 | 614 | { |
| 583 | - if (isset($_GET[$temp])) |
|
| 584 | - unset($_GET[$temp]); |
|
| 615 | + if (isset($_GET[$temp])) { |
|
| 616 | + unset($_GET[$temp]); |
|
| 617 | + } |
|
| 585 | 618 | $temp = substr($temp, 1); |
| 586 | 619 | } |
| 587 | 620 | |
@@ -608,32 +641,39 @@ discard block |
||
| 608 | 641 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 609 | 642 | |
| 610 | 643 | // Need legacy scripts? |
| 611 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 612 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 644 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 645 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 646 | + } |
|
| 647 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 648 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 649 | + } |
|
| 650 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 651 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 652 | + } |
|
| 617 | 653 | |
| 618 | 654 | // We don't need "-utf8" files anymore... |
| 619 | 655 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 620 | 656 | |
| 621 | 657 | // This needs to exist! |
| 622 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 623 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 624 | - else |
|
| 625 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 658 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 659 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 660 | + } else { |
|
| 661 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 662 | + } |
|
| 626 | 663 | |
| 627 | - if (!$check) |
|
| 628 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 664 | + if (!$check) { |
|
| 665 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 629 | 666 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 667 | + } |
|
| 630 | 668 | |
| 631 | 669 | // Do they meet the install requirements? |
| 632 | - if (!php_version_check()) |
|
| 633 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 670 | + if (!php_version_check()) { |
|
| 671 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 672 | + } |
|
| 634 | 673 | |
| 635 | - if (!db_version_check()) |
|
| 636 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 674 | + if (!db_version_check()) { |
|
| 675 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 676 | + } |
|
| 637 | 677 | |
| 638 | 678 | // Do some checks to make sure they have proper privileges |
| 639 | 679 | db_extend('packages'); |
@@ -648,14 +688,16 @@ discard block |
||
| 648 | 688 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 649 | 689 | |
| 650 | 690 | // Sorry... we need CREATE, ALTER and DROP |
| 651 | - if (!$create || !$alter || !$drop) |
|
| 652 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 691 | + if (!$create || !$alter || !$drop) { |
|
| 692 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Do a quick version spot check. |
| 655 | 696 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 656 | 697 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 657 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 658 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 698 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 699 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 700 | + } |
|
| 659 | 701 | |
| 660 | 702 | // What absolutely needs to be writable? |
| 661 | 703 | $writable_files = array( |
@@ -677,12 +719,13 @@ discard block |
||
| 677 | 719 | quickFileWritable($custom_av_dir); |
| 678 | 720 | |
| 679 | 721 | // Are we good now? |
| 680 | - if (!is_writable($custom_av_dir)) |
|
| 681 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 682 | - elseif ($need_settings_update) |
|
| 722 | + if (!is_writable($custom_av_dir)) { |
|
| 723 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 724 | + } elseif ($need_settings_update) |
|
| 683 | 725 | { |
| 684 | - if (!function_exists('cache_put_data')) |
|
| 685 | - require_once($sourcedir . '/Load.php'); |
|
| 726 | + if (!function_exists('cache_put_data')) { |
|
| 727 | + require_once($sourcedir . '/Load.php'); |
|
| 728 | + } |
|
| 686 | 729 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 687 | 730 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 688 | 731 | } |
@@ -691,28 +734,33 @@ discard block |
||
| 691 | 734 | |
| 692 | 735 | // Check the cache directory. |
| 693 | 736 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 694 | - if (!file_exists($cachedir_temp)) |
|
| 695 | - @mkdir($cachedir_temp); |
|
| 696 | - if (!file_exists($cachedir_temp)) |
|
| 697 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 698 | - |
|
| 699 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 700 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 701 | - elseif (!isset($_GET['skiplang'])) |
|
| 737 | + if (!file_exists($cachedir_temp)) { |
|
| 738 | + @mkdir($cachedir_temp); |
|
| 739 | + } |
|
| 740 | + if (!file_exists($cachedir_temp)) { |
|
| 741 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 745 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 746 | + } elseif (!isset($_GET['skiplang'])) |
|
| 702 | 747 | { |
| 703 | 748 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 704 | 749 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 705 | 750 | |
| 706 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 707 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 751 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 752 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 753 | + } |
|
| 708 | 754 | } |
| 709 | 755 | |
| 710 | - if (!makeFilesWritable($writable_files)) |
|
| 711 | - return false; |
|
| 756 | + if (!makeFilesWritable($writable_files)) { |
|
| 757 | + return false; |
|
| 758 | + } |
|
| 712 | 759 | |
| 713 | 760 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 714 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 715 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 761 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 762 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 763 | + } |
|
| 716 | 764 | |
| 717 | 765 | // Upgrade the agreement. |
| 718 | 766 | elseif (isset($modSettings['agreement'])) |
@@ -723,8 +771,8 @@ discard block |
||
| 723 | 771 | } |
| 724 | 772 | |
| 725 | 773 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 726 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 727 | - $upcontext['warning'] = ' |
|
| 774 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 775 | + $upcontext['warning'] = ' |
|
| 728 | 776 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 729 | 777 | <ul> |
| 730 | 778 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -732,19 +780,23 @@ discard block |
||
| 732 | 780 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 733 | 781 | </ul> |
| 734 | 782 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 783 | + } |
|
| 735 | 784 | |
| 736 | 785 | // Confirm mbstring is loaded... |
| 737 | - if (!extension_loaded('mbstring')) |
|
| 738 | - return throw_error($txt['install_no_mbstring']); |
|
| 786 | + if (!extension_loaded('mbstring')) { |
|
| 787 | + return throw_error($txt['install_no_mbstring']); |
|
| 788 | + } |
|
| 739 | 789 | |
| 740 | 790 | // Check for https stream support. |
| 741 | 791 | $supported_streams = stream_get_wrappers(); |
| 742 | - if (!in_array('https', $supported_streams)) |
|
| 743 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 792 | + if (!in_array('https', $supported_streams)) { |
|
| 793 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 794 | + } |
|
| 744 | 795 | |
| 745 | 796 | // Either we're logged in or we're going to present the login. |
| 746 | - if (checkLogin()) |
|
| 747 | - return true; |
|
| 797 | + if (checkLogin()) { |
|
| 798 | + return true; |
|
| 799 | + } |
|
| 748 | 800 | |
| 749 | 801 | $upcontext += createToken('login'); |
| 750 | 802 | |
@@ -758,15 +810,17 @@ discard block |
||
| 758 | 810 | global $smcFunc, $db_type, $support_js; |
| 759 | 811 | |
| 760 | 812 | // Don't bother if the security is disabled. |
| 761 | - if ($disable_security) |
|
| 762 | - return true; |
|
| 813 | + if ($disable_security) { |
|
| 814 | + return true; |
|
| 815 | + } |
|
| 763 | 816 | |
| 764 | 817 | // Are we trying to login? |
| 765 | 818 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 766 | 819 | { |
| 767 | 820 | // If we've disabled security pick a suitable name! |
| 768 | - if (empty($_POST['user'])) |
|
| 769 | - $_POST['user'] = 'Administrator'; |
|
| 821 | + if (empty($_POST['user'])) { |
|
| 822 | + $_POST['user'] = 'Administrator'; |
|
| 823 | + } |
|
| 770 | 824 | |
| 771 | 825 | // Before 2.0 these column names were different! |
| 772 | 826 | $oldDB = false; |
@@ -781,16 +835,17 @@ discard block |
||
| 781 | 835 | 'db_error_skip' => true, |
| 782 | 836 | ) |
| 783 | 837 | ); |
| 784 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 785 | - $oldDB = true; |
|
| 838 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 839 | + $oldDB = true; |
|
| 840 | + } |
|
| 786 | 841 | $smcFunc['db_free_result']($request); |
| 787 | 842 | } |
| 788 | 843 | |
| 789 | 844 | // Get what we believe to be their details. |
| 790 | 845 | if (!$disable_security) |
| 791 | 846 | { |
| 792 | - if ($oldDB) |
|
| 793 | - $request = $smcFunc['db_query']('', ' |
|
| 847 | + if ($oldDB) { |
|
| 848 | + $request = $smcFunc['db_query']('', ' |
|
| 794 | 849 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 795 | 850 | additionalGroups AS additional_groups, lngfile |
| 796 | 851 | FROM {db_prefix}members |
@@ -800,8 +855,8 @@ discard block |
||
| 800 | 855 | 'db_error_skip' => true, |
| 801 | 856 | ) |
| 802 | 857 | ); |
| 803 | - else |
|
| 804 | - $request = $smcFunc['db_query']('', ' |
|
| 858 | + } else { |
|
| 859 | + $request = $smcFunc['db_query']('', ' |
|
| 805 | 860 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 806 | 861 | FROM {db_prefix}members |
| 807 | 862 | WHERE member_name = {string:member_name}', |
@@ -810,6 +865,7 @@ discard block |
||
| 810 | 865 | 'db_error_skip' => true, |
| 811 | 866 | ) |
| 812 | 867 | ); |
| 868 | + } |
|
| 813 | 869 | if ($smcFunc['db_num_rows']($request) != 0) |
| 814 | 870 | { |
| 815 | 871 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -817,16 +873,17 @@ discard block |
||
| 817 | 873 | $groups = explode(',', $addGroups); |
| 818 | 874 | $groups[] = $id_group; |
| 819 | 875 | |
| 820 | - foreach ($groups as $k => $v) |
|
| 821 | - $groups[$k] = (int) $v; |
|
| 876 | + foreach ($groups as $k => $v) { |
|
| 877 | + $groups[$k] = (int) $v; |
|
| 878 | + } |
|
| 822 | 879 | |
| 823 | 880 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 824 | 881 | |
| 825 | 882 | // We don't use "-utf8" anymore... |
| 826 | 883 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 884 | + } else { |
|
| 885 | + $upcontext['username_incorrect'] = true; |
|
| 827 | 886 | } |
| 828 | - else |
|
| 829 | - $upcontext['username_incorrect'] = true; |
|
| 830 | 887 | $smcFunc['db_free_result']($request); |
| 831 | 888 | } |
| 832 | 889 | $upcontext['username'] = $_POST['user']; |
@@ -836,13 +893,14 @@ discard block |
||
| 836 | 893 | { |
| 837 | 894 | $upcontext['upgrade_status']['js'] = 1; |
| 838 | 895 | $support_js = 1; |
| 896 | + } else { |
|
| 897 | + $support_js = 0; |
|
| 839 | 898 | } |
| 840 | - else |
|
| 841 | - $support_js = 0; |
|
| 842 | 899 | |
| 843 | 900 | // Note down the version we are coming from. |
| 844 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 845 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 901 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 902 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 903 | + } |
|
| 846 | 904 | |
| 847 | 905 | // Didn't get anywhere? |
| 848 | 906 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -876,15 +934,15 @@ discard block |
||
| 876 | 934 | 'db_error_skip' => true, |
| 877 | 935 | ) |
| 878 | 936 | ); |
| 879 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 880 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 937 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 938 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 939 | + } |
|
| 881 | 940 | $smcFunc['db_free_result']($request); |
| 882 | 941 | } |
| 883 | 942 | |
| 884 | 943 | $upcontext['user']['id'] = $id_member; |
| 885 | 944 | $upcontext['user']['name'] = $name; |
| 886 | - } |
|
| 887 | - else |
|
| 945 | + } else |
|
| 888 | 946 | { |
| 889 | 947 | $upcontext['user']['id'] = 1; |
| 890 | 948 | $upcontext['user']['name'] = 'Administrator'; |
@@ -900,11 +958,11 @@ discard block |
||
| 900 | 958 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 901 | 959 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 902 | 960 | |
| 903 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 904 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 905 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 906 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 907 | - else |
|
| 961 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 962 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 963 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 964 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 965 | + } else |
|
| 908 | 966 | { |
| 909 | 967 | // Set this as the new language. |
| 910 | 968 | $upcontext['language'] = $user_language; |
@@ -948,8 +1006,9 @@ discard block |
||
| 948 | 1006 | unset($member_columns); |
| 949 | 1007 | |
| 950 | 1008 | // If we've not submitted then we're done. |
| 951 | - if (empty($_POST['upcont'])) |
|
| 952 | - return false; |
|
| 1009 | + if (empty($_POST['upcont'])) { |
|
| 1010 | + return false; |
|
| 1011 | + } |
|
| 953 | 1012 | |
| 954 | 1013 | // Firstly, if they're enabling SM stat collection just do it. |
| 955 | 1014 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -969,16 +1028,17 @@ discard block |
||
| 969 | 1028 | fwrite($fp, $out); |
| 970 | 1029 | |
| 971 | 1030 | $return_data = ''; |
| 972 | - while (!feof($fp)) |
|
| 973 | - $return_data .= fgets($fp, 128); |
|
| 1031 | + while (!feof($fp)) { |
|
| 1032 | + $return_data .= fgets($fp, 128); |
|
| 1033 | + } |
|
| 974 | 1034 | |
| 975 | 1035 | fclose($fp); |
| 976 | 1036 | |
| 977 | 1037 | // Get the unique site ID. |
| 978 | 1038 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 979 | 1039 | |
| 980 | - if (!empty($ID[1])) |
|
| 981 | - $smcFunc['db_insert']('replace', |
|
| 1040 | + if (!empty($ID[1])) { |
|
| 1041 | + $smcFunc['db_insert']('replace', |
|
| 982 | 1042 | $db_prefix . 'settings', |
| 983 | 1043 | array('variable' => 'string', 'value' => 'string'), |
| 984 | 1044 | array( |
@@ -987,9 +1047,9 @@ discard block |
||
| 987 | 1047 | ), |
| 988 | 1048 | array('variable') |
| 989 | 1049 | ); |
| 1050 | + } |
|
| 990 | 1051 | } |
| 991 | - } |
|
| 992 | - else |
|
| 1052 | + } else |
|
| 993 | 1053 | { |
| 994 | 1054 | $smcFunc['db_insert']('replace', |
| 995 | 1055 | $db_prefix . 'settings', |
@@ -1000,8 +1060,8 @@ discard block |
||
| 1000 | 1060 | } |
| 1001 | 1061 | } |
| 1002 | 1062 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1003 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1004 | - $smcFunc['db_query']('', ' |
|
| 1063 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1064 | + $smcFunc['db_query']('', ' |
|
| 1005 | 1065 | DELETE FROM {db_prefix}settings |
| 1006 | 1066 | WHERE variable = {string:enable_sm_stats}', |
| 1007 | 1067 | array( |
@@ -1009,6 +1069,7 @@ discard block |
||
| 1009 | 1069 | 'db_error_skip' => true, |
| 1010 | 1070 | ) |
| 1011 | 1071 | ); |
| 1072 | + } |
|
| 1012 | 1073 | |
| 1013 | 1074 | // Deleting old karma stuff? |
| 1014 | 1075 | if (!empty($_POST['delete_karma'])) |
@@ -1023,20 +1084,22 @@ discard block |
||
| 1023 | 1084 | ); |
| 1024 | 1085 | |
| 1025 | 1086 | // Cleaning up old karma member settings. |
| 1026 | - if ($upcontext['karma_installed']['good']) |
|
| 1027 | - $smcFunc['db_query']('', ' |
|
| 1087 | + if ($upcontext['karma_installed']['good']) { |
|
| 1088 | + $smcFunc['db_query']('', ' |
|
| 1028 | 1089 | ALTER TABLE {db_prefix}members |
| 1029 | 1090 | DROP karma_good', |
| 1030 | 1091 | array() |
| 1031 | 1092 | ); |
| 1093 | + } |
|
| 1032 | 1094 | |
| 1033 | 1095 | // Does karma bad was enable? |
| 1034 | - if ($upcontext['karma_installed']['bad']) |
|
| 1035 | - $smcFunc['db_query']('', ' |
|
| 1096 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1097 | + $smcFunc['db_query']('', ' |
|
| 1036 | 1098 | ALTER TABLE {db_prefix}members |
| 1037 | 1099 | DROP karma_bad', |
| 1038 | 1100 | array() |
| 1039 | 1101 | ); |
| 1102 | + } |
|
| 1040 | 1103 | |
| 1041 | 1104 | // Cleaning up old karma permissions. |
| 1042 | 1105 | $smcFunc['db_query']('', ' |
@@ -1049,32 +1112,37 @@ discard block |
||
| 1049 | 1112 | } |
| 1050 | 1113 | |
| 1051 | 1114 | // Emptying the error log? |
| 1052 | - if (!empty($_POST['empty_error'])) |
|
| 1053 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1115 | + if (!empty($_POST['empty_error'])) { |
|
| 1116 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1054 | 1117 | TRUNCATE {db_prefix}log_errors', |
| 1055 | 1118 | array( |
| 1056 | 1119 | ) |
| 1057 | 1120 | ); |
| 1121 | + } |
|
| 1058 | 1122 | |
| 1059 | 1123 | $changes = array(); |
| 1060 | 1124 | |
| 1061 | 1125 | // Add proxy settings. |
| 1062 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1063 | - $changes += array( |
|
| 1126 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1127 | + $changes += array( |
|
| 1064 | 1128 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1065 | 1129 | 'image_proxy_maxsize' => 5190, |
| 1066 | 1130 | 'image_proxy_enabled' => 0, |
| 1067 | 1131 | ); |
| 1132 | + } |
|
| 1068 | 1133 | |
| 1069 | 1134 | // If $boardurl reflects https, set force_ssl |
| 1070 | - if (!function_exists('cache_put_data')) |
|
| 1071 | - require_once($sourcedir . '/Load.php'); |
|
| 1072 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1073 | - updateSettings(array('force_ssl' => '2')); |
|
| 1135 | + if (!function_exists('cache_put_data')) { |
|
| 1136 | + require_once($sourcedir . '/Load.php'); |
|
| 1137 | + } |
|
| 1138 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1139 | + updateSettings(array('force_ssl' => '2')); |
|
| 1140 | + } |
|
| 1074 | 1141 | |
| 1075 | 1142 | // If we're overriding the language follow it through. |
| 1076 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1077 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1143 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1144 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1145 | + } |
|
| 1078 | 1146 | |
| 1079 | 1147 | if (!empty($_POST['maint'])) |
| 1080 | 1148 | { |
@@ -1086,26 +1154,29 @@ discard block |
||
| 1086 | 1154 | { |
| 1087 | 1155 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1088 | 1156 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1089 | - } |
|
| 1090 | - else |
|
| 1157 | + } else |
|
| 1091 | 1158 | { |
| 1092 | 1159 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1093 | 1160 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1094 | 1161 | } |
| 1095 | 1162 | } |
| 1096 | 1163 | |
| 1097 | - if ($command_line) |
|
| 1098 | - echo ' * Updating Settings.php...'; |
|
| 1164 | + if ($command_line) { |
|
| 1165 | + echo ' * Updating Settings.php...'; |
|
| 1166 | + } |
|
| 1099 | 1167 | |
| 1100 | 1168 | // Fix some old paths. |
| 1101 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1102 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1169 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1170 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1171 | + } |
|
| 1103 | 1172 | |
| 1104 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1105 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1173 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1174 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1175 | + } |
|
| 1106 | 1176 | |
| 1107 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1108 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1177 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1178 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1179 | + } |
|
| 1109 | 1180 | |
| 1110 | 1181 | // If they have a "host:port" setup for the host, split that into separate values |
| 1111 | 1182 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1116,32 +1187,36 @@ discard block |
||
| 1116 | 1187 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1117 | 1188 | |
| 1118 | 1189 | // Only set this if we're not using the default port |
| 1119 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1120 | - $changes['db_port'] = (int) $db_port; |
|
| 1121 | - } |
|
| 1122 | - elseif (!empty($db_port)) |
|
| 1190 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1191 | + $changes['db_port'] = (int) $db_port; |
|
| 1192 | + } |
|
| 1193 | + } elseif (!empty($db_port)) |
|
| 1123 | 1194 | { |
| 1124 | 1195 | // If db_port is set and is the same as the default, set it to '' |
| 1125 | 1196 | if ($db_type == 'mysql') |
| 1126 | 1197 | { |
| 1127 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1128 | - $changes['db_port'] = '\'\''; |
|
| 1129 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1130 | - $changes['db_port'] = '\'\''; |
|
| 1198 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1199 | + $changes['db_port'] = '\'\''; |
|
| 1200 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1201 | + $changes['db_port'] = '\'\''; |
|
| 1202 | + } |
|
| 1131 | 1203 | } |
| 1132 | 1204 | } |
| 1133 | 1205 | |
| 1134 | 1206 | // Maybe we haven't had this option yet? |
| 1135 | - if (empty($packagesdir)) |
|
| 1136 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1207 | + if (empty($packagesdir)) { |
|
| 1208 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1209 | + } |
|
| 1137 | 1210 | |
| 1138 | 1211 | // Add support for $tasksdir var. |
| 1139 | - if (empty($tasksdir)) |
|
| 1140 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1212 | + if (empty($tasksdir)) { |
|
| 1213 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1214 | + } |
|
| 1141 | 1215 | |
| 1142 | 1216 | // Make sure we fix the language as well. |
| 1143 | - if (stristr($language, '-utf8')) |
|
| 1144 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1217 | + if (stristr($language, '-utf8')) { |
|
| 1218 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1219 | + } |
|
| 1145 | 1220 | |
| 1146 | 1221 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1147 | 1222 | |
@@ -1149,8 +1224,9 @@ discard block |
||
| 1149 | 1224 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1150 | 1225 | updateSettingsFile($changes); |
| 1151 | 1226 | |
| 1152 | - if ($command_line) |
|
| 1153 | - echo ' Successful.' . "\n"; |
|
| 1227 | + if ($command_line) { |
|
| 1228 | + echo ' Successful.' . "\n"; |
|
| 1229 | + } |
|
| 1154 | 1230 | |
| 1155 | 1231 | // Are we doing debug? |
| 1156 | 1232 | if (isset($_POST['debug'])) |
@@ -1160,8 +1236,9 @@ discard block |
||
| 1160 | 1236 | } |
| 1161 | 1237 | |
| 1162 | 1238 | // If we're not backing up then jump one. |
| 1163 | - if (empty($_POST['backup'])) |
|
| 1164 | - $upcontext['current_step']++; |
|
| 1239 | + if (empty($_POST['backup'])) { |
|
| 1240 | + $upcontext['current_step']++; |
|
| 1241 | + } |
|
| 1165 | 1242 | |
| 1166 | 1243 | // If we've got here then let's proceed to the next step! |
| 1167 | 1244 | return true; |
@@ -1176,8 +1253,9 @@ discard block |
||
| 1176 | 1253 | $upcontext['page_title'] = 'Backup Database'; |
| 1177 | 1254 | |
| 1178 | 1255 | // Done it already - js wise? |
| 1179 | - if (!empty($_POST['backup_done'])) |
|
| 1180 | - return true; |
|
| 1256 | + if (!empty($_POST['backup_done'])) { |
|
| 1257 | + return true; |
|
| 1258 | + } |
|
| 1181 | 1259 | |
| 1182 | 1260 | // Some useful stuff here. |
| 1183 | 1261 | db_extend(); |
@@ -1191,9 +1269,10 @@ discard block |
||
| 1191 | 1269 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1192 | 1270 | |
| 1193 | 1271 | $table_names = array(); |
| 1194 | - foreach ($tables as $table) |
|
| 1195 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1272 | + foreach ($tables as $table) { |
|
| 1273 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1196 | 1274 | $table_names[] = $table; |
| 1275 | + } |
|
| 1197 | 1276 | |
| 1198 | 1277 | $upcontext['table_count'] = count($table_names); |
| 1199 | 1278 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1203,12 +1282,14 @@ discard block |
||
| 1203 | 1282 | $file_steps = $upcontext['table_count']; |
| 1204 | 1283 | |
| 1205 | 1284 | // What ones have we already done? |
| 1206 | - foreach ($table_names as $id => $table) |
|
| 1207 | - if ($id < $_GET['substep']) |
|
| 1285 | + foreach ($table_names as $id => $table) { |
|
| 1286 | + if ($id < $_GET['substep']) |
|
| 1208 | 1287 | $upcontext['previous_tables'][] = $table; |
| 1288 | + } |
|
| 1209 | 1289 | |
| 1210 | - if ($command_line) |
|
| 1211 | - echo 'Backing Up Tables.'; |
|
| 1290 | + if ($command_line) { |
|
| 1291 | + echo 'Backing Up Tables.'; |
|
| 1292 | + } |
|
| 1212 | 1293 | |
| 1213 | 1294 | // If we don't support javascript we backup here. |
| 1214 | 1295 | if (!$support_js || isset($_GET['xml'])) |
@@ -1227,8 +1308,9 @@ discard block |
||
| 1227 | 1308 | backupTable($table_names[$substep]); |
| 1228 | 1309 | |
| 1229 | 1310 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1230 | - if (isset($_GET['xml'])) |
|
| 1231 | - return upgradeExit(); |
|
| 1311 | + if (isset($_GET['xml'])) { |
|
| 1312 | + return upgradeExit(); |
|
| 1313 | + } |
|
| 1232 | 1314 | } |
| 1233 | 1315 | |
| 1234 | 1316 | if ($command_line) |
@@ -1261,9 +1343,10 @@ discard block |
||
| 1261 | 1343 | |
| 1262 | 1344 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1263 | 1345 | |
| 1264 | - if ($command_line) |
|
| 1265 | - echo ' done.'; |
|
| 1266 | -} |
|
| 1346 | + if ($command_line) { |
|
| 1347 | + echo ' done.'; |
|
| 1348 | + } |
|
| 1349 | + } |
|
| 1267 | 1350 | |
| 1268 | 1351 | // Step 2: Everything. |
| 1269 | 1352 | function DatabaseChanges() |
@@ -1272,8 +1355,9 @@ discard block |
||
| 1272 | 1355 | global $upcontext, $support_js, $db_type; |
| 1273 | 1356 | |
| 1274 | 1357 | // Have we just completed this? |
| 1275 | - if (!empty($_POST['database_done'])) |
|
| 1276 | - return true; |
|
| 1358 | + if (!empty($_POST['database_done'])) { |
|
| 1359 | + return true; |
|
| 1360 | + } |
|
| 1277 | 1361 | |
| 1278 | 1362 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1279 | 1363 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1288,15 +1372,16 @@ discard block |
||
| 1288 | 1372 | ); |
| 1289 | 1373 | |
| 1290 | 1374 | // How many files are there in total? |
| 1291 | - if (isset($_GET['filecount'])) |
|
| 1292 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1293 | - else |
|
| 1375 | + if (isset($_GET['filecount'])) { |
|
| 1376 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1377 | + } else |
|
| 1294 | 1378 | { |
| 1295 | 1379 | $upcontext['file_count'] = 0; |
| 1296 | 1380 | foreach ($files as $file) |
| 1297 | 1381 | { |
| 1298 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1299 | - $upcontext['file_count']++; |
|
| 1382 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1383 | + $upcontext['file_count']++; |
|
| 1384 | + } |
|
| 1300 | 1385 | } |
| 1301 | 1386 | } |
| 1302 | 1387 | |
@@ -1306,9 +1391,9 @@ discard block |
||
| 1306 | 1391 | $upcontext['cur_file_num'] = 0; |
| 1307 | 1392 | foreach ($files as $file) |
| 1308 | 1393 | { |
| 1309 | - if ($did_not_do) |
|
| 1310 | - $did_not_do--; |
|
| 1311 | - else |
|
| 1394 | + if ($did_not_do) { |
|
| 1395 | + $did_not_do--; |
|
| 1396 | + } else |
|
| 1312 | 1397 | { |
| 1313 | 1398 | $upcontext['cur_file_num']++; |
| 1314 | 1399 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1335,12 +1420,13 @@ discard block |
||
| 1335 | 1420 | // Flag to move on to the next. |
| 1336 | 1421 | $upcontext['completed_step'] = true; |
| 1337 | 1422 | // Did we complete the whole file? |
| 1338 | - if ($nextFile) |
|
| 1339 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1423 | + if ($nextFile) { |
|
| 1424 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1425 | + } |
|
| 1340 | 1426 | return upgradeExit(); |
| 1427 | + } elseif ($support_js) { |
|
| 1428 | + break; |
|
| 1341 | 1429 | } |
| 1342 | - elseif ($support_js) |
|
| 1343 | - break; |
|
| 1344 | 1430 | } |
| 1345 | 1431 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1346 | 1432 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1365,8 +1451,9 @@ discard block |
||
| 1365 | 1451 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1366 | 1452 | |
| 1367 | 1453 | // Now it's nice to have some of the basic SMF source files. |
| 1368 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1369 | - redirectLocation('&ssi=1'); |
|
| 1454 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1455 | + redirectLocation('&ssi=1'); |
|
| 1456 | + } |
|
| 1370 | 1457 | |
| 1371 | 1458 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1372 | 1459 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1382,14 +1469,16 @@ discard block |
||
| 1382 | 1469 | // Are we in maintenance mode? |
| 1383 | 1470 | if (isset($upcontext['user']['main'])) |
| 1384 | 1471 | { |
| 1385 | - if ($command_line) |
|
| 1386 | - echo ' * '; |
|
| 1472 | + if ($command_line) { |
|
| 1473 | + echo ' * '; |
|
| 1474 | + } |
|
| 1387 | 1475 | $upcontext['removed_maintenance'] = true; |
| 1388 | 1476 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1389 | 1477 | } |
| 1390 | 1478 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1391 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1392 | - $changes['maintenance'] = 1; |
|
| 1479 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1480 | + $changes['maintenance'] = 1; |
|
| 1481 | + } |
|
| 1393 | 1482 | |
| 1394 | 1483 | // Wipe this out... |
| 1395 | 1484 | $upcontext['user'] = array(); |
@@ -1404,9 +1493,9 @@ discard block |
||
| 1404 | 1493 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1405 | 1494 | |
| 1406 | 1495 | // Now is the perfect time to fetch the SM files. |
| 1407 | - if ($command_line) |
|
| 1408 | - cli_scheduled_fetchSMfiles(); |
|
| 1409 | - else |
|
| 1496 | + if ($command_line) { |
|
| 1497 | + cli_scheduled_fetchSMfiles(); |
|
| 1498 | + } else |
|
| 1410 | 1499 | { |
| 1411 | 1500 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1412 | 1501 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1414,8 +1503,9 @@ discard block |
||
| 1414 | 1503 | } |
| 1415 | 1504 | |
| 1416 | 1505 | // Log what we've done. |
| 1417 | - if (empty($user_info['id'])) |
|
| 1418 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1506 | + if (empty($user_info['id'])) { |
|
| 1507 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1508 | + } |
|
| 1419 | 1509 | |
| 1420 | 1510 | // Log the action manually, so CLI still works. |
| 1421 | 1511 | $smcFunc['db_insert']('', |
@@ -1434,8 +1524,9 @@ discard block |
||
| 1434 | 1524 | |
| 1435 | 1525 | // Save the current database version. |
| 1436 | 1526 | $server_version = $smcFunc['db_server_info'](); |
| 1437 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1438 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1527 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1528 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1529 | + } |
|
| 1439 | 1530 | |
| 1440 | 1531 | if ($command_line) |
| 1441 | 1532 | { |
@@ -1447,8 +1538,9 @@ discard block |
||
| 1447 | 1538 | |
| 1448 | 1539 | // Make sure it says we're done. |
| 1449 | 1540 | $upcontext['overall_percent'] = 100; |
| 1450 | - if (isset($upcontext['step_progress'])) |
|
| 1451 | - unset($upcontext['step_progress']); |
|
| 1541 | + if (isset($upcontext['step_progress'])) { |
|
| 1542 | + unset($upcontext['step_progress']); |
|
| 1543 | + } |
|
| 1452 | 1544 | |
| 1453 | 1545 | $_GET['substep'] = 0; |
| 1454 | 1546 | return false; |
@@ -1459,8 +1551,9 @@ discard block |
||
| 1459 | 1551 | { |
| 1460 | 1552 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1461 | 1553 | |
| 1462 | - if (empty($modSettings['time_format'])) |
|
| 1463 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1554 | + if (empty($modSettings['time_format'])) { |
|
| 1555 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1556 | + } |
|
| 1464 | 1557 | |
| 1465 | 1558 | // What files do we want to get |
| 1466 | 1559 | $request = $smcFunc['db_query']('', ' |
@@ -1494,8 +1587,9 @@ discard block |
||
| 1494 | 1587 | $file_data = fetch_web_data($url); |
| 1495 | 1588 | |
| 1496 | 1589 | // If we got an error - give up - the site might be down. |
| 1497 | - if ($file_data === false) |
|
| 1498 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1590 | + if ($file_data === false) { |
|
| 1591 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1592 | + } |
|
| 1499 | 1593 | |
| 1500 | 1594 | // Save the file to the database. |
| 1501 | 1595 | $smcFunc['db_query']('substring', ' |
@@ -1537,8 +1631,9 @@ discard block |
||
| 1537 | 1631 | $themeData = array(); |
| 1538 | 1632 | foreach ($values as $variable => $value) |
| 1539 | 1633 | { |
| 1540 | - if (!isset($value) || $value === null) |
|
| 1541 | - $value = 0; |
|
| 1634 | + if (!isset($value) || $value === null) { |
|
| 1635 | + $value = 0; |
|
| 1636 | + } |
|
| 1542 | 1637 | |
| 1543 | 1638 | $themeData[] = array(0, 1, $variable, $value); |
| 1544 | 1639 | } |
@@ -1567,8 +1662,9 @@ discard block |
||
| 1567 | 1662 | |
| 1568 | 1663 | foreach ($values as $variable => $value) |
| 1569 | 1664 | { |
| 1570 | - if (empty($modSettings[$value[0]])) |
|
| 1571 | - continue; |
|
| 1665 | + if (empty($modSettings[$value[0]])) { |
|
| 1666 | + continue; |
|
| 1667 | + } |
|
| 1572 | 1668 | |
| 1573 | 1669 | $smcFunc['db_query']('', ' |
| 1574 | 1670 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1654,19 +1750,21 @@ discard block |
||
| 1654 | 1750 | set_error_handler( |
| 1655 | 1751 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1656 | 1752 | { |
| 1657 | - if ($support_js) |
|
| 1658 | - return true; |
|
| 1659 | - else |
|
| 1660 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1753 | + if ($support_js) { |
|
| 1754 | + return true; |
|
| 1755 | + } else { |
|
| 1756 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1757 | + } |
|
| 1661 | 1758 | } |
| 1662 | 1759 | ); |
| 1663 | 1760 | |
| 1664 | 1761 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1665 | 1762 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1666 | - if ($db_type == 'mysql') |
|
| 1667 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1668 | - else |
|
| 1669 | - $db_collation = ''; |
|
| 1763 | + if ($db_type == 'mysql') { |
|
| 1764 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1765 | + } else { |
|
| 1766 | + $db_collation = ''; |
|
| 1767 | + } |
|
| 1670 | 1768 | |
| 1671 | 1769 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1672 | 1770 | |
@@ -1678,8 +1776,9 @@ discard block |
||
| 1678 | 1776 | $last_step = ''; |
| 1679 | 1777 | |
| 1680 | 1778 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1681 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1682 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1779 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1780 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1781 | + } |
|
| 1683 | 1782 | |
| 1684 | 1783 | // Count the total number of steps within this file - for progress. |
| 1685 | 1784 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1699,15 +1798,18 @@ discard block |
||
| 1699 | 1798 | $do_current = $substep >= $_GET['substep']; |
| 1700 | 1799 | |
| 1701 | 1800 | // Get rid of any comments in the beginning of the line... |
| 1702 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1703 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1801 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1802 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1803 | + } |
|
| 1704 | 1804 | |
| 1705 | 1805 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1706 | - if ($is_debug && !$support_js && $command_line) |
|
| 1707 | - flush(); |
|
| 1806 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1807 | + flush(); |
|
| 1808 | + } |
|
| 1708 | 1809 | |
| 1709 | - if (trim($line) === '') |
|
| 1710 | - continue; |
|
| 1810 | + if (trim($line) === '') { |
|
| 1811 | + continue; |
|
| 1812 | + } |
|
| 1711 | 1813 | |
| 1712 | 1814 | if (trim(substr($line, 0, 3)) === '---') |
| 1713 | 1815 | { |
@@ -1717,8 +1819,9 @@ discard block |
||
| 1717 | 1819 | if (trim($current_data) != '' && $type !== '}') |
| 1718 | 1820 | { |
| 1719 | 1821 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1720 | - if ($command_line) |
|
| 1721 | - echo $upcontext['error_message']; |
|
| 1822 | + if ($command_line) { |
|
| 1823 | + echo $upcontext['error_message']; |
|
| 1824 | + } |
|
| 1722 | 1825 | } |
| 1723 | 1826 | |
| 1724 | 1827 | if ($type == ' ') |
@@ -1736,17 +1839,18 @@ discard block |
||
| 1736 | 1839 | if ($do_current) |
| 1737 | 1840 | { |
| 1738 | 1841 | $upcontext['actioned_items'][] = $last_step; |
| 1739 | - if ($command_line) |
|
| 1740 | - echo ' * '; |
|
| 1842 | + if ($command_line) { |
|
| 1843 | + echo ' * '; |
|
| 1844 | + } |
|
| 1741 | 1845 | } |
| 1742 | - } |
|
| 1743 | - elseif ($type == '#') |
|
| 1846 | + } elseif ($type == '#') |
|
| 1744 | 1847 | { |
| 1745 | 1848 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1746 | 1849 | |
| 1747 | 1850 | $upcontext['current_debug_item_num']++; |
| 1748 | - if (trim($line) != '---#') |
|
| 1749 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1851 | + if (trim($line) != '---#') { |
|
| 1852 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1853 | + } |
|
| 1750 | 1854 | |
| 1751 | 1855 | // Have we already done something? |
| 1752 | 1856 | if (isset($_GET['xml']) && $done_something) |
@@ -1757,34 +1861,36 @@ discard block |
||
| 1757 | 1861 | |
| 1758 | 1862 | if ($do_current) |
| 1759 | 1863 | { |
| 1760 | - if (trim($line) == '---#' && $command_line) |
|
| 1761 | - echo ' done.', $endl; |
|
| 1762 | - elseif ($command_line) |
|
| 1763 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1764 | - elseif (trim($line) != '---#') |
|
| 1864 | + if (trim($line) == '---#' && $command_line) { |
|
| 1865 | + echo ' done.', $endl; |
|
| 1866 | + } elseif ($command_line) { |
|
| 1867 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1868 | + } elseif (trim($line) != '---#') |
|
| 1765 | 1869 | { |
| 1766 | - if ($is_debug) |
|
| 1767 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1870 | + if ($is_debug) { |
|
| 1871 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1872 | + } |
|
| 1768 | 1873 | } |
| 1769 | 1874 | } |
| 1770 | 1875 | |
| 1771 | 1876 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1772 | 1877 | { |
| 1773 | - if ($command_line) |
|
| 1774 | - echo ' * '; |
|
| 1775 | - else |
|
| 1776 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1878 | + if ($command_line) { |
|
| 1879 | + echo ' * '; |
|
| 1880 | + } else { |
|
| 1881 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1882 | + } |
|
| 1777 | 1883 | } |
| 1778 | 1884 | |
| 1779 | 1885 | // Small step - only if we're actually doing stuff. |
| 1780 | - if ($do_current) |
|
| 1781 | - nextSubstep(++$substep); |
|
| 1782 | - else |
|
| 1783 | - $substep++; |
|
| 1784 | - } |
|
| 1785 | - elseif ($type == '{') |
|
| 1786 | - $current_type = 'code'; |
|
| 1787 | - elseif ($type == '}') |
|
| 1886 | + if ($do_current) { |
|
| 1887 | + nextSubstep(++$substep); |
|
| 1888 | + } else { |
|
| 1889 | + $substep++; |
|
| 1890 | + } |
|
| 1891 | + } elseif ($type == '{') { |
|
| 1892 | + $current_type = 'code'; |
|
| 1893 | + } elseif ($type == '}') |
|
| 1788 | 1894 | { |
| 1789 | 1895 | $current_type = 'sql'; |
| 1790 | 1896 | |
@@ -1797,8 +1903,9 @@ discard block |
||
| 1797 | 1903 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1798 | 1904 | { |
| 1799 | 1905 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1800 | - if ($command_line) |
|
| 1801 | - echo $upcontext['error_message']; |
|
| 1906 | + if ($command_line) { |
|
| 1907 | + echo $upcontext['error_message']; |
|
| 1908 | + } |
|
| 1802 | 1909 | } |
| 1803 | 1910 | |
| 1804 | 1911 | // Done with code! |
@@ -1878,8 +1985,9 @@ discard block |
||
| 1878 | 1985 | $db_unbuffered = false; |
| 1879 | 1986 | |
| 1880 | 1987 | // Failure?! |
| 1881 | - if ($result !== false) |
|
| 1882 | - return $result; |
|
| 1988 | + if ($result !== false) { |
|
| 1989 | + return $result; |
|
| 1990 | + } |
|
| 1883 | 1991 | |
| 1884 | 1992 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1885 | 1993 | // If MySQL we do something more clever. |
@@ -1907,54 +2015,61 @@ discard block |
||
| 1907 | 2015 | { |
| 1908 | 2016 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1909 | 2017 | $result = mysqli_query($db_connection, $string); |
| 1910 | - if ($result !== false) |
|
| 1911 | - return $result; |
|
| 2018 | + if ($result !== false) { |
|
| 2019 | + return $result; |
|
| 2020 | + } |
|
| 1912 | 2021 | } |
| 1913 | - } |
|
| 1914 | - elseif ($mysqli_errno == 2013) |
|
| 2022 | + } elseif ($mysqli_errno == 2013) |
|
| 1915 | 2023 | { |
| 1916 | 2024 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1917 | 2025 | mysqli_select_db($db_connection, $db_name); |
| 1918 | 2026 | if ($db_connection) |
| 1919 | 2027 | { |
| 1920 | 2028 | $result = mysqli_query($db_connection, $string); |
| 1921 | - if ($result !== false) |
|
| 1922 | - return $result; |
|
| 2029 | + if ($result !== false) { |
|
| 2030 | + return $result; |
|
| 2031 | + } |
|
| 1923 | 2032 | } |
| 1924 | 2033 | } |
| 1925 | 2034 | // Duplicate column name... should be okay ;). |
| 1926 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1927 | - return false; |
|
| 2035 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2036 | + return false; |
|
| 2037 | + } |
|
| 1928 | 2038 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1929 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1930 | - return false; |
|
| 2039 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2040 | + return false; |
|
| 2041 | + } |
|
| 1931 | 2042 | // Creating an index on a non-existent column. |
| 1932 | - elseif ($mysqli_errno == 1072) |
|
| 1933 | - return false; |
|
| 1934 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1935 | - return false; |
|
| 2043 | + elseif ($mysqli_errno == 1072) { |
|
| 2044 | + return false; |
|
| 2045 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2046 | + return false; |
|
| 2047 | + } |
|
| 1936 | 2048 | } |
| 1937 | 2049 | // If a table already exists don't go potty. |
| 1938 | 2050 | else |
| 1939 | 2051 | { |
| 1940 | 2052 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1941 | 2053 | { |
| 1942 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1943 | - return true; |
|
| 1944 | - } |
|
| 1945 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2054 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2055 | + return true; |
|
| 2056 | + } |
|
| 2057 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1946 | 2058 | { |
| 1947 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1948 | - return true; |
|
| 2059 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2060 | + return true; |
|
| 2061 | + } |
|
| 1949 | 2062 | } |
| 1950 | 2063 | } |
| 1951 | 2064 | |
| 1952 | 2065 | // Get the query string so we pass everything. |
| 1953 | 2066 | $query_string = ''; |
| 1954 | - foreach ($_GET as $k => $v) |
|
| 1955 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1956 | - if (strlen($query_string) != 0) |
|
| 1957 | - $query_string = '?' . substr($query_string, 1); |
|
| 2067 | + foreach ($_GET as $k => $v) { |
|
| 2068 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2069 | + } |
|
| 2070 | + if (strlen($query_string) != 0) { |
|
| 2071 | + $query_string = '?' . substr($query_string, 1); |
|
| 2072 | + } |
|
| 1958 | 2073 | |
| 1959 | 2074 | if ($command_line) |
| 1960 | 2075 | { |
@@ -2009,16 +2124,18 @@ discard block |
||
| 2009 | 2124 | { |
| 2010 | 2125 | $found |= 1; |
| 2011 | 2126 | // Do some checks on the data if we have it set. |
| 2012 | - if (isset($change['col_type'])) |
|
| 2013 | - $found &= $change['col_type'] === $column['type']; |
|
| 2014 | - if (isset($change['null_allowed'])) |
|
| 2015 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2016 | - if (isset($change['default'])) |
|
| 2017 | - $found &= $change['default'] === $column['default']; |
|
| 2127 | + if (isset($change['col_type'])) { |
|
| 2128 | + $found &= $change['col_type'] === $column['type']; |
|
| 2129 | + } |
|
| 2130 | + if (isset($change['null_allowed'])) { |
|
| 2131 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2132 | + } |
|
| 2133 | + if (isset($change['default'])) { |
|
| 2134 | + $found &= $change['default'] === $column['default']; |
|
| 2135 | + } |
|
| 2018 | 2136 | } |
| 2019 | 2137 | } |
| 2020 | - } |
|
| 2021 | - elseif ($change['type'] === 'index') |
|
| 2138 | + } elseif ($change['type'] === 'index') |
|
| 2022 | 2139 | { |
| 2023 | 2140 | $request = upgrade_query(' |
| 2024 | 2141 | SHOW INDEX |
@@ -2027,9 +2144,10 @@ discard block |
||
| 2027 | 2144 | { |
| 2028 | 2145 | $cur_index = array(); |
| 2029 | 2146 | |
| 2030 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2031 | - if ($row['Key_name'] === $change['name']) |
|
| 2147 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2148 | + if ($row['Key_name'] === $change['name']) |
|
| 2032 | 2149 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2150 | + } |
|
| 2033 | 2151 | |
| 2034 | 2152 | ksort($cur_index, SORT_NUMERIC); |
| 2035 | 2153 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2039,14 +2157,17 @@ discard block |
||
| 2039 | 2157 | } |
| 2040 | 2158 | |
| 2041 | 2159 | // If we're trying to add and it's added, we're done. |
| 2042 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2043 | - return true; |
|
| 2160 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2161 | + return true; |
|
| 2162 | + } |
|
| 2044 | 2163 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2045 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2046 | - return true; |
|
| 2164 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2165 | + return true; |
|
| 2166 | + } |
|
| 2047 | 2167 | // Otherwise is it just a test? |
| 2048 | - elseif ($is_test) |
|
| 2049 | - return false; |
|
| 2168 | + elseif ($is_test) { |
|
| 2169 | + return false; |
|
| 2170 | + } |
|
| 2050 | 2171 | |
| 2051 | 2172 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2052 | 2173 | $running = false; |
@@ -2057,8 +2178,9 @@ discard block |
||
| 2057 | 2178 | SHOW FULL PROCESSLIST'); |
| 2058 | 2179 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2059 | 2180 | { |
| 2060 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2061 | - $found = true; |
|
| 2181 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2182 | + $found = true; |
|
| 2183 | + } |
|
| 2062 | 2184 | } |
| 2063 | 2185 | |
| 2064 | 2186 | // Can't find it? Then we need to run it fools! |
@@ -2070,8 +2192,9 @@ discard block |
||
| 2070 | 2192 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2071 | 2193 | ' . $change['text'], true) !== false; |
| 2072 | 2194 | |
| 2073 | - if (!$success) |
|
| 2074 | - return false; |
|
| 2195 | + if (!$success) { |
|
| 2196 | + return false; |
|
| 2197 | + } |
|
| 2075 | 2198 | |
| 2076 | 2199 | // Return |
| 2077 | 2200 | $running = true; |
@@ -2113,8 +2236,9 @@ discard block |
||
| 2113 | 2236 | 'db_error_skip' => true, |
| 2114 | 2237 | ) |
| 2115 | 2238 | ); |
| 2116 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2117 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2239 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2240 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2241 | + } |
|
| 2118 | 2242 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2119 | 2243 | $smcFunc['db_free_result']($request); |
| 2120 | 2244 | |
@@ -2136,18 +2260,19 @@ discard block |
||
| 2136 | 2260 | ) |
| 2137 | 2261 | ); |
| 2138 | 2262 | // No results? Just forget it all together. |
| 2139 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2140 | - unset($table_row['Collation']); |
|
| 2141 | - else |
|
| 2142 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2263 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2264 | + unset($table_row['Collation']); |
|
| 2265 | + } else { |
|
| 2266 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2267 | + } |
|
| 2143 | 2268 | $smcFunc['db_free_result']($request); |
| 2144 | 2269 | } |
| 2145 | 2270 | |
| 2146 | 2271 | if ($column_fix) |
| 2147 | 2272 | { |
| 2148 | 2273 | // Make sure there are no NULL's left. |
| 2149 | - if ($null_fix) |
|
| 2150 | - $smcFunc['db_query']('', ' |
|
| 2274 | + if ($null_fix) { |
|
| 2275 | + $smcFunc['db_query']('', ' |
|
| 2151 | 2276 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2152 | 2277 | SET ' . $change['column'] . ' = {string:default} |
| 2153 | 2278 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2156,6 +2281,7 @@ discard block |
||
| 2156 | 2281 | 'db_error_skip' => true, |
| 2157 | 2282 | ) |
| 2158 | 2283 | ); |
| 2284 | + } |
|
| 2159 | 2285 | |
| 2160 | 2286 | // Do the actual alteration. |
| 2161 | 2287 | $smcFunc['db_query']('', ' |
@@ -2184,8 +2310,9 @@ discard block |
||
| 2184 | 2310 | } |
| 2185 | 2311 | |
| 2186 | 2312 | // Not a column we need to check on? |
| 2187 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2188 | - return; |
|
| 2313 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2314 | + return; |
|
| 2315 | + } |
|
| 2189 | 2316 | |
| 2190 | 2317 | // Break it up you (six|seven). |
| 2191 | 2318 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2204,13 +2331,13 @@ discard block |
||
| 2204 | 2331 | 'new_name' => $temp[2], |
| 2205 | 2332 | )); |
| 2206 | 2333 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2207 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2208 | - return; |
|
| 2334 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2335 | + return; |
|
| 2336 | + } |
|
| 2209 | 2337 | |
| 2210 | 2338 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2211 | 2339 | $smcFunc['db_free_result']($request); |
| 2212 | - } |
|
| 2213 | - else |
|
| 2340 | + } else |
|
| 2214 | 2341 | { |
| 2215 | 2342 | // Do this the old fashion, sure method way. |
| 2216 | 2343 | $request = $smcFunc['db_query']('', ' |
@@ -2221,21 +2348,24 @@ discard block |
||
| 2221 | 2348 | )); |
| 2222 | 2349 | // Mayday! |
| 2223 | 2350 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2224 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2225 | - return; |
|
| 2351 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2352 | + return; |
|
| 2353 | + } |
|
| 2226 | 2354 | |
| 2227 | 2355 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2228 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2229 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2356 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2357 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2230 | 2358 | { |
| 2231 | 2359 | $current_type = $row['Type']; |
| 2360 | + } |
|
| 2232 | 2361 | break; |
| 2233 | 2362 | } |
| 2234 | 2363 | } |
| 2235 | 2364 | |
| 2236 | 2365 | // If this doesn't match, the column may of been altered for a reason. |
| 2237 | - if (trim($current_type) != trim($temp[3])) |
|
| 2238 | - $temp[3] = $current_type; |
|
| 2366 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2367 | + $temp[3] = $current_type; |
|
| 2368 | + } |
|
| 2239 | 2369 | |
| 2240 | 2370 | // Piece this back together. |
| 2241 | 2371 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2247,8 +2377,9 @@ discard block |
||
| 2247 | 2377 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2248 | 2378 | global $step_progress, $is_debug, $upcontext; |
| 2249 | 2379 | |
| 2250 | - if ($_GET['substep'] < $substep) |
|
| 2251 | - $_GET['substep'] = $substep; |
|
| 2380 | + if ($_GET['substep'] < $substep) { |
|
| 2381 | + $_GET['substep'] = $substep; |
|
| 2382 | + } |
|
| 2252 | 2383 | |
| 2253 | 2384 | if ($command_line) |
| 2254 | 2385 | { |
@@ -2261,29 +2392,33 @@ discard block |
||
| 2261 | 2392 | } |
| 2262 | 2393 | |
| 2263 | 2394 | @set_time_limit(300); |
| 2264 | - if (function_exists('apache_reset_timeout')) |
|
| 2265 | - @apache_reset_timeout(); |
|
| 2395 | + if (function_exists('apache_reset_timeout')) { |
|
| 2396 | + @apache_reset_timeout(); |
|
| 2397 | + } |
|
| 2266 | 2398 | |
| 2267 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2268 | - return; |
|
| 2399 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2400 | + return; |
|
| 2401 | + } |
|
| 2269 | 2402 | |
| 2270 | 2403 | // Do we have some custom step progress stuff? |
| 2271 | 2404 | if (!empty($step_progress)) |
| 2272 | 2405 | { |
| 2273 | 2406 | $upcontext['substep_progress'] = 0; |
| 2274 | 2407 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2275 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2276 | - $upcontext['substep_progress'] = 99.9; |
|
| 2277 | - else |
|
| 2278 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2408 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2409 | + $upcontext['substep_progress'] = 99.9; |
|
| 2410 | + } else { |
|
| 2411 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2412 | + } |
|
| 2279 | 2413 | |
| 2280 | 2414 | // Make it nicely rounded. |
| 2281 | 2415 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2282 | 2416 | } |
| 2283 | 2417 | |
| 2284 | 2418 | // If this is XML we just exit right away! |
| 2285 | - if (isset($_GET['xml'])) |
|
| 2286 | - return upgradeExit(); |
|
| 2419 | + if (isset($_GET['xml'])) { |
|
| 2420 | + return upgradeExit(); |
|
| 2421 | + } |
|
| 2287 | 2422 | |
| 2288 | 2423 | // We're going to pause after this! |
| 2289 | 2424 | $upcontext['pause'] = true; |
@@ -2291,13 +2426,15 @@ discard block |
||
| 2291 | 2426 | $upcontext['query_string'] = ''; |
| 2292 | 2427 | foreach ($_GET as $k => $v) |
| 2293 | 2428 | { |
| 2294 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2295 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2429 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2430 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2431 | + } |
|
| 2296 | 2432 | } |
| 2297 | 2433 | |
| 2298 | 2434 | // Custom warning? |
| 2299 | - if (!empty($custom_warning)) |
|
| 2300 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2435 | + if (!empty($custom_warning)) { |
|
| 2436 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2437 | + } |
|
| 2301 | 2438 | |
| 2302 | 2439 | upgradeExit(); |
| 2303 | 2440 | } |
@@ -2312,25 +2449,26 @@ discard block |
||
| 2312 | 2449 | ob_implicit_flush(true); |
| 2313 | 2450 | @set_time_limit(600); |
| 2314 | 2451 | |
| 2315 | - if (!isset($_SERVER['argv'])) |
|
| 2316 | - $_SERVER['argv'] = array(); |
|
| 2452 | + if (!isset($_SERVER['argv'])) { |
|
| 2453 | + $_SERVER['argv'] = array(); |
|
| 2454 | + } |
|
| 2317 | 2455 | $_GET['maint'] = 1; |
| 2318 | 2456 | |
| 2319 | 2457 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2320 | 2458 | { |
| 2321 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2322 | - $_GET['lang'] = $match[1]; |
|
| 2323 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2324 | - continue; |
|
| 2325 | - elseif ($arg == '--no-maintenance') |
|
| 2326 | - $_GET['maint'] = 0; |
|
| 2327 | - elseif ($arg == '--debug') |
|
| 2328 | - $is_debug = true; |
|
| 2329 | - elseif ($arg == '--backup') |
|
| 2330 | - $_POST['backup'] = 1; |
|
| 2331 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2332 | - $_GET['conv'] = 1; |
|
| 2333 | - elseif ($i != 0) |
|
| 2459 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2460 | + $_GET['lang'] = $match[1]; |
|
| 2461 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2462 | + continue; |
|
| 2463 | + } elseif ($arg == '--no-maintenance') { |
|
| 2464 | + $_GET['maint'] = 0; |
|
| 2465 | + } elseif ($arg == '--debug') { |
|
| 2466 | + $is_debug = true; |
|
| 2467 | + } elseif ($arg == '--backup') { |
|
| 2468 | + $_POST['backup'] = 1; |
|
| 2469 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2470 | + $_GET['conv'] = 1; |
|
| 2471 | + } elseif ($i != 0) |
|
| 2334 | 2472 | { |
| 2335 | 2473 | echo 'SMF Command-line Upgrader |
| 2336 | 2474 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2344,10 +2482,12 @@ discard block |
||
| 2344 | 2482 | } |
| 2345 | 2483 | } |
| 2346 | 2484 | |
| 2347 | - if (!php_version_check()) |
|
| 2348 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2349 | - if (!db_version_check()) |
|
| 2350 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2485 | + if (!php_version_check()) { |
|
| 2486 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2487 | + } |
|
| 2488 | + if (!db_version_check()) { |
|
| 2489 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2490 | + } |
|
| 2351 | 2491 | |
| 2352 | 2492 | // Do some checks to make sure they have proper privileges |
| 2353 | 2493 | db_extend('packages'); |
@@ -2362,39 +2502,45 @@ discard block |
||
| 2362 | 2502 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2363 | 2503 | |
| 2364 | 2504 | // Sorry... we need CREATE, ALTER and DROP |
| 2365 | - if (!$create || !$alter || !$drop) |
|
| 2366 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2505 | + if (!$create || !$alter || !$drop) { |
|
| 2506 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2507 | + } |
|
| 2367 | 2508 | |
| 2368 | 2509 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2369 | 2510 | && @file_exists($sourcedir . '/QueryString.php') |
| 2370 | 2511 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2371 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2372 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2512 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2513 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2514 | + } |
|
| 2373 | 2515 | |
| 2374 | 2516 | // Do a quick version spot check. |
| 2375 | 2517 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2376 | 2518 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2377 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2378 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2519 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2520 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2521 | + } |
|
| 2379 | 2522 | |
| 2380 | 2523 | // Make sure Settings.php is writable. |
| 2381 | 2524 | quickFileWritable($boarddir . '/Settings.php'); |
| 2382 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2383 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2525 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2526 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2527 | + } |
|
| 2384 | 2528 | |
| 2385 | 2529 | // Make sure Settings_bak.php is writable. |
| 2386 | 2530 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2387 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2388 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2531 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2532 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2533 | + } |
|
| 2389 | 2534 | |
| 2390 | 2535 | // Make sure db_last_error.php is writable. |
| 2391 | 2536 | quickFileWritable($boarddir . '/db_last_error.php'); |
| 2392 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
| 2393 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2537 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
| 2538 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2539 | + } |
|
| 2394 | 2540 | |
| 2395 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2396 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2397 | - elseif (isset($modSettings['agreement'])) |
|
| 2541 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2542 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2543 | + } elseif (isset($modSettings['agreement'])) |
|
| 2398 | 2544 | { |
| 2399 | 2545 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2400 | 2546 | fwrite($fp, $modSettings['agreement']); |
@@ -2404,31 +2550,36 @@ discard block |
||
| 2404 | 2550 | // Make sure Themes is writable. |
| 2405 | 2551 | quickFileWritable($modSettings['theme_dir']); |
| 2406 | 2552 | |
| 2407 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2408 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2553 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2554 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2555 | + } |
|
| 2409 | 2556 | |
| 2410 | 2557 | // Make sure cache directory exists and is writable! |
| 2411 | 2558 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2412 | - if (!file_exists($cachedir_temp)) |
|
| 2413 | - @mkdir($cachedir_temp); |
|
| 2559 | + if (!file_exists($cachedir_temp)) { |
|
| 2560 | + @mkdir($cachedir_temp); |
|
| 2561 | + } |
|
| 2414 | 2562 | |
| 2415 | 2563 | // Make sure the cache temp dir is writable. |
| 2416 | 2564 | quickFileWritable($cachedir_temp); |
| 2417 | 2565 | |
| 2418 | - if (!is_writable($cachedir_temp)) |
|
| 2419 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2566 | + if (!is_writable($cachedir_temp)) { |
|
| 2567 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2568 | + } |
|
| 2420 | 2569 | |
| 2421 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2422 | - print_error('Error: Unable to find language files!', true); |
|
| 2423 | - else |
|
| 2570 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2571 | + print_error('Error: Unable to find language files!', true); |
|
| 2572 | + } else |
|
| 2424 | 2573 | { |
| 2425 | 2574 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2426 | 2575 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2427 | 2576 | |
| 2428 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2429 | - print_error('Error: Language files out of date.', true); |
|
| 2430 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2431 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2577 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2578 | + print_error('Error: Language files out of date.', true); |
|
| 2579 | + } |
|
| 2580 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2581 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2582 | + } |
|
| 2432 | 2583 | |
| 2433 | 2584 | // Otherwise include it! |
| 2434 | 2585 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2447,8 +2598,9 @@ discard block |
||
| 2447 | 2598 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2448 | 2599 | |
| 2449 | 2600 | // Done it already? |
| 2450 | - if (!empty($_POST['utf8_done'])) |
|
| 2451 | - return true; |
|
| 2601 | + if (!empty($_POST['utf8_done'])) { |
|
| 2602 | + return true; |
|
| 2603 | + } |
|
| 2452 | 2604 | |
| 2453 | 2605 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2454 | 2606 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2461,8 +2613,7 @@ discard block |
||
| 2461 | 2613 | ); |
| 2462 | 2614 | |
| 2463 | 2615 | return true; |
| 2464 | - } |
|
| 2465 | - else |
|
| 2616 | + } else |
|
| 2466 | 2617 | { |
| 2467 | 2618 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2468 | 2619 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2506,8 +2657,9 @@ discard block |
||
| 2506 | 2657 | ) |
| 2507 | 2658 | ); |
| 2508 | 2659 | $db_charsets = array(); |
| 2509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2510 | - $db_charsets[] = $row['Charset']; |
|
| 2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2661 | + $db_charsets[] = $row['Charset']; |
|
| 2662 | + } |
|
| 2511 | 2663 | |
| 2512 | 2664 | $smcFunc['db_free_result']($request); |
| 2513 | 2665 | |
@@ -2543,13 +2695,15 @@ discard block |
||
| 2543 | 2695 | // If there's a fulltext index, we need to drop it first... |
| 2544 | 2696 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2545 | 2697 | { |
| 2546 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2547 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2699 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2548 | 2700 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2701 | + } |
|
| 2549 | 2702 | $smcFunc['db_free_result']($request); |
| 2550 | 2703 | |
| 2551 | - if (isset($upcontext['fulltext_index'])) |
|
| 2552 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2704 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2705 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2706 | + } |
|
| 2553 | 2707 | } |
| 2554 | 2708 | |
| 2555 | 2709 | // Drop it and make a note... |
@@ -2739,8 +2893,9 @@ discard block |
||
| 2739 | 2893 | $replace = '%field%'; |
| 2740 | 2894 | |
| 2741 | 2895 | // Build a huge REPLACE statement... |
| 2742 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2743 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2896 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2897 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2898 | + } |
|
| 2744 | 2899 | } |
| 2745 | 2900 | |
| 2746 | 2901 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2750,9 +2905,10 @@ discard block |
||
| 2750 | 2905 | $upcontext['table_count'] = count($queryTables); |
| 2751 | 2906 | |
| 2752 | 2907 | // What ones have we already done? |
| 2753 | - foreach ($queryTables as $id => $table) |
|
| 2754 | - if ($id < $_GET['substep']) |
|
| 2908 | + foreach ($queryTables as $id => $table) { |
|
| 2909 | + if ($id < $_GET['substep']) |
|
| 2755 | 2910 | $upcontext['previous_tables'][] = $table; |
| 2911 | + } |
|
| 2756 | 2912 | |
| 2757 | 2913 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2758 | 2914 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2789,8 +2945,9 @@ discard block |
||
| 2789 | 2945 | nextSubstep($substep); |
| 2790 | 2946 | |
| 2791 | 2947 | // Just to make sure it doesn't time out. |
| 2792 | - if (function_exists('apache_reset_timeout')) |
|
| 2793 | - @apache_reset_timeout(); |
|
| 2948 | + if (function_exists('apache_reset_timeout')) { |
|
| 2949 | + @apache_reset_timeout(); |
|
| 2950 | + } |
|
| 2794 | 2951 | |
| 2795 | 2952 | $table_charsets = array(); |
| 2796 | 2953 | |
@@ -2813,8 +2970,9 @@ discard block |
||
| 2813 | 2970 | |
| 2814 | 2971 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2815 | 2972 | if ($charset != 'utf8') { |
| 2816 | - if (!isset($table_charsets[$charset])) |
|
| 2817 | - $table_charsets[$charset] = array(); |
|
| 2973 | + if (!isset($table_charsets[$charset])) { |
|
| 2974 | + $table_charsets[$charset] = array(); |
|
| 2975 | + } |
|
| 2818 | 2976 | |
| 2819 | 2977 | $table_charsets[$charset][] = $column_info; |
| 2820 | 2978 | } |
@@ -2855,10 +3013,11 @@ discard block |
||
| 2855 | 3013 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2856 | 3014 | { |
| 2857 | 3015 | $update = ''; |
| 2858 | - foreach ($table_charsets as $charset => $columns) |
|
| 2859 | - foreach ($columns as $column) |
|
| 3016 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3017 | + foreach ($columns as $column) |
|
| 2860 | 3018 | $update .= ' |
| 2861 | 3019 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3020 | + } |
|
| 2862 | 3021 | |
| 2863 | 3022 | $smcFunc['db_query']('', ' |
| 2864 | 3023 | UPDATE {raw:table_name} |
@@ -2883,8 +3042,9 @@ discard block |
||
| 2883 | 3042 | // Now do the actual conversion (if still needed). |
| 2884 | 3043 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2885 | 3044 | { |
| 2886 | - if ($command_line) |
|
| 2887 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3045 | + if ($command_line) { |
|
| 3046 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3047 | + } |
|
| 2888 | 3048 | |
| 2889 | 3049 | $smcFunc['db_query']('', ' |
| 2890 | 3050 | ALTER TABLE {raw:table_name} |
@@ -2894,12 +3054,14 @@ discard block |
||
| 2894 | 3054 | ) |
| 2895 | 3055 | ); |
| 2896 | 3056 | |
| 2897 | - if ($command_line) |
|
| 2898 | - echo " done.\n"; |
|
| 3057 | + if ($command_line) { |
|
| 3058 | + echo " done.\n"; |
|
| 3059 | + } |
|
| 2899 | 3060 | } |
| 2900 | 3061 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2901 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 2902 | - return upgradeExit(); |
|
| 3062 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3063 | + return upgradeExit(); |
|
| 3064 | + } |
|
| 2903 | 3065 | } |
| 2904 | 3066 | |
| 2905 | 3067 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2928,8 +3090,8 @@ discard block |
||
| 2928 | 3090 | ); |
| 2929 | 3091 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2930 | 3092 | { |
| 2931 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 2932 | - $smcFunc['db_query']('', ' |
|
| 3093 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3094 | + $smcFunc['db_query']('', ' |
|
| 2933 | 3095 | UPDATE {db_prefix}log_actions |
| 2934 | 3096 | SET extra = {string:extra} |
| 2935 | 3097 | WHERE id_action = {int:current_action}', |
@@ -2938,6 +3100,7 @@ discard block |
||
| 2938 | 3100 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2939 | 3101 | ) |
| 2940 | 3102 | ); |
| 3103 | + } |
|
| 2941 | 3104 | } |
| 2942 | 3105 | $smcFunc['db_free_result']($request); |
| 2943 | 3106 | |
@@ -2959,15 +3122,17 @@ discard block |
||
| 2959 | 3122 | // First thing's first - did we already do this? |
| 2960 | 3123 | if (!empty($modSettings['json_done'])) |
| 2961 | 3124 | { |
| 2962 | - if ($command_line) |
|
| 2963 | - return DeleteUpgrade(); |
|
| 2964 | - else |
|
| 2965 | - return true; |
|
| 3125 | + if ($command_line) { |
|
| 3126 | + return DeleteUpgrade(); |
|
| 3127 | + } else { |
|
| 3128 | + return true; |
|
| 3129 | + } |
|
| 2966 | 3130 | } |
| 2967 | 3131 | |
| 2968 | 3132 | // Done it already - js wise? |
| 2969 | - if (!empty($_POST['json_done'])) |
|
| 2970 | - return true; |
|
| 3133 | + if (!empty($_POST['json_done'])) { |
|
| 3134 | + return true; |
|
| 3135 | + } |
|
| 2971 | 3136 | |
| 2972 | 3137 | // List of tables affected by this function |
| 2973 | 3138 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2999,12 +3164,14 @@ discard block |
||
| 2999 | 3164 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3000 | 3165 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3001 | 3166 | |
| 3002 | - foreach ($keys as $id => $table) |
|
| 3003 | - if ($id < $_GET['substep']) |
|
| 3167 | + foreach ($keys as $id => $table) { |
|
| 3168 | + if ($id < $_GET['substep']) |
|
| 3004 | 3169 | $upcontext['previous_tables'][] = $table; |
| 3170 | + } |
|
| 3005 | 3171 | |
| 3006 | - if ($command_line) |
|
| 3007 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3172 | + if ($command_line) { |
|
| 3173 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3174 | + } |
|
| 3008 | 3175 | |
| 3009 | 3176 | if (!$support_js || isset($_GET['xml'])) |
| 3010 | 3177 | { |
@@ -3044,8 +3211,9 @@ discard block |
||
| 3044 | 3211 | |
| 3045 | 3212 | // Loop through and fix these... |
| 3046 | 3213 | $new_settings = array(); |
| 3047 | - if ($command_line) |
|
| 3048 | - echo "\n" . 'Fixing some settings...'; |
|
| 3214 | + if ($command_line) { |
|
| 3215 | + echo "\n" . 'Fixing some settings...'; |
|
| 3216 | + } |
|
| 3049 | 3217 | |
| 3050 | 3218 | foreach ($serialized_settings as $var) |
| 3051 | 3219 | { |
@@ -3053,22 +3221,24 @@ discard block |
||
| 3053 | 3221 | { |
| 3054 | 3222 | // Attempt to unserialize the setting |
| 3055 | 3223 | $temp = @safe_unserialize($modSettings[$var]); |
| 3056 | - if (!$temp && $command_line) |
|
| 3057 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3058 | - elseif ($temp !== false) |
|
| 3059 | - $new_settings[$var] = json_encode($temp); |
|
| 3224 | + if (!$temp && $command_line) { |
|
| 3225 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3226 | + } elseif ($temp !== false) { |
|
| 3227 | + $new_settings[$var] = json_encode($temp); |
|
| 3228 | + } |
|
| 3060 | 3229 | } |
| 3061 | 3230 | } |
| 3062 | 3231 | |
| 3063 | 3232 | // Update everything at once |
| 3064 | - if (!function_exists('cache_put_data')) |
|
| 3065 | - require_once($sourcedir . '/Load.php'); |
|
| 3233 | + if (!function_exists('cache_put_data')) { |
|
| 3234 | + require_once($sourcedir . '/Load.php'); |
|
| 3235 | + } |
|
| 3066 | 3236 | updateSettings($new_settings, true); |
| 3067 | 3237 | |
| 3068 | - if ($command_line) |
|
| 3069 | - echo ' done.'; |
|
| 3070 | - } |
|
| 3071 | - elseif ($table == 'themes') |
|
| 3238 | + if ($command_line) { |
|
| 3239 | + echo ' done.'; |
|
| 3240 | + } |
|
| 3241 | + } elseif ($table == 'themes') |
|
| 3072 | 3242 | { |
| 3073 | 3243 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3074 | 3244 | $query = $smcFunc['db_query']('', ' |
@@ -3087,10 +3257,11 @@ discard block |
||
| 3087 | 3257 | |
| 3088 | 3258 | if ($command_line) |
| 3089 | 3259 | { |
| 3090 | - if ($temp === false) |
|
| 3091 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3092 | - else |
|
| 3093 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3260 | + if ($temp === false) { |
|
| 3261 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3262 | + } else { |
|
| 3263 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3264 | + } |
|
| 3094 | 3265 | } |
| 3095 | 3266 | |
| 3096 | 3267 | if ($temp !== false) |
@@ -3112,15 +3283,15 @@ discard block |
||
| 3112 | 3283 | ) |
| 3113 | 3284 | ); |
| 3114 | 3285 | |
| 3115 | - if ($command_line) |
|
| 3116 | - echo ' done.'; |
|
| 3286 | + if ($command_line) { |
|
| 3287 | + echo ' done.'; |
|
| 3288 | + } |
|
| 3117 | 3289 | } |
| 3118 | 3290 | } |
| 3119 | 3291 | |
| 3120 | 3292 | $smcFunc['db_free_result']($query); |
| 3121 | 3293 | } |
| 3122 | - } |
|
| 3123 | - else |
|
| 3294 | + } else |
|
| 3124 | 3295 | { |
| 3125 | 3296 | // First item is always the key... |
| 3126 | 3297 | $key = $info[0]; |
@@ -3131,8 +3302,7 @@ discard block |
||
| 3131 | 3302 | { |
| 3132 | 3303 | $col_select = $info[1]; |
| 3133 | 3304 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3134 | - } |
|
| 3135 | - else |
|
| 3305 | + } else |
|
| 3136 | 3306 | { |
| 3137 | 3307 | $col_select = implode(', ', $info); |
| 3138 | 3308 | } |
@@ -3165,8 +3335,7 @@ discard block |
||
| 3165 | 3335 | if ($temp === false && $command_line) |
| 3166 | 3336 | { |
| 3167 | 3337 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3168 | - } |
|
| 3169 | - else |
|
| 3338 | + } else |
|
| 3170 | 3339 | { |
| 3171 | 3340 | $row[$col] = json_encode($temp); |
| 3172 | 3341 | |
@@ -3191,16 +3360,18 @@ discard block |
||
| 3191 | 3360 | } |
| 3192 | 3361 | } |
| 3193 | 3362 | |
| 3194 | - if ($command_line) |
|
| 3195 | - echo ' done.'; |
|
| 3363 | + if ($command_line) { |
|
| 3364 | + echo ' done.'; |
|
| 3365 | + } |
|
| 3196 | 3366 | |
| 3197 | 3367 | // Free up some memory... |
| 3198 | 3368 | $smcFunc['db_free_result']($query); |
| 3199 | 3369 | } |
| 3200 | 3370 | } |
| 3201 | 3371 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3202 | - if (isset($_GET['xml'])) |
|
| 3203 | - return upgradeExit(); |
|
| 3372 | + if (isset($_GET['xml'])) { |
|
| 3373 | + return upgradeExit(); |
|
| 3374 | + } |
|
| 3204 | 3375 | } |
| 3205 | 3376 | |
| 3206 | 3377 | if ($command_line) |
@@ -3215,8 +3386,9 @@ discard block |
||
| 3215 | 3386 | |
| 3216 | 3387 | $_GET['substep'] = 0; |
| 3217 | 3388 | // Make sure we move on! |
| 3218 | - if ($command_line) |
|
| 3219 | - return DeleteUpgrade(); |
|
| 3389 | + if ($command_line) { |
|
| 3390 | + return DeleteUpgrade(); |
|
| 3391 | + } |
|
| 3220 | 3392 | |
| 3221 | 3393 | return true; |
| 3222 | 3394 | } |
@@ -3236,14 +3408,16 @@ discard block |
||
| 3236 | 3408 | global $upcontext, $txt, $settings; |
| 3237 | 3409 | |
| 3238 | 3410 | // Don't call me twice! |
| 3239 | - if (!empty($upcontext['chmod_called'])) |
|
| 3240 | - return; |
|
| 3411 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3412 | + return; |
|
| 3413 | + } |
|
| 3241 | 3414 | |
| 3242 | 3415 | $upcontext['chmod_called'] = true; |
| 3243 | 3416 | |
| 3244 | 3417 | // Nothing? |
| 3245 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3246 | - return; |
|
| 3418 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3419 | + return; |
|
| 3420 | + } |
|
| 3247 | 3421 | |
| 3248 | 3422 | // Was it a problem with Windows? |
| 3249 | 3423 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3275,11 +3449,12 @@ discard block |
||
| 3275 | 3449 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3276 | 3450 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3277 | 3451 | |
| 3278 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3279 | - echo ' |
|
| 3452 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3453 | + echo ' |
|
| 3280 | 3454 | content.write(\'<hr>\n\t\t\t\'); |
| 3281 | 3455 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3282 | 3456 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3457 | + } |
|
| 3283 | 3458 | |
| 3284 | 3459 | echo ' |
| 3285 | 3460 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3287,17 +3462,19 @@ discard block |
||
| 3287 | 3462 | } |
| 3288 | 3463 | </script>'; |
| 3289 | 3464 | |
| 3290 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3291 | - echo ' |
|
| 3465 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3466 | + echo ' |
|
| 3292 | 3467 | <div class="error_message red"> |
| 3293 | 3468 | The following error was encountered when trying to connect:<br><br> |
| 3294 | 3469 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3295 | 3470 | </div> |
| 3296 | 3471 | <br>'; |
| 3472 | + } |
|
| 3297 | 3473 | |
| 3298 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3299 | - echo ' |
|
| 3474 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3475 | + echo ' |
|
| 3300 | 3476 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3477 | + } |
|
| 3301 | 3478 | |
| 3302 | 3479 | echo ' |
| 3303 | 3480 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3332,10 +3509,11 @@ discard block |
||
| 3332 | 3509 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3333 | 3510 | </div>'; |
| 3334 | 3511 | |
| 3335 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3336 | - echo ' |
|
| 3512 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3513 | + echo ' |
|
| 3337 | 3514 | </form>'; |
| 3338 | -} |
|
| 3515 | + } |
|
| 3516 | + } |
|
| 3339 | 3517 | |
| 3340 | 3518 | function template_upgrade_above() |
| 3341 | 3519 | { |
@@ -3395,9 +3573,10 @@ discard block |
||
| 3395 | 3573 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3396 | 3574 | <ul>'; |
| 3397 | 3575 | |
| 3398 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3399 | - echo ' |
|
| 3576 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3577 | + echo ' |
|
| 3400 | 3578 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3579 | + } |
|
| 3401 | 3580 | |
| 3402 | 3581 | echo ' |
| 3403 | 3582 | </ul> |
@@ -3410,8 +3589,8 @@ discard block |
||
| 3410 | 3589 | </div> |
| 3411 | 3590 | </div>'; |
| 3412 | 3591 | |
| 3413 | - if (isset($upcontext['step_progress'])) |
|
| 3414 | - echo ' |
|
| 3592 | + if (isset($upcontext['step_progress'])) { |
|
| 3593 | + echo ' |
|
| 3415 | 3594 | <br> |
| 3416 | 3595 | <br> |
| 3417 | 3596 | <div id="progress_bar_step"> |
@@ -3420,6 +3599,7 @@ discard block |
||
| 3420 | 3599 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3421 | 3600 | </div> |
| 3422 | 3601 | </div>'; |
| 3602 | + } |
|
| 3423 | 3603 | |
| 3424 | 3604 | echo ' |
| 3425 | 3605 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3450,32 +3630,36 @@ discard block |
||
| 3450 | 3630 | { |
| 3451 | 3631 | global $upcontext, $txt; |
| 3452 | 3632 | |
| 3453 | - if (!empty($upcontext['pause'])) |
|
| 3454 | - echo ' |
|
| 3633 | + if (!empty($upcontext['pause'])) { |
|
| 3634 | + echo ' |
|
| 3455 | 3635 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3456 | 3636 | |
| 3457 | 3637 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3458 | 3638 | <h3> |
| 3459 | 3639 | ', $txt['upgrade_paused_overload'], ' |
| 3460 | 3640 | </h3>'; |
| 3641 | + } |
|
| 3461 | 3642 | |
| 3462 | - if (!empty($upcontext['custom_warning'])) |
|
| 3463 | - echo ' |
|
| 3643 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3644 | + echo ' |
|
| 3464 | 3645 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3465 | 3646 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3466 | 3647 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3467 | 3648 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3468 | 3649 | </div>'; |
| 3650 | + } |
|
| 3469 | 3651 | |
| 3470 | 3652 | echo ' |
| 3471 | 3653 | <div class="righttext" style="margin: 1ex;">'; |
| 3472 | 3654 | |
| 3473 | - if (!empty($upcontext['continue'])) |
|
| 3474 | - echo ' |
|
| 3655 | + if (!empty($upcontext['continue'])) { |
|
| 3656 | + echo ' |
|
| 3475 | 3657 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3476 | - if (!empty($upcontext['skip'])) |
|
| 3477 | - echo ' |
|
| 3658 | + } |
|
| 3659 | + if (!empty($upcontext['skip'])) { |
|
| 3660 | + echo ' |
|
| 3478 | 3661 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3662 | + } |
|
| 3479 | 3663 | |
| 3480 | 3664 | echo ' |
| 3481 | 3665 | </div> |
@@ -3525,11 +3709,12 @@ discard block |
||
| 3525 | 3709 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3526 | 3710 | <smf>'; |
| 3527 | 3711 | |
| 3528 | - if (!empty($upcontext['get_data'])) |
|
| 3529 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3712 | + if (!empty($upcontext['get_data'])) { |
|
| 3713 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3530 | 3714 | echo ' |
| 3531 | 3715 | <get key="', $k, '">', $v, '</get>'; |
| 3532 | -} |
|
| 3716 | + } |
|
| 3717 | + } |
|
| 3533 | 3718 | |
| 3534 | 3719 | function template_xml_below() |
| 3535 | 3720 | { |
@@ -3570,8 +3755,8 @@ discard block |
||
| 3570 | 3755 | template_chmod(); |
| 3571 | 3756 | |
| 3572 | 3757 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3573 | - if ($upcontext['is_large_forum']) |
|
| 3574 | - echo ' |
|
| 3758 | + if ($upcontext['is_large_forum']) { |
|
| 3759 | + echo ' |
|
| 3575 | 3760 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3576 | 3761 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3577 | 3762 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3579,10 +3764,11 @@ discard block |
||
| 3579 | 3764 | ', $txt['upgrade_warning_lots_data'], ' |
| 3580 | 3765 | </div> |
| 3581 | 3766 | </div>'; |
| 3767 | + } |
|
| 3582 | 3768 | |
| 3583 | 3769 | // A warning message? |
| 3584 | - if (!empty($upcontext['warning'])) |
|
| 3585 | - echo ' |
|
| 3770 | + if (!empty($upcontext['warning'])) { |
|
| 3771 | + echo ' |
|
| 3586 | 3772 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3587 | 3773 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3588 | 3774 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3590,6 +3776,7 @@ discard block |
||
| 3590 | 3776 | ', $upcontext['warning'], ' |
| 3591 | 3777 | </div> |
| 3592 | 3778 | </div>'; |
| 3779 | + } |
|
| 3593 | 3780 | |
| 3594 | 3781 | // Paths are incorrect? |
| 3595 | 3782 | echo ' |
@@ -3605,20 +3792,22 @@ discard block |
||
| 3605 | 3792 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3606 | 3793 | { |
| 3607 | 3794 | $ago = time() - $upcontext['started']; |
| 3608 | - if ($ago < 60) |
|
| 3609 | - $ago = $ago . ' seconds'; |
|
| 3610 | - elseif ($ago < 3600) |
|
| 3611 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3612 | - else |
|
| 3613 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3795 | + if ($ago < 60) { |
|
| 3796 | + $ago = $ago . ' seconds'; |
|
| 3797 | + } elseif ($ago < 3600) { |
|
| 3798 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3799 | + } else { |
|
| 3800 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3801 | + } |
|
| 3614 | 3802 | |
| 3615 | 3803 | $active = time() - $upcontext['updated']; |
| 3616 | - if ($active < 60) |
|
| 3617 | - $updated = $active . ' seconds'; |
|
| 3618 | - elseif ($active < 3600) |
|
| 3619 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3620 | - else |
|
| 3621 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3804 | + if ($active < 60) { |
|
| 3805 | + $updated = $active . ' seconds'; |
|
| 3806 | + } elseif ($active < 3600) { |
|
| 3807 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3808 | + } else { |
|
| 3809 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3810 | + } |
|
| 3622 | 3811 | |
| 3623 | 3812 | echo ' |
| 3624 | 3813 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3627,16 +3816,18 @@ discard block |
||
| 3627 | 3816 | <div style="padding-left: 6ex;"> |
| 3628 | 3817 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3629 | 3818 | |
| 3630 | - if ($active < 600) |
|
| 3631 | - echo ' |
|
| 3819 | + if ($active < 600) { |
|
| 3820 | + echo ' |
|
| 3632 | 3821 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3822 | + } |
|
| 3633 | 3823 | |
| 3634 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3635 | - echo ' |
|
| 3824 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3825 | + echo ' |
|
| 3636 | 3826 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3637 | - else |
|
| 3638 | - echo ' |
|
| 3827 | + } else { |
|
| 3828 | + echo ' |
|
| 3639 | 3829 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3830 | + } |
|
| 3640 | 3831 | |
| 3641 | 3832 | echo ' |
| 3642 | 3833 | </div> |
@@ -3652,9 +3843,10 @@ discard block |
||
| 3652 | 3843 | <td> |
| 3653 | 3844 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3654 | 3845 | |
| 3655 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3656 | - echo ' |
|
| 3846 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3847 | + echo ' |
|
| 3657 | 3848 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3849 | + } |
|
| 3658 | 3850 | |
| 3659 | 3851 | echo ' |
| 3660 | 3852 | </td> |
@@ -3665,9 +3857,10 @@ discard block |
||
| 3665 | 3857 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3666 | 3858 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3667 | 3859 | |
| 3668 | - if (!empty($upcontext['password_failed'])) |
|
| 3669 | - echo ' |
|
| 3860 | + if (!empty($upcontext['password_failed'])) { |
|
| 3861 | + echo ' |
|
| 3670 | 3862 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3863 | + } |
|
| 3671 | 3864 | |
| 3672 | 3865 | echo ' |
| 3673 | 3866 | </td> |
@@ -3738,8 +3931,8 @@ discard block |
||
| 3738 | 3931 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3739 | 3932 | |
| 3740 | 3933 | // Warning message? |
| 3741 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3742 | - echo ' |
|
| 3934 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3935 | + echo ' |
|
| 3743 | 3936 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3744 | 3937 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3745 | 3938 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3747,6 +3940,7 @@ discard block |
||
| 3747 | 3940 | ', $upcontext['upgrade_options_warning'], ' |
| 3748 | 3941 | </div> |
| 3749 | 3942 | </div>'; |
| 3943 | + } |
|
| 3750 | 3944 | |
| 3751 | 3945 | echo ' |
| 3752 | 3946 | <table> |
@@ -3789,8 +3983,8 @@ discard block |
||
| 3789 | 3983 | </td> |
| 3790 | 3984 | </tr>'; |
| 3791 | 3985 | |
| 3792 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3793 | - echo ' |
|
| 3986 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3987 | + echo ' |
|
| 3794 | 3988 | <tr valign="top"> |
| 3795 | 3989 | <td width="2%"> |
| 3796 | 3990 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3799,6 +3993,7 @@ discard block |
||
| 3799 | 3993 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3800 | 3994 | </td> |
| 3801 | 3995 | </tr>'; |
| 3996 | + } |
|
| 3802 | 3997 | |
| 3803 | 3998 | echo ' |
| 3804 | 3999 | <tr valign="top"> |
@@ -3836,10 +4031,11 @@ discard block |
||
| 3836 | 4031 | </div>'; |
| 3837 | 4032 | |
| 3838 | 4033 | // Dont any tables so far? |
| 3839 | - if (!empty($upcontext['previous_tables'])) |
|
| 3840 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4034 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4035 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3841 | 4036 | echo ' |
| 3842 | 4037 | <br>Completed Table: "', $table, '".'; |
| 4038 | + } |
|
| 3843 | 4039 | |
| 3844 | 4040 | echo ' |
| 3845 | 4041 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3876,12 +4072,13 @@ discard block |
||
| 3876 | 4072 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3877 | 4073 | |
| 3878 | 4074 | // If debug flood the screen. |
| 3879 | - if ($is_debug) |
|
| 3880 | - echo ' |
|
| 4075 | + if ($is_debug) { |
|
| 4076 | + echo ' |
|
| 3881 | 4077 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3882 | 4078 | |
| 3883 | 4079 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3884 | 4080 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4081 | + } |
|
| 3885 | 4082 | |
| 3886 | 4083 | echo ' |
| 3887 | 4084 | // Get the next update... |
@@ -3914,8 +4111,9 @@ discard block |
||
| 3914 | 4111 | { |
| 3915 | 4112 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3916 | 4113 | |
| 3917 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3918 | - $is_debug = true; |
|
| 4114 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4115 | + $is_debug = true; |
|
| 4116 | + } |
|
| 3919 | 4117 | |
| 3920 | 4118 | echo ' |
| 3921 | 4119 | <h3>Executing database changes</h3> |
@@ -3930,8 +4128,9 @@ discard block |
||
| 3930 | 4128 | { |
| 3931 | 4129 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3932 | 4130 | { |
| 3933 | - if ($num != 0) |
|
| 3934 | - echo ' Successful!'; |
|
| 4131 | + if ($num != 0) { |
|
| 4132 | + echo ' Successful!'; |
|
| 4133 | + } |
|
| 3935 | 4134 | echo '<br>' . $item; |
| 3936 | 4135 | } |
| 3937 | 4136 | if (!empty($upcontext['changes_complete'])) |
@@ -3944,28 +4143,32 @@ discard block |
||
| 3944 | 4143 | $seconds = intval($active % 60); |
| 3945 | 4144 | |
| 3946 | 4145 | $totalTime = ''; |
| 3947 | - if ($hours > 0) |
|
| 3948 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3949 | - if ($minutes > 0) |
|
| 3950 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3951 | - if ($seconds > 0) |
|
| 3952 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4146 | + if ($hours > 0) { |
|
| 4147 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4148 | + } |
|
| 4149 | + if ($minutes > 0) { |
|
| 4150 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4151 | + } |
|
| 4152 | + if ($seconds > 0) { |
|
| 4153 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4154 | + } |
|
| 3953 | 4155 | } |
| 3954 | 4156 | |
| 3955 | - if ($is_debug && !empty($totalTime)) |
|
| 3956 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3957 | - else |
|
| 3958 | - echo ' Successful!<br><br>'; |
|
| 4157 | + if ($is_debug && !empty($totalTime)) { |
|
| 4158 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4159 | + } else { |
|
| 4160 | + echo ' Successful!<br><br>'; |
|
| 4161 | + } |
|
| 3959 | 4162 | |
| 3960 | 4163 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3961 | 4164 | } |
| 3962 | - } |
|
| 3963 | - else |
|
| 4165 | + } else |
|
| 3964 | 4166 | { |
| 3965 | 4167 | // Tell them how many files we have in total. |
| 3966 | - if ($upcontext['file_count'] > 1) |
|
| 3967 | - echo ' |
|
| 4168 | + if ($upcontext['file_count'] > 1) { |
|
| 4169 | + echo ' |
|
| 3968 | 4170 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4171 | + } |
|
| 3969 | 4172 | |
| 3970 | 4173 | echo ' |
| 3971 | 4174 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3981,19 +4184,23 @@ discard block |
||
| 3981 | 4184 | $seconds = intval($active % 60); |
| 3982 | 4185 | |
| 3983 | 4186 | $totalTime = ''; |
| 3984 | - if ($hours > 0) |
|
| 3985 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3986 | - if ($minutes > 0) |
|
| 3987 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3988 | - if ($seconds > 0) |
|
| 3989 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4187 | + if ($hours > 0) { |
|
| 4188 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4189 | + } |
|
| 4190 | + if ($minutes > 0) { |
|
| 4191 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4192 | + } |
|
| 4193 | + if ($seconds > 0) { |
|
| 4194 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4195 | + } |
|
| 3990 | 4196 | } |
| 3991 | 4197 | |
| 3992 | 4198 | echo ' |
| 3993 | 4199 | <br><span id="upgradeCompleted">'; |
| 3994 | 4200 | |
| 3995 | - if (!empty($totalTime)) |
|
| 3996 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4201 | + if (!empty($totalTime)) { |
|
| 4202 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4203 | + } |
|
| 3997 | 4204 | |
| 3998 | 4205 | echo '</span> |
| 3999 | 4206 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4030,9 +4237,10 @@ discard block |
||
| 4030 | 4237 | var getData = ""; |
| 4031 | 4238 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4032 | 4239 | |
| 4033 | - if ($is_debug) |
|
| 4034 | - echo ' |
|
| 4240 | + if ($is_debug) { |
|
| 4241 | + echo ' |
|
| 4035 | 4242 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4243 | + } |
|
| 4036 | 4244 | |
| 4037 | 4245 | echo ' |
| 4038 | 4246 | function getNextItem() |
@@ -4072,9 +4280,10 @@ discard block |
||
| 4072 | 4280 | document.getElementById("error_block").style.display = ""; |
| 4073 | 4281 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4074 | 4282 | |
| 4075 | - if ($is_debug) |
|
| 4076 | - echo ' |
|
| 4283 | + if ($is_debug) { |
|
| 4284 | + echo ' |
|
| 4077 | 4285 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4286 | + } |
|
| 4078 | 4287 | |
| 4079 | 4288 | echo ' |
| 4080 | 4289 | } |
@@ -4095,9 +4304,10 @@ discard block |
||
| 4095 | 4304 | document.getElementById("error_block").style.display = ""; |
| 4096 | 4305 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4097 | 4306 | |
| 4098 | - if ($is_debug) |
|
| 4099 | - echo ' |
|
| 4307 | + if ($is_debug) { |
|
| 4308 | + echo ' |
|
| 4100 | 4309 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4310 | + } |
|
| 4101 | 4311 | |
| 4102 | 4312 | echo ' |
| 4103 | 4313 | } |
@@ -4156,8 +4366,8 @@ discard block |
||
| 4156 | 4366 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4157 | 4367 | {'; |
| 4158 | 4368 | |
| 4159 | - if ($is_debug) |
|
| 4160 | - echo ' |
|
| 4369 | + if ($is_debug) { |
|
| 4370 | + echo ' |
|
| 4161 | 4371 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4162 | 4372 | |
| 4163 | 4373 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4175,6 +4385,7 @@ discard block |
||
| 4175 | 4385 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4176 | 4386 | |
| 4177 | 4387 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4388 | + } |
|
| 4178 | 4389 | |
| 4179 | 4390 | echo ' |
| 4180 | 4391 | |
@@ -4182,9 +4393,10 @@ discard block |
||
| 4182 | 4393 | document.getElementById(\'contbutt\').disabled = 0; |
| 4183 | 4394 | document.getElementById(\'database_done\').value = 1;'; |
| 4184 | 4395 | |
| 4185 | - if ($upcontext['file_count'] > 1) |
|
| 4186 | - echo ' |
|
| 4396 | + if ($upcontext['file_count'] > 1) { |
|
| 4397 | + echo ' |
|
| 4187 | 4398 | document.getElementById(\'info1\').style.display = "none";'; |
| 4399 | + } |
|
| 4188 | 4400 | |
| 4189 | 4401 | echo ' |
| 4190 | 4402 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4197,9 +4409,10 @@ discard block |
||
| 4197 | 4409 | lastItem = 0; |
| 4198 | 4410 | prevFile = curFile;'; |
| 4199 | 4411 | |
| 4200 | - if ($is_debug) |
|
| 4201 | - echo ' |
|
| 4412 | + if ($is_debug) { |
|
| 4413 | + echo ' |
|
| 4202 | 4414 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4415 | + } |
|
| 4203 | 4416 | |
| 4204 | 4417 | echo ' |
| 4205 | 4418 | getNextItem(); |
@@ -4207,8 +4420,8 @@ discard block |
||
| 4207 | 4420 | }'; |
| 4208 | 4421 | |
| 4209 | 4422 | // If debug scroll the screen. |
| 4210 | - if ($is_debug) |
|
| 4211 | - echo ' |
|
| 4423 | + if ($is_debug) { |
|
| 4424 | + echo ' |
|
| 4212 | 4425 | if (iLastSubStepProgress == -1) |
| 4213 | 4426 | { |
| 4214 | 4427 | // Give it consistent dots. |
@@ -4227,6 +4440,7 @@ discard block |
||
| 4227 | 4440 | |
| 4228 | 4441 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4229 | 4442 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4443 | + } |
|
| 4230 | 4444 | |
| 4231 | 4445 | echo ' |
| 4232 | 4446 | // Update the page. |
@@ -4287,9 +4501,10 @@ discard block |
||
| 4287 | 4501 | }'; |
| 4288 | 4502 | |
| 4289 | 4503 | // Start things off assuming we've not errored. |
| 4290 | - if (empty($upcontext['error_message'])) |
|
| 4291 | - echo ' |
|
| 4504 | + if (empty($upcontext['error_message'])) { |
|
| 4505 | + echo ' |
|
| 4292 | 4506 | getNextItem();'; |
| 4507 | + } |
|
| 4293 | 4508 | |
| 4294 | 4509 | echo ' |
| 4295 | 4510 | //# sourceURL=dynamicScript-dbch.js |
@@ -4307,18 +4522,21 @@ discard block |
||
| 4307 | 4522 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4308 | 4523 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4309 | 4524 | |
| 4310 | - if (!empty($upcontext['error_message'])) |
|
| 4311 | - echo ' |
|
| 4525 | + if (!empty($upcontext['error_message'])) { |
|
| 4526 | + echo ' |
|
| 4312 | 4527 | <error>', $upcontext['error_message'], '</error>'; |
| 4528 | + } |
|
| 4313 | 4529 | |
| 4314 | - if (!empty($upcontext['error_string'])) |
|
| 4315 | - echo ' |
|
| 4530 | + if (!empty($upcontext['error_string'])) { |
|
| 4531 | + echo ' |
|
| 4316 | 4532 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4533 | + } |
|
| 4317 | 4534 | |
| 4318 | - if ($is_debug) |
|
| 4319 | - echo ' |
|
| 4535 | + if ($is_debug) { |
|
| 4536 | + echo ' |
|
| 4320 | 4537 | <curtime>', time(), '</curtime>'; |
| 4321 | -} |
|
| 4538 | + } |
|
| 4539 | + } |
|
| 4322 | 4540 | |
| 4323 | 4541 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4324 | 4542 | function template_convert_utf8() |
@@ -4337,18 +4555,20 @@ discard block |
||
| 4337 | 4555 | </div>'; |
| 4338 | 4556 | |
| 4339 | 4557 | // Done any tables so far? |
| 4340 | - if (!empty($upcontext['previous_tables'])) |
|
| 4341 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4558 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4559 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4342 | 4560 | echo ' |
| 4343 | 4561 | <br>Completed Table: "', $table, '".'; |
| 4562 | + } |
|
| 4344 | 4563 | |
| 4345 | 4564 | echo ' |
| 4346 | 4565 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4347 | 4566 | |
| 4348 | 4567 | // If we dropped their index, let's let them know |
| 4349 | - if ($upcontext['dropping_index']) |
|
| 4350 | - echo ' |
|
| 4568 | + if ($upcontext['dropping_index']) { |
|
| 4569 | + echo ' |
|
| 4351 | 4570 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4571 | + } |
|
| 4352 | 4572 | |
| 4353 | 4573 | // Completion notification |
| 4354 | 4574 | echo ' |
@@ -4385,12 +4605,13 @@ discard block |
||
| 4385 | 4605 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4386 | 4606 | |
| 4387 | 4607 | // If debug flood the screen. |
| 4388 | - if ($is_debug) |
|
| 4389 | - echo ' |
|
| 4608 | + if ($is_debug) { |
|
| 4609 | + echo ' |
|
| 4390 | 4610 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4391 | 4611 | |
| 4392 | 4612 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4393 | 4613 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4614 | + } |
|
| 4394 | 4615 | |
| 4395 | 4616 | echo ' |
| 4396 | 4617 | // Get the next update... |
@@ -4438,19 +4659,21 @@ discard block |
||
| 4438 | 4659 | </div>'; |
| 4439 | 4660 | |
| 4440 | 4661 | // Dont any tables so far? |
| 4441 | - if (!empty($upcontext['previous_tables'])) |
|
| 4442 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4662 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4663 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4443 | 4664 | echo ' |
| 4444 | 4665 | <br>Completed Table: "', $table, '".'; |
| 4666 | + } |
|
| 4445 | 4667 | |
| 4446 | 4668 | echo ' |
| 4447 | 4669 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4448 | 4670 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4449 | 4671 | |
| 4450 | 4672 | // Try to make sure substep was reset. |
| 4451 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4452 | - echo ' |
|
| 4673 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4674 | + echo ' |
|
| 4453 | 4675 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4676 | + } |
|
| 4454 | 4677 | |
| 4455 | 4678 | // Continue please! |
| 4456 | 4679 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4483,12 +4706,13 @@ discard block |
||
| 4483 | 4706 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4484 | 4707 | |
| 4485 | 4708 | // If debug flood the screen. |
| 4486 | - if ($is_debug) |
|
| 4487 | - echo ' |
|
| 4709 | + if ($is_debug) { |
|
| 4710 | + echo ' |
|
| 4488 | 4711 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4489 | 4712 | |
| 4490 | 4713 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4491 | 4714 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4715 | + } |
|
| 4492 | 4716 | |
| 4493 | 4717 | echo ' |
| 4494 | 4718 | // Get the next update... |
@@ -4524,8 +4748,8 @@ discard block |
||
| 4524 | 4748 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4525 | 4749 | <form action="', $boardurl, '/index.php">'; |
| 4526 | 4750 | |
| 4527 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4528 | - echo ' |
|
| 4751 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4752 | + echo ' |
|
| 4529 | 4753 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4530 | 4754 | <script> |
| 4531 | 4755 | function doTheDelete(theCheck) |
@@ -4537,6 +4761,7 @@ discard block |
||
| 4537 | 4761 | } |
| 4538 | 4762 | </script> |
| 4539 | 4763 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4764 | + } |
|
| 4540 | 4765 | |
| 4541 | 4766 | $active = time() - $upcontext['started']; |
| 4542 | 4767 | $hours = floor($active / 3600); |
@@ -4546,16 +4771,20 @@ discard block |
||
| 4546 | 4771 | if ($is_debug) |
| 4547 | 4772 | { |
| 4548 | 4773 | $totalTime = ''; |
| 4549 | - if ($hours > 0) |
|
| 4550 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4551 | - if ($minutes > 0) |
|
| 4552 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4553 | - if ($seconds > 0) |
|
| 4554 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4774 | + if ($hours > 0) { |
|
| 4775 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4776 | + } |
|
| 4777 | + if ($minutes > 0) { |
|
| 4778 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4779 | + } |
|
| 4780 | + if ($seconds > 0) { |
|
| 4781 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4782 | + } |
|
| 4555 | 4783 | } |
| 4556 | 4784 | |
| 4557 | - if ($is_debug && !empty($totalTime)) |
|
| 4558 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4785 | + if ($is_debug && !empty($totalTime)) { |
|
| 4786 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4787 | + } |
|
| 4559 | 4788 | |
| 4560 | 4789 | echo '<br> |
| 4561 | 4790 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4582,8 +4811,9 @@ discard block |
||
| 4582 | 4811 | |
| 4583 | 4812 | $current_substep = $_GET['substep']; |
| 4584 | 4813 | |
| 4585 | - if (empty($_GET['a'])) |
|
| 4586 | - $_GET['a'] = 0; |
|
| 4814 | + if (empty($_GET['a'])) { |
|
| 4815 | + $_GET['a'] = 0; |
|
| 4816 | + } |
|
| 4587 | 4817 | $step_progress['name'] = 'Converting ips'; |
| 4588 | 4818 | $step_progress['current'] = $_GET['a']; |
| 4589 | 4819 | |
@@ -4626,16 +4856,19 @@ discard block |
||
| 4626 | 4856 | 'empty' => '', |
| 4627 | 4857 | 'limit' => $limit, |
| 4628 | 4858 | )); |
| 4629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4630 | - $arIp[] = $row[$oldCol]; |
|
| 4859 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4860 | + $arIp[] = $row[$oldCol]; |
|
| 4861 | + } |
|
| 4631 | 4862 | $smcFunc['db_free_result']($request); |
| 4632 | 4863 | |
| 4633 | 4864 | // Special case, null ip could keep us in a loop. |
| 4634 | - if (is_null($arIp[0])) |
|
| 4635 | - unset($arIp[0]); |
|
| 4865 | + if (is_null($arIp[0])) { |
|
| 4866 | + unset($arIp[0]); |
|
| 4867 | + } |
|
| 4636 | 4868 | |
| 4637 | - if (empty($arIp)) |
|
| 4638 | - $is_done = true; |
|
| 4869 | + if (empty($arIp)) { |
|
| 4870 | + $is_done = true; |
|
| 4871 | + } |
|
| 4639 | 4872 | |
| 4640 | 4873 | $updates = array(); |
| 4641 | 4874 | $cases = array(); |
@@ -4644,16 +4877,18 @@ discard block |
||
| 4644 | 4877 | { |
| 4645 | 4878 | $arIp[$i] = trim($arIp[$i]); |
| 4646 | 4879 | |
| 4647 | - if (empty($arIp[$i])) |
|
| 4648 | - continue; |
|
| 4880 | + if (empty($arIp[$i])) { |
|
| 4881 | + continue; |
|
| 4882 | + } |
|
| 4649 | 4883 | |
| 4650 | 4884 | $updates['ip' . $i] = $arIp[$i]; |
| 4651 | 4885 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4652 | 4886 | |
| 4653 | 4887 | if ($setSize > 0 && $i % $setSize === 0) |
| 4654 | 4888 | { |
| 4655 | - if (count($updates) == 1) |
|
| 4656 | - continue; |
|
| 4889 | + if (count($updates) == 1) { |
|
| 4890 | + continue; |
|
| 4891 | + } |
|
| 4657 | 4892 | |
| 4658 | 4893 | $updates['whereSet'] = array_values($updates); |
| 4659 | 4894 | $smcFunc['db_query']('', ' |
@@ -4687,8 +4922,7 @@ discard block |
||
| 4687 | 4922 | 'ip' => $ip |
| 4688 | 4923 | )); |
| 4689 | 4924 | } |
| 4690 | - } |
|
| 4691 | - else |
|
| 4925 | + } else |
|
| 4692 | 4926 | { |
| 4693 | 4927 | $updates['whereSet'] = array_values($updates); |
| 4694 | 4928 | $smcFunc['db_query']('', ' |
@@ -4702,9 +4936,9 @@ discard block |
||
| 4702 | 4936 | $updates |
| 4703 | 4937 | ); |
| 4704 | 4938 | } |
| 4939 | + } else { |
|
| 4940 | + $is_done = true; |
|
| 4705 | 4941 | } |
| 4706 | - else |
|
| 4707 | - $is_done = true; |
|
| 4708 | 4942 | |
| 4709 | 4943 | $_GET['a'] += $limit; |
| 4710 | 4944 | $step_progress['current'] = $_GET['a']; |
@@ -4730,10 +4964,11 @@ discard block |
||
| 4730 | 4964 | |
| 4731 | 4965 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4732 | 4966 | |
| 4733 | - if (isset($columns[$column])) |
|
| 4734 | - return $columns[$column]; |
|
| 4735 | - else |
|
| 4736 | - return null; |
|
| 4737 | -} |
|
| 4967 | + if (isset($columns[$column])) { |
|
| 4968 | + return $columns[$column]; |
|
| 4969 | + } else { |
|
| 4970 | + return null; |
|
| 4971 | + } |
|
| 4972 | + } |
|
| 4738 | 4973 | |
| 4739 | 4974 | ?> |
| 4740 | 4975 | \ No newline at end of file |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Don't do anything if SMF is already loaded. |
| 15 | -if (defined('SMF')) |
|
| 15 | +if (defined('SMF')) { |
|
| 16 | 16 | return true; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | define('SMF', 'SSI'); |
| 19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
| 28 | 29 | $time_start = microtime(true); |
| 29 | 30 | |
| 30 | 31 | // Just being safe... |
| 31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 32 | 33 | if (isset($GLOBALS[$variable])) |
| 33 | 34 | unset($GLOBALS[$variable]); |
| 35 | +} |
|
| 34 | 36 | |
| 35 | 37 | // Get the forum's settings for database and file paths. |
| 36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 37 | 39 | |
| 38 | 40 | // Make absolutely sure the cache directory is defined. |
| 39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 40 | 42 | $cachedir = $boarddir . '/cache'; |
| 43 | +} |
|
| 41 | 44 | |
| 42 | 45 | $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
| 48 | 51 | $ssi_on_error_method = false; |
| 49 | 52 | |
| 50 | 53 | // Don't do john didley if the forum's been shut down completely. |
| 51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
| 54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
| 52 | 55 | die($mmessage); |
| 56 | +} |
|
| 53 | 57 | |
| 54 | 58 | // Fix for using the current directory as a path. |
| 55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 61 | +} |
|
| 57 | 62 | |
| 58 | 63 | // Load the important includes. |
| 59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,34 +83,38 @@ discard block |
||
| 78 | 83 | cleanRequest(); |
| 79 | 84 | |
| 80 | 85 | // Seed the random generator? |
| 81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 82 | 87 | smf_seed_generator(); |
| 88 | +} |
|
| 83 | 89 | |
| 84 | 90 | // Check on any hacking attempts. |
| 85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 86 | 92 | die('No direct access...'); |
| 87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
| 93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
| 88 | 94 | die('No direct access...'); |
| 89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
| 95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
| 90 | 96 | die('No direct access...'); |
| 91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
| 97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
| 92 | 98 | die('No direct access...'); |
| 93 | -if (isset($_REQUEST['context'])) |
|
| 99 | +} |
|
| 100 | +if (isset($_REQUEST['context'])) { |
|
| 94 | 101 | die('No direct access...'); |
| 102 | +} |
|
| 95 | 103 | |
| 96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
| 97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
| 105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
| 98 | 106 | ob_start('ob_gzhandler'); |
| 99 | -else |
|
| 107 | +} else { |
|
| 100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
| 109 | +} |
|
| 101 | 110 | |
| 102 | 111 | // Primarily, this is to fix the URLs... |
| 103 | 112 | ob_start('ob_sessrewrite'); |
| 104 | 113 | |
| 105 | 114 | // Start the session... known to scramble SSI includes in cases... |
| 106 | -if (!headers_sent()) |
|
| 115 | +if (!headers_sent()) { |
|
| 107 | 116 | loadSession(); |
| 108 | -else |
|
| 117 | +} else |
|
| 109 | 118 | { |
| 110 | 119 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
| 111 | 120 | { |
@@ -139,12 +148,14 @@ discard block |
||
| 139 | 148 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
| 140 | 149 | |
| 141 | 150 | // @todo: probably not the best place, but somewhere it should be set... |
| 142 | -if (!headers_sent()) |
|
| 151 | +if (!headers_sent()) { |
|
| 143 | 152 | header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
| 153 | +} |
|
| 144 | 154 | |
| 145 | 155 | // Take care of any banning that needs to be done. |
| 146 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
| 156 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
| 147 | 157 | is_not_banned(); |
| 158 | +} |
|
| 148 | 159 | |
| 149 | 160 | // Do we allow guests in here? |
| 150 | 161 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -159,17 +170,19 @@ discard block |
||
| 159 | 170 | { |
| 160 | 171 | $context['template_layers'] = $ssi_layers; |
| 161 | 172 | template_header(); |
| 162 | -} |
|
| 163 | -else |
|
| 173 | +} else { |
|
| 164 | 174 | setupThemeContext(); |
| 175 | +} |
|
| 165 | 176 | |
| 166 | 177 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
| 167 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
| 178 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
| 168 | 179 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
| 180 | +} |
|
| 169 | 181 | |
| 170 | 182 | // Without visiting the forum this session variable might not be set on submit. |
| 171 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
| 183 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
| 172 | 184 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
| 185 | +} |
|
| 173 | 186 | |
| 174 | 187 | // Have the ability to easily add functions to SSI. |
| 175 | 188 | call_integration_hook('integrate_SSI'); |
@@ -178,11 +191,13 @@ discard block |
||
| 178 | 191 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
| 179 | 192 | { |
| 180 | 193 | // You shouldn't just access SSI.php directly by URL!! |
| 181 | - if (!isset($_GET['ssi_function'])) |
|
| 182 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
| 194 | + if (!isset($_GET['ssi_function'])) { |
|
| 195 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
| 196 | + } |
|
| 183 | 197 | // Call a function passed by GET. |
| 184 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
| 185 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
| 198 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
| 199 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
| 200 | + } |
|
| 186 | 201 | exit; |
| 187 | 202 | } |
| 188 | 203 | |
@@ -199,9 +214,10 @@ discard block |
||
| 199 | 214 | */ |
| 200 | 215 | function ssi_shutdown() |
| 201 | 216 | { |
| 202 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
| 203 | - template_footer(); |
|
| 204 | -} |
|
| 217 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
| 218 | + template_footer(); |
|
| 219 | + } |
|
| 220 | + } |
|
| 205 | 221 | |
| 206 | 222 | /** |
| 207 | 223 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -214,15 +230,17 @@ discard block |
||
| 214 | 230 | |
| 215 | 231 | if ($output_method == 'echo') |
| 216 | 232 | { |
| 217 | - if ($context['user']['is_guest']) |
|
| 218 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 219 | - else |
|
| 220 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 233 | + if ($context['user']['is_guest']) { |
|
| 234 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 235 | + } else { |
|
| 236 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 237 | + } |
|
| 221 | 238 | } |
| 222 | 239 | // Don't echo... then do what?! |
| 223 | - else |
|
| 224 | - return $context['user']; |
|
| 225 | -} |
|
| 240 | + else { |
|
| 241 | + return $context['user']; |
|
| 242 | + } |
|
| 243 | + } |
|
| 226 | 244 | |
| 227 | 245 | /** |
| 228 | 246 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -233,12 +251,14 @@ discard block |
||
| 233 | 251 | { |
| 234 | 252 | global $context; |
| 235 | 253 | |
| 236 | - if ($output_method == 'echo') |
|
| 237 | - template_menu(); |
|
| 254 | + if ($output_method == 'echo') { |
|
| 255 | + template_menu(); |
|
| 256 | + } |
|
| 238 | 257 | // What else could this do? |
| 239 | - else |
|
| 240 | - return $context['menu_buttons']; |
|
| 241 | -} |
|
| 258 | + else { |
|
| 259 | + return $context['menu_buttons']; |
|
| 260 | + } |
|
| 261 | + } |
|
| 242 | 262 | |
| 243 | 263 | /** |
| 244 | 264 | * Show a logout link. |
@@ -250,20 +270,23 @@ discard block |
||
| 250 | 270 | { |
| 251 | 271 | global $context, $txt, $scripturl; |
| 252 | 272 | |
| 253 | - if ($redirect_to != '') |
|
| 254 | - $_SESSION['logout_url'] = $redirect_to; |
|
| 273 | + if ($redirect_to != '') { |
|
| 274 | + $_SESSION['logout_url'] = $redirect_to; |
|
| 275 | + } |
|
| 255 | 276 | |
| 256 | 277 | // Guests can't log out. |
| 257 | - if ($context['user']['is_guest']) |
|
| 258 | - return false; |
|
| 278 | + if ($context['user']['is_guest']) { |
|
| 279 | + return false; |
|
| 280 | + } |
|
| 259 | 281 | |
| 260 | 282 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
| 261 | 283 | |
| 262 | - if ($output_method == 'echo') |
|
| 263 | - echo $link; |
|
| 264 | - else |
|
| 265 | - return $link; |
|
| 266 | -} |
|
| 284 | + if ($output_method == 'echo') { |
|
| 285 | + echo $link; |
|
| 286 | + } else { |
|
| 287 | + return $link; |
|
| 288 | + } |
|
| 289 | + } |
|
| 267 | 290 | |
| 268 | 291 | /** |
| 269 | 292 | * Recent post list: [board] Subject by Poster Date |
@@ -279,17 +302,17 @@ discard block |
||
| 279 | 302 | global $modSettings, $context; |
| 280 | 303 | |
| 281 | 304 | // Excluding certain boards... |
| 282 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 283 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 284 | - else |
|
| 285 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 305 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 306 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 307 | + } else { |
|
| 308 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 309 | + } |
|
| 286 | 310 | |
| 287 | 311 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
| 288 | 312 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 289 | 313 | { |
| 290 | 314 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 291 | - } |
|
| 292 | - elseif ($include_boards != null) |
|
| 315 | + } elseif ($include_boards != null) |
|
| 293 | 316 | { |
| 294 | 317 | $include_boards = array(); |
| 295 | 318 | } |
@@ -326,8 +349,9 @@ discard block |
||
| 326 | 349 | { |
| 327 | 350 | global $modSettings; |
| 328 | 351 | |
| 329 | - if (empty($post_ids)) |
|
| 330 | - return; |
|
| 352 | + if (empty($post_ids)) { |
|
| 353 | + return; |
|
| 354 | + } |
|
| 331 | 355 | |
| 332 | 356 | // Allow the user to request more than one - why not? |
| 333 | 357 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -362,8 +386,9 @@ discard block |
||
| 362 | 386 | global $scripturl, $txt, $user_info; |
| 363 | 387 | global $modSettings, $smcFunc, $context; |
| 364 | 388 | |
| 365 | - if (!empty($modSettings['enable_likes'])) |
|
| 366 | - $context['can_like'] = allowedTo('likes_like'); |
|
| 389 | + if (!empty($modSettings['enable_likes'])) { |
|
| 390 | + $context['can_like'] = allowedTo('likes_like'); |
|
| 391 | + } |
|
| 367 | 392 | |
| 368 | 393 | // Find all the posts. Newer ones will have higher IDs. |
| 369 | 394 | $request = $smcFunc['db_query']('substring', ' |
@@ -429,12 +454,13 @@ discard block |
||
| 429 | 454 | ); |
| 430 | 455 | |
| 431 | 456 | // Get the likes for each message. |
| 432 | - if (!empty($modSettings['enable_likes'])) |
|
| 433 | - $posts[$row['id_msg']]['likes'] = array( |
|
| 457 | + if (!empty($modSettings['enable_likes'])) { |
|
| 458 | + $posts[$row['id_msg']]['likes'] = array( |
|
| 434 | 459 | 'count' => $row['likes'], |
| 435 | 460 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
| 436 | 461 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 437 | 462 | ); |
| 463 | + } |
|
| 438 | 464 | } |
| 439 | 465 | $smcFunc['db_free_result']($request); |
| 440 | 466 | |
@@ -442,13 +468,14 @@ discard block |
||
| 442 | 468 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
| 443 | 469 | |
| 444 | 470 | // Just return it. |
| 445 | - if ($output_method != 'echo' || empty($posts)) |
|
| 446 | - return $posts; |
|
| 471 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 472 | + return $posts; |
|
| 473 | + } |
|
| 447 | 474 | |
| 448 | 475 | echo ' |
| 449 | 476 | <table style="border: none" class="ssi_table">'; |
| 450 | - foreach ($posts as $post) |
|
| 451 | - echo ' |
|
| 477 | + foreach ($posts as $post) { |
|
| 478 | + echo ' |
|
| 452 | 479 | <tr> |
| 453 | 480 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 454 | 481 | [', $post['board']['link'], '] |
@@ -462,6 +489,7 @@ discard block |
||
| 462 | 489 | ', $post['time'], ' |
| 463 | 490 | </td> |
| 464 | 491 | </tr>'; |
| 492 | + } |
|
| 465 | 493 | echo ' |
| 466 | 494 | </table>'; |
| 467 | 495 | } |
@@ -479,25 +507,26 @@ discard block |
||
| 479 | 507 | global $settings, $scripturl, $txt, $user_info; |
| 480 | 508 | global $modSettings, $smcFunc, $context; |
| 481 | 509 | |
| 482 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 483 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 484 | - else |
|
| 485 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 510 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 511 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 512 | + } else { |
|
| 513 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 514 | + } |
|
| 486 | 515 | |
| 487 | 516 | // Only some boards?. |
| 488 | 517 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 489 | 518 | { |
| 490 | 519 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 491 | - } |
|
| 492 | - elseif ($include_boards != null) |
|
| 520 | + } elseif ($include_boards != null) |
|
| 493 | 521 | { |
| 494 | 522 | $output_method = $include_boards; |
| 495 | 523 | $include_boards = array(); |
| 496 | 524 | } |
| 497 | 525 | |
| 498 | 526 | $icon_sources = array(); |
| 499 | - foreach ($context['stable_icons'] as $icon) |
|
| 500 | - $icon_sources[$icon] = 'images_url'; |
|
| 527 | + foreach ($context['stable_icons'] as $icon) { |
|
| 528 | + $icon_sources[$icon] = 'images_url'; |
|
| 529 | + } |
|
| 501 | 530 | |
| 502 | 531 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
| 503 | 532 | $request = $smcFunc['db_query']('substring', ' |
@@ -522,13 +551,15 @@ discard block |
||
| 522 | 551 | ) |
| 523 | 552 | ); |
| 524 | 553 | $topics = array(); |
| 525 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 526 | - $topics[$row['id_topic']] = $row; |
|
| 554 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 555 | + $topics[$row['id_topic']] = $row; |
|
| 556 | + } |
|
| 527 | 557 | $smcFunc['db_free_result']($request); |
| 528 | 558 | |
| 529 | 559 | // Did we find anything? If not, bail. |
| 530 | - if (empty($topics)) |
|
| 531 | - return array(); |
|
| 560 | + if (empty($topics)) { |
|
| 561 | + return array(); |
|
| 562 | + } |
|
| 532 | 563 | |
| 533 | 564 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 534 | 565 | |
@@ -556,19 +587,22 @@ discard block |
||
| 556 | 587 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 557 | 588 | { |
| 558 | 589 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 559 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 560 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 590 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 591 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 592 | + } |
|
| 561 | 593 | |
| 562 | 594 | // Censor the subject. |
| 563 | 595 | censorText($row['subject']); |
| 564 | 596 | censorText($row['body']); |
| 565 | 597 | |
| 566 | 598 | // Recycled icon |
| 567 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
| 568 | - $row['icon'] = 'recycled'; |
|
| 599 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
| 600 | + $row['icon'] = 'recycled'; |
|
| 601 | + } |
|
| 569 | 602 | |
| 570 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 571 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 603 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 604 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 605 | + } |
|
| 572 | 606 | |
| 573 | 607 | // Build the array. |
| 574 | 608 | $posts[] = array( |
@@ -607,13 +641,14 @@ discard block |
||
| 607 | 641 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
| 608 | 642 | |
| 609 | 643 | // Just return it. |
| 610 | - if ($output_method != 'echo' || empty($posts)) |
|
| 611 | - return $posts; |
|
| 644 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 645 | + return $posts; |
|
| 646 | + } |
|
| 612 | 647 | |
| 613 | 648 | echo ' |
| 614 | 649 | <table style="border: none" class="ssi_table">'; |
| 615 | - foreach ($posts as $post) |
|
| 616 | - echo ' |
|
| 650 | + foreach ($posts as $post) { |
|
| 651 | + echo ' |
|
| 617 | 652 | <tr> |
| 618 | 653 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 619 | 654 | [', $post['board']['link'], '] |
@@ -627,6 +662,7 @@ discard block |
||
| 627 | 662 | ', $post['time'], ' |
| 628 | 663 | </td> |
| 629 | 664 | </tr>'; |
| 665 | + } |
|
| 630 | 666 | echo ' |
| 631 | 667 | </table>'; |
| 632 | 668 | } |
@@ -651,27 +687,30 @@ discard block |
||
| 651 | 687 | ) |
| 652 | 688 | ); |
| 653 | 689 | $return = array(); |
| 654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 655 | - $return[] = array( |
|
| 690 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 691 | + $return[] = array( |
|
| 656 | 692 | 'id' => $row['id_member'], |
| 657 | 693 | 'name' => $row['real_name'], |
| 658 | 694 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
| 659 | 695 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
| 660 | 696 | 'posts' => $row['posts'] |
| 661 | 697 | ); |
| 698 | + } |
|
| 662 | 699 | $smcFunc['db_free_result']($request); |
| 663 | 700 | |
| 664 | 701 | // If mods want to do somthing with this list of members, let them do that now. |
| 665 | 702 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
| 666 | 703 | |
| 667 | 704 | // Just return all the top posters. |
| 668 | - if ($output_method != 'echo') |
|
| 669 | - return $return; |
|
| 705 | + if ($output_method != 'echo') { |
|
| 706 | + return $return; |
|
| 707 | + } |
|
| 670 | 708 | |
| 671 | 709 | // Make a quick array to list the links in. |
| 672 | 710 | $temp_array = array(); |
| 673 | - foreach ($return as $member) |
|
| 674 | - $temp_array[] = $member['link']; |
|
| 711 | + foreach ($return as $member) { |
|
| 712 | + $temp_array[] = $member['link']; |
|
| 713 | + } |
|
| 675 | 714 | |
| 676 | 715 | echo implode(', ', $temp_array); |
| 677 | 716 | } |
@@ -703,8 +742,8 @@ discard block |
||
| 703 | 742 | ) |
| 704 | 743 | ); |
| 705 | 744 | $boards = array(); |
| 706 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 707 | - $boards[] = array( |
|
| 745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 746 | + $boards[] = array( |
|
| 708 | 747 | 'id' => $row['id_board'], |
| 709 | 748 | 'num_posts' => $row['num_posts'], |
| 710 | 749 | 'num_topics' => $row['num_topics'], |
@@ -713,14 +752,16 @@ discard block |
||
| 713 | 752 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
| 714 | 753 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
| 715 | 754 | ); |
| 755 | + } |
|
| 716 | 756 | $smcFunc['db_free_result']($request); |
| 717 | 757 | |
| 718 | 758 | // If mods want to do somthing with this list of boards, let them do that now. |
| 719 | 759 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
| 720 | 760 | |
| 721 | 761 | // If we shouldn't output or have nothing to output, just jump out. |
| 722 | - if ($output_method != 'echo' || empty($boards)) |
|
| 723 | - return $boards; |
|
| 762 | + if ($output_method != 'echo' || empty($boards)) { |
|
| 763 | + return $boards; |
|
| 764 | + } |
|
| 724 | 765 | |
| 725 | 766 | echo ' |
| 726 | 767 | <table class="ssi_table"> |
@@ -729,13 +770,14 @@ discard block |
||
| 729 | 770 | <th style="text-align: left">', $txt['board_topics'], '</th> |
| 730 | 771 | <th style="text-align: left">', $txt['posts'], '</th> |
| 731 | 772 | </tr>'; |
| 732 | - foreach ($boards as $sBoard) |
|
| 733 | - echo ' |
|
| 773 | + foreach ($boards as $sBoard) { |
|
| 774 | + echo ' |
|
| 734 | 775 | <tr> |
| 735 | 776 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
| 736 | 777 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
| 737 | 778 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
| 738 | 779 | </tr>'; |
| 780 | + } |
|
| 739 | 781 | echo ' |
| 740 | 782 | </table>'; |
| 741 | 783 | } |
@@ -768,12 +810,13 @@ discard block |
||
| 768 | 810 | ) |
| 769 | 811 | ); |
| 770 | 812 | $topic_ids = array(); |
| 771 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 772 | - $topic_ids[] = $row['id_topic']; |
|
| 813 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 814 | + $topic_ids[] = $row['id_topic']; |
|
| 815 | + } |
|
| 773 | 816 | $smcFunc['db_free_result']($request); |
| 817 | + } else { |
|
| 818 | + $topic_ids = array(); |
|
| 774 | 819 | } |
| 775 | - else |
|
| 776 | - $topic_ids = array(); |
|
| 777 | 820 | |
| 778 | 821 | $request = $smcFunc['db_query']('', ' |
| 779 | 822 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -812,8 +855,9 @@ discard block |
||
| 812 | 855 | // If mods want to do somthing with this list of topics, let them do that now. |
| 813 | 856 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
| 814 | 857 | |
| 815 | - if ($output_method != 'echo' || empty($topics)) |
|
| 816 | - return $topics; |
|
| 858 | + if ($output_method != 'echo' || empty($topics)) { |
|
| 859 | + return $topics; |
|
| 860 | + } |
|
| 817 | 861 | |
| 818 | 862 | echo ' |
| 819 | 863 | <table class="ssi_table"> |
@@ -822,8 +866,8 @@ discard block |
||
| 822 | 866 | <th style="text-align: left">', $txt['views'], '</th> |
| 823 | 867 | <th style="text-align: left">', $txt['replies'], '</th> |
| 824 | 868 | </tr>'; |
| 825 | - foreach ($topics as $sTopic) |
|
| 826 | - echo ' |
|
| 869 | + foreach ($topics as $sTopic) { |
|
| 870 | + echo ' |
|
| 827 | 871 | <tr> |
| 828 | 872 | <td style="text-align: left"> |
| 829 | 873 | ', $sTopic['link'], ' |
@@ -831,6 +875,7 @@ discard block |
||
| 831 | 875 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
| 832 | 876 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
| 833 | 877 | </tr>'; |
| 878 | + } |
|
| 834 | 879 | echo ' |
| 835 | 880 | </table>'; |
| 836 | 881 | } |
@@ -866,12 +911,13 @@ discard block |
||
| 866 | 911 | { |
| 867 | 912 | global $txt, $context; |
| 868 | 913 | |
| 869 | - if ($output_method == 'echo') |
|
| 870 | - echo ' |
|
| 914 | + if ($output_method == 'echo') { |
|
| 915 | + echo ' |
|
| 871 | 916 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
| 872 | - else |
|
| 873 | - return $context['common_stats']['latest_member']; |
|
| 874 | -} |
|
| 917 | + } else { |
|
| 918 | + return $context['common_stats']['latest_member']; |
|
| 919 | + } |
|
| 920 | + } |
|
| 875 | 921 | |
| 876 | 922 | /** |
| 877 | 923 | * Fetches a random member. |
@@ -920,8 +966,9 @@ discard block |
||
| 920 | 966 | } |
| 921 | 967 | |
| 922 | 968 | // Just to be sure put the random generator back to something... random. |
| 923 | - if ($random_type != '') |
|
| 924 | - mt_srand(time()); |
|
| 969 | + if ($random_type != '') { |
|
| 970 | + mt_srand(time()); |
|
| 971 | + } |
|
| 925 | 972 | |
| 926 | 973 | return $result; |
| 927 | 974 | } |
@@ -934,8 +981,9 @@ discard block |
||
| 934 | 981 | */ |
| 935 | 982 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
| 936 | 983 | { |
| 937 | - if (empty($member_ids)) |
|
| 938 | - return; |
|
| 984 | + if (empty($member_ids)) { |
|
| 985 | + return; |
|
| 986 | + } |
|
| 939 | 987 | |
| 940 | 988 | // Can have more than one member if you really want... |
| 941 | 989 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -960,8 +1008,9 @@ discard block |
||
| 960 | 1008 | */ |
| 961 | 1009 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
| 962 | 1010 | { |
| 963 | - if ($group_id === null) |
|
| 964 | - return; |
|
| 1011 | + if ($group_id === null) { |
|
| 1012 | + return; |
|
| 1013 | + } |
|
| 965 | 1014 | |
| 966 | 1015 | $query_where = ' |
| 967 | 1016 | id_group = {int:id_group} |
@@ -988,8 +1037,9 @@ discard block |
||
| 988 | 1037 | { |
| 989 | 1038 | global $smcFunc, $memberContext; |
| 990 | 1039 | |
| 991 | - if ($query_where === null) |
|
| 992 | - return; |
|
| 1040 | + if ($query_where === null) { |
|
| 1041 | + return; |
|
| 1042 | + } |
|
| 993 | 1043 | |
| 994 | 1044 | // Fetch the members in question. |
| 995 | 1045 | $request = $smcFunc['db_query']('', ' |
@@ -1002,12 +1052,14 @@ discard block |
||
| 1002 | 1052 | )) |
| 1003 | 1053 | ); |
| 1004 | 1054 | $members = array(); |
| 1005 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1006 | - $members[] = $row['id_member']; |
|
| 1055 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1056 | + $members[] = $row['id_member']; |
|
| 1057 | + } |
|
| 1007 | 1058 | $smcFunc['db_free_result']($request); |
| 1008 | 1059 | |
| 1009 | - if (empty($members)) |
|
| 1010 | - return array(); |
|
| 1060 | + if (empty($members)) { |
|
| 1061 | + return array(); |
|
| 1062 | + } |
|
| 1011 | 1063 | |
| 1012 | 1064 | // If mods want to do somthing with this list of members, let them do that now. |
| 1013 | 1065 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1016,23 +1068,25 @@ discard block |
||
| 1016 | 1068 | loadMemberData($members); |
| 1017 | 1069 | |
| 1018 | 1070 | // Draw the table! |
| 1019 | - if ($output_method == 'echo') |
|
| 1020 | - echo ' |
|
| 1071 | + if ($output_method == 'echo') { |
|
| 1072 | + echo ' |
|
| 1021 | 1073 | <table style="border: none" class="ssi_table">'; |
| 1074 | + } |
|
| 1022 | 1075 | |
| 1023 | 1076 | $query_members = array(); |
| 1024 | 1077 | foreach ($members as $member) |
| 1025 | 1078 | { |
| 1026 | 1079 | // Load their context data. |
| 1027 | - if (!loadMemberContext($member)) |
|
| 1028 | - continue; |
|
| 1080 | + if (!loadMemberContext($member)) { |
|
| 1081 | + continue; |
|
| 1082 | + } |
|
| 1029 | 1083 | |
| 1030 | 1084 | // Store this member's information. |
| 1031 | 1085 | $query_members[$member] = $memberContext[$member]; |
| 1032 | 1086 | |
| 1033 | 1087 | // Only do something if we're echo'ing. |
| 1034 | - if ($output_method == 'echo') |
|
| 1035 | - echo ' |
|
| 1088 | + if ($output_method == 'echo') { |
|
| 1089 | + echo ' |
|
| 1036 | 1090 | <tr> |
| 1037 | 1091 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 1038 | 1092 | ', $query_members[$member]['link'], ' |
@@ -1040,12 +1094,14 @@ discard block |
||
| 1040 | 1094 | <br>', $query_members[$member]['avatar']['image'], ' |
| 1041 | 1095 | </td> |
| 1042 | 1096 | </tr>'; |
| 1097 | + } |
|
| 1043 | 1098 | } |
| 1044 | 1099 | |
| 1045 | 1100 | // End the table if appropriate. |
| 1046 | - if ($output_method == 'echo') |
|
| 1047 | - echo ' |
|
| 1101 | + if ($output_method == 'echo') { |
|
| 1102 | + echo ' |
|
| 1048 | 1103 | </table>'; |
| 1104 | + } |
|
| 1049 | 1105 | |
| 1050 | 1106 | // Send back the data. |
| 1051 | 1107 | return $query_members; |
@@ -1060,8 +1116,9 @@ discard block |
||
| 1060 | 1116 | { |
| 1061 | 1117 | global $txt, $scripturl, $modSettings, $smcFunc; |
| 1062 | 1118 | |
| 1063 | - if (!allowedTo('view_stats')) |
|
| 1064 | - return; |
|
| 1119 | + if (!allowedTo('view_stats')) { |
|
| 1120 | + return; |
|
| 1121 | + } |
|
| 1065 | 1122 | |
| 1066 | 1123 | $totals = array( |
| 1067 | 1124 | 'members' => $modSettings['totalMembers'], |
@@ -1090,8 +1147,9 @@ discard block |
||
| 1090 | 1147 | // If mods want to do somthing with the board stats, let them do that now. |
| 1091 | 1148 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
| 1092 | 1149 | |
| 1093 | - if ($output_method != 'echo') |
|
| 1094 | - return $totals; |
|
| 1150 | + if ($output_method != 'echo') { |
|
| 1151 | + return $totals; |
|
| 1152 | + } |
|
| 1095 | 1153 | |
| 1096 | 1154 | echo ' |
| 1097 | 1155 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1120,8 +1178,8 @@ discard block |
||
| 1120 | 1178 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
| 1121 | 1179 | |
| 1122 | 1180 | // Add some redundancy for backwards compatibility reasons. |
| 1123 | - if ($output_method != 'echo') |
|
| 1124 | - return $return + array( |
|
| 1181 | + if ($output_method != 'echo') { |
|
| 1182 | + return $return + array( |
|
| 1125 | 1183 | 'users' => $return['users_online'], |
| 1126 | 1184 | 'guests' => $return['num_guests'], |
| 1127 | 1185 | 'hidden' => $return['num_users_hidden'], |
@@ -1129,29 +1187,35 @@ discard block |
||
| 1129 | 1187 | 'num_users' => $return['num_users_online'], |
| 1130 | 1188 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
| 1131 | 1189 | ); |
| 1190 | + } |
|
| 1132 | 1191 | |
| 1133 | 1192 | echo ' |
| 1134 | 1193 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
| 1135 | 1194 | |
| 1136 | 1195 | $bracketList = array(); |
| 1137 | - if (!empty($user_info['buddies'])) |
|
| 1138 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1139 | - if (!empty($return['num_spiders'])) |
|
| 1140 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1141 | - if (!empty($return['num_users_hidden'])) |
|
| 1142 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1196 | + if (!empty($user_info['buddies'])) { |
|
| 1197 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1198 | + } |
|
| 1199 | + if (!empty($return['num_spiders'])) { |
|
| 1200 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1201 | + } |
|
| 1202 | + if (!empty($return['num_users_hidden'])) { |
|
| 1203 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1204 | + } |
|
| 1143 | 1205 | |
| 1144 | - if (!empty($bracketList)) |
|
| 1145 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1206 | + if (!empty($bracketList)) { |
|
| 1207 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1208 | + } |
|
| 1146 | 1209 | |
| 1147 | 1210 | echo '<br> |
| 1148 | 1211 | ', implode(', ', $return['list_users_online']); |
| 1149 | 1212 | |
| 1150 | 1213 | // Showing membergroups? |
| 1151 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
| 1152 | - echo '<br> |
|
| 1214 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
| 1215 | + echo '<br> |
|
| 1153 | 1216 | [' . implode('] [', $return['membergroups']) . ']'; |
| 1154 | -} |
|
| 1217 | + } |
|
| 1218 | + } |
|
| 1155 | 1219 | |
| 1156 | 1220 | /** |
| 1157 | 1221 | * Just like whosOnline except it also logs the online presence. |
@@ -1162,11 +1226,12 @@ discard block |
||
| 1162 | 1226 | { |
| 1163 | 1227 | writeLog(); |
| 1164 | 1228 | |
| 1165 | - if ($output_method != 'echo') |
|
| 1166 | - return ssi_whosOnline($output_method); |
|
| 1167 | - else |
|
| 1168 | - ssi_whosOnline($output_method); |
|
| 1169 | -} |
|
| 1229 | + if ($output_method != 'echo') { |
|
| 1230 | + return ssi_whosOnline($output_method); |
|
| 1231 | + } else { |
|
| 1232 | + ssi_whosOnline($output_method); |
|
| 1233 | + } |
|
| 1234 | + } |
|
| 1170 | 1235 | |
| 1171 | 1236 | // Shows a login box. |
| 1172 | 1237 | /** |
@@ -1179,11 +1244,13 @@ discard block |
||
| 1179 | 1244 | { |
| 1180 | 1245 | global $scripturl, $txt, $user_info, $context; |
| 1181 | 1246 | |
| 1182 | - if ($redirect_to != '') |
|
| 1183 | - $_SESSION['login_url'] = $redirect_to; |
|
| 1247 | + if ($redirect_to != '') { |
|
| 1248 | + $_SESSION['login_url'] = $redirect_to; |
|
| 1249 | + } |
|
| 1184 | 1250 | |
| 1185 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
| 1186 | - return $user_info['is_guest']; |
|
| 1251 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
| 1252 | + return $user_info['is_guest']; |
|
| 1253 | + } |
|
| 1187 | 1254 | |
| 1188 | 1255 | // Create a login token |
| 1189 | 1256 | createToken('login'); |
@@ -1235,8 +1302,9 @@ discard block |
||
| 1235 | 1302 | |
| 1236 | 1303 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
| 1237 | 1304 | |
| 1238 | - if (empty($boardsAllowed)) |
|
| 1239 | - return array(); |
|
| 1305 | + if (empty($boardsAllowed)) { |
|
| 1306 | + return array(); |
|
| 1307 | + } |
|
| 1240 | 1308 | |
| 1241 | 1309 | $request = $smcFunc['db_query']('', ' |
| 1242 | 1310 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1269,12 +1337,14 @@ discard block |
||
| 1269 | 1337 | $smcFunc['db_free_result']($request); |
| 1270 | 1338 | |
| 1271 | 1339 | // This user has voted on all the polls. |
| 1272 | - if (empty($row) || !is_array($row)) |
|
| 1273 | - return array(); |
|
| 1340 | + if (empty($row) || !is_array($row)) { |
|
| 1341 | + return array(); |
|
| 1342 | + } |
|
| 1274 | 1343 | |
| 1275 | 1344 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
| 1276 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
| 1277 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1345 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
| 1346 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1347 | + } |
|
| 1278 | 1348 | |
| 1279 | 1349 | $request = $smcFunc['db_query']('', ' |
| 1280 | 1350 | SELECT COUNT(DISTINCT id_member) |
@@ -1338,8 +1408,9 @@ discard block |
||
| 1338 | 1408 | // If mods want to do somthing with this list of polls, let them do that now. |
| 1339 | 1409 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
| 1340 | 1410 | |
| 1341 | - if ($output_method != 'echo') |
|
| 1342 | - return $return; |
|
| 1411 | + if ($output_method != 'echo') { |
|
| 1412 | + return $return; |
|
| 1413 | + } |
|
| 1343 | 1414 | |
| 1344 | 1415 | if ($allow_view_results) |
| 1345 | 1416 | { |
@@ -1348,19 +1419,20 @@ discard block |
||
| 1348 | 1419 | <strong>', $return['question'], '</strong><br> |
| 1349 | 1420 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1350 | 1421 | |
| 1351 | - foreach ($return['options'] as $option) |
|
| 1352 | - echo ' |
|
| 1422 | + foreach ($return['options'] as $option) { |
|
| 1423 | + echo ' |
|
| 1353 | 1424 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1425 | + } |
|
| 1354 | 1426 | |
| 1355 | 1427 | echo ' |
| 1356 | 1428 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
| 1357 | 1429 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1358 | 1430 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1359 | 1431 | </form>'; |
| 1432 | + } else { |
|
| 1433 | + echo $txt['poll_cannot_see']; |
|
| 1434 | + } |
|
| 1360 | 1435 | } |
| 1361 | - else |
|
| 1362 | - echo $txt['poll_cannot_see']; |
|
| 1363 | -} |
|
| 1364 | 1436 | |
| 1365 | 1437 | /** |
| 1366 | 1438 | * Shows the poll from the specified topic |
@@ -1374,13 +1446,15 @@ discard block |
||
| 1374 | 1446 | |
| 1375 | 1447 | $boardsAllowed = boardsAllowedTo('poll_view'); |
| 1376 | 1448 | |
| 1377 | - if (empty($boardsAllowed)) |
|
| 1378 | - return array(); |
|
| 1449 | + if (empty($boardsAllowed)) { |
|
| 1450 | + return array(); |
|
| 1451 | + } |
|
| 1379 | 1452 | |
| 1380 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
| 1381 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1382 | - else |
|
| 1383 | - $topic = (int) $topic; |
|
| 1453 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
| 1454 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1455 | + } else { |
|
| 1456 | + $topic = (int) $topic; |
|
| 1457 | + } |
|
| 1384 | 1458 | |
| 1385 | 1459 | $request = $smcFunc['db_query']('', ' |
| 1386 | 1460 | SELECT |
@@ -1401,17 +1475,18 @@ discard block |
||
| 1401 | 1475 | ); |
| 1402 | 1476 | |
| 1403 | 1477 | // Either this topic has no poll, or the user cannot view it. |
| 1404 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1405 | - return array(); |
|
| 1478 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1479 | + return array(); |
|
| 1480 | + } |
|
| 1406 | 1481 | |
| 1407 | 1482 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1408 | 1483 | $smcFunc['db_free_result']($request); |
| 1409 | 1484 | |
| 1410 | 1485 | // Check if they can vote. |
| 1411 | 1486 | $already_voted = false; |
| 1412 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
| 1413 | - $allow_vote = false; |
|
| 1414 | - elseif ($user_info['is_guest']) |
|
| 1487 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
| 1488 | + $allow_vote = false; |
|
| 1489 | + } elseif ($user_info['is_guest']) |
|
| 1415 | 1490 | { |
| 1416 | 1491 | // There's a difference between "allowed to vote" and "already voted"... |
| 1417 | 1492 | $allow_vote = $row['guest_vote']; |
@@ -1421,10 +1496,9 @@ discard block |
||
| 1421 | 1496 | { |
| 1422 | 1497 | $already_voted = true; |
| 1423 | 1498 | } |
| 1424 | - } |
|
| 1425 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
| 1426 | - $allow_vote = false; |
|
| 1427 | - else |
|
| 1499 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
| 1500 | + $allow_vote = false; |
|
| 1501 | + } else |
|
| 1428 | 1502 | { |
| 1429 | 1503 | $request = $smcFunc['db_query']('', ' |
| 1430 | 1504 | SELECT id_member |
@@ -1506,8 +1580,9 @@ discard block |
||
| 1506 | 1580 | // If mods want to do somthing with this poll, let them do that now. |
| 1507 | 1581 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
| 1508 | 1582 | |
| 1509 | - if ($output_method != 'echo') |
|
| 1510 | - return $return; |
|
| 1583 | + if ($output_method != 'echo') { |
|
| 1584 | + return $return; |
|
| 1585 | + } |
|
| 1511 | 1586 | |
| 1512 | 1587 | if ($return['allow_vote']) |
| 1513 | 1588 | { |
@@ -1516,17 +1591,17 @@ discard block |
||
| 1516 | 1591 | <strong>', $return['question'], '</strong><br> |
| 1517 | 1592 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1518 | 1593 | |
| 1519 | - foreach ($return['options'] as $option) |
|
| 1520 | - echo ' |
|
| 1594 | + foreach ($return['options'] as $option) { |
|
| 1595 | + echo ' |
|
| 1521 | 1596 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1597 | + } |
|
| 1522 | 1598 | |
| 1523 | 1599 | echo ' |
| 1524 | 1600 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
| 1525 | 1601 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1526 | 1602 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1527 | 1603 | </form>'; |
| 1528 | - } |
|
| 1529 | - else |
|
| 1604 | + } else |
|
| 1530 | 1605 | { |
| 1531 | 1606 | echo ' |
| 1532 | 1607 | <div class="ssi_poll"> |
@@ -1606,27 +1681,32 @@ discard block |
||
| 1606 | 1681 | 'is_approved' => 1, |
| 1607 | 1682 | ) |
| 1608 | 1683 | ); |
| 1609 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1610 | - die; |
|
| 1684 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1685 | + die; |
|
| 1686 | + } |
|
| 1611 | 1687 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1612 | 1688 | $smcFunc['db_free_result']($request); |
| 1613 | 1689 | |
| 1614 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 1615 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1690 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 1691 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1692 | + } |
|
| 1616 | 1693 | |
| 1617 | 1694 | // Too many options checked? |
| 1618 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 1619 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1695 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 1696 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1697 | + } |
|
| 1620 | 1698 | |
| 1621 | 1699 | // It's a guest who has already voted? |
| 1622 | 1700 | if ($user_info['is_guest']) |
| 1623 | 1701 | { |
| 1624 | 1702 | // Guest voting disabled? |
| 1625 | - if (!$row['guest_vote']) |
|
| 1626 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1703 | + if (!$row['guest_vote']) { |
|
| 1704 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1705 | + } |
|
| 1627 | 1706 | // Already voted? |
| 1628 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
| 1629 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1707 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
| 1708 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1709 | + } |
|
| 1630 | 1710 | } |
| 1631 | 1711 | |
| 1632 | 1712 | $sOptions = array(); |
@@ -1680,11 +1760,13 @@ discard block |
||
| 1680 | 1760 | { |
| 1681 | 1761 | global $scripturl, $txt, $context; |
| 1682 | 1762 | |
| 1683 | - if (!allowedTo('search_posts')) |
|
| 1684 | - return; |
|
| 1763 | + if (!allowedTo('search_posts')) { |
|
| 1764 | + return; |
|
| 1765 | + } |
|
| 1685 | 1766 | |
| 1686 | - if ($output_method != 'echo') |
|
| 1687 | - return $scripturl . '?action=search'; |
|
| 1767 | + if ($output_method != 'echo') { |
|
| 1768 | + return $scripturl . '?action=search'; |
|
| 1769 | + } |
|
| 1688 | 1770 | |
| 1689 | 1771 | echo ' |
| 1690 | 1772 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1706,8 +1788,9 @@ discard block |
||
| 1706 | 1788 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
| 1707 | 1789 | call_integration_hook('integrate_ssi_news'); |
| 1708 | 1790 | |
| 1709 | - if ($output_method != 'echo') |
|
| 1710 | - return $context['random_news_line']; |
|
| 1791 | + if ($output_method != 'echo') { |
|
| 1792 | + return $context['random_news_line']; |
|
| 1793 | + } |
|
| 1711 | 1794 | |
| 1712 | 1795 | echo $context['random_news_line']; |
| 1713 | 1796 | } |
@@ -1721,8 +1804,9 @@ discard block |
||
| 1721 | 1804 | { |
| 1722 | 1805 | global $scripturl, $modSettings, $user_info; |
| 1723 | 1806 | |
| 1724 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
| 1725 | - return; |
|
| 1807 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
| 1808 | + return; |
|
| 1809 | + } |
|
| 1726 | 1810 | |
| 1727 | 1811 | $eventOptions = array( |
| 1728 | 1812 | 'include_birthdays' => true, |
@@ -1733,13 +1817,15 @@ discard block |
||
| 1733 | 1817 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1734 | 1818 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1735 | 1819 | |
| 1736 | - if ($output_method != 'echo') |
|
| 1737 | - return $return['calendar_birthdays']; |
|
| 1820 | + if ($output_method != 'echo') { |
|
| 1821 | + return $return['calendar_birthdays']; |
|
| 1822 | + } |
|
| 1738 | 1823 | |
| 1739 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1740 | - echo ' |
|
| 1824 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1825 | + echo ' |
|
| 1741 | 1826 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
| 1742 | -} |
|
| 1827 | + } |
|
| 1828 | + } |
|
| 1743 | 1829 | |
| 1744 | 1830 | /** |
| 1745 | 1831 | * Shows today's holidays. |
@@ -1750,8 +1836,9 @@ discard block |
||
| 1750 | 1836 | { |
| 1751 | 1837 | global $modSettings, $user_info; |
| 1752 | 1838 | |
| 1753 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1754 | - return; |
|
| 1839 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1840 | + return; |
|
| 1841 | + } |
|
| 1755 | 1842 | |
| 1756 | 1843 | $eventOptions = array( |
| 1757 | 1844 | 'include_holidays' => true, |
@@ -1762,8 +1849,9 @@ discard block |
||
| 1762 | 1849 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1763 | 1850 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1764 | 1851 | |
| 1765 | - if ($output_method != 'echo') |
|
| 1766 | - return $return['calendar_holidays']; |
|
| 1852 | + if ($output_method != 'echo') { |
|
| 1853 | + return $return['calendar_holidays']; |
|
| 1854 | + } |
|
| 1767 | 1855 | |
| 1768 | 1856 | echo ' |
| 1769 | 1857 | ', implode(', ', $return['calendar_holidays']); |
@@ -1777,8 +1865,9 @@ discard block |
||
| 1777 | 1865 | { |
| 1778 | 1866 | global $modSettings, $user_info; |
| 1779 | 1867 | |
| 1780 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1781 | - return; |
|
| 1868 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1869 | + return; |
|
| 1870 | + } |
|
| 1782 | 1871 | |
| 1783 | 1872 | $eventOptions = array( |
| 1784 | 1873 | 'include_events' => true, |
@@ -1789,14 +1878,16 @@ discard block |
||
| 1789 | 1878 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1790 | 1879 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1791 | 1880 | |
| 1792 | - if ($output_method != 'echo') |
|
| 1793 | - return $return['calendar_events']; |
|
| 1881 | + if ($output_method != 'echo') { |
|
| 1882 | + return $return['calendar_events']; |
|
| 1883 | + } |
|
| 1794 | 1884 | |
| 1795 | 1885 | foreach ($return['calendar_events'] as $event) |
| 1796 | 1886 | { |
| 1797 | - if ($event['can_edit']) |
|
| 1798 | - echo ' |
|
| 1887 | + if ($event['can_edit']) { |
|
| 1888 | + echo ' |
|
| 1799 | 1889 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1890 | + } |
|
| 1800 | 1891 | echo ' |
| 1801 | 1892 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1802 | 1893 | } |
@@ -1811,8 +1902,9 @@ discard block |
||
| 1811 | 1902 | { |
| 1812 | 1903 | global $modSettings, $txt, $scripturl, $user_info; |
| 1813 | 1904 | |
| 1814 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1815 | - return; |
|
| 1905 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1906 | + return; |
|
| 1907 | + } |
|
| 1816 | 1908 | |
| 1817 | 1909 | $eventOptions = array( |
| 1818 | 1910 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1825,19 +1917,22 @@ discard block |
||
| 1825 | 1917 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1826 | 1918 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1827 | 1919 | |
| 1828 | - if ($output_method != 'echo') |
|
| 1829 | - return $return; |
|
| 1920 | + if ($output_method != 'echo') { |
|
| 1921 | + return $return; |
|
| 1922 | + } |
|
| 1830 | 1923 | |
| 1831 | - if (!empty($return['calendar_holidays'])) |
|
| 1832 | - echo ' |
|
| 1924 | + if (!empty($return['calendar_holidays'])) { |
|
| 1925 | + echo ' |
|
| 1833 | 1926 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
| 1927 | + } |
|
| 1834 | 1928 | if (!empty($return['calendar_birthdays'])) |
| 1835 | 1929 | { |
| 1836 | 1930 | echo ' |
| 1837 | 1931 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
| 1838 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1839 | - echo ' |
|
| 1932 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1933 | + echo ' |
|
| 1840 | 1934 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
| 1935 | + } |
|
| 1841 | 1936 | echo ' |
| 1842 | 1937 | <br>'; |
| 1843 | 1938 | } |
@@ -1847,9 +1942,10 @@ discard block |
||
| 1847 | 1942 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
| 1848 | 1943 | foreach ($return['calendar_events'] as $event) |
| 1849 | 1944 | { |
| 1850 | - if ($event['can_edit']) |
|
| 1851 | - echo ' |
|
| 1945 | + if ($event['can_edit']) { |
|
| 1946 | + echo ' |
|
| 1852 | 1947 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1948 | + } |
|
| 1853 | 1949 | echo ' |
| 1854 | 1950 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1855 | 1951 | } |
@@ -1873,25 +1969,29 @@ discard block |
||
| 1873 | 1969 | loadLanguage('Stats'); |
| 1874 | 1970 | |
| 1875 | 1971 | // Must be integers.... |
| 1876 | - if ($limit === null) |
|
| 1877 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1878 | - else |
|
| 1879 | - $limit = (int) $limit; |
|
| 1880 | - |
|
| 1881 | - if ($start === null) |
|
| 1882 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1883 | - else |
|
| 1884 | - $start = (int) $start; |
|
| 1885 | - |
|
| 1886 | - if ($board !== null) |
|
| 1887 | - $board = (int) $board; |
|
| 1888 | - elseif (isset($_GET['board'])) |
|
| 1889 | - $board = (int) $_GET['board']; |
|
| 1890 | - |
|
| 1891 | - if ($length === null) |
|
| 1892 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1893 | - else |
|
| 1894 | - $length = (int) $length; |
|
| 1972 | + if ($limit === null) { |
|
| 1973 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1974 | + } else { |
|
| 1975 | + $limit = (int) $limit; |
|
| 1976 | + } |
|
| 1977 | + |
|
| 1978 | + if ($start === null) { |
|
| 1979 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1980 | + } else { |
|
| 1981 | + $start = (int) $start; |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + if ($board !== null) { |
|
| 1985 | + $board = (int) $board; |
|
| 1986 | + } elseif (isset($_GET['board'])) { |
|
| 1987 | + $board = (int) $_GET['board']; |
|
| 1988 | + } |
|
| 1989 | + |
|
| 1990 | + if ($length === null) { |
|
| 1991 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1992 | + } else { |
|
| 1993 | + $length = (int) $length; |
|
| 1994 | + } |
|
| 1895 | 1995 | |
| 1896 | 1996 | $limit = max(0, $limit); |
| 1897 | 1997 | $start = max(0, $start); |
@@ -1909,17 +2009,19 @@ discard block |
||
| 1909 | 2009 | ); |
| 1910 | 2010 | if ($smcFunc['db_num_rows']($request) == 0) |
| 1911 | 2011 | { |
| 1912 | - if ($output_method == 'echo') |
|
| 1913 | - die($txt['ssi_no_guests']); |
|
| 1914 | - else |
|
| 1915 | - return array(); |
|
| 2012 | + if ($output_method == 'echo') { |
|
| 2013 | + die($txt['ssi_no_guests']); |
|
| 2014 | + } else { |
|
| 2015 | + return array(); |
|
| 2016 | + } |
|
| 1916 | 2017 | } |
| 1917 | 2018 | list ($board) = $smcFunc['db_fetch_row']($request); |
| 1918 | 2019 | $smcFunc['db_free_result']($request); |
| 1919 | 2020 | |
| 1920 | 2021 | $icon_sources = array(); |
| 1921 | - foreach ($context['stable_icons'] as $icon) |
|
| 1922 | - $icon_sources[$icon] = 'images_url'; |
|
| 2022 | + foreach ($context['stable_icons'] as $icon) { |
|
| 2023 | + $icon_sources[$icon] = 'images_url'; |
|
| 2024 | + } |
|
| 1923 | 2025 | |
| 1924 | 2026 | if (!empty($modSettings['enable_likes'])) |
| 1925 | 2027 | { |
@@ -1942,12 +2044,14 @@ discard block |
||
| 1942 | 2044 | ) |
| 1943 | 2045 | ); |
| 1944 | 2046 | $posts = array(); |
| 1945 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1946 | - $posts[] = $row['id_first_msg']; |
|
| 2047 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2048 | + $posts[] = $row['id_first_msg']; |
|
| 2049 | + } |
|
| 1947 | 2050 | $smcFunc['db_free_result']($request); |
| 1948 | 2051 | |
| 1949 | - if (empty($posts)) |
|
| 1950 | - return array(); |
|
| 2052 | + if (empty($posts)) { |
|
| 2053 | + return array(); |
|
| 2054 | + } |
|
| 1951 | 2055 | |
| 1952 | 2056 | // Find the posts. |
| 1953 | 2057 | $request = $smcFunc['db_query']('', ' |
@@ -1977,24 +2081,28 @@ discard block |
||
| 1977 | 2081 | $last_space = strrpos($row['body'], ' '); |
| 1978 | 2082 | $last_open = strrpos($row['body'], '<'); |
| 1979 | 2083 | $last_close = strrpos($row['body'], '>'); |
| 1980 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
| 1981 | - $cutoff = $last_open; |
|
| 1982 | - elseif (empty($last_close) || $last_close < $last_open) |
|
| 1983 | - $cutoff = $last_space; |
|
| 2084 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
| 2085 | + $cutoff = $last_open; |
|
| 2086 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
| 2087 | + $cutoff = $last_space; |
|
| 2088 | + } |
|
| 1984 | 2089 | |
| 1985 | - if ($cutoff !== false) |
|
| 1986 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2090 | + if ($cutoff !== false) { |
|
| 2091 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2092 | + } |
|
| 1987 | 2093 | $row['body'] .= '...'; |
| 1988 | 2094 | } |
| 1989 | 2095 | |
| 1990 | 2096 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 1991 | 2097 | |
| 1992 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 1993 | - $row['icon'] = 'recycled'; |
|
| 2098 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 2099 | + $row['icon'] = 'recycled'; |
|
| 2100 | + } |
|
| 1994 | 2101 | |
| 1995 | 2102 | // Check that this message icon is there... |
| 1996 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 1997 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2103 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 2104 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2105 | + } |
|
| 1998 | 2106 | |
| 1999 | 2107 | censorText($row['subject']); |
| 2000 | 2108 | censorText($row['body']); |
@@ -2031,16 +2139,18 @@ discard block |
||
| 2031 | 2139 | } |
| 2032 | 2140 | $smcFunc['db_free_result']($request); |
| 2033 | 2141 | |
| 2034 | - if (empty($return)) |
|
| 2035 | - return $return; |
|
| 2142 | + if (empty($return)) { |
|
| 2143 | + return $return; |
|
| 2144 | + } |
|
| 2036 | 2145 | |
| 2037 | 2146 | $return[count($return) - 1]['is_last'] = true; |
| 2038 | 2147 | |
| 2039 | 2148 | // If mods want to do somthing with this list of posts, let them do that now. |
| 2040 | 2149 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
| 2041 | 2150 | |
| 2042 | - if ($output_method != 'echo') |
|
| 2043 | - return $return; |
|
| 2151 | + if ($output_method != 'echo') { |
|
| 2152 | + return $return; |
|
| 2153 | + } |
|
| 2044 | 2154 | |
| 2045 | 2155 | foreach ($return as $news) |
| 2046 | 2156 | { |
@@ -2092,9 +2202,10 @@ discard block |
||
| 2092 | 2202 | echo ' |
| 2093 | 2203 | </div>'; |
| 2094 | 2204 | |
| 2095 | - if (!$news['is_last']) |
|
| 2096 | - echo ' |
|
| 2205 | + if (!$news['is_last']) { |
|
| 2206 | + echo ' |
|
| 2097 | 2207 | <hr>'; |
| 2208 | + } |
|
| 2098 | 2209 | } |
| 2099 | 2210 | } |
| 2100 | 2211 | |
@@ -2108,8 +2219,9 @@ discard block |
||
| 2108 | 2219 | { |
| 2109 | 2220 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
| 2110 | 2221 | |
| 2111 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 2112 | - return; |
|
| 2222 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 2223 | + return; |
|
| 2224 | + } |
|
| 2113 | 2225 | |
| 2114 | 2226 | // Find all events which are happening in the near future that the member can see. |
| 2115 | 2227 | $request = $smcFunc['db_query']('', ' |
@@ -2135,20 +2247,23 @@ discard block |
||
| 2135 | 2247 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2136 | 2248 | { |
| 2137 | 2249 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
| 2138 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
| 2139 | - continue; |
|
| 2250 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
| 2251 | + continue; |
|
| 2252 | + } |
|
| 2140 | 2253 | |
| 2141 | 2254 | // Censor the title. |
| 2142 | 2255 | censorText($row['title']); |
| 2143 | 2256 | |
| 2144 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
| 2145 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2146 | - else |
|
| 2147 | - $date = $row['start_date']; |
|
| 2257 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
| 2258 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2259 | + } else { |
|
| 2260 | + $date = $row['start_date']; |
|
| 2261 | + } |
|
| 2148 | 2262 | |
| 2149 | 2263 | // If the topic it is attached to is not approved then don't link it. |
| 2150 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
| 2151 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2264 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
| 2265 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2266 | + } |
|
| 2152 | 2267 | |
| 2153 | 2268 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
| 2154 | 2269 | |
@@ -2174,24 +2289,27 @@ discard block |
||
| 2174 | 2289 | } |
| 2175 | 2290 | $smcFunc['db_free_result']($request); |
| 2176 | 2291 | |
| 2177 | - foreach ($return as $mday => $array) |
|
| 2178 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2292 | + foreach ($return as $mday => $array) { |
|
| 2293 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2294 | + } |
|
| 2179 | 2295 | |
| 2180 | 2296 | // If mods want to do somthing with this list of events, let them do that now. |
| 2181 | 2297 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
| 2182 | 2298 | |
| 2183 | - if ($output_method != 'echo' || empty($return)) |
|
| 2184 | - return $return; |
|
| 2299 | + if ($output_method != 'echo' || empty($return)) { |
|
| 2300 | + return $return; |
|
| 2301 | + } |
|
| 2185 | 2302 | |
| 2186 | 2303 | // Well the output method is echo. |
| 2187 | 2304 | echo ' |
| 2188 | 2305 | <span class="event">' . $txt['events'] . '</span> '; |
| 2189 | - foreach ($return as $mday => $array) |
|
| 2190 | - foreach ($array as $event) |
|
| 2306 | + foreach ($return as $mday => $array) { |
|
| 2307 | + foreach ($array as $event) |
|
| 2191 | 2308 | { |
| 2192 | 2309 | if ($event['can_edit']) |
| 2193 | 2310 | echo ' |
| 2194 | 2311 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 2312 | + } |
|
| 2195 | 2313 | |
| 2196 | 2314 | echo ' |
| 2197 | 2315 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2210,8 +2328,9 @@ discard block |
||
| 2210 | 2328 | global $smcFunc; |
| 2211 | 2329 | |
| 2212 | 2330 | // If $id is null, this was most likely called from a query string and should do nothing. |
| 2213 | - if ($id === null) |
|
| 2214 | - return; |
|
| 2331 | + if ($id === null) { |
|
| 2332 | + return; |
|
| 2333 | + } |
|
| 2215 | 2334 | |
| 2216 | 2335 | $request = $smcFunc['db_query']('', ' |
| 2217 | 2336 | SELECT passwd, member_name, is_activated |
@@ -2243,8 +2362,9 @@ discard block |
||
| 2243 | 2362 | $attachments_boards = boardsAllowedTo('view_attachments'); |
| 2244 | 2363 | |
| 2245 | 2364 | // No boards? Adios amigo. |
| 2246 | - if (empty($attachments_boards)) |
|
| 2247 | - return array(); |
|
| 2365 | + if (empty($attachments_boards)) { |
|
| 2366 | + return array(); |
|
| 2367 | + } |
|
| 2248 | 2368 | |
| 2249 | 2369 | // Is it an array? |
| 2250 | 2370 | $attachment_ext = (array) $attachment_ext; |
@@ -2328,8 +2448,9 @@ discard block |
||
| 2328 | 2448 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
| 2329 | 2449 | |
| 2330 | 2450 | // So you just want an array? Here you can have it. |
| 2331 | - if ($output_method == 'array' || empty($attachments)) |
|
| 2332 | - return $attachments; |
|
| 2451 | + if ($output_method == 'array' || empty($attachments)) { |
|
| 2452 | + return $attachments; |
|
| 2453 | + } |
|
| 2333 | 2454 | |
| 2334 | 2455 | // Give them the default. |
| 2335 | 2456 | echo ' |
@@ -2340,14 +2461,15 @@ discard block |
||
| 2340 | 2461 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
| 2341 | 2462 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
| 2342 | 2463 | </tr>'; |
| 2343 | - foreach ($attachments as $attach) |
|
| 2344 | - echo ' |
|
| 2464 | + foreach ($attachments as $attach) { |
|
| 2465 | + echo ' |
|
| 2345 | 2466 | <tr> |
| 2346 | 2467 | <td>', $attach['file']['link'], '</td> |
| 2347 | 2468 | <td>', $attach['member']['link'], '</td> |
| 2348 | 2469 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
| 2349 | 2470 | <td>', $attach['file']['filesize'], '</td> |
| 2350 | 2471 | </tr>'; |
| 2472 | + } |
|
| 2351 | 2473 | echo ' |
| 2352 | 2474 | </table>'; |
| 2353 | 2475 | } |