@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * Generate the timestamp for the calculation |
281 | 281 | * |
282 | - * @return integer Timestamp |
|
282 | + * @return double Timestamp |
|
283 | 283 | */ |
284 | 284 | public function generateTimestamp() |
285 | 285 | { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * Truncate the given hash down to just what we need |
291 | 291 | * |
292 | 292 | * @param string $hash Hash to truncate |
293 | - * @return string Truncated hash value |
|
293 | + * @return integer Truncated hash value |
|
294 | 294 | */ |
295 | 295 | public function truncateHash($hash) |
296 | 296 | { |
@@ -474,7 +474,7 @@ |
||
474 | 474 | * Used by fatal_error(), fatal_lang_error() |
475 | 475 | * |
476 | 476 | * @param string $error The error |
477 | - * @param array $sprintf An array of data to be sprintf()'d into the specified message |
|
477 | + * @param boolean $sprintf An array of data to be sprintf()'d into the specified message |
|
478 | 478 | */ |
479 | 479 | function log_error_online($error, $sprintf = array()) |
480 | 480 | { |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $error_call++; |
40 | 40 | |
41 | 41 | // are we in a loop? |
42 | - if($error_call > 2) |
|
42 | + if ($error_call > 2) |
|
43 | 43 | { |
44 | 44 | if (!isset($db_show_debug) || $db_show_debug === false) |
45 | 45 | $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Log an error, if the error logging is enabled. |
@@ -41,17 +42,19 @@ discard block |
||
41 | 42 | // are we in a loop? |
42 | 43 | if($error_call > 2) |
43 | 44 | { |
44 | - if (!isset($db_show_debug) || $db_show_debug === false) |
|
45 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
46 | - else |
|
47 | - $backtrace = debug_backtrace(); |
|
45 | + if (!isset($db_show_debug) || $db_show_debug === false) { |
|
46 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
47 | + } else { |
|
48 | + $backtrace = debug_backtrace(); |
|
49 | + } |
|
48 | 50 | var_dump($backtrace); |
49 | 51 | die('Error loop.'); |
50 | 52 | } |
51 | 53 | |
52 | 54 | // Check if error logging is actually on. |
53 | - if (empty($modSettings['enableErrorLogging'])) |
|
54 | - return $error_message; |
|
55 | + if (empty($modSettings['enableErrorLogging'])) { |
|
56 | + return $error_message; |
|
57 | + } |
|
55 | 58 | |
56 | 59 | // Basically, htmlspecialchars it minus &. (for entities!) |
57 | 60 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -59,33 +62,39 @@ discard block |
||
59 | 62 | |
60 | 63 | // Add a file and line to the error message? |
61 | 64 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
62 | - if ($file == null) |
|
63 | - $file = ''; |
|
64 | - else |
|
65 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
65 | + if ($file == null) { |
|
66 | + $file = ''; |
|
67 | + } else { |
|
68 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
66 | 69 | $file = str_replace('\\', '/', $file); |
70 | + } |
|
67 | 71 | |
68 | - if ($line == null) |
|
69 | - $line = 0; |
|
70 | - else |
|
71 | - $line = (int) $line; |
|
72 | + if ($line == null) { |
|
73 | + $line = 0; |
|
74 | + } else { |
|
75 | + $line = (int) $line; |
|
76 | + } |
|
72 | 77 | |
73 | 78 | // Just in case there's no id_member or IP set yet. |
74 | - if (empty($user_info['id'])) |
|
75 | - $user_info['id'] = 0; |
|
76 | - if (empty($user_info['ip'])) |
|
77 | - $user_info['ip'] = ''; |
|
79 | + if (empty($user_info['id'])) { |
|
80 | + $user_info['id'] = 0; |
|
81 | + } |
|
82 | + if (empty($user_info['ip'])) { |
|
83 | + $user_info['ip'] = ''; |
|
84 | + } |
|
78 | 85 | |
79 | 86 | // Find the best query string we can... |
80 | 87 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
81 | 88 | |
82 | 89 | // Don't log the session hash in the url twice, it's a waste. |
83 | - if (!empty($smcFunc['htmlspecialchars'])) |
|
84 | - $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
90 | + if (!empty($smcFunc['htmlspecialchars'])) { |
|
91 | + $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
92 | + } |
|
85 | 93 | |
86 | 94 | // Just so we know what board error messages are from. |
87 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
88 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
95 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
96 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
97 | + } |
|
89 | 98 | |
90 | 99 | // What types of categories do we have? |
91 | 100 | $known_error_types = array( |
@@ -146,12 +155,14 @@ discard block |
||
146 | 155 | global $txt; |
147 | 156 | |
148 | 157 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
149 | - if (!empty($status)) |
|
150 | - send_http_status($status); |
|
158 | + if (!empty($status)) { |
|
159 | + send_http_status($status); |
|
160 | + } |
|
151 | 161 | |
152 | 162 | // We don't have $txt yet, but that's okay... |
153 | - if (empty($txt)) |
|
154 | - die($error); |
|
163 | + if (empty($txt)) { |
|
164 | + die($error); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | log_error_online($error, false); |
157 | 168 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -178,8 +189,9 @@ discard block |
||
178 | 189 | static $fatal_error_called = false; |
179 | 190 | |
180 | 191 | // Send the status header - set this to 0 or false if you don't want to send one at all |
181 | - if (!empty($status)) |
|
182 | - send_http_status($status); |
|
192 | + if (!empty($status)) { |
|
193 | + send_http_status($status); |
|
194 | + } |
|
183 | 195 | |
184 | 196 | // Try to load a theme if we don't have one. |
185 | 197 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -189,8 +201,9 @@ discard block |
||
189 | 201 | } |
190 | 202 | |
191 | 203 | // If we have no theme stuff we can't have the language file... |
192 | - if (empty($context['theme_loaded'])) |
|
193 | - die($error); |
|
204 | + if (empty($context['theme_loaded'])) { |
|
205 | + die($error); |
|
206 | + } |
|
194 | 207 | |
195 | 208 | $reload_lang_file = true; |
196 | 209 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -226,8 +239,9 @@ discard block |
||
226 | 239 | global $settings, $modSettings, $db_show_debug; |
227 | 240 | |
228 | 241 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
229 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
230 | - return; |
|
242 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
243 | + return; |
|
244 | + } |
|
231 | 245 | |
232 | 246 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
233 | 247 | { |
@@ -235,19 +249,22 @@ discard block |
||
235 | 249 | $count = count($array); |
236 | 250 | for ($i = 0; $i < $count; $i++) |
237 | 251 | { |
238 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
239 | - continue; |
|
252 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
253 | + continue; |
|
254 | + } |
|
240 | 255 | |
241 | 256 | // This is a bug in PHP, with eval, it seems! |
242 | - if (empty($array[$i]['args'])) |
|
243 | - $i++; |
|
257 | + if (empty($array[$i]['args'])) { |
|
258 | + $i++; |
|
259 | + } |
|
244 | 260 | break; |
245 | 261 | } |
246 | 262 | |
247 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
248 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
249 | - else |
|
250 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
263 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
264 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
265 | + } else { |
|
266 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
267 | + } |
|
251 | 268 | } |
252 | 269 | |
253 | 270 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -256,8 +273,9 @@ discard block |
||
256 | 273 | if ($error_level % 255 != E_ERROR) |
257 | 274 | { |
258 | 275 | $temporary = ob_get_contents(); |
259 | - if (substr($temporary, -2) == '="') |
|
260 | - echo '"'; |
|
276 | + if (substr($temporary, -2) == '="') { |
|
277 | + echo '"'; |
|
278 | + } |
|
261 | 279 | } |
262 | 280 | |
263 | 281 | // Debugging! This should look like a PHP error message. |
@@ -273,23 +291,27 @@ discard block |
||
273 | 291 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
274 | 292 | |
275 | 293 | // Dying on these errors only causes MORE problems (blank pages!) |
276 | - if ($file == 'Unknown') |
|
277 | - return; |
|
294 | + if ($file == 'Unknown') { |
|
295 | + return; |
|
296 | + } |
|
278 | 297 | |
279 | 298 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
280 | - if ($error_level % 255 == E_ERROR) |
|
281 | - obExit(false); |
|
282 | - else |
|
283 | - return; |
|
299 | + if ($error_level % 255 == E_ERROR) { |
|
300 | + obExit(false); |
|
301 | + } else { |
|
302 | + return; |
|
303 | + } |
|
284 | 304 | |
285 | 305 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
286 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
287 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
306 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
307 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
308 | + } |
|
288 | 309 | |
289 | 310 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
290 | - if ($error_level % 255 == E_ERROR) |
|
291 | - die('No direct access...'); |
|
292 | -} |
|
311 | + if ($error_level % 255 == E_ERROR) { |
|
312 | + die('No direct access...'); |
|
313 | + } |
|
314 | + } |
|
293 | 315 | |
294 | 316 | /** |
295 | 317 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -305,24 +327,28 @@ discard block |
||
305 | 327 | |
306 | 328 | // Attempt to prevent a recursive loop. |
307 | 329 | ++$level; |
308 | - if ($level > 1) |
|
309 | - return false; |
|
330 | + if ($level > 1) { |
|
331 | + return false; |
|
332 | + } |
|
310 | 333 | |
311 | 334 | // Maybe they came from dlattach or similar? |
312 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
313 | - loadTheme(); |
|
335 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
336 | + loadTheme(); |
|
337 | + } |
|
314 | 338 | |
315 | 339 | // Don't bother indexing errors mate... |
316 | 340 | $context['robot_no_index'] = true; |
317 | 341 | |
318 | - if (!isset($context['error_title'])) |
|
319 | - $context['error_title'] = $txt['error_occured']; |
|
342 | + if (!isset($context['error_title'])) { |
|
343 | + $context['error_title'] = $txt['error_occured']; |
|
344 | + } |
|
320 | 345 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
321 | 346 | |
322 | 347 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
323 | 348 | |
324 | - if (empty($context['page_title'])) |
|
325 | - $context['page_title'] = $context['error_title']; |
|
349 | + if (empty($context['page_title'])) { |
|
350 | + $context['page_title'] = $context['error_title']; |
|
351 | + } |
|
326 | 352 | |
327 | 353 | loadTemplate('Errors'); |
328 | 354 | $context['sub_template'] = 'fatal_error'; |
@@ -330,23 +356,26 @@ discard block |
||
330 | 356 | // If this is SSI, what do they want us to do? |
331 | 357 | if (SMF == 'SSI') |
332 | 358 | { |
333 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
334 | - $ssi_on_error_method(); |
|
335 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
336 | - loadSubTemplate('fatal_error'); |
|
359 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
360 | + $ssi_on_error_method(); |
|
361 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
362 | + loadSubTemplate('fatal_error'); |
|
363 | + } |
|
337 | 364 | |
338 | 365 | // No layers? |
339 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
340 | - exit; |
|
366 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
367 | + exit; |
|
368 | + } |
|
341 | 369 | } |
342 | 370 | // Alternatively from the cron call? |
343 | 371 | elseif (SMF == 'BACKGROUND') |
344 | 372 | { |
345 | 373 | // We can't rely on even having language files available. |
346 | - if (defined('FROM_CLI') && FROM_CLI) |
|
347 | - echo 'cron error: ', $context['error_message']; |
|
348 | - else |
|
349 | - echo 'An error occurred. More information may be available in your logs.'; |
|
374 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
375 | + echo 'cron error: ', $context['error_message']; |
|
376 | + } else { |
|
377 | + echo 'An error occurred. More information may be available in your logs.'; |
|
378 | + } |
|
350 | 379 | exit; |
351 | 380 | } |
352 | 381 | |
@@ -374,8 +403,8 @@ discard block |
||
374 | 403 | |
375 | 404 | set_fatal_error_headers(); |
376 | 405 | |
377 | - if (!empty($maintenance)) |
|
378 | - echo '<!DOCTYPE html> |
|
406 | + if (!empty($maintenance)) { |
|
407 | + echo '<!DOCTYPE html> |
|
379 | 408 | <html> |
380 | 409 | <head> |
381 | 410 | <meta name="robots" content="noindex"> |
@@ -386,6 +415,7 @@ discard block |
||
386 | 415 | ', $mmessage, ' |
387 | 416 | </body> |
388 | 417 | </html>'; |
418 | + } |
|
389 | 419 | |
390 | 420 | die(); |
391 | 421 | } |
@@ -407,15 +437,17 @@ discard block |
||
407 | 437 | // For our purposes, we're gonna want this on if at all possible. |
408 | 438 | $modSettings['cache_enable'] = '1'; |
409 | 439 | |
410 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
411 | - $db_last_error = max($db_last_error, $temp); |
|
440 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
441 | + $db_last_error = max($db_last_error, $temp); |
|
442 | + } |
|
412 | 443 | |
413 | 444 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
414 | 445 | { |
415 | 446 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
416 | 447 | cache_put_data('db_last_error', time(), 600); |
417 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
418 | - logLastDatabaseError(); |
|
448 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
449 | + logLastDatabaseError(); |
|
450 | + } |
|
419 | 451 | |
420 | 452 | // Language files aren't loaded yet :(. |
421 | 453 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -496,12 +528,14 @@ discard block |
||
496 | 528 | global $smcFunc, $user_info, $modSettings; |
497 | 529 | |
498 | 530 | // Don't bother if Who's Online is disabled. |
499 | - if (empty($modSettings['who_enabled'])) |
|
500 | - return; |
|
531 | + if (empty($modSettings['who_enabled'])) { |
|
532 | + return; |
|
533 | + } |
|
501 | 534 | |
502 | 535 | // Maybe they came from SSI or similar where sessions are not recorded? |
503 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
504 | - return; |
|
536 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
537 | + return; |
|
538 | + } |
|
505 | 539 | |
506 | 540 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); |
507 | 541 | |
@@ -527,8 +561,9 @@ discard block |
||
527 | 561 | $url = $smcFunc['json_decode']($url, true); |
528 | 562 | $url['error'] = $error; |
529 | 563 | |
530 | - if (!empty($sprintf)) |
|
531 | - $url['error_params'] = $sprintf; |
|
564 | + if (!empty($sprintf)) { |
|
565 | + $url['error_params'] = $sprintf; |
|
566 | + } |
|
532 | 567 | |
533 | 568 | $smcFunc['db_query']('', ' |
534 | 569 | UPDATE {db_prefix}log_online |
@@ -559,10 +594,11 @@ discard block |
||
559 | 594 | |
560 | 595 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
561 | 596 | |
562 | - if (!isset($statuses[$code])) |
|
563 | - header($protocol . ' 500 Internal Server Error'); |
|
564 | - else |
|
565 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
566 | -} |
|
597 | + if (!isset($statuses[$code])) { |
|
598 | + header($protocol . ' 500 Internal Server Error'); |
|
599 | + } else { |
|
600 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
601 | + } |
|
602 | + } |
|
567 | 603 | |
568 | 604 | ?> |
569 | 605 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Get a list of versions that are currently installed on the server. |
21 | - * @param array $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'xcache', 'apc', 'php' or 'server' |
|
21 | + * @param string[] $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'xcache', 'apc', 'php' or 'server' |
|
22 | 22 | * @return array An array of versions (keys are same as what was in $checkFor, values are the versions) |
23 | 23 | */ |
24 | 24 | function getServerVersions($checkFor) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
45 | 46 | $temp2 = $temp->getVersion(); |
46 | 47 | $im_version = $temp2['versionString']; |
47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
48 | - } |
|
49 | - else |
|
49 | + } else |
|
50 | 50 | { |
51 | 51 | $im_version = MagickGetVersionString(); |
52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | if (in_array('db_server', $checkFor)) |
62 | 62 | { |
63 | 63 | db_extend(); |
64 | - if (!isset($db_connection) || $db_connection === false) |
|
65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
66 | - else |
|
64 | + if (!isset($db_connection) || $db_connection === false) { |
|
65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
66 | + } else |
|
67 | 67 | { |
68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_engine'](); |
@@ -75,24 +75,31 @@ discard block |
||
75 | 75 | |
76 | 76 | // If we're using memcache we need the server info. |
77 | 77 | $memcache_version = '???'; |
78 | - if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) |
|
79 | - $memcache_version = $cacheAPI->getVersion(); |
|
78 | + if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) { |
|
79 | + $memcache_version = $cacheAPI->getVersion(); |
|
80 | + } |
|
80 | 81 | |
81 | 82 | // Check to see if we have any accelerators installed... |
82 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
83 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
84 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
85 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
86 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
87 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
88 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
89 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
83 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
84 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
85 | + } |
|
86 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
87 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
88 | + } |
|
89 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
90 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
91 | + } |
|
92 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
93 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
94 | + } |
|
90 | 95 | |
91 | - if (in_array('php', $checkFor)) |
|
92 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
96 | + if (in_array('php', $checkFor)) { |
|
97 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
98 | + } |
|
93 | 99 | |
94 | - if (in_array('server', $checkFor)) |
|
95 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
100 | + if (in_array('server', $checkFor)) { |
|
101 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
102 | + } |
|
96 | 103 | |
97 | 104 | return $versions; |
98 | 105 | } |
@@ -132,11 +139,13 @@ discard block |
||
132 | 139 | fclose($fp); |
133 | 140 | |
134 | 141 | // The comment looks rougly like... that. |
135 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
136 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
142 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
143 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
144 | + } |
|
137 | 145 | // Not found! This is bad. |
138 | - else |
|
139 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
146 | + else { |
|
147 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
148 | + } |
|
140 | 149 | } |
141 | 150 | |
142 | 151 | // Do the paid subscriptions handler? |
@@ -147,11 +156,13 @@ discard block |
||
147 | 156 | fclose($fp); |
148 | 157 | |
149 | 158 | // Found it? |
150 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
151 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
159 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
160 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
161 | + } |
|
152 | 162 | // If we haven't how do we all get paid? |
153 | - else |
|
154 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
163 | + else { |
|
164 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
165 | + } |
|
155 | 166 | } |
156 | 167 | |
157 | 168 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -166,11 +177,13 @@ discard block |
||
166 | 177 | fclose($fp); |
167 | 178 | |
168 | 179 | // Look for the version comment in the file header. |
169 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
170 | - $version_info['file_versions'][$entry] = $match[1]; |
|
180 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
181 | + $version_info['file_versions'][$entry] = $match[1]; |
|
182 | + } |
|
171 | 183 | // It wasn't found, but the file was... show a '??'. |
172 | - else |
|
173 | - $version_info['file_versions'][$entry] = '??'; |
|
184 | + else { |
|
185 | + $version_info['file_versions'][$entry] = '??'; |
|
186 | + } |
|
174 | 187 | } |
175 | 188 | } |
176 | 189 | $sources_dir->close(); |
@@ -189,11 +202,13 @@ discard block |
||
189 | 202 | fclose($fp); |
190 | 203 | |
191 | 204 | // Look for the version comment in the file header. |
192 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
193 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
205 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
206 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
207 | + } |
|
194 | 208 | // It wasn't found, but the file was... show a '??'. |
195 | - else |
|
196 | - $version_info['tasks_versions'][$entry] = '??'; |
|
209 | + else { |
|
210 | + $version_info['tasks_versions'][$entry] = '??'; |
|
211 | + } |
|
197 | 212 | } |
198 | 213 | } |
199 | 214 | $tasks_dir->close(); |
@@ -201,8 +216,9 @@ discard block |
||
201 | 216 | |
202 | 217 | // Load all the files in the default template directory - and the current theme if applicable. |
203 | 218 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
204 | - if ($settings['theme_id'] != 1) |
|
205 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
219 | + if ($settings['theme_id'] != 1) { |
|
220 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
221 | + } |
|
206 | 222 | |
207 | 223 | foreach ($directories as $type => $dirname) |
208 | 224 | { |
@@ -217,11 +233,13 @@ discard block |
||
217 | 233 | fclose($fp); |
218 | 234 | |
219 | 235 | // Look for the version comment in the file header. |
220 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
221 | - $version_info[$type][$entry] = $match[1]; |
|
236 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
237 | + $version_info[$type][$entry] = $match[1]; |
|
238 | + } |
|
222 | 239 | // It wasn't found, but the file was... show a '??'. |
223 | - else |
|
224 | - $version_info[$type][$entry] = '??'; |
|
240 | + else { |
|
241 | + $version_info[$type][$entry] = '??'; |
|
242 | + } |
|
225 | 243 | } |
226 | 244 | } |
227 | 245 | $this_dir->close(); |
@@ -242,11 +260,13 @@ discard block |
||
242 | 260 | list ($name, $language) = explode('.', $entry); |
243 | 261 | |
244 | 262 | // Look for the version comment in the file header. |
245 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
246 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
263 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
264 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
265 | + } |
|
247 | 266 | // It wasn't found, but the file was... show a '??'. |
248 | - else |
|
249 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
267 | + else { |
|
268 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
269 | + } |
|
250 | 270 | } |
251 | 271 | } |
252 | 272 | $this_dir->close(); |
@@ -261,8 +281,9 @@ discard block |
||
261 | 281 | ksort($version_info['tasks_versions']); |
262 | 282 | |
263 | 283 | // For languages sort each language too. |
264 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
265 | - ksort($version_info['default_language_versions'][$language]); |
|
284 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
285 | + ksort($version_info['default_language_versions'][$language]); |
|
286 | + } |
|
266 | 287 | } |
267 | 288 | return $version_info; |
268 | 289 | } |
@@ -304,27 +325,31 @@ discard block |
||
304 | 325 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
305 | 326 | |
306 | 327 | // Break it up based on \r or \n, and then clean out extra characters. |
307 | - if (strpos($settingsArray, "\n") !== false) |
|
308 | - $settingsArray = explode("\n", $settingsArray); |
|
309 | - elseif (strpos($settingsArray, "\r") !== false) |
|
310 | - $settingsArray = explode("\r", $settingsArray); |
|
311 | - else |
|
312 | - return; |
|
328 | + if (strpos($settingsArray, "\n") !== false) { |
|
329 | + $settingsArray = explode("\n", $settingsArray); |
|
330 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
331 | + $settingsArray = explode("\r", $settingsArray); |
|
332 | + } else { |
|
333 | + return; |
|
334 | + } |
|
313 | 335 | |
314 | 336 | // Presumably, the file has to have stuff in it for this function to be called :P. |
315 | - if (count($settingsArray) < 10) |
|
316 | - return; |
|
337 | + if (count($settingsArray) < 10) { |
|
338 | + return; |
|
339 | + } |
|
317 | 340 | |
318 | 341 | // remove any /r's that made there way in here |
319 | - foreach ($settingsArray as $k => $dummy) |
|
320 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
342 | + foreach ($settingsArray as $k => $dummy) { |
|
343 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
344 | + } |
|
321 | 345 | |
322 | 346 | // go line by line and see whats changing |
323 | 347 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
324 | 348 | { |
325 | 349 | // Don't trim or bother with it if it's not a variable. |
326 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
327 | - continue; |
|
350 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
351 | + continue; |
|
352 | + } |
|
328 | 353 | |
329 | 354 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
330 | 355 | |
@@ -336,8 +361,7 @@ discard block |
||
336 | 361 | { |
337 | 362 | updateDbLastError($val); |
338 | 363 | unset($config_vars[$var]); |
339 | - } |
|
340 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
364 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
341 | 365 | { |
342 | 366 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
343 | 367 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -348,34 +372,39 @@ discard block |
||
348 | 372 | } |
349 | 373 | |
350 | 374 | // End of the file ... maybe |
351 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
352 | - $end = $i; |
|
375 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
376 | + $end = $i; |
|
377 | + } |
|
353 | 378 | } |
354 | 379 | |
355 | 380 | // This should never happen, but apparently it is happening. |
356 | - if (empty($end) || $end < 10) |
|
357 | - $end = count($settingsArray) - 1; |
|
381 | + if (empty($end) || $end < 10) { |
|
382 | + $end = count($settingsArray) - 1; |
|
383 | + } |
|
358 | 384 | |
359 | 385 | // Still more variables to go? Then lets add them at the end. |
360 | 386 | if (!empty($config_vars)) |
361 | 387 | { |
362 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
363 | - $settingsArray[$end++] = ''; |
|
364 | - else |
|
365 | - $end++; |
|
388 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
389 | + $settingsArray[$end++] = ''; |
|
390 | + } else { |
|
391 | + $end++; |
|
392 | + } |
|
366 | 393 | |
367 | 394 | // Add in any newly defined vars that were passed |
368 | - foreach ($config_vars as $var => $val) |
|
369 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
395 | + foreach ($config_vars as $var => $val) { |
|
396 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
397 | + } |
|
370 | 398 | |
371 | 399 | $settingsArray[$end] = '?' . '>'; |
400 | + } else { |
|
401 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
372 | 402 | } |
373 | - else |
|
374 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
375 | 403 | |
376 | 404 | // Sanity error checking: the file needs to be at least 12 lines. |
377 | - if (count($settingsArray) < 12) |
|
378 | - return; |
|
405 | + if (count($settingsArray) < 12) { |
|
406 | + return; |
|
407 | + } |
|
379 | 408 | |
380 | 409 | // Try to avoid a few pitfalls: |
381 | 410 | // - like a possible race condition, |
@@ -383,8 +412,9 @@ discard block |
||
383 | 412 | // |
384 | 413 | // Check before you act: if cache is enabled, we can do a simple write test |
385 | 414 | // to validate that we even write things on this filesystem. |
386 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
387 | - $cachedir = $boarddir . '/cache'; |
|
415 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
416 | + $cachedir = $boarddir . '/cache'; |
|
417 | + } |
|
388 | 418 | |
389 | 419 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
390 | 420 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
419 | 449 | // Well this is not good at all, lets see if we can save this |
420 | 450 | $context['settings_message'] = 'settings_error'; |
421 | 451 | |
422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
454 | + } |
|
424 | 455 | } |
425 | 456 | } |
426 | 457 | |
427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
429 | - if (function_exists('opcache_invalidate')) |
|
430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
431 | -} |
|
460 | + if (function_exists('opcache_invalidate')) { |
|
461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
462 | + } |
|
463 | + } |
|
432 | 464 | |
433 | 465 | /** |
434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
455 | 487 | |
456 | 488 | // This must exist! |
457 | - if (!isset($context['admin_preferences'])) |
|
458 | - return false; |
|
489 | + if (!isset($context['admin_preferences'])) { |
|
490 | + return false; |
|
491 | + } |
|
459 | 492 | |
460 | 493 | // This is what we'll be saving. |
461 | 494 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
519 | 552 | $emails_sent = array(); |
520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
521 | 554 | { |
522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
523 | - continue; |
|
555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
556 | + continue; |
|
557 | + } |
|
524 | 558 | |
525 | 559 | // Stick their particulars in the replacement data. |
526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
539 | 573 | $smcFunc['db_free_result']($request); |
540 | 574 | |
541 | 575 | // Any additional users we must email this to? |
542 | - if (!empty($additional_recipients)) |
|
543 | - foreach ($additional_recipients as $recipient) |
|
576 | + if (!empty($additional_recipients)) { |
|
577 | + foreach ($additional_recipients as $recipient) |
|
544 | 578 | { |
545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
546 | 580 | continue; |
581 | + } |
|
547 | 582 | |
548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -150,7 +150,7 @@ |
||
150 | 150 | * |
151 | 151 | * @param bool $local Whether we want local cookies |
152 | 152 | * @param bool $global Whether we want global cookies |
153 | - * @return array An array to set the cookie on with domain and path in it, in that order |
|
153 | + * @return string An array to set the cookie on with domain and path in it, in that order |
|
154 | 154 | */ |
155 | 155 | function url_parts($local, $global) |
156 | 156 | { |
@@ -58,7 +58,7 @@ |
||
58 | 58 | |
59 | 59 | // Get the data and path to set it on. |
60 | 60 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
61 | - $dataAr = empty($id) ? array(0, '', 0, 'path' => $cookie_url[1]) : array($id, $password, time() + $cookie_length, $cookie_state,'path' => $cookie_url[1]); |
|
61 | + $dataAr = empty($id) ? array(0, '', 0, 'path' => $cookie_url[1]) : array($id, $password, time() + $cookie_length, $cookie_state, 'path' => $cookie_url[1]); |
|
62 | 62 | $data = $smcFunc['json_encode']($dataAr); |
63 | 63 | |
64 | 64 | // Set the cookie, $_COOKIE, and session variable. |
@@ -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 | * Sets the SMF-style login cookie and session based on the id_member and password passed. |
@@ -43,15 +44,17 @@ discard block |
||
43 | 44 | $array = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
44 | 45 | |
45 | 46 | // Legacy format |
46 | - if (is_null($array)) |
|
47 | - $array = safe_unserialize($_COOKIE[$cookiename]); |
|
47 | + if (is_null($array)) { |
|
48 | + $array = safe_unserialize($_COOKIE[$cookiename]); |
|
49 | + } |
|
48 | 50 | |
49 | 51 | // Out with the old, in with the new! |
50 | 52 | if (isset($array[3]) && $array[3] != $cookie_state) |
51 | 53 | { |
52 | 54 | $cookie_url = url_parts($array[3] & 1 > 0, $array[3] & 2 > 0); |
53 | - if (isset($_COOKIE[$cookiename]['path'])) |
|
54 | - $cookie_url[1] = $_COOKIE[$cookiename]['path']; |
|
55 | + if (isset($_COOKIE[$cookiename]['path'])) { |
|
56 | + $cookie_url[1] = $_COOKIE[$cookiename]['path']; |
|
57 | + } |
|
55 | 58 | smf_setcookie($cookiename, $smcFunc['json_encode'](array(0, '', 0, 'path' => $cookie_url[1])), 1, $cookie_url[1], $cookie_url[0]); |
56 | 59 | } |
57 | 60 | } |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]); |
66 | 69 | |
67 | 70 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
68 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
69 | - smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
71 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
72 | + smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Any alias URLs? This is mainly for use with frames, etc. |
72 | 76 | if (!empty($modSettings['forum_alias_urls'])) |
@@ -82,8 +86,9 @@ discard block |
||
82 | 86 | |
83 | 87 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
84 | 88 | |
85 | - if ($cookie_url[0] == '') |
|
86 | - $cookie_url[0] = strtok($alias, '/'); |
|
89 | + if ($cookie_url[0] == '') { |
|
90 | + $cookie_url[0] = strtok($alias, '/'); |
|
91 | + } |
|
87 | 92 | |
88 | 93 | $dataAr['path'] = $cookie_url[1]; |
89 | 94 | $data = $smcFunc['json_encode']($dataAr); |
@@ -132,8 +137,9 @@ discard block |
||
132 | 137 | $identifier = $cookiename . '_tfa'; |
133 | 138 | $cookie_state = (empty($modSettings['localCookies']) ? 0 : 1) | (empty($modSettings['globalCookies']) ? 0 : 2); |
134 | 139 | |
135 | - if ($preserve) |
|
136 | - $cookie_length = 81600 * 30; |
|
140 | + if ($preserve) { |
|
141 | + $cookie_length = 81600 * 30; |
|
142 | + } |
|
137 | 143 | |
138 | 144 | // Get the data and path to set it on. |
139 | 145 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
@@ -143,8 +149,9 @@ discard block |
||
143 | 149 | smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]); |
144 | 150 | |
145 | 151 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
146 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
147 | - smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
152 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
153 | + smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
154 | + } |
|
148 | 155 | |
149 | 156 | $_COOKIE[$identifier] = $data; |
150 | 157 | } |
@@ -166,23 +173,28 @@ discard block |
||
166 | 173 | $parsed_url = parse_url($boardurl); |
167 | 174 | |
168 | 175 | // Is local cookies off? |
169 | - if (empty($parsed_url['path']) || !$local) |
|
170 | - $parsed_url['path'] = ''; |
|
176 | + if (empty($parsed_url['path']) || !$local) { |
|
177 | + $parsed_url['path'] = ''; |
|
178 | + } |
|
171 | 179 | |
172 | - if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) |
|
173 | - $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
180 | + if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) { |
|
181 | + $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
182 | + } |
|
174 | 183 | |
175 | 184 | // Globalize cookies across domains (filter out IP-addresses)? |
176 | - elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
177 | - $parsed_url['host'] = '.' . $parts[1]; |
|
185 | + elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
186 | + $parsed_url['host'] = '.' . $parts[1]; |
|
187 | + } |
|
178 | 188 | |
179 | 189 | // We shouldn't use a host at all if both options are off. |
180 | - elseif (!$local && !$global) |
|
181 | - $parsed_url['host'] = ''; |
|
190 | + elseif (!$local && !$global) { |
|
191 | + $parsed_url['host'] = ''; |
|
192 | + } |
|
182 | 193 | |
183 | 194 | // The host also shouldn't be set if there aren't any dots in it. |
184 | - elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) |
|
185 | - $parsed_url['host'] = ''; |
|
195 | + elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) { |
|
196 | + $parsed_url['host'] = ''; |
|
197 | + } |
|
186 | 198 | |
187 | 199 | return array($parsed_url['host'], $parsed_url['path'] . '/'); |
188 | 200 | } |
@@ -201,8 +213,9 @@ discard block |
||
201 | 213 | createToken('login'); |
202 | 214 | |
203 | 215 | // Never redirect to an attachment |
204 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
205 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
216 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
217 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
218 | + } |
|
206 | 219 | |
207 | 220 | $context['sub_template'] = 'kick_guest'; |
208 | 221 | $context['page_title'] = $txt['login']; |
@@ -257,10 +270,12 @@ discard block |
||
257 | 270 | $txt['security_wrong'] = sprintf($txt['security_wrong'], isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $txt['unknown'], $_SERVER['HTTP_USER_AGENT'], $user_info['ip']); |
258 | 271 | log_error($txt['security_wrong'], 'critical'); |
259 | 272 | |
260 | - if (isset($_POST[$type . '_hash_pass'])) |
|
261 | - unset($_POST[$type . '_hash_pass']); |
|
262 | - if (isset($_POST[$type . '_pass'])) |
|
263 | - unset($_POST[$type . '_pass']); |
|
273 | + if (isset($_POST[$type . '_hash_pass'])) { |
|
274 | + unset($_POST[$type . '_hash_pass']); |
|
275 | + } |
|
276 | + if (isset($_POST[$type . '_pass'])) { |
|
277 | + unset($_POST[$type . '_pass']); |
|
278 | + } |
|
264 | 279 | |
265 | 280 | $context['incorrect_password'] = true; |
266 | 281 | } |
@@ -273,15 +288,17 @@ discard block |
||
273 | 288 | |
274 | 289 | // Now go through $_POST. Make sure the session hash is sent. |
275 | 290 | $_POST[$context['session_var']] = $context['session_id']; |
276 | - foreach ($_POST as $k => $v) |
|
277 | - $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
291 | + foreach ($_POST as $k => $v) { |
|
292 | + $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
293 | + } |
|
278 | 294 | |
279 | 295 | // Now we'll use the admin_login sub template of the Login template. |
280 | 296 | $context['sub_template'] = 'admin_login'; |
281 | 297 | |
282 | 298 | // And title the page something like "Login". |
283 | - if (!isset($context['page_title'])) |
|
284 | - $context['page_title'] = $txt['login']; |
|
299 | + if (!isset($context['page_title'])) { |
|
300 | + $context['page_title'] = $txt['login']; |
|
301 | + } |
|
285 | 302 | |
286 | 303 | // The type of action. |
287 | 304 | $context['sessionCheckType'] = $type; |
@@ -304,14 +321,15 @@ discard block |
||
304 | 321 | { |
305 | 322 | global $smcFunc; |
306 | 323 | |
307 | - if (!is_array($v)) |
|
308 | - return ' |
|
324 | + if (!is_array($v)) { |
|
325 | + return ' |
|
309 | 326 | <input type="hidden" name="' . $smcFunc['htmlspecialchars']($k) . '" value="' . strtr($v, array('"' => '"', '<' => '<', '>' => '>')) . '">'; |
310 | - else |
|
327 | + } else |
|
311 | 328 | { |
312 | 329 | $ret = ''; |
313 | - foreach ($v as $k2 => $v2) |
|
314 | - $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
330 | + foreach ($v as $k2 => $v2) { |
|
331 | + $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
332 | + } |
|
315 | 333 | |
316 | 334 | return $ret; |
317 | 335 | } |
@@ -338,18 +356,20 @@ discard block |
||
338 | 356 | foreach ($get as $k => $v) |
339 | 357 | { |
340 | 358 | // Only if it's not already in the $scripturl! |
341 | - if (!isset($temp[$k])) |
|
342 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
359 | + if (!isset($temp[$k])) { |
|
360 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
361 | + } |
|
343 | 362 | // If it changed, put it out there, but with an ampersand. |
344 | - elseif ($temp[$k] != $get[$k]) |
|
345 | - $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
363 | + elseif ($temp[$k] != $get[$k]) { |
|
364 | + $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
365 | + } |
|
346 | 366 | } |
347 | - } |
|
348 | - else |
|
367 | + } else |
|
349 | 368 | { |
350 | 369 | // Add up all the data from $_GET into get_data. |
351 | - foreach ($get as $k => $v) |
|
352 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
370 | + foreach ($get as $k => $v) { |
|
371 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
372 | + } |
|
353 | 373 | } |
354 | 374 | |
355 | 375 | $query_string = substr($query_string, 0, -1); |
@@ -372,8 +392,9 @@ discard block |
||
372 | 392 | global $scripturl, $user_info, $smcFunc; |
373 | 393 | |
374 | 394 | // If it's not already an array, make it one. |
375 | - if (!is_array($names)) |
|
376 | - $names = explode(',', $names); |
|
395 | + if (!is_array($names)) { |
|
396 | + $names = explode(',', $names); |
|
397 | + } |
|
377 | 398 | |
378 | 399 | $maybe_email = false; |
379 | 400 | foreach ($names as $i => $name) |
@@ -384,10 +405,11 @@ discard block |
||
384 | 405 | $maybe_email |= strpos($name, '@') !== false; |
385 | 406 | |
386 | 407 | // Make it so standard wildcards will work. (* and ?) |
387 | - if ($use_wildcards) |
|
388 | - $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
389 | - else |
|
390 | - $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
408 | + if ($use_wildcards) { |
|
409 | + $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
410 | + } else { |
|
411 | + $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
412 | + } |
|
391 | 413 | } |
392 | 414 | |
393 | 415 | // What are we using to compare? |
@@ -397,11 +419,12 @@ discard block |
||
397 | 419 | $results = array(); |
398 | 420 | |
399 | 421 | // This ensures you can't search someones email address if you can't see it. |
400 | - if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) |
|
401 | - $email_condition = ' |
|
422 | + if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) { |
|
423 | + $email_condition = ' |
|
402 | 424 | OR (email_address ' . $comparison . ' \'' . implode('\') OR (email_address ' . $comparison . ' \'', $names) . '\')'; |
403 | - else |
|
404 | - $email_condition = ''; |
|
425 | + } else { |
|
426 | + $email_condition = ''; |
|
427 | + } |
|
405 | 428 | |
406 | 429 | // Get the case of the columns right - but only if we need to as things like MySQL will go slow needlessly otherwise. |
407 | 430 | $member_name = $smcFunc['db_case_sensitive'] ? 'LOWER(member_name)' : 'member_name'; |
@@ -459,10 +482,11 @@ discard block |
||
459 | 482 | $context['template_layers'] = array(); |
460 | 483 | $context['sub_template'] = 'find_members'; |
461 | 484 | |
462 | - if (isset($_REQUEST['search'])) |
|
463 | - $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
464 | - else |
|
465 | - $_REQUEST['start'] = 0; |
|
485 | + if (isset($_REQUEST['search'])) { |
|
486 | + $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
487 | + } else { |
|
488 | + $_REQUEST['start'] = 0; |
|
489 | + } |
|
466 | 490 | |
467 | 491 | // Allow the user to pass the input to be added to to the box. |
468 | 492 | $context['input_box_name'] = isset($_REQUEST['input']) && preg_match('~^[\w-]+$~', $_REQUEST['input']) === 1 ? $_REQUEST['input'] : 'to'; |
@@ -503,10 +527,10 @@ discard block |
||
503 | 527 | ); |
504 | 528 | |
505 | 529 | $context['results'] = array_slice($context['results'], $_REQUEST['start'], 7); |
530 | + } else { |
|
531 | + $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
532 | + } |
|
506 | 533 | } |
507 | - else |
|
508 | - $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
509 | -} |
|
510 | 534 | |
511 | 535 | /** |
512 | 536 | * Outputs each member name on its own line. |
@@ -522,8 +546,9 @@ discard block |
||
522 | 546 | $_REQUEST['search'] = trim($smcFunc['strtolower']($_REQUEST['search'])); |
523 | 547 | $_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '&' => '&')); |
524 | 548 | |
525 | - if (function_exists('iconv')) |
|
526 | - header('Content-Type: text/plain; charset=UTF-8'); |
|
549 | + if (function_exists('iconv')) { |
|
550 | + header('Content-Type: text/plain; charset=UTF-8'); |
|
551 | + } |
|
527 | 552 | |
528 | 553 | $request = $smcFunc['db_query']('', ' |
529 | 554 | SELECT real_name |
@@ -543,14 +568,16 @@ discard block |
||
543 | 568 | if (function_exists('iconv')) |
544 | 569 | { |
545 | 570 | $utf8 = iconv($txt['lang_character_set'], 'UTF-8', $row['real_name']); |
546 | - if ($utf8) |
|
547 | - $row['real_name'] = $utf8; |
|
571 | + if ($utf8) { |
|
572 | + $row['real_name'] = $utf8; |
|
573 | + } |
|
548 | 574 | } |
549 | 575 | |
550 | 576 | $row['real_name'] = strtr($row['real_name'], array('&' => '&', '<' => '<', '>' => '>', '"' => '"')); |
551 | 577 | |
552 | - if (preg_match('~&#\d+;~', $row['real_name']) != 0) |
|
553 | - $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
578 | + if (preg_match('~&#\d+;~', $row['real_name']) != 0) { |
|
579 | + $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
580 | + } |
|
554 | 581 | |
555 | 582 | echo $row['real_name'], "\n"; |
556 | 583 | } |
@@ -607,9 +634,9 @@ discard block |
||
607 | 634 | |
608 | 635 | // Update the database... |
609 | 636 | updateMemberData($memID, array('member_name' => $user, 'passwd' => $newPassword_sha1)); |
637 | + } else { |
|
638 | + updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
610 | 639 | } |
611 | - else |
|
612 | - updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
613 | 640 | |
614 | 641 | call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword)); |
615 | 642 | |
@@ -640,31 +667,37 @@ discard block |
||
640 | 667 | $errors = array(); |
641 | 668 | |
642 | 669 | // Don't use too long a name. |
643 | - if ($smcFunc['strlen']($username) > 25) |
|
644 | - $errors[] = array('lang', 'error_long_name'); |
|
670 | + if ($smcFunc['strlen']($username) > 25) { |
|
671 | + $errors[] = array('lang', 'error_long_name'); |
|
672 | + } |
|
645 | 673 | |
646 | 674 | // No name?! How can you register with no name? |
647 | - if ($username == '') |
|
648 | - $errors[] = array('lang', 'need_username'); |
|
675 | + if ($username == '') { |
|
676 | + $errors[] = array('lang', 'need_username'); |
|
677 | + } |
|
649 | 678 | |
650 | 679 | // Only these characters are permitted. |
651 | - if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) |
|
652 | - $errors[] = array('lang', 'error_invalid_characters_username'); |
|
680 | + if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) { |
|
681 | + $errors[] = array('lang', 'error_invalid_characters_username'); |
|
682 | + } |
|
653 | 683 | |
654 | - if (stristr($username, $txt['guest_title']) !== false) |
|
655 | - $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
684 | + if (stristr($username, $txt['guest_title']) !== false) { |
|
685 | + $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
686 | + } |
|
656 | 687 | |
657 | 688 | if ($check_reserved_name) |
658 | 689 | { |
659 | 690 | require_once($sourcedir . '/Subs-Members.php'); |
660 | - if (isReservedName($username, $memID, false)) |
|
661 | - $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
691 | + if (isReservedName($username, $memID, false)) { |
|
692 | + $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
693 | + } |
|
662 | 694 | } |
663 | 695 | |
664 | - if ($return_error) |
|
665 | - return $errors; |
|
666 | - elseif (empty($errors)) |
|
667 | - return null; |
|
696 | + if ($return_error) { |
|
697 | + return $errors; |
|
698 | + } elseif (empty($errors)) { |
|
699 | + return null; |
|
700 | + } |
|
668 | 701 | |
669 | 702 | loadLanguage('Errors'); |
670 | 703 | $error = $errors[0]; |
@@ -690,22 +723,26 @@ discard block |
||
690 | 723 | global $modSettings, $smcFunc; |
691 | 724 | |
692 | 725 | // Perform basic requirements first. |
693 | - if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) |
|
694 | - return 'short'; |
|
726 | + if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) { |
|
727 | + return 'short'; |
|
728 | + } |
|
695 | 729 | |
696 | 730 | // Is this enough? |
697 | - if (empty($modSettings['password_strength'])) |
|
698 | - return null; |
|
731 | + if (empty($modSettings['password_strength'])) { |
|
732 | + return null; |
|
733 | + } |
|
699 | 734 | |
700 | 735 | // Otherwise, perform the medium strength test - checking if password appears in the restricted string. |
701 | - if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) |
|
702 | - return 'restricted_words'; |
|
703 | - elseif ($smcFunc['strpos']($password, $username) !== false) |
|
704 | - return 'restricted_words'; |
|
736 | + if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) { |
|
737 | + return 'restricted_words'; |
|
738 | + } elseif ($smcFunc['strpos']($password, $username) !== false) { |
|
739 | + return 'restricted_words'; |
|
740 | + } |
|
705 | 741 | |
706 | 742 | // If just medium, we're done. |
707 | - if ($modSettings['password_strength'] == 1) |
|
708 | - return null; |
|
743 | + if ($modSettings['password_strength'] == 1) { |
|
744 | + return null; |
|
745 | + } |
|
709 | 746 | |
710 | 747 | // Otherwise, hard test next, check for numbers and letters, uppercase too. |
711 | 748 | $good = preg_match('~(\D\d|\d\D)~', $password) != 0; |
@@ -737,14 +774,16 @@ discard block |
||
737 | 774 | ) |
738 | 775 | ); |
739 | 776 | $groups = array(); |
740 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
741 | - $groups[] = $row['id_group']; |
|
777 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
778 | + $groups[] = $row['id_group']; |
|
779 | + } |
|
742 | 780 | $smcFunc['db_free_result']($request); |
743 | 781 | |
744 | - if (empty($groups)) |
|
745 | - $group_query = '0=1'; |
|
746 | - else |
|
747 | - $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
782 | + if (empty($groups)) { |
|
783 | + $group_query = '0=1'; |
|
784 | + } else { |
|
785 | + $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
786 | + } |
|
748 | 787 | } |
749 | 788 | |
750 | 789 | // Then, same again, just the boards this time! |
@@ -754,10 +793,11 @@ discard block |
||
754 | 793 | { |
755 | 794 | $boards = boardsAllowedTo('moderate_board', true); |
756 | 795 | |
757 | - if (empty($boards)) |
|
758 | - $board_query = '0=1'; |
|
759 | - else |
|
760 | - $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
796 | + if (empty($boards)) { |
|
797 | + $board_query = '0=1'; |
|
798 | + } else { |
|
799 | + $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
800 | + } |
|
761 | 801 | } |
762 | 802 | |
763 | 803 | // What boards are they the moderator of? |
@@ -772,8 +812,9 @@ discard block |
||
772 | 812 | 'current_member' => $user_info['id'], |
773 | 813 | ) |
774 | 814 | ); |
775 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
776 | - $boards_mod[] = $row['id_board']; |
|
815 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
816 | + $boards_mod[] = $row['id_board']; |
|
817 | + } |
|
777 | 818 | $smcFunc['db_free_result']($request); |
778 | 819 | |
779 | 820 | // Can any of the groups they're in moderate any of the boards? |
@@ -785,8 +826,9 @@ discard block |
||
785 | 826 | 'groups' => $user_info['groups'], |
786 | 827 | ) |
787 | 828 | ); |
788 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
789 | - $boards_mod[] = $row['id_board']; |
|
829 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
830 | + $boards_mod[] = $row['id_board']; |
|
831 | + } |
|
790 | 832 | $smcFunc['db_free_result']($request); |
791 | 833 | |
792 | 834 | // Just in case we've got duplicates here... |
@@ -831,10 +873,12 @@ discard block |
||
831 | 873 | global $modSettings; |
832 | 874 | |
833 | 875 | // In case a customization wants to override the default settings |
834 | - if ($httponly === null) |
|
835 | - $httponly = !empty($modSettings['httponlyCookies']); |
|
836 | - if ($secure === null) |
|
837 | - $secure = !empty($modSettings['secureCookies']); |
|
876 | + if ($httponly === null) { |
|
877 | + $httponly = !empty($modSettings['httponlyCookies']); |
|
878 | + } |
|
879 | + if ($secure === null) { |
|
880 | + $secure = !empty($modSettings['secureCookies']); |
|
881 | + } |
|
838 | 882 | |
839 | 883 | // Intercept cookie? |
840 | 884 | call_integration_hook('integrate_cookie', array($name, $value, $expire, $path, $domain, $secure, $httponly)); |
@@ -854,8 +898,9 @@ discard block |
||
854 | 898 | function hash_password($username, $password, $cost = null) |
855 | 899 | { |
856 | 900 | global $sourcedir, $smcFunc, $modSettings; |
857 | - if (!function_exists('password_hash')) |
|
858 | - require_once($sourcedir . '/Subs-Password.php'); |
|
901 | + if (!function_exists('password_hash')) { |
|
902 | + require_once($sourcedir . '/Subs-Password.php'); |
|
903 | + } |
|
859 | 904 | |
860 | 905 | $cost = empty($cost) ? (empty($modSettings['bcrypt_hash_cost']) ? 10 : $modSettings['bcrypt_hash_cost']) : $cost; |
861 | 906 | |
@@ -887,8 +932,9 @@ discard block |
||
887 | 932 | function hash_verify_password($username, $password, $hash) |
888 | 933 | { |
889 | 934 | global $sourcedir, $smcFunc; |
890 | - if (!function_exists('password_verify')) |
|
891 | - require_once($sourcedir . '/Subs-Password.php'); |
|
935 | + if (!function_exists('password_verify')) { |
|
936 | + require_once($sourcedir . '/Subs-Password.php'); |
|
937 | + } |
|
892 | 938 | |
893 | 939 | return password_verify($smcFunc['strtolower']($username) . $password, $hash); |
894 | 940 | } |
@@ -62,16 +62,17 @@ |
||
62 | 62 | <div id="error_box" class="errorbox"> |
63 | 63 | <ul id="error_list">'; |
64 | 64 | |
65 | - foreach ($context['post_errors'] as $key => $error) |
|
66 | - echo ' |
|
65 | + foreach ($context['post_errors'] as $key => $error) { |
|
66 | + echo ' |
|
67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
68 | + } |
|
68 | 69 | |
69 | 70 | echo ' |
70 | 71 | </ul>'; |
71 | - } |
|
72 | - else |
|
73 | - echo ' |
|
72 | + } else { |
|
73 | + echo ' |
|
74 | 74 | <div style="display:none" id="error_box" class="errorbox">'; |
75 | + } |
|
75 | 76 | |
76 | 77 | echo ' |
77 | 78 | </div>'; |
@@ -180,7 +180,7 @@ |
||
180 | 180 | * |
181 | 181 | * @access public |
182 | 182 | * @param string $dir A valid path |
183 | - * @return boolean If this was successful or not. |
|
183 | + * @return boolean|null If this was successful or not. |
|
184 | 184 | */ |
185 | 185 | public function setCachedir($dir = null) |
186 | 186 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -43,8 +44,9 @@ discard block |
||
43 | 44 | { |
44 | 45 | $supported = is_writable($this->cachedir); |
45 | 46 | |
46 | - if ($test) |
|
47 | - return $supported; |
|
47 | + if ($test) { |
|
48 | + return $supported; |
|
49 | + } |
|
48 | 50 | return parent::isSupported() && $supported; |
49 | 51 | } |
50 | 52 | |
@@ -61,11 +63,13 @@ discard block |
||
61 | 63 | { |
62 | 64 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
63 | 65 | // causing newer files to take effect a while later. |
64 | - if (function_exists('opcache_invalidate')) |
|
65 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
66 | + if (function_exists('opcache_invalidate')) { |
|
67 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
68 | + } |
|
66 | 69 | |
67 | - if (function_exists('apc_delete_file')) |
|
68 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
70 | + if (function_exists('apc_delete_file')) { |
|
71 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
72 | + } |
|
69 | 73 | |
70 | 74 | // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution |
71 | 75 | @include($cachedir . '/data_' . $key . '.php'); |
@@ -89,16 +93,18 @@ discard block |
||
89 | 93 | |
90 | 94 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
91 | 95 | // causing newer files to take effect a while later. |
92 | - if (function_exists('opcache_invalidate')) |
|
93 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
96 | + if (function_exists('opcache_invalidate')) { |
|
97 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
98 | + } |
|
94 | 99 | |
95 | - if (function_exists('apc_delete_file')) |
|
96 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
100 | + if (function_exists('apc_delete_file')) { |
|
101 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
102 | + } |
|
97 | 103 | |
98 | 104 | // Otherwise custom cache? |
99 | - if ($value === null) |
|
100 | - @unlink($cachedir . '/data_' . $key . '.php'); |
|
101 | - else |
|
105 | + if ($value === null) { |
|
106 | + @unlink($cachedir . '/data_' . $key . '.php'); |
|
107 | + } else |
|
102 | 108 | { |
103 | 109 | $cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>'; |
104 | 110 | |
@@ -109,9 +115,9 @@ discard block |
||
109 | 115 | { |
110 | 116 | @unlink($cachedir . '/data_' . $key . '.php'); |
111 | 117 | return false; |
118 | + } else { |
|
119 | + return true; |
|
112 | 120 | } |
113 | - else |
|
114 | - return true; |
|
115 | 121 | } |
116 | 122 | } |
117 | 123 | |
@@ -123,15 +129,17 @@ discard block |
||
123 | 129 | $cachedir = $this->cachedir; |
124 | 130 | |
125 | 131 | // No directory = no game. |
126 | - if (!is_dir($cachedir)) |
|
127 | - return; |
|
132 | + if (!is_dir($cachedir)) { |
|
133 | + return; |
|
134 | + } |
|
128 | 135 | |
129 | 136 | // Remove the files in SMF's own disk cache, if any |
130 | 137 | $dh = opendir($cachedir); |
131 | 138 | while ($file = readdir($dh)) |
132 | 139 | { |
133 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) |
|
134 | - @unlink($cachedir . '/' . $file); |
|
140 | + if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { |
|
141 | + @unlink($cachedir . '/' . $file); |
|
142 | + } |
|
135 | 143 | } |
136 | 144 | closedir($dh); |
137 | 145 | |
@@ -165,8 +173,9 @@ discard block |
||
165 | 173 | $config_vars[] = $txt['cache_smf_settings']; |
166 | 174 | $config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'); |
167 | 175 | |
168 | - if (!isset($context['settings_post_javascript'])) |
|
169 | - $context['settings_post_javascript'] = ''; |
|
176 | + if (!isset($context['settings_post_javascript'])) { |
|
177 | + $context['settings_post_javascript'] = ''; |
|
178 | + } |
|
170 | 179 | |
171 | 180 | $context['settings_post_javascript'] .= ' |
172 | 181 | $("#cache_accelerator").change(function (e) { |
@@ -187,10 +196,11 @@ discard block |
||
187 | 196 | global $cachedir; |
188 | 197 | |
189 | 198 | // If its invalid, use SMF's. |
190 | - if (is_null($dir) || !is_writable($dir)) |
|
191 | - $this->cachedir = $cachedir; |
|
192 | - else |
|
193 | - $this->cachedir = $dir; |
|
199 | + if (is_null($dir) || !is_writable($dir)) { |
|
200 | + $this->cachedir = $cachedir; |
|
201 | + } else { |
|
202 | + $this->cachedir = $dir; |
|
203 | + } |
|
194 | 204 | } |
195 | 205 | |
196 | 206 | /** |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $server = trim($servers[array_rand($servers)]); |
62 | 62 | |
63 | 63 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
64 | + if (strpos($server, '/') !== false) |
|
65 | 65 | $host = $server; |
66 | 66 | else |
67 | 67 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcache'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
61 | 63 | $server = trim($servers[array_rand($servers)]); |
62 | 64 | |
63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
65 | - $host = $server; |
|
66 | - else |
|
66 | + if (strpos($server,'/') !== false) { |
|
67 | + $host = $server; |
|
68 | + } else |
|
67 | 69 | { |
68 | 70 | $server = explode(':', $server); |
69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
74 | - if (empty($db_persist)) |
|
75 | - $connected = $this->memcache->connect($host, $port); |
|
76 | - else |
|
77 | - $connected = $this->memcache->pconnect($host, $port); |
|
76 | + if (empty($db_persist)) { |
|
77 | + $connected = $this->memcache->connect($host, $port); |
|
78 | + } else { |
|
79 | + $connected = $this->memcache->pconnect($host, $port); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | $value = $this->memcache->get($key); |
91 | 94 | |
92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
93 | - if ($value === false) |
|
94 | - return null; |
|
96 | + if ($value === false) { |
|
97 | + return null; |
|
98 | + } |
|
95 | 99 | return $value; |
96 | 100 | } |
97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
134 | 138 | |
135 | - if (!isset($context['settings_post_javascript'])) |
|
136 | - $context['settings_post_javascript'] = ''; |
|
139 | + if (!isset($context['settings_post_javascript'])) { |
|
140 | + $context['settings_post_javascript'] = ''; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $context['settings_post_javascript'] .= ' |
139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $currentServers = $this->memcached->getServerList(); |
55 | 55 | foreach ($servers as $server) |
56 | 56 | { |
57 | - if (strpos($server,'/') !== false) |
|
57 | + if (strpos($server, '/') !== false) |
|
58 | 58 | $tempServer = array($server, 0); |
59 | 59 | else |
60 | 60 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcached'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -53,9 +55,9 @@ discard block |
||
53 | 55 | $currentServers = $this->memcached->getServerList(); |
54 | 56 | foreach ($servers as $server) |
55 | 57 | { |
56 | - if (strpos($server,'/') !== false) |
|
57 | - $tempServer = array($server, 0); |
|
58 | - else |
|
58 | + if (strpos($server,'/') !== false) { |
|
59 | + $tempServer = array($server, 0); |
|
60 | + } else |
|
59 | 61 | { |
60 | 62 | $server = explode(':', $server); |
61 | 63 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | } |
74 | 76 | |
75 | 77 | // Found it? |
76 | - if (empty($foundServer)) |
|
77 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
78 | + if (empty($foundServer)) { |
|
79 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | // Best guess is this worked. |
@@ -91,8 +94,9 @@ discard block |
||
91 | 94 | $value = $this->memcached->get($key); |
92 | 95 | |
93 | 96 | // $value should return either data or false (from failure, key not found or empty array). |
94 | - if ($value === false) |
|
95 | - return null; |
|
97 | + if ($value === false) { |
|
98 | + return null; |
|
99 | + } |
|
96 | 100 | return $value; |
97 | 101 | } |
98 | 102 | |
@@ -135,8 +139,9 @@ discard block |
||
135 | 139 | $config_vars[] = $txt['cache_memcache_settings']; |
136 | 140 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
137 | 141 | |
138 | - if (!isset($context['settings_post_javascript'])) |
|
139 | - $context['settings_post_javascript'] = ''; |
|
142 | + if (!isset($context['settings_post_javascript'])) { |
|
143 | + $context['settings_post_javascript'] = ''; |
|
144 | + } |
|
140 | 145 | |
141 | 146 | $context['settings_post_javascript'] .= ' |
142 | 147 | $("#cache_accelerator").change(function (e) { |
@@ -1619,8 +1619,7 @@ |
||
1619 | 1619 | updateStats('topic'); |
1620 | 1620 | |
1621 | 1621 | // This function is needed to do the updateStats('subject') call. |
1622 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
1623 | - function($string){ |
|
1622 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
1624 | 1623 | global $sourcedir; |
1625 | 1624 | if (function_exists('mb_strtolower')) |
1626 | 1625 | return mb_strtolower($string, 'UTF-8'); |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting for fatal errors. |
154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
237 | 246 | { |
238 | 247 | // Get PHP's default timezone, if set |
239 | 248 | $ini_tz = ini_get('date.timezone'); |
240 | - if (!empty($ini_tz)) |
|
241 | - $timezone_id = $ini_tz; |
|
242 | - else |
|
243 | - $timezone_id = ''; |
|
249 | + if (!empty($ini_tz)) { |
|
250 | + $timezone_id = $ini_tz; |
|
251 | + } else { |
|
252 | + $timezone_id = ''; |
|
253 | + } |
|
244 | 254 | |
245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
271 | 281 | while ($entry = $dir->read()) |
272 | 282 | { |
273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
285 | + } |
|
275 | 286 | } |
276 | 287 | $dir->close(); |
277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
306 | 317 | } |
307 | 318 | |
308 | 319 | // Override the language file? |
309 | - if (isset($_GET['lang_file'])) |
|
310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
320 | + if (isset($_GET['lang_file'])) { |
|
321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
324 | + } |
|
313 | 325 | |
314 | 326 | // Make sure it exists, if it doesn't reset it. |
315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
319 | 331 | |
320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
335 | + } |
|
323 | 336 | } |
324 | 337 | |
325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
334 | 347 | |
335 | - if (empty($sourcedir)) |
|
336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
348 | + if (empty($sourcedir)) { |
|
349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
350 | + } |
|
337 | 351 | |
338 | 352 | // Need this to check whether we need the database password. |
339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
340 | - if (!defined('SMF')) |
|
341 | - define('SMF', 1); |
|
342 | - if (empty($smcFunc)) |
|
343 | - $smcFunc = array(); |
|
354 | + if (!defined('SMF')) { |
|
355 | + define('SMF', 1); |
|
356 | + } |
|
357 | + if (empty($smcFunc)) { |
|
358 | + $smcFunc = array(); |
|
359 | + } |
|
344 | 360 | |
345 | 361 | $modSettings['disableQueryCheck'] = true; |
346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
348 | 364 | if (!$db_connection) |
349 | 365 | { |
350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
369 | + } |
|
353 | 370 | |
354 | 371 | $db_options = array('persist' => $db_persist); |
355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
360 | 377 | if ($db_type == 'mysql') |
361 | 378 | { |
362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
363 | - } |
|
364 | - elseif ($db_type == 'postgresql') |
|
380 | + } elseif ($db_type == 'postgresql') |
|
365 | 381 | { |
366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
368 | 384 | } |
369 | 385 | } |
370 | 386 | |
371 | - if (!empty($port)) |
|
372 | - $db_options['port'] = $port; |
|
387 | + if (!empty($port)) { |
|
388 | + $db_options['port'] = $port; |
|
389 | + } |
|
373 | 390 | |
374 | - if (!$db_connection) |
|
375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
391 | + if (!$db_connection) { |
|
392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
393 | + } |
|
376 | 394 | } |
377 | 395 | } |
378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
400 | 418 | // @todo REMOVE THIS!! |
401 | 419 | else |
402 | 420 | { |
403 | - if (function_exists('doStep' . $_GET['step'])) |
|
404 | - call_user_func('doStep' . $_GET['step']); |
|
421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
422 | + call_user_func('doStep' . $_GET['step']); |
|
423 | + } |
|
405 | 424 | } |
406 | 425 | // Show the footer. |
407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
420 | 439 | |
421 | 440 | // Done the submission? |
422 | - if (isset($_POST['contbutt'])) |
|
423 | - return true; |
|
441 | + if (isset($_POST['contbutt'])) { |
|
442 | + return true; |
|
443 | + } |
|
424 | 444 | |
425 | 445 | // See if we think they have already installed it? |
426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
428 | 448 | $probably_installed = 0; |
429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
430 | 450 | { |
431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
432 | - $probably_installed++; |
|
433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
434 | - $probably_installed++; |
|
451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
452 | + $probably_installed++; |
|
453 | + } |
|
454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
455 | + $probably_installed++; |
|
456 | + } |
|
435 | 457 | } |
436 | 458 | |
437 | - if ($probably_installed == 2) |
|
438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
459 | + if ($probably_installed == 2) { |
|
460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
461 | + } |
|
439 | 462 | } |
440 | 463 | |
441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
450 | 473 | $databases[$key]['supported'] = false; |
451 | 474 | $notFoundSQLFile = true; |
452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
476 | + } else { |
|
477 | + $incontext['supported_databases'][] = $db; |
|
453 | 478 | } |
454 | - else |
|
455 | - $incontext['supported_databases'][] = $db; |
|
456 | 479 | } |
457 | 480 | } |
458 | 481 | |
459 | 482 | // Check the PHP version. |
460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
461 | - $error = 'error_php_too_low'; |
|
483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
484 | + $error = 'error_php_too_low'; |
|
485 | + } |
|
462 | 486 | // Make sure we have a supported database |
463 | - elseif (empty($incontext['supported_databases'])) |
|
464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
487 | + elseif (empty($incontext['supported_databases'])) { |
|
488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
489 | + } |
|
465 | 490 | // How about session support? Some crazy sysadmin remove it? |
466 | - elseif (!function_exists('session_start')) |
|
467 | - $error = 'error_session_missing'; |
|
491 | + elseif (!function_exists('session_start')) { |
|
492 | + $error = 'error_session_missing'; |
|
493 | + } |
|
468 | 494 | // Make sure they uploaded all the files. |
469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
470 | - $error = 'error_missing_files'; |
|
495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
496 | + $error = 'error_missing_files'; |
|
497 | + } |
|
471 | 498 | // Very simple check on the session.save_path for Windows. |
472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
474 | - $error = 'error_session_save_path'; |
|
500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
501 | + $error = 'error_session_save_path'; |
|
502 | + } |
|
475 | 503 | |
476 | 504 | // Since each of the three messages would look the same, anyway... |
477 | - if (isset($error)) |
|
478 | - $incontext['error'] = $txt[$error]; |
|
505 | + if (isset($error)) { |
|
506 | + $incontext['error'] = $txt[$error]; |
|
507 | + } |
|
479 | 508 | |
480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
512 | + } |
|
483 | 513 | |
484 | 514 | // Confirm mbstring is loaded... |
485 | - if (!extension_loaded('mbstring')) |
|
486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
515 | + if (!extension_loaded('mbstring')) { |
|
516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
517 | + } |
|
487 | 518 | |
488 | 519 | // Check for https stream support. |
489 | 520 | $supported_streams = stream_get_wrappers(); |
490 | - if (!in_array('https', $supported_streams)) |
|
491 | - $incontext['warning'] = $txt['install_no_https']; |
|
521 | + if (!in_array('https', $supported_streams)) { |
|
522 | + $incontext['warning'] = $txt['install_no_https']; |
|
523 | + } |
|
492 | 524 | |
493 | 525 | return false; |
494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
514 | 546 | 'db_last_error.php', |
515 | 547 | ); |
516 | 548 | |
517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
551 | + } |
|
519 | 552 | |
520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
556 | + } |
|
523 | 557 | |
524 | 558 | $failed_files = array(); |
525 | 559 | |
@@ -531,20 +565,23 @@ discard block |
||
531 | 565 | foreach ($writable_files as $file) |
532 | 566 | { |
533 | 567 | // Some files won't exist, try to address up front |
534 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
535 | - @touch(dirname(__FILE__) . '/' . $file); |
|
568 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
569 | + @touch(dirname(__FILE__) . '/' . $file); |
|
570 | + } |
|
536 | 571 | // NOW do the writable check... |
537 | 572 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
538 | 573 | { |
539 | 574 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
540 | 575 | |
541 | 576 | // Well, 755 hopefully worked... if not, try 777. |
542 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
543 | - $failed_files[] = $file; |
|
577 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
578 | + $failed_files[] = $file; |
|
579 | + } |
|
544 | 580 | } |
545 | 581 | } |
546 | - foreach ($extra_files as $file) |
|
547 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
582 | + foreach ($extra_files as $file) { |
|
583 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
584 | + } |
|
548 | 585 | } |
549 | 586 | // Windows is trickier. Let's try opening for r+... |
550 | 587 | else |
@@ -554,30 +591,35 @@ discard block |
||
554 | 591 | foreach ($writable_files as $file) |
555 | 592 | { |
556 | 593 | // Folders can't be opened for write... but the index.php in them can ;) |
557 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
558 | - $file .= '/index.php'; |
|
594 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
595 | + $file .= '/index.php'; |
|
596 | + } |
|
559 | 597 | |
560 | 598 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
561 | 599 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
562 | 600 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
563 | 601 | |
564 | 602 | // Hmm, okay, try just for write in that case... |
565 | - if (!is_resource($fp)) |
|
566 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
603 | + if (!is_resource($fp)) { |
|
604 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
605 | + } |
|
567 | 606 | |
568 | - if (!is_resource($fp)) |
|
569 | - $failed_files[] = $file; |
|
607 | + if (!is_resource($fp)) { |
|
608 | + $failed_files[] = $file; |
|
609 | + } |
|
570 | 610 | |
571 | 611 | @fclose($fp); |
572 | 612 | } |
573 | - foreach ($extra_files as $file) |
|
574 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
613 | + foreach ($extra_files as $file) { |
|
614 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
615 | + } |
|
575 | 616 | } |
576 | 617 | |
577 | 618 | $failure = count($failed_files) >= 1; |
578 | 619 | |
579 | - if (!isset($_SERVER)) |
|
580 | - return !$failure; |
|
620 | + if (!isset($_SERVER)) { |
|
621 | + return !$failure; |
|
622 | + } |
|
581 | 623 | |
582 | 624 | // Put the list into context. |
583 | 625 | $incontext['failed_files'] = $failed_files; |
@@ -625,19 +667,23 @@ discard block |
||
625 | 667 | |
626 | 668 | if (!isset($ftp) || $ftp->error !== false) |
627 | 669 | { |
628 | - if (!isset($ftp)) |
|
629 | - $ftp = new ftp_connection(null); |
|
670 | + if (!isset($ftp)) { |
|
671 | + $ftp = new ftp_connection(null); |
|
672 | + } |
|
630 | 673 | // Save the error so we can mess with listing... |
631 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
632 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
674 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
675 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
676 | + } |
|
633 | 677 | |
634 | 678 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
635 | 679 | |
636 | - if (empty($_POST['ftp_path']) && $found_path) |
|
637 | - $_POST['ftp_path'] = $detect_path; |
|
680 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
681 | + $_POST['ftp_path'] = $detect_path; |
|
682 | + } |
|
638 | 683 | |
639 | - if (!isset($_POST['ftp_username'])) |
|
640 | - $_POST['ftp_username'] = $username; |
|
684 | + if (!isset($_POST['ftp_username'])) { |
|
685 | + $_POST['ftp_username'] = $username; |
|
686 | + } |
|
641 | 687 | |
642 | 688 | // Set the username etc, into context. |
643 | 689 | $incontext['ftp'] = array( |
@@ -649,8 +695,7 @@ discard block |
||
649 | 695 | ); |
650 | 696 | |
651 | 697 | return false; |
652 | - } |
|
653 | - else |
|
698 | + } else |
|
654 | 699 | { |
655 | 700 | $_SESSION['installer_temp_ftp'] = array( |
656 | 701 | 'server' => $_POST['ftp_server'], |
@@ -664,10 +709,12 @@ discard block |
||
664 | 709 | |
665 | 710 | foreach ($failed_files as $file) |
666 | 711 | { |
667 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
668 | - $ftp->chmod($file, 0755); |
|
669 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
670 | - $ftp->chmod($file, 0777); |
|
712 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
713 | + $ftp->chmod($file, 0755); |
|
714 | + } |
|
715 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
716 | + $ftp->chmod($file, 0777); |
|
717 | + } |
|
671 | 718 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
672 | 719 | { |
673 | 720 | $failed_files_updated[] = $file; |
@@ -723,15 +770,17 @@ discard block |
||
723 | 770 | |
724 | 771 | if (!$foundOne) |
725 | 772 | { |
726 | - if (isset($db['default_host'])) |
|
727 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
773 | + if (isset($db['default_host'])) { |
|
774 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
775 | + } |
|
728 | 776 | if (isset($db['default_user'])) |
729 | 777 | { |
730 | 778 | $incontext['db']['user'] = ini_get($db['default_user']); |
731 | 779 | $incontext['db']['name'] = ini_get($db['default_user']); |
732 | 780 | } |
733 | - if (isset($db['default_password'])) |
|
734 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
781 | + if (isset($db['default_password'])) { |
|
782 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
783 | + } |
|
735 | 784 | |
736 | 785 | // For simplicity and less confusion, leave the port blank by default |
737 | 786 | $incontext['db']['port'] = ''; |
@@ -750,10 +799,10 @@ discard block |
||
750 | 799 | $incontext['db']['server'] = $_POST['db_server']; |
751 | 800 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
752 | 801 | |
753 | - if (!empty($_POST['db_port'])) |
|
754 | - $incontext['db']['port'] = $_POST['db_port']; |
|
755 | - } |
|
756 | - else |
|
802 | + if (!empty($_POST['db_port'])) { |
|
803 | + $incontext['db']['port'] = $_POST['db_port']; |
|
804 | + } |
|
805 | + } else |
|
757 | 806 | { |
758 | 807 | $incontext['db']['prefix'] = 'smf_'; |
759 | 808 | } |
@@ -789,10 +838,11 @@ discard block |
||
789 | 838 | if (!empty($_POST['db_port'])) |
790 | 839 | { |
791 | 840 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
792 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
793 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
794 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
795 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
841 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
842 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
843 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
844 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
845 | + } |
|
796 | 846 | } |
797 | 847 | |
798 | 848 | // God I hope it saved! |
@@ -805,8 +855,9 @@ discard block |
||
805 | 855 | // Make sure it works. |
806 | 856 | require(dirname(__FILE__) . '/Settings.php'); |
807 | 857 | |
808 | - if (empty($sourcedir)) |
|
809 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
858 | + if (empty($sourcedir)) { |
|
859 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
860 | + } |
|
810 | 861 | |
811 | 862 | // Better find the database file! |
812 | 863 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -816,18 +867,21 @@ discard block |
||
816 | 867 | } |
817 | 868 | |
818 | 869 | // Now include it for database functions! |
819 | - if (!defined('SMF')) |
|
820 | - define('SMF', 1); |
|
870 | + if (!defined('SMF')) { |
|
871 | + define('SMF', 1); |
|
872 | + } |
|
821 | 873 | |
822 | 874 | $modSettings['disableQueryCheck'] = true; |
823 | - if (empty($smcFunc)) |
|
824 | - $smcFunc = array(); |
|
875 | + if (empty($smcFunc)) { |
|
876 | + $smcFunc = array(); |
|
877 | + } |
|
825 | 878 | |
826 | 879 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
827 | 880 | |
828 | 881 | // What - running PHP4? The shame! |
829 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
830 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
882 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
883 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
884 | + } |
|
831 | 885 | |
832 | 886 | // Attempt a connection. |
833 | 887 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -915,12 +969,14 @@ discard block |
||
915 | 969 | $incontext['page_title'] = $txt['install_settings']; |
916 | 970 | |
917 | 971 | // Let's see if we got the database type correct. |
918 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
919 | - $db_type = $_POST['db_type']; |
|
972 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
973 | + $db_type = $_POST['db_type']; |
|
974 | + } |
|
920 | 975 | |
921 | 976 | // Else we'd better be able to get the connection. |
922 | - else |
|
923 | - load_database(); |
|
977 | + else { |
|
978 | + load_database(); |
|
979 | + } |
|
924 | 980 | |
925 | 981 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
926 | 982 | |
@@ -957,18 +1013,21 @@ discard block |
||
957 | 1013 | // Submitting? |
958 | 1014 | if (isset($_POST['boardurl'])) |
959 | 1015 | { |
960 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
961 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
962 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
963 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
964 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
965 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1016 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1017 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1018 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1019 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1020 | + } |
|
1021 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1022 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1023 | + } |
|
966 | 1024 | |
967 | 1025 | //Make sure boardurl is aligned with ssl setting |
968 | - if (empty($_POST['force_ssl'])) |
|
969 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
970 | - else |
|
971 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1026 | + if (empty($_POST['force_ssl'])) { |
|
1027 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1028 | + } else { |
|
1029 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1030 | + } |
|
972 | 1031 | |
973 | 1032 | // Save these variables. |
974 | 1033 | $vars = array( |
@@ -1007,10 +1066,10 @@ discard block |
||
1007 | 1066 | { |
1008 | 1067 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1009 | 1068 | return false; |
1010 | - } |
|
1011 | - else |
|
1012 | - // Set the character set here. |
|
1069 | + } else { |
|
1070 | + // Set the character set here. |
|
1013 | 1071 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1072 | + } |
|
1014 | 1073 | } |
1015 | 1074 | |
1016 | 1075 | // Good, skip on. |
@@ -1030,8 +1089,9 @@ discard block |
||
1030 | 1089 | $incontext['continue'] = 1; |
1031 | 1090 | |
1032 | 1091 | // Already done? |
1033 | - if (isset($_POST['pop_done'])) |
|
1034 | - return true; |
|
1092 | + if (isset($_POST['pop_done'])) { |
|
1093 | + return true; |
|
1094 | + } |
|
1035 | 1095 | |
1036 | 1096 | // Reload settings. |
1037 | 1097 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1049,8 +1109,9 @@ discard block |
||
1049 | 1109 | $modSettings = array(); |
1050 | 1110 | if ($result !== false) |
1051 | 1111 | { |
1052 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1053 | - $modSettings[$row['variable']] = $row['value']; |
|
1112 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1113 | + $modSettings[$row['variable']] = $row['value']; |
|
1114 | + } |
|
1054 | 1115 | $smcFunc['db_free_result']($result); |
1055 | 1116 | |
1056 | 1117 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1063,20 +1124,22 @@ discard block |
||
1063 | 1124 | $modSettings['disableQueryCheck'] = true; |
1064 | 1125 | |
1065 | 1126 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1066 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1067 | - $smcFunc['db_query']('', ' |
|
1127 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1128 | + $smcFunc['db_query']('', ' |
|
1068 | 1129 | SET NAMES {string:utf8}', |
1069 | 1130 | array( |
1070 | 1131 | 'db_error_skip' => true, |
1071 | 1132 | 'utf8' => 'utf8', |
1072 | 1133 | ) |
1073 | 1134 | ); |
1135 | + } |
|
1074 | 1136 | |
1075 | 1137 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1076 | - if (substr(__DIR__, -1) == '\\') |
|
1077 | - $attachdir = __DIR__ . 'attachments'; |
|
1078 | - else |
|
1079 | - $attachdir = __DIR__ . '/attachments'; |
|
1138 | + if (substr(__DIR__, -1) == '\\') { |
|
1139 | + $attachdir = __DIR__ . 'attachments'; |
|
1140 | + } else { |
|
1141 | + $attachdir = __DIR__ . '/attachments'; |
|
1142 | + } |
|
1080 | 1143 | |
1081 | 1144 | $replaces = array( |
1082 | 1145 | '{$db_prefix}' => $db_prefix, |
@@ -1093,8 +1156,9 @@ discard block |
||
1093 | 1156 | |
1094 | 1157 | foreach ($txt as $key => $value) |
1095 | 1158 | { |
1096 | - if (substr($key, 0, 8) == 'default_') |
|
1097 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1159 | + if (substr($key, 0, 8) == 'default_') { |
|
1160 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1161 | + } |
|
1098 | 1162 | } |
1099 | 1163 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1100 | 1164 | |
@@ -1109,8 +1173,9 @@ discard block |
||
1109 | 1173 | |
1110 | 1174 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1111 | 1175 | { |
1112 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1113 | - $engines[] = $row['Engine']; |
|
1176 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1177 | + $engines[] = $row['Engine']; |
|
1178 | + } |
|
1114 | 1179 | } |
1115 | 1180 | |
1116 | 1181 | // Done with this now |
@@ -1134,8 +1199,7 @@ discard block |
||
1134 | 1199 | $replaces['START TRANSACTION;'] = ''; |
1135 | 1200 | $replaces['COMMIT;'] = ''; |
1136 | 1201 | } |
1137 | - } |
|
1138 | - else |
|
1202 | + } else |
|
1139 | 1203 | { |
1140 | 1204 | $has_innodb = false; |
1141 | 1205 | } |
@@ -1157,21 +1221,24 @@ discard block |
||
1157 | 1221 | foreach ($sql_lines as $count => $line) |
1158 | 1222 | { |
1159 | 1223 | // No comments allowed! |
1160 | - if (substr(trim($line), 0, 1) != '#') |
|
1161 | - $current_statement .= "\n" . rtrim($line); |
|
1224 | + if (substr(trim($line), 0, 1) != '#') { |
|
1225 | + $current_statement .= "\n" . rtrim($line); |
|
1226 | + } |
|
1162 | 1227 | |
1163 | 1228 | // Is this the end of the query string? |
1164 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1165 | - continue; |
|
1229 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1230 | + continue; |
|
1231 | + } |
|
1166 | 1232 | |
1167 | 1233 | // Does this table already exist? If so, don't insert more data into it! |
1168 | 1234 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1169 | 1235 | { |
1170 | 1236 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1171 | - if (!empty($matches[0])) |
|
1172 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1173 | - else |
|
1174 | - $incontext['sql_results']['insert_dups']++; |
|
1237 | + if (!empty($matches[0])) { |
|
1238 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1239 | + } else { |
|
1240 | + $incontext['sql_results']['insert_dups']++; |
|
1241 | + } |
|
1175 | 1242 | |
1176 | 1243 | $current_statement = ''; |
1177 | 1244 | continue; |
@@ -1180,8 +1247,9 @@ discard block |
||
1180 | 1247 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1181 | 1248 | { |
1182 | 1249 | // Use the appropriate function based on the DB type |
1183 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1184 | - $db_errorno = $db_type . '_errno'; |
|
1250 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1251 | + $db_errorno = $db_type . '_errno'; |
|
1252 | + } |
|
1185 | 1253 | |
1186 | 1254 | // Error 1050: Table already exists! |
1187 | 1255 | // @todo Needs to be made better! |
@@ -1196,18 +1264,18 @@ discard block |
||
1196 | 1264 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1197 | 1265 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1198 | 1266 | } |
1199 | - } |
|
1200 | - else |
|
1267 | + } else |
|
1201 | 1268 | { |
1202 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1203 | - $incontext['sql_results']['tables']++; |
|
1204 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1269 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1270 | + $incontext['sql_results']['tables']++; |
|
1271 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1205 | 1272 | { |
1206 | 1273 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1207 | - if (!empty($matches[0])) |
|
1208 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1209 | - else |
|
1210 | - $incontext['sql_results']['inserts']++; |
|
1274 | + if (!empty($matches[0])) { |
|
1275 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1276 | + } else { |
|
1277 | + $incontext['sql_results']['inserts']++; |
|
1278 | + } |
|
1211 | 1279 | } |
1212 | 1280 | } |
1213 | 1281 | |
@@ -1220,15 +1288,17 @@ discard block |
||
1220 | 1288 | // Sort out the context for the SQL. |
1221 | 1289 | foreach ($incontext['sql_results'] as $key => $number) |
1222 | 1290 | { |
1223 | - if ($number == 0) |
|
1224 | - unset($incontext['sql_results'][$key]); |
|
1225 | - else |
|
1226 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1291 | + if ($number == 0) { |
|
1292 | + unset($incontext['sql_results'][$key]); |
|
1293 | + } else { |
|
1294 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1295 | + } |
|
1227 | 1296 | } |
1228 | 1297 | |
1229 | 1298 | // Make sure UTF will be used globally. |
1230 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1231 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1299 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1300 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1301 | + } |
|
1232 | 1302 | |
1233 | 1303 | // Auto-detect local & global cookie settings |
1234 | 1304 | $url_parts = parse_url($boardurl); |
@@ -1257,15 +1327,19 @@ discard block |
||
1257 | 1327 | |
1258 | 1328 | // Look for subfolder, if found, set localCookie |
1259 | 1329 | // Checking for len > 1 ensures you don't have just a slash... |
1260 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
1261 | - $localCookies = '1'; |
|
1330 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
1331 | + $localCookies = '1'; |
|
1332 | + } |
|
1262 | 1333 | |
1263 | - if (isset($globalCookies)) |
|
1264 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
1265 | - if (isset($globalCookiesDomain)) |
|
1266 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1267 | - if (isset($localCookies)) |
|
1268 | - $newSettings[] = array('localCookies', $localCookies); |
|
1334 | + if (isset($globalCookies)) { |
|
1335 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
1336 | + } |
|
1337 | + if (isset($globalCookiesDomain)) { |
|
1338 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1339 | + } |
|
1340 | + if (isset($localCookies)) { |
|
1341 | + $newSettings[] = array('localCookies', $localCookies); |
|
1342 | + } |
|
1269 | 1343 | } |
1270 | 1344 | |
1271 | 1345 | // Are we allowing stat collection? |
@@ -1283,16 +1357,17 @@ discard block |
||
1283 | 1357 | fwrite($fp, $out); |
1284 | 1358 | |
1285 | 1359 | $return_data = ''; |
1286 | - while (!feof($fp)) |
|
1287 | - $return_data .= fgets($fp, 128); |
|
1360 | + while (!feof($fp)) { |
|
1361 | + $return_data .= fgets($fp, 128); |
|
1362 | + } |
|
1288 | 1363 | |
1289 | 1364 | fclose($fp); |
1290 | 1365 | |
1291 | 1366 | // Get the unique site ID. |
1292 | 1367 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1293 | 1368 | |
1294 | - if (!empty($ID[1])) |
|
1295 | - $smcFunc['db_insert']('replace', |
|
1369 | + if (!empty($ID[1])) { |
|
1370 | + $smcFunc['db_insert']('replace', |
|
1296 | 1371 | $db_prefix . 'settings', |
1297 | 1372 | array('variable' => 'string', 'value' => 'string'), |
1298 | 1373 | array( |
@@ -1301,11 +1376,12 @@ discard block |
||
1301 | 1376 | ), |
1302 | 1377 | array('variable') |
1303 | 1378 | ); |
1379 | + } |
|
1304 | 1380 | } |
1305 | 1381 | } |
1306 | 1382 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1307 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1308 | - $smcFunc['db_query']('', ' |
|
1383 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1384 | + $smcFunc['db_query']('', ' |
|
1309 | 1385 | DELETE FROM {db_prefix}settings |
1310 | 1386 | WHERE variable = {string:enable_sm_stats}', |
1311 | 1387 | array( |
@@ -1313,20 +1389,23 @@ discard block |
||
1313 | 1389 | 'db_error_skip' => true, |
1314 | 1390 | ) |
1315 | 1391 | ); |
1392 | + } |
|
1316 | 1393 | |
1317 | 1394 | // Are we enabling SSL? |
1318 | - if (!empty($_POST['force_ssl'])) |
|
1319 | - $newSettings[] = array('force_ssl', 2); |
|
1395 | + if (!empty($_POST['force_ssl'])) { |
|
1396 | + $newSettings[] = array('force_ssl', 2); |
|
1397 | + } |
|
1320 | 1398 | |
1321 | 1399 | // Setting a timezone is required. |
1322 | 1400 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1323 | 1401 | { |
1324 | 1402 | // Get PHP's default timezone, if set |
1325 | 1403 | $ini_tz = ini_get('date.timezone'); |
1326 | - if (!empty($ini_tz)) |
|
1327 | - $timezone_id = $ini_tz; |
|
1328 | - else |
|
1329 | - $timezone_id = ''; |
|
1404 | + if (!empty($ini_tz)) { |
|
1405 | + $timezone_id = $ini_tz; |
|
1406 | + } else { |
|
1407 | + $timezone_id = ''; |
|
1408 | + } |
|
1330 | 1409 | |
1331 | 1410 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1332 | 1411 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1335,8 +1414,9 @@ discard block |
||
1335 | 1414 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1336 | 1415 | } |
1337 | 1416 | |
1338 | - if (date_default_timezone_set($timezone_id)) |
|
1339 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1417 | + if (date_default_timezone_set($timezone_id)) { |
|
1418 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1419 | + } |
|
1340 | 1420 | } |
1341 | 1421 | |
1342 | 1422 | if (!empty($newSettings)) |
@@ -1367,16 +1447,18 @@ discard block |
||
1367 | 1447 | } |
1368 | 1448 | |
1369 | 1449 | // MySQL specific stuff |
1370 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1371 | - return false; |
|
1450 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1451 | + return false; |
|
1452 | + } |
|
1372 | 1453 | |
1373 | 1454 | // Find database user privileges. |
1374 | 1455 | $privs = array(); |
1375 | 1456 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1376 | 1457 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1377 | 1458 | { |
1378 | - if ($row['Privilege'] == 'Alter') |
|
1379 | - $privs[] = $row['Privilege']; |
|
1459 | + if ($row['Privilege'] == 'Alter') { |
|
1460 | + $privs[] = $row['Privilege']; |
|
1461 | + } |
|
1380 | 1462 | } |
1381 | 1463 | $smcFunc['db_free_result']($get_privs); |
1382 | 1464 | |
@@ -1406,8 +1488,9 @@ discard block |
||
1406 | 1488 | $incontext['continue'] = 1; |
1407 | 1489 | |
1408 | 1490 | // Skipping? |
1409 | - if (!empty($_POST['skip'])) |
|
1410 | - return true; |
|
1491 | + if (!empty($_POST['skip'])) { |
|
1492 | + return true; |
|
1493 | + } |
|
1411 | 1494 | |
1412 | 1495 | // Need this to check whether we need the database password. |
1413 | 1496 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1424,18 +1507,22 @@ discard block |
||
1424 | 1507 | // We need this to properly hash the password for Admin |
1425 | 1508 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1426 | 1509 | global $sourcedir; |
1427 | - if (function_exists('mb_strtolower')) |
|
1428 | - return mb_strtolower($string, 'UTF-8'); |
|
1510 | + if (function_exists('mb_strtolower')) { |
|
1511 | + return mb_strtolower($string, 'UTF-8'); |
|
1512 | + } |
|
1429 | 1513 | require_once($sourcedir . '/Subs-Charset.php'); |
1430 | 1514 | return utf8_strtolower($string); |
1431 | 1515 | }; |
1432 | 1516 | |
1433 | - if (!isset($_POST['username'])) |
|
1434 | - $_POST['username'] = ''; |
|
1435 | - if (!isset($_POST['email'])) |
|
1436 | - $_POST['email'] = ''; |
|
1437 | - if (!isset($_POST['server_email'])) |
|
1438 | - $_POST['server_email'] = ''; |
|
1517 | + if (!isset($_POST['username'])) { |
|
1518 | + $_POST['username'] = ''; |
|
1519 | + } |
|
1520 | + if (!isset($_POST['email'])) { |
|
1521 | + $_POST['email'] = ''; |
|
1522 | + } |
|
1523 | + if (!isset($_POST['server_email'])) { |
|
1524 | + $_POST['server_email'] = ''; |
|
1525 | + } |
|
1439 | 1526 | |
1440 | 1527 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1441 | 1528 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1454,8 +1541,9 @@ discard block |
||
1454 | 1541 | 'admin_group' => 1, |
1455 | 1542 | ) |
1456 | 1543 | ); |
1457 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1458 | - $incontext['skip'] = 1; |
|
1544 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1545 | + $incontext['skip'] = 1; |
|
1546 | + } |
|
1459 | 1547 | $smcFunc['db_free_result']($request); |
1460 | 1548 | |
1461 | 1549 | // Trying to create an account? |
@@ -1486,8 +1574,9 @@ discard block |
||
1486 | 1574 | } |
1487 | 1575 | |
1488 | 1576 | // Update the webmaster's email? |
1489 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1490 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1577 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1578 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1579 | + } |
|
1491 | 1580 | |
1492 | 1581 | // Work out whether we're going to have dodgy characters and remove them. |
1493 | 1582 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1510,32 +1599,27 @@ discard block |
||
1510 | 1599 | $smcFunc['db_free_result']($result); |
1511 | 1600 | |
1512 | 1601 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1513 | - } |
|
1514 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1602 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1515 | 1603 | { |
1516 | 1604 | // Try the previous step again. |
1517 | 1605 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1518 | 1606 | return false; |
1519 | - } |
|
1520 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1607 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1521 | 1608 | { |
1522 | 1609 | // Try the previous step again. |
1523 | 1610 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1524 | 1611 | return false; |
1525 | - } |
|
1526 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1612 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1527 | 1613 | { |
1528 | 1614 | // One step back, this time fill out a proper admin email address. |
1529 | 1615 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1530 | 1616 | return false; |
1531 | - } |
|
1532 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1617 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1533 | 1618 | { |
1534 | 1619 | // One step back, this time fill out a proper admin email address. |
1535 | 1620 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1536 | 1621 | return false; |
1537 | - } |
|
1538 | - elseif ($_POST['username'] != '') |
|
1622 | + } elseif ($_POST['username'] != '') |
|
1539 | 1623 | { |
1540 | 1624 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1541 | 1625 | |
@@ -1603,17 +1687,19 @@ discard block |
||
1603 | 1687 | reloadSettings(); |
1604 | 1688 | |
1605 | 1689 | // Bring a warning over. |
1606 | - if (!empty($incontext['account_existed'])) |
|
1607 | - $incontext['warning'] = $incontext['account_existed']; |
|
1690 | + if (!empty($incontext['account_existed'])) { |
|
1691 | + $incontext['warning'] = $incontext['account_existed']; |
|
1692 | + } |
|
1608 | 1693 | |
1609 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1610 | - $smcFunc['db_query']('', ' |
|
1694 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1695 | + $smcFunc['db_query']('', ' |
|
1611 | 1696 | SET NAMES {string:db_character_set}', |
1612 | 1697 | array( |
1613 | 1698 | 'db_character_set' => $db_character_set, |
1614 | 1699 | 'db_error_skip' => true, |
1615 | 1700 | ) |
1616 | 1701 | ); |
1702 | + } |
|
1617 | 1703 | |
1618 | 1704 | // As track stats is by default enabled let's add some activity. |
1619 | 1705 | $smcFunc['db_insert']('ignore', |
@@ -1634,14 +1720,16 @@ discard block |
||
1634 | 1720 | // Only proceed if we can load the data. |
1635 | 1721 | if ($request) |
1636 | 1722 | { |
1637 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1638 | - $modSettings[$row[0]] = $row[1]; |
|
1723 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1724 | + $modSettings[$row[0]] = $row[1]; |
|
1725 | + } |
|
1639 | 1726 | $smcFunc['db_free_result']($request); |
1640 | 1727 | } |
1641 | 1728 | |
1642 | 1729 | // Automatically log them in ;) |
1643 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1644 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1730 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1731 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1732 | + } |
|
1645 | 1733 | |
1646 | 1734 | $result = $smcFunc['db_query']('', ' |
1647 | 1735 | SELECT value |
@@ -1652,13 +1740,14 @@ discard block |
||
1652 | 1740 | 'db_error_skip' => true, |
1653 | 1741 | ) |
1654 | 1742 | ); |
1655 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1656 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1743 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1744 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1745 | + } |
|
1657 | 1746 | $smcFunc['db_free_result']($result); |
1658 | 1747 | |
1659 | - if (empty($db_sessions)) |
|
1660 | - $_SESSION['admin_time'] = time(); |
|
1661 | - else |
|
1748 | + if (empty($db_sessions)) { |
|
1749 | + $_SESSION['admin_time'] = time(); |
|
1750 | + } else |
|
1662 | 1751 | { |
1663 | 1752 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1664 | 1753 | |
@@ -1682,8 +1771,9 @@ discard block |
||
1682 | 1771 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1683 | 1772 | function($string){ |
1684 | 1773 | global $sourcedir; |
1685 | - if (function_exists('mb_strtolower')) |
|
1686 | - return mb_strtolower($string, 'UTF-8'); |
|
1774 | + if (function_exists('mb_strtolower')) { |
|
1775 | + return mb_strtolower($string, 'UTF-8'); |
|
1776 | + } |
|
1687 | 1777 | require_once($sourcedir . '/Subs-Charset.php'); |
1688 | 1778 | return utf8_strtolower($string); |
1689 | 1779 | }; |
@@ -1699,8 +1789,9 @@ discard block |
||
1699 | 1789 | ) |
1700 | 1790 | ); |
1701 | 1791 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1702 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1703 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1792 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1793 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1794 | + } |
|
1704 | 1795 | $smcFunc['db_free_result']($request); |
1705 | 1796 | |
1706 | 1797 | // Now is the perfect time to fetch the SM files. |
@@ -1719,8 +1810,9 @@ discard block |
||
1719 | 1810 | |
1720 | 1811 | // Check if we need some stupid MySQL fix. |
1721 | 1812 | $server_version = $smcFunc['db_server_info'](); |
1722 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1723 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1813 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1814 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1815 | + } |
|
1724 | 1816 | |
1725 | 1817 | // Some final context for the template. |
1726 | 1818 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1740,8 +1832,9 @@ discard block |
||
1740 | 1832 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1741 | 1833 | |
1742 | 1834 | // @todo Do we just want to read the file in clean, and split it this way always? |
1743 | - if (count($settingsArray) == 1) |
|
1744 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1835 | + if (count($settingsArray) == 1) { |
|
1836 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1837 | + } |
|
1745 | 1838 | |
1746 | 1839 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1747 | 1840 | { |
@@ -1756,19 +1849,22 @@ discard block |
||
1756 | 1849 | continue; |
1757 | 1850 | } |
1758 | 1851 | |
1759 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1760 | - $settingsArray[$i] = ''; |
|
1852 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1853 | + $settingsArray[$i] = ''; |
|
1854 | + } |
|
1761 | 1855 | |
1762 | 1856 | // Don't trim or bother with it if it's not a variable. |
1763 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1764 | - continue; |
|
1857 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1858 | + continue; |
|
1859 | + } |
|
1765 | 1860 | |
1766 | 1861 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1767 | 1862 | |
1768 | - foreach ($vars as $var => $val) |
|
1769 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1863 | + foreach ($vars as $var => $val) { |
|
1864 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1770 | 1865 | { |
1771 | 1866 | $comment = strstr($settingsArray[$i], '#'); |
1867 | + } |
|
1772 | 1868 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1773 | 1869 | unset($vars[$var]); |
1774 | 1870 | } |
@@ -1778,36 +1874,41 @@ discard block |
||
1778 | 1874 | if (!empty($vars)) |
1779 | 1875 | { |
1780 | 1876 | $settingsArray[$i++] = ''; |
1781 | - foreach ($vars as $var => $val) |
|
1782 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1877 | + foreach ($vars as $var => $val) { |
|
1878 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1879 | + } |
|
1783 | 1880 | } |
1784 | 1881 | |
1785 | 1882 | // Blank out the file - done to fix a oddity with some servers. |
1786 | 1883 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1787 | - if (!$fp) |
|
1788 | - return false; |
|
1884 | + if (!$fp) { |
|
1885 | + return false; |
|
1886 | + } |
|
1789 | 1887 | fclose($fp); |
1790 | 1888 | |
1791 | 1889 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1792 | 1890 | |
1793 | 1891 | // Gotta have one of these ;) |
1794 | - if (trim($settingsArray[0]) != '<?php') |
|
1795 | - fwrite($fp, "<?php\n"); |
|
1892 | + if (trim($settingsArray[0]) != '<?php') { |
|
1893 | + fwrite($fp, "<?php\n"); |
|
1894 | + } |
|
1796 | 1895 | |
1797 | 1896 | $lines = count($settingsArray); |
1798 | 1897 | for ($i = 0; $i < $lines - 1; $i++) |
1799 | 1898 | { |
1800 | 1899 | // Don't just write a bunch of blank lines. |
1801 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1802 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1900 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1901 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1902 | + } |
|
1803 | 1903 | } |
1804 | 1904 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1805 | 1905 | fclose($fp); |
1806 | 1906 | |
1807 | 1907 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1808 | 1908 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1809 | - if (function_exists('opcache_invalidate')) |
|
1810 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1909 | + if (function_exists('opcache_invalidate')) { |
|
1910 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1911 | + } |
|
1811 | 1912 | |
1812 | 1913 | return true; |
1813 | 1914 | } |
@@ -1832,9 +1933,9 @@ discard block |
||
1832 | 1933 | SecFilterScanPOST Off |
1833 | 1934 | </IfModule>'; |
1834 | 1935 | |
1835 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1836 | - return true; |
|
1837 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1936 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1937 | + return true; |
|
1938 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1838 | 1939 | { |
1839 | 1940 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1840 | 1941 | |
@@ -1846,29 +1947,28 @@ discard block |
||
1846 | 1947 | fwrite($ht_handle, $htaccess_addition); |
1847 | 1948 | fclose($ht_handle); |
1848 | 1949 | return true; |
1950 | + } else { |
|
1951 | + return false; |
|
1849 | 1952 | } |
1850 | - else |
|
1851 | - return false; |
|
1953 | + } else { |
|
1954 | + return true; |
|
1852 | 1955 | } |
1853 | - else |
|
1854 | - return true; |
|
1855 | - } |
|
1856 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1857 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1858 | - elseif (is_writable(dirname(__FILE__))) |
|
1956 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1957 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1958 | + } elseif (is_writable(dirname(__FILE__))) |
|
1859 | 1959 | { |
1860 | 1960 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1861 | 1961 | { |
1862 | 1962 | fwrite($ht_handle, $htaccess_addition); |
1863 | 1963 | fclose($ht_handle); |
1864 | 1964 | return true; |
1965 | + } else { |
|
1966 | + return false; |
|
1865 | 1967 | } |
1866 | - else |
|
1968 | + } else { |
|
1867 | 1969 | return false; |
1868 | 1970 | } |
1869 | - else |
|
1870 | - return false; |
|
1871 | -} |
|
1971 | + } |
|
1872 | 1972 | |
1873 | 1973 | function template_install_above() |
1874 | 1974 | { |
@@ -1906,9 +2006,10 @@ discard block |
||
1906 | 2006 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1907 | 2007 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1908 | 2008 | |
1909 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1910 | - echo ' |
|
2009 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2010 | + echo ' |
|
1911 | 2011 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
2012 | + } |
|
1912 | 2013 | |
1913 | 2014 | echo ' |
1914 | 2015 | </select> |
@@ -1928,9 +2029,10 @@ discard block |
||
1928 | 2029 | <h2>', $txt['upgrade_progress'], '</h2> |
1929 | 2030 | <ul>'; |
1930 | 2031 | |
1931 | - foreach ($incontext['steps'] as $num => $step) |
|
1932 | - echo ' |
|
2032 | + foreach ($incontext['steps'] as $num => $step) { |
|
2033 | + echo ' |
|
1933 | 2034 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2035 | + } |
|
1934 | 2036 | |
1935 | 2037 | echo ' |
1936 | 2038 | </ul> |
@@ -1955,20 +2057,23 @@ discard block |
||
1955 | 2057 | echo ' |
1956 | 2058 | <div class="floatright">'; |
1957 | 2059 | |
1958 | - if (!empty($incontext['continue'])) |
|
1959 | - echo ' |
|
2060 | + if (!empty($incontext['continue'])) { |
|
2061 | + echo ' |
|
1960 | 2062 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
1961 | - if (!empty($incontext['skip'])) |
|
1962 | - echo ' |
|
2063 | + } |
|
2064 | + if (!empty($incontext['skip'])) { |
|
2065 | + echo ' |
|
1963 | 2066 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
2067 | + } |
|
1964 | 2068 | echo ' |
1965 | 2069 | </div>'; |
1966 | 2070 | } |
1967 | 2071 | |
1968 | 2072 | // Show the closing form tag and other data only if not in the last step |
1969 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1970 | - echo ' |
|
2073 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2074 | + echo ' |
|
1971 | 2075 | </form>'; |
2076 | + } |
|
1972 | 2077 | |
1973 | 2078 | echo ' |
1974 | 2079 | </div> |
@@ -2003,13 +2108,15 @@ discard block |
||
2003 | 2108 | </div>'; |
2004 | 2109 | |
2005 | 2110 | // Show the warnings, or not. |
2006 | - if (template_warning_divs()) |
|
2007 | - echo ' |
|
2111 | + if (template_warning_divs()) { |
|
2112 | + echo ' |
|
2008 | 2113 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2114 | + } |
|
2009 | 2115 | |
2010 | 2116 | // Say we want the continue button! |
2011 | - if (empty($incontext['error'])) |
|
2012 | - $incontext['continue'] = 1; |
|
2117 | + if (empty($incontext['error'])) { |
|
2118 | + $incontext['continue'] = 1; |
|
2119 | + } |
|
2013 | 2120 | |
2014 | 2121 | // For the latest version stuff. |
2015 | 2122 | echo ' |
@@ -2043,8 +2150,8 @@ discard block |
||
2043 | 2150 | global $txt, $incontext; |
2044 | 2151 | |
2045 | 2152 | // Errors are very serious.. |
2046 | - if (!empty($incontext['error'])) |
|
2047 | - echo ' |
|
2153 | + if (!empty($incontext['error'])) { |
|
2154 | + echo ' |
|
2048 | 2155 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2049 | 2156 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2050 | 2157 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2052,9 +2159,10 @@ discard block |
||
2052 | 2159 | ', $incontext['error'], ' |
2053 | 2160 | </div> |
2054 | 2161 | </div>'; |
2162 | + } |
|
2055 | 2163 | // A warning message? |
2056 | - elseif (!empty($incontext['warning'])) |
|
2057 | - echo ' |
|
2164 | + elseif (!empty($incontext['warning'])) { |
|
2165 | + echo ' |
|
2058 | 2166 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2059 | 2167 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2060 | 2168 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2062,6 +2170,7 @@ discard block |
||
2062 | 2170 | ', $incontext['warning'], ' |
2063 | 2171 | </div> |
2064 | 2172 | </div>'; |
2173 | + } |
|
2065 | 2174 | |
2066 | 2175 | return empty($incontext['error']) && empty($incontext['warning']); |
2067 | 2176 | } |
@@ -2077,27 +2186,30 @@ discard block |
||
2077 | 2186 | <li>', $incontext['failed_files']), '</li> |
2078 | 2187 | </ul>'; |
2079 | 2188 | |
2080 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2081 | - echo ' |
|
2189 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2190 | + echo ' |
|
2082 | 2191 | <hr> |
2083 | 2192 | <p>', $txt['chmod_linux_info'], '</p> |
2084 | 2193 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2194 | + } |
|
2085 | 2195 | |
2086 | 2196 | // This is serious! |
2087 | - if (!template_warning_divs()) |
|
2088 | - return; |
|
2197 | + if (!template_warning_divs()) { |
|
2198 | + return; |
|
2199 | + } |
|
2089 | 2200 | |
2090 | 2201 | echo ' |
2091 | 2202 | <hr> |
2092 | 2203 | <p>', $txt['ftp_setup_info'], '</p>'; |
2093 | 2204 | |
2094 | - if (!empty($incontext['ftp_errors'])) |
|
2095 | - echo ' |
|
2205 | + if (!empty($incontext['ftp_errors'])) { |
|
2206 | + echo ' |
|
2096 | 2207 | <div class="error_message"> |
2097 | 2208 | ', $txt['error_ftp_no_connect'], '<br><br> |
2098 | 2209 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2099 | 2210 | </div> |
2100 | 2211 | <br>'; |
2212 | + } |
|
2101 | 2213 | |
2102 | 2214 | echo ' |
2103 | 2215 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2157,17 +2269,17 @@ discard block |
||
2157 | 2269 | <td> |
2158 | 2270 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2159 | 2271 | |
2160 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2161 | - echo ' |
|
2272 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2273 | + echo ' |
|
2162 | 2274 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2275 | + } |
|
2163 | 2276 | |
2164 | 2277 | echo ' |
2165 | 2278 | </select> |
2166 | 2279 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2167 | 2280 | </td> |
2168 | 2281 | </tr>'; |
2169 | - } |
|
2170 | - else |
|
2282 | + } else |
|
2171 | 2283 | { |
2172 | 2284 | echo ' |
2173 | 2285 | <tr style="display: none;"> |
@@ -2360,9 +2472,10 @@ discard block |
||
2360 | 2472 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2361 | 2473 | <ul>'; |
2362 | 2474 | |
2363 | - foreach ($incontext['failures'] as $line => $fail) |
|
2364 | - echo ' |
|
2475 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2476 | + echo ' |
|
2365 | 2477 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2478 | + } |
|
2366 | 2479 | |
2367 | 2480 | echo ' |
2368 | 2481 | </ul>'; |
@@ -2423,15 +2536,16 @@ discard block |
||
2423 | 2536 | </tr> |
2424 | 2537 | </table>'; |
2425 | 2538 | |
2426 | - if ($incontext['require_db_confirm']) |
|
2427 | - echo ' |
|
2539 | + if ($incontext['require_db_confirm']) { |
|
2540 | + echo ' |
|
2428 | 2541 | <h2>', $txt['user_settings_database'], '</h2> |
2429 | 2542 | <p>', $txt['user_settings_database_info'], '</p> |
2430 | 2543 | |
2431 | 2544 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2432 | 2545 | <input type="password" name="password3" size="30" /> |
2433 | 2546 | </div>'; |
2434 | -} |
|
2547 | + } |
|
2548 | + } |
|
2435 | 2549 | |
2436 | 2550 | // Tell them it's done, and to delete. |
2437 | 2551 | function template_delete_install() |
@@ -2444,14 +2558,15 @@ discard block |
||
2444 | 2558 | template_warning_divs(); |
2445 | 2559 | |
2446 | 2560 | // Install directory still writable? |
2447 | - if ($incontext['dir_still_writable']) |
|
2448 | - echo ' |
|
2561 | + if ($incontext['dir_still_writable']) { |
|
2562 | + echo ' |
|
2449 | 2563 | <em>', $txt['still_writable'], '</em><br> |
2450 | 2564 | <br>'; |
2565 | + } |
|
2451 | 2566 | |
2452 | 2567 | // Don't show the box if it's like 99% sure it won't work :P. |
2453 | - if ($incontext['probably_delete_install']) |
|
2454 | - echo ' |
|
2568 | + if ($incontext['probably_delete_install']) { |
|
2569 | + echo ' |
|
2455 | 2570 | <div style="margin: 1ex; font-weight: bold;"> |
2456 | 2571 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2457 | 2572 | </div> |
@@ -2467,6 +2582,7 @@ discard block |
||
2467 | 2582 | } |
2468 | 2583 | </script> |
2469 | 2584 | <br>'; |
2585 | + } |
|
2470 | 2586 | |
2471 | 2587 | echo ' |
2472 | 2588 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |