@@ -384,7 +384,7 @@ |
||
| 384 | 384 | clean_cache(); |
| 385 | 385 | |
| 386 | 386 | // If warning decrement is enabled and we have people who have not had a new warning in 24 hours, lower their warning level. |
| 387 | - list (, , $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']); |
|
| 387 | + list (,, $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']); |
|
| 388 | 388 | if ($modSettings['warning_decrement']) |
| 389 | 389 | { |
| 390 | 390 | // Find every member who has a warning level... |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
| 24 | 25 | global $time_start, $smcFunc; |
| 25 | 26 | |
| 26 | 27 | // Special case for doing the mail queue. |
| 27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
| 28 | - ReduceMailQueue(); |
|
| 29 | - else |
|
| 28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
| 29 | + ReduceMailQueue(); |
|
| 30 | + } else |
|
| 30 | 31 | { |
| 31 | 32 | $task_string = ''; |
| 32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | // How long in seconds it the gap? |
| 55 | 56 | $duration = $row['time_regularity']; |
| 56 | - if ($row['time_unit'] == 'm') |
|
| 57 | - $duration *= 60; |
|
| 58 | - elseif ($row['time_unit'] == 'h') |
|
| 59 | - $duration *= 3600; |
|
| 60 | - elseif ($row['time_unit'] == 'd') |
|
| 61 | - $duration *= 86400; |
|
| 62 | - elseif ($row['time_unit'] == 'w') |
|
| 63 | - $duration *= 604800; |
|
| 57 | + if ($row['time_unit'] == 'm') { |
|
| 58 | + $duration *= 60; |
|
| 59 | + } elseif ($row['time_unit'] == 'h') { |
|
| 60 | + $duration *= 3600; |
|
| 61 | + } elseif ($row['time_unit'] == 'd') { |
|
| 62 | + $duration *= 86400; |
|
| 63 | + } elseif ($row['time_unit'] == 'w') { |
|
| 64 | + $duration *= 604800; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // If we were really late running this task actually skip the next one. |
| 66 | - if (time() + ($duration / 2) > $next_time) |
|
| 67 | - $next_time += $duration; |
|
| 68 | + if (time() + ($duration / 2) > $next_time) { |
|
| 69 | + $next_time += $duration; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Update it now, so no others run this! |
| 70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
| 81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
| 82 | 85 | |
| 83 | 86 | // What kind of task are we handling? |
| 84 | - if (!empty($row['callable'])) |
|
| 85 | - $task_string = $row['callable']; |
|
| 87 | + if (!empty($row['callable'])) { |
|
| 88 | + $task_string = $row['callable']; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | // Default SMF task or old mods? |
| 88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 89 | - $task_string = 'scheduled_' . $row['task']; |
|
| 92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 93 | + $task_string = 'scheduled_' . $row['task']; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // One last resource, the task name. |
| 92 | - elseif (!empty($row['task'])) |
|
| 93 | - $task_string = $row['task']; |
|
| 97 | + elseif (!empty($row['task'])) { |
|
| 98 | + $task_string = $row['task']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
| 96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
| 101 | 107 | $callable_task = call_helper($task_string, true); |
| 102 | 108 | |
| 103 | 109 | // Perform the task. |
| 104 | - if (!empty($callable_task)) |
|
| 105 | - $completed = call_user_func($callable_task); |
|
| 106 | - |
|
| 107 | - else |
|
| 108 | - $completed = false; |
|
| 110 | + if (!empty($callable_task)) { |
|
| 111 | + $completed = call_user_func($callable_task); |
|
| 112 | + } else { |
|
| 113 | + $completed = false; |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | // Log that we did it ;) |
| 111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
| 138 | 144 | ) |
| 139 | 145 | ); |
| 140 | 146 | // No new task scheduled yet? |
| 141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 142 | - $nextEvent = time() + 86400; |
|
| 143 | - else |
|
| 144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 148 | + $nextEvent = time() + 86400; |
|
| 149 | + } else { |
|
| 150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 151 | + } |
|
| 145 | 152 | $smcFunc['db_free_result']($request); |
| 146 | 153 | |
| 147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | 157 | // Shall we return? |
| 151 | - if (!isset($_GET['scheduled'])) |
|
| 152 | - return true; |
|
| 158 | + if (!isset($_GET['scheduled'])) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | // Finally, send some stuff... |
| 155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
| 181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 182 | 190 | { |
| 183 | 191 | // If this is no longer around we'll ignore it. |
| 184 | - if (empty($row['id_topic'])) |
|
| 185 | - continue; |
|
| 192 | + if (empty($row['id_topic'])) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 186 | 195 | |
| 187 | 196 | // What type is it? |
| 188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
| 189 | - $type = 'topic'; |
|
| 190 | - elseif ($row['id_attach']) |
|
| 191 | - $type = 'attach'; |
|
| 192 | - else |
|
| 193 | - $type = 'msg'; |
|
| 197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
| 198 | + $type = 'topic'; |
|
| 199 | + } elseif ($row['id_attach']) { |
|
| 200 | + $type = 'attach'; |
|
| 201 | + } else { |
|
| 202 | + $type = 'msg'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | // Add it to the array otherwise. |
| 196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
| 211 | 221 | ); |
| 212 | 222 | |
| 213 | 223 | // If nothing quit now. |
| 214 | - if (empty($notices)) |
|
| 215 | - return true; |
|
| 224 | + if (empty($notices)) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 216 | 227 | |
| 217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
| 218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
| 231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 232 | 243 | { |
| 233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
| 234 | - if ($row['id_group'] < 2) |
|
| 235 | - continue; |
|
| 245 | + if ($row['id_group'] < 2) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
| 238 | 250 | |
| 239 | 251 | // Anyone who can access has to be considered. |
| 240 | - if ($row['add_deny']) |
|
| 241 | - $addGroups[] = $row['id_group']; |
|
| 252 | + if ($row['add_deny']) { |
|
| 253 | + $addGroups[] = $row['id_group']; |
|
| 254 | + } |
|
| 242 | 255 | } |
| 243 | 256 | $smcFunc['db_free_result']($request); |
| 244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | if (!empty($row['mod_prefs'])) |
| 284 | 297 | { |
| 285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
| 286 | - if (!($pref_binary & 4)) |
|
| 287 | - continue; |
|
| 299 | + if (!($pref_binary & 4)) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | |
| 290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
| 309 | 323 | $emailbody = ''; |
| 310 | 324 | |
| 311 | 325 | // Load the language file as required. |
| 312 | - if (empty($current_language) || $current_language != $member['language']) |
|
| 313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
| 327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | // Loop through each notice... |
| 316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
| 318 | 333 | $access = false; |
| 319 | 334 | |
| 320 | 335 | // Can they mod in this board? |
| 321 | - if (isset($mods[$id][$board])) |
|
| 322 | - $access = true; |
|
| 336 | + if (isset($mods[$id][$board])) { |
|
| 337 | + $access = true; |
|
| 338 | + } |
|
| 323 | 339 | |
| 324 | 340 | // Do the group check... |
| 325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
| 326 | 342 | { |
| 327 | 343 | // They can access?! |
| 328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
| 329 | - $access = true; |
|
| 344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
| 345 | + $access = true; |
|
| 346 | + } |
|
| 330 | 347 | |
| 331 | 348 | // If they have deny rights don't consider them! |
| 332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
| 333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
| 350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 334 | 351 | $access = false; |
| 352 | + } |
|
| 335 | 353 | } |
| 336 | 354 | |
| 337 | 355 | // Finally, fix it for admins! |
| 338 | - if (in_array(1, $member['groups'])) |
|
| 339 | - $access = true; |
|
| 356 | + if (in_array(1, $member['groups'])) { |
|
| 357 | + $access = true; |
|
| 358 | + } |
|
| 340 | 359 | |
| 341 | 360 | // If they can't access it then give it a break! |
| 342 | - if (!$access) |
|
| 343 | - continue; |
|
| 361 | + if (!$access) { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 344 | 364 | |
| 345 | 365 | foreach ($notice as $type => $items) |
| 346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
| 348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
| 349 | 369 | '------------------------------------------------------' . "\n"; |
| 350 | 370 | |
| 351 | - foreach ($items as $item) |
|
| 352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 371 | + foreach ($items as $item) { |
|
| 372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 373 | + } |
|
| 353 | 374 | |
| 354 | 375 | $emailbody .= "\n"; |
| 355 | 376 | } |
| 356 | 377 | } |
| 357 | 378 | |
| 358 | - if ($emailbody == '') |
|
| 359 | - continue; |
|
| 379 | + if ($emailbody == '') { |
|
| 380 | + continue; |
|
| 381 | + } |
|
| 360 | 382 | |
| 361 | 383 | $replacements = array( |
| 362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
| 397 | 419 | ) |
| 398 | 420 | ); |
| 399 | 421 | $members = array(); |
| 400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 401 | - $members[$row['id_member']] = $row['warning']; |
|
| 422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 423 | + $members[$row['id_member']] = $row['warning']; |
|
| 424 | + } |
|
| 402 | 425 | $smcFunc['db_free_result']($request); |
| 403 | 426 | |
| 404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
| 420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 421 | 444 | { |
| 422 | 445 | // More than 24 hours ago? |
| 423 | - if ($row['last_warning'] <= time() - 86400) |
|
| 424 | - $member_changes[] = array( |
|
| 446 | + if ($row['last_warning'] <= time() - 86400) { |
|
| 447 | + $member_changes[] = array( |
|
| 425 | 448 | 'id' => $row['id_recipient'], |
| 426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
| 427 | 450 | ); |
| 451 | + } |
|
| 428 | 452 | } |
| 429 | 453 | $smcFunc['db_free_result']($request); |
| 430 | 454 | |
| 431 | 455 | // Have some members to change? |
| 432 | - if (!empty($member_changes)) |
|
| 433 | - foreach ($member_changes as $change) |
|
| 456 | + if (!empty($member_changes)) { |
|
| 457 | + foreach ($member_changes as $change) |
|
| 434 | 458 | $smcFunc['db_query']('', ' |
| 435 | 459 | UPDATE {db_prefix}members |
| 436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
| 440 | 464 | 'id_member' => $change['id'], |
| 441 | 465 | ) |
| 442 | 466 | ); |
| 467 | + } |
|
| 443 | 468 | } |
| 444 | 469 | } |
| 445 | 470 | |
@@ -506,15 +531,17 @@ discard block |
||
| 506 | 531 | |
| 507 | 532 | // Store this useful data! |
| 508 | 533 | $boards[$row['id_board']] = $row['id_board']; |
| 509 | - if ($row['id_topic']) |
|
| 510 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 511 | - else |
|
| 512 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 534 | + if ($row['id_topic']) { |
|
| 535 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 536 | + } else { |
|
| 537 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 538 | + } |
|
| 513 | 539 | } |
| 514 | 540 | $smcFunc['db_free_result']($request); |
| 515 | 541 | |
| 516 | - if (empty($boards)) |
|
| 517 | - return true; |
|
| 542 | + if (empty($boards)) { |
|
| 543 | + return true; |
|
| 544 | + } |
|
| 518 | 545 | |
| 519 | 546 | // Just get the board names. |
| 520 | 547 | $request = $smcFunc['db_query']('', ' |
@@ -526,12 +553,14 @@ discard block |
||
| 526 | 553 | ) |
| 527 | 554 | ); |
| 528 | 555 | $boards = array(); |
| 529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 530 | - $boards[$row['id_board']] = $row['name']; |
|
| 556 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 557 | + $boards[$row['id_board']] = $row['name']; |
|
| 558 | + } |
|
| 531 | 559 | $smcFunc['db_free_result']($request); |
| 532 | 560 | |
| 533 | - if (empty($boards)) |
|
| 534 | - return true; |
|
| 561 | + if (empty($boards)) { |
|
| 562 | + return true; |
|
| 563 | + } |
|
| 535 | 564 | |
| 536 | 565 | // Get the actual topics... |
| 537 | 566 | $request = $smcFunc['db_query']('', ' |
@@ -551,52 +580,57 @@ discard block |
||
| 551 | 580 | $types = array(); |
| 552 | 581 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 553 | 582 | { |
| 554 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
| 555 | - $types[$row['note_type']][$row['id_board']] = array( |
|
| 583 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
| 584 | + $types[$row['note_type']][$row['id_board']] = array( |
|
| 556 | 585 | 'lines' => array(), |
| 557 | 586 | 'name' => $row['board_name'], |
| 558 | 587 | 'id' => $row['id_board'], |
| 559 | 588 | ); |
| 589 | + } |
|
| 560 | 590 | |
| 561 | 591 | if ($row['note_type'] == 'reply') |
| 562 | 592 | { |
| 563 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 564 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 565 | - else |
|
| 566 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 593 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 594 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 595 | + } else { |
|
| 596 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 567 | 597 | 'id' => $row['id_topic'], |
| 568 | 598 | 'subject' => un_htmlspecialchars($row['subject']), |
| 569 | 599 | 'count' => 1, |
| 570 | 600 | ); |
| 571 | - } |
|
| 572 | - elseif ($row['note_type'] == 'topic') |
|
| 601 | + } |
|
| 602 | + } elseif ($row['note_type'] == 'topic') |
|
| 573 | 603 | { |
| 574 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 575 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 604 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 605 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 576 | 606 | 'id' => $row['id_topic'], |
| 577 | 607 | 'subject' => un_htmlspecialchars($row['subject']), |
| 578 | 608 | ); |
| 579 | - } |
|
| 580 | - else |
|
| 609 | + } |
|
| 610 | + } else |
|
| 581 | 611 | { |
| 582 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 583 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 612 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 613 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 584 | 614 | 'id' => $row['id_topic'], |
| 585 | 615 | 'subject' => un_htmlspecialchars($row['subject']), |
| 586 | 616 | 'starter' => $row['id_member_started'], |
| 587 | 617 | ); |
| 618 | + } |
|
| 588 | 619 | } |
| 589 | 620 | |
| 590 | 621 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
| 591 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
| 592 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 593 | - if (!empty($notify['boards'][$row['id_board']])) |
|
| 594 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 622 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
| 623 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 624 | + } |
|
| 625 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
| 626 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 627 | + } |
|
| 595 | 628 | } |
| 596 | 629 | $smcFunc['db_free_result']($request); |
| 597 | 630 | |
| 598 | - if (empty($types)) |
|
| 599 | - return true; |
|
| 631 | + if (empty($types)) { |
|
| 632 | + return true; |
|
| 633 | + } |
|
| 600 | 634 | |
| 601 | 635 | // Let's load all the languages into a cache thingy. |
| 602 | 636 | $langtxt = array(); |
@@ -637,8 +671,9 @@ discard block |
||
| 637 | 671 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
| 638 | 672 | |
| 639 | 673 | // Did they not elect to choose this? |
| 640 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
| 641 | - continue; |
|
| 674 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 642 | 677 | |
| 643 | 678 | // Right character set! |
| 644 | 679 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -654,39 +689,43 @@ discard block |
||
| 654 | 689 | if (isset($types['topic'])) |
| 655 | 690 | { |
| 656 | 691 | $titled = false; |
| 657 | - foreach ($types['topic'] as $id => $board) |
|
| 658 | - foreach ($board['lines'] as $topic) |
|
| 692 | + foreach ($types['topic'] as $id => $board) { |
|
| 693 | + foreach ($board['lines'] as $topic) |
|
| 659 | 694 | if (in_array($mid, $topic['members'])) |
| 660 | 695 | { |
| 661 | 696 | if (!$titled) |
| 662 | 697 | { |
| 663 | 698 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
| 699 | + } |
|
| 664 | 700 | $titled = true; |
| 665 | 701 | } |
| 666 | 702 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
| 667 | 703 | } |
| 668 | - if ($titled) |
|
| 669 | - $email['body'] .= "\n"; |
|
| 704 | + if ($titled) { |
|
| 705 | + $email['body'] .= "\n"; |
|
| 706 | + } |
|
| 670 | 707 | } |
| 671 | 708 | |
| 672 | 709 | // What about replies? |
| 673 | 710 | if (isset($types['reply'])) |
| 674 | 711 | { |
| 675 | 712 | $titled = false; |
| 676 | - foreach ($types['reply'] as $id => $board) |
|
| 677 | - foreach ($board['lines'] as $topic) |
|
| 713 | + foreach ($types['reply'] as $id => $board) { |
|
| 714 | + foreach ($board['lines'] as $topic) |
|
| 678 | 715 | if (in_array($mid, $topic['members'])) |
| 679 | 716 | { |
| 680 | 717 | if (!$titled) |
| 681 | 718 | { |
| 682 | 719 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
| 720 | + } |
|
| 683 | 721 | $titled = true; |
| 684 | 722 | } |
| 685 | 723 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
| 686 | 724 | } |
| 687 | 725 | |
| 688 | - if ($titled) |
|
| 689 | - $email['body'] .= "\n"; |
|
| 726 | + if ($titled) { |
|
| 727 | + $email['body'] .= "\n"; |
|
| 728 | + } |
|
| 690 | 729 | } |
| 691 | 730 | |
| 692 | 731 | // Finally, moderation actions! |
@@ -695,24 +734,27 @@ discard block |
||
| 695 | 734 | $titled = false; |
| 696 | 735 | foreach ($types as $note_type => $type) |
| 697 | 736 | { |
| 698 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
| 699 | - continue; |
|
| 737 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 700 | 740 | |
| 701 | - foreach ($type as $id => $board) |
|
| 702 | - foreach ($board['lines'] as $topic) |
|
| 741 | + foreach ($type as $id => $board) { |
|
| 742 | + foreach ($board['lines'] as $topic) |
|
| 703 | 743 | if (in_array($mid, $topic['members'])) |
| 704 | 744 | { |
| 705 | 745 | if (!$titled) |
| 706 | 746 | { |
| 707 | 747 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
| 748 | + } |
|
| 708 | 749 | $titled = true; |
| 709 | 750 | } |
| 710 | 751 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
| 711 | 752 | } |
| 712 | 753 | } |
| 713 | 754 | } |
| 714 | - if ($titled) |
|
| 715 | - $email['body'] .= "\n"; |
|
| 755 | + if ($titled) { |
|
| 756 | + $email['body'] .= "\n"; |
|
| 757 | + } |
|
| 716 | 758 | |
| 717 | 759 | // Then just say our goodbyes! |
| 718 | 760 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -740,8 +782,7 @@ discard block |
||
| 740 | 782 | 'not_daily' => 0, |
| 741 | 783 | ) |
| 742 | 784 | ); |
| 743 | - } |
|
| 744 | - else |
|
| 785 | + } else |
|
| 745 | 786 | { |
| 746 | 787 | // Clear any only weekly ones, and stop us from sending daily again. |
| 747 | 788 | $smcFunc['db_query']('', ' |
@@ -803,16 +844,19 @@ discard block |
||
| 803 | 844 | global $modSettings, $smcFunc, $sourcedir; |
| 804 | 845 | |
| 805 | 846 | // Are we intending another script to be sending out the queue? |
| 806 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
| 807 | - return false; |
|
| 847 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
| 848 | + return false; |
|
| 849 | + } |
|
| 808 | 850 | |
| 809 | 851 | // By default send 5 at once. |
| 810 | - if (!$number) |
|
| 811 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 852 | + if (!$number) { |
|
| 853 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 854 | + } |
|
| 812 | 855 | |
| 813 | 856 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
| 814 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
| 815 | - return false; |
|
| 857 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
| 858 | + return false; |
|
| 859 | + } |
|
| 816 | 860 | |
| 817 | 861 | // By default move the next sending on by 10 seconds, and require an affected row. |
| 818 | 862 | if (!$override_limit) |
@@ -829,8 +873,9 @@ discard block |
||
| 829 | 873 | 'last_send' => $modSettings['mail_next_send'], |
| 830 | 874 | ) |
| 831 | 875 | ); |
| 832 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 833 | - return false; |
|
| 876 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 877 | + return false; |
|
| 878 | + } |
|
| 834 | 879 | $modSettings['mail_next_send'] = time() + $delay; |
| 835 | 880 | } |
| 836 | 881 | |
@@ -851,8 +896,9 @@ discard block |
||
| 851 | 896 | $mn += $number; |
| 852 | 897 | } |
| 853 | 898 | // No more I'm afraid, return! |
| 854 | - else |
|
| 855 | - return false; |
|
| 899 | + else { |
|
| 900 | + return false; |
|
| 901 | + } |
|
| 856 | 902 | |
| 857 | 903 | // Reflect that we're about to send some, do it now to be safe. |
| 858 | 904 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -887,14 +933,15 @@ discard block |
||
| 887 | 933 | $smcFunc['db_free_result']($request); |
| 888 | 934 | |
| 889 | 935 | // Delete, delete, delete!!! |
| 890 | - if (!empty($ids)) |
|
| 891 | - $smcFunc['db_query']('', ' |
|
| 936 | + if (!empty($ids)) { |
|
| 937 | + $smcFunc['db_query']('', ' |
|
| 892 | 938 | DELETE FROM {db_prefix}mail_queue |
| 893 | 939 | WHERE id_mail IN ({array_int:mail_list})', |
| 894 | 940 | array( |
| 895 | 941 | 'mail_list' => $ids, |
| 896 | 942 | ) |
| 897 | 943 | ); |
| 944 | + } |
|
| 898 | 945 | |
| 899 | 946 | // Don't believe we have any left? |
| 900 | 947 | if (count($ids) < $number) |
@@ -912,11 +959,13 @@ discard block |
||
| 912 | 959 | ); |
| 913 | 960 | } |
| 914 | 961 | |
| 915 | - if (empty($ids)) |
|
| 916 | - return false; |
|
| 962 | + if (empty($ids)) { |
|
| 963 | + return false; |
|
| 964 | + } |
|
| 917 | 965 | |
| 918 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
| 919 | - require_once($sourcedir . '/Subs-Post.php'); |
|
| 966 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
| 967 | + require_once($sourcedir . '/Subs-Post.php'); |
|
| 968 | + } |
|
| 920 | 969 | |
| 921 | 970 | // Send each email, yea! |
| 922 | 971 | $failed_emails = array(); |
@@ -936,15 +985,17 @@ discard block |
||
| 936 | 985 | |
| 937 | 986 | // Try to stop a timeout, this would be bad... |
| 938 | 987 | @set_time_limit(300); |
| 939 | - if (function_exists('apache_reset_timeout')) |
|
| 940 | - @apache_reset_timeout(); |
|
| 988 | + if (function_exists('apache_reset_timeout')) { |
|
| 989 | + @apache_reset_timeout(); |
|
| 990 | + } |
|
| 991 | + } else { |
|
| 992 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 941 | 993 | } |
| 942 | - else |
|
| 943 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 944 | 994 | |
| 945 | 995 | // Hopefully it sent? |
| 946 | - if (!$result) |
|
| 947 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 996 | + if (!$result) { |
|
| 997 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 998 | + } |
|
| 948 | 999 | } |
| 949 | 1000 | |
| 950 | 1001 | // Any emails that didn't send? |
@@ -959,8 +1010,8 @@ discard block |
||
| 959 | 1010 | ); |
| 960 | 1011 | |
| 961 | 1012 | // If we have failed to many times, tell mail to wait a bit and try again. |
| 962 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
| 963 | - $smcFunc['db_query']('', ' |
|
| 1013 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
| 1014 | + $smcFunc['db_query']('', ' |
|
| 964 | 1015 | UPDATE {db_prefix}settings |
| 965 | 1016 | SET value = {string:next_mail_send} |
| 966 | 1017 | WHERE variable = {literal:mail_next_send} |
@@ -969,6 +1020,7 @@ discard block |
||
| 969 | 1020 | 'next_mail_send' => time() + 60, |
| 970 | 1021 | 'last_send' => $modSettings['mail_next_send'], |
| 971 | 1022 | )); |
| 1023 | + } |
|
| 972 | 1024 | |
| 973 | 1025 | // Add our email back to the queue, manually. |
| 974 | 1026 | $smcFunc['db_insert']('insert', |
@@ -981,8 +1033,8 @@ discard block |
||
| 981 | 1033 | return false; |
| 982 | 1034 | } |
| 983 | 1035 | // We where unable to send the email, clear our failed attempts. |
| 984 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
| 985 | - $smcFunc['db_query']('', ' |
|
| 1036 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
| 1037 | + $smcFunc['db_query']('', ' |
|
| 986 | 1038 | UPDATE {db_prefix}settings |
| 987 | 1039 | SET value = {string:zero} |
| 988 | 1040 | WHERE variable = {string:mail_failed_attempts}', |
@@ -990,6 +1042,7 @@ discard block |
||
| 990 | 1042 | 'zero' => '0', |
| 991 | 1043 | 'mail_failed_attempts' => 'mail_failed_attempts', |
| 992 | 1044 | )); |
| 1045 | + } |
|
| 993 | 1046 | |
| 994 | 1047 | // Had something to send... |
| 995 | 1048 | return true; |
@@ -1006,16 +1059,18 @@ discard block |
||
| 1006 | 1059 | global $modSettings, $smcFunc; |
| 1007 | 1060 | |
| 1008 | 1061 | $task_query = ''; |
| 1009 | - if (!is_array($tasks)) |
|
| 1010 | - $tasks = array($tasks); |
|
| 1062 | + if (!is_array($tasks)) { |
|
| 1063 | + $tasks = array($tasks); |
|
| 1064 | + } |
|
| 1011 | 1065 | |
| 1012 | 1066 | // Actually have something passed? |
| 1013 | 1067 | if (!empty($tasks)) |
| 1014 | 1068 | { |
| 1015 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
| 1016 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1017 | - else |
|
| 1018 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1069 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
| 1070 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1071 | + } else { |
|
| 1072 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1073 | + } |
|
| 1019 | 1074 | } |
| 1020 | 1075 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
| 1021 | 1076 | |
@@ -1036,20 +1091,22 @@ discard block |
||
| 1036 | 1091 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
| 1037 | 1092 | |
| 1038 | 1093 | // Only bother moving the task if it's out of place or we're forcing it! |
| 1039 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
| 1040 | - $tasks[$row['id_task']] = $next_time; |
|
| 1041 | - else |
|
| 1042 | - $next_time = $row['next_time']; |
|
| 1094 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
| 1095 | + $tasks[$row['id_task']] = $next_time; |
|
| 1096 | + } else { |
|
| 1097 | + $next_time = $row['next_time']; |
|
| 1098 | + } |
|
| 1043 | 1099 | |
| 1044 | 1100 | // If this is sooner than the current next task, make this the next task. |
| 1045 | - if ($next_time < $nextTaskTime) |
|
| 1046 | - $nextTaskTime = $next_time; |
|
| 1101 | + if ($next_time < $nextTaskTime) { |
|
| 1102 | + $nextTaskTime = $next_time; |
|
| 1103 | + } |
|
| 1047 | 1104 | } |
| 1048 | 1105 | $smcFunc['db_free_result']($request); |
| 1049 | 1106 | |
| 1050 | 1107 | // Now make the changes! |
| 1051 | - foreach ($tasks as $id => $time) |
|
| 1052 | - $smcFunc['db_query']('', ' |
|
| 1108 | + foreach ($tasks as $id => $time) { |
|
| 1109 | + $smcFunc['db_query']('', ' |
|
| 1053 | 1110 | UPDATE {db_prefix}scheduled_tasks |
| 1054 | 1111 | SET next_time = {int:next_time} |
| 1055 | 1112 | WHERE id_task = {int:id_task}', |
@@ -1058,11 +1115,13 @@ discard block |
||
| 1058 | 1115 | 'id_task' => $id, |
| 1059 | 1116 | ) |
| 1060 | 1117 | ); |
| 1118 | + } |
|
| 1061 | 1119 | |
| 1062 | 1120 | // If the next task is now different update. |
| 1063 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
| 1064 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1065 | -} |
|
| 1121 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
| 1122 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1066 | 1125 | |
| 1067 | 1126 | /** |
| 1068 | 1127 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1075,8 +1134,9 @@ discard block |
||
| 1075 | 1134 | function next_time($regularity, $unit, $offset) |
| 1076 | 1135 | { |
| 1077 | 1136 | // Just in case! |
| 1078 | - if ($regularity == 0) |
|
| 1079 | - $regularity = 2; |
|
| 1137 | + if ($regularity == 0) { |
|
| 1138 | + $regularity = 2; |
|
| 1139 | + } |
|
| 1080 | 1140 | |
| 1081 | 1141 | $curMin = date('i', time()); |
| 1082 | 1142 | |
@@ -1086,15 +1146,16 @@ discard block |
||
| 1086 | 1146 | $off = date('i', $offset); |
| 1087 | 1147 | |
| 1088 | 1148 | // If it's now just pretend it ain't, |
| 1089 | - if ($off == $curMin) |
|
| 1090 | - $next_time = time() + $regularity; |
|
| 1091 | - else |
|
| 1149 | + if ($off == $curMin) { |
|
| 1150 | + $next_time = time() + $regularity; |
|
| 1151 | + } else |
|
| 1092 | 1152 | { |
| 1093 | 1153 | // Make sure that the offset is always in the past. |
| 1094 | 1154 | $off = $off > $curMin ? $off - 60 : $off; |
| 1095 | 1155 | |
| 1096 | - while ($off <= $curMin) |
|
| 1097 | - $off += $regularity; |
|
| 1156 | + while ($off <= $curMin) { |
|
| 1157 | + $off += $regularity; |
|
| 1158 | + } |
|
| 1098 | 1159 | |
| 1099 | 1160 | // Now we know when the time should be! |
| 1100 | 1161 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1114,11 +1175,13 @@ discard block |
||
| 1114 | 1175 | // Default we'll jump in hours. |
| 1115 | 1176 | $applyOffset = 3600; |
| 1116 | 1177 | // 24 hours = 1 day. |
| 1117 | - if ($unit == 'd') |
|
| 1118 | - $applyOffset = 86400; |
|
| 1178 | + if ($unit == 'd') { |
|
| 1179 | + $applyOffset = 86400; |
|
| 1180 | + } |
|
| 1119 | 1181 | // Otherwise a week. |
| 1120 | - if ($unit == 'w') |
|
| 1121 | - $applyOffset = 604800; |
|
| 1182 | + if ($unit == 'w') { |
|
| 1183 | + $applyOffset = 604800; |
|
| 1184 | + } |
|
| 1122 | 1185 | |
| 1123 | 1186 | $applyOffset *= $regularity; |
| 1124 | 1187 | |
@@ -1155,8 +1218,9 @@ discard block |
||
| 1155 | 1218 | $settings[$row['variable']] = $row['value']; |
| 1156 | 1219 | |
| 1157 | 1220 | // Is this the default theme? |
| 1158 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
| 1159 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1221 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
| 1222 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1223 | + } |
|
| 1160 | 1224 | } |
| 1161 | 1225 | $smcFunc['db_free_result']($result); |
| 1162 | 1226 | |
@@ -1166,12 +1230,14 @@ discard block |
||
| 1166 | 1230 | $settings['template_dirs'] = array($settings['theme_dir']); |
| 1167 | 1231 | |
| 1168 | 1232 | // Based on theme (if there is one). |
| 1169 | - if (!empty($settings['base_theme_dir'])) |
|
| 1170 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1233 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1234 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1235 | + } |
|
| 1171 | 1236 | |
| 1172 | 1237 | // Lastly the default theme. |
| 1173 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1174 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1238 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1239 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1240 | + } |
|
| 1175 | 1241 | } |
| 1176 | 1242 | |
| 1177 | 1243 | // Assume we want this. |
@@ -1318,8 +1384,9 @@ discard block |
||
| 1318 | 1384 | // Ok should we prune the logs? |
| 1319 | 1385 | if (!empty($modSettings['pruningOptions'])) |
| 1320 | 1386 | { |
| 1321 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
| 1322 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1387 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
| 1388 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1389 | + } |
|
| 1323 | 1390 | |
| 1324 | 1391 | if (!empty($modSettings['pruneErrorLog'])) |
| 1325 | 1392 | { |
@@ -1385,8 +1452,9 @@ discard block |
||
| 1385 | 1452 | ) |
| 1386 | 1453 | ); |
| 1387 | 1454 | |
| 1388 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
| 1389 | - $reports[] = $row[0]; |
|
| 1455 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
| 1456 | + $reports[] = $row[0]; |
|
| 1457 | + } |
|
| 1390 | 1458 | |
| 1391 | 1459 | $smcFunc['db_free_result']($result); |
| 1392 | 1460 | |
@@ -1548,8 +1616,9 @@ discard block |
||
| 1548 | 1616 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
| 1549 | 1617 | |
| 1550 | 1618 | // Send the actual email. |
| 1551 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
| 1552 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1619 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
| 1620 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1621 | + } |
|
| 1553 | 1622 | |
| 1554 | 1623 | if ($notifyPrefs[$row['id_member']] & 0x01) |
| 1555 | 1624 | { |
@@ -1572,18 +1641,19 @@ discard block |
||
| 1572 | 1641 | } |
| 1573 | 1642 | |
| 1574 | 1643 | // Insert the alerts if any |
| 1575 | - if (!empty($alert_rows)) |
|
| 1576 | - $smcFunc['db_insert']('', |
|
| 1644 | + if (!empty($alert_rows)) { |
|
| 1645 | + $smcFunc['db_insert']('', |
|
| 1577 | 1646 | '{db_prefix}user_alerts', |
| 1578 | 1647 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 1579 | 1648 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 1580 | 1649 | $alert_rows, |
| 1581 | 1650 | array() |
| 1582 | 1651 | ); |
| 1652 | + } |
|
| 1583 | 1653 | |
| 1584 | 1654 | // Mark the reminder as sent. |
| 1585 | - if (!empty($subs_reminded)) |
|
| 1586 | - $smcFunc['db_query']('', ' |
|
| 1655 | + if (!empty($subs_reminded)) { |
|
| 1656 | + $smcFunc['db_query']('', ' |
|
| 1587 | 1657 | UPDATE {db_prefix}log_subscribed |
| 1588 | 1658 | SET reminder_sent = {int:reminder_sent} |
| 1589 | 1659 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1592,6 +1662,7 @@ discard block |
||
| 1592 | 1662 | 'reminder_sent' => 1, |
| 1593 | 1663 | ) |
| 1594 | 1664 | ); |
| 1665 | + } |
|
| 1595 | 1666 | |
| 1596 | 1667 | return true; |
| 1597 | 1668 | } |
@@ -1607,13 +1678,13 @@ discard block |
||
| 1607 | 1678 | // We need to know where this thing is going. |
| 1608 | 1679 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1609 | 1680 | { |
| 1610 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 1611 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 1681 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 1682 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 1683 | + } |
|
| 1612 | 1684 | |
| 1613 | 1685 | // Just use the current path for temp files. |
| 1614 | 1686 | $attach_dirs = $modSettings['attachmentUploadDir']; |
| 1615 | - } |
|
| 1616 | - else |
|
| 1687 | + } else |
|
| 1617 | 1688 | { |
| 1618 | 1689 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
| 1619 | 1690 | } |
@@ -1632,14 +1703,16 @@ discard block |
||
| 1632 | 1703 | |
| 1633 | 1704 | while ($file = readdir($dir)) |
| 1634 | 1705 | { |
| 1635 | - if ($file == '.' || $file == '..') |
|
| 1636 | - continue; |
|
| 1706 | + if ($file == '.' || $file == '..') { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1637 | 1709 | |
| 1638 | 1710 | if (strpos($file, 'post_tmp_') !== false) |
| 1639 | 1711 | { |
| 1640 | 1712 | // Temp file is more than 5 hours old! |
| 1641 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1642 | - @unlink($attach_dir . '/' . $file); |
|
| 1713 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1714 | + @unlink($attach_dir . '/' . $file); |
|
| 1715 | + } |
|
| 1643 | 1716 | } |
| 1644 | 1717 | } |
| 1645 | 1718 | closedir($dir); |
@@ -1672,8 +1745,9 @@ discard block |
||
| 1672 | 1745 | ) |
| 1673 | 1746 | ); |
| 1674 | 1747 | |
| 1675 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1676 | - $topics[] = $row[0]; |
|
| 1748 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1749 | + $topics[] = $row[0]; |
|
| 1750 | + } |
|
| 1677 | 1751 | $smcFunc['db_free_result']($request); |
| 1678 | 1752 | |
| 1679 | 1753 | // Zap, your gone |
@@ -1693,8 +1767,9 @@ discard block |
||
| 1693 | 1767 | { |
| 1694 | 1768 | global $smcFunc, $sourcedir, $modSettings; |
| 1695 | 1769 | |
| 1696 | - if (empty($modSettings['drafts_keep_days'])) |
|
| 1697 | - return true; |
|
| 1770 | + if (empty($modSettings['drafts_keep_days'])) { |
|
| 1771 | + return true; |
|
| 1772 | + } |
|
| 1698 | 1773 | |
| 1699 | 1774 | // init |
| 1700 | 1775 | $drafts = array(); |
@@ -1712,8 +1787,9 @@ discard block |
||
| 1712 | 1787 | ) |
| 1713 | 1788 | ); |
| 1714 | 1789 | |
| 1715 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1716 | - $drafts[] = (int) $row[0]; |
|
| 1790 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1791 | + $drafts[] = (int) $row[0]; |
|
| 1792 | + } |
|
| 1717 | 1793 | $smcFunc['db_free_result']($request); |
| 1718 | 1794 | |
| 1719 | 1795 | // If we have old one, remove them |
@@ -3031,8 +3031,7 @@ |
||
| 3031 | 3031 | <div class="roundframe"> |
| 3032 | 3032 | <div> |
| 3033 | 3033 | ', !empty($context['tfa_backup']) ? ' |
| 3034 | - <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : |
|
| 3035 | - ($modSettings['tfa_mode'] == 2 ? ' |
|
| 3034 | + <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? ' |
|
| 3036 | 3035 | <div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), ' |
| 3037 | 3036 | <div class="smalltext">', $txt['tfa_desc'], '</div> |
| 3038 | 3037 | <div id="basicinfo" style="width: 60%"> |
@@ -18,23 +18,25 @@ discard block |
||
| 18 | 18 | global $context; |
| 19 | 19 | |
| 20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
| 21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
| 22 | - echo ' |
|
| 21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <script> |
| 24 | 24 | disableAutoComplete(); |
| 25 | 25 | </script>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
| 28 | 29 | echo ' |
| 29 | 30 | ', template_error_message(); |
| 30 | 31 | |
| 31 | 32 | // If the profile was update successfully, let the user know this. |
| 32 | - if (!empty($context['profile_updated'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile_updated'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="infobox"> |
| 35 | 36 | ', $context['profile_updated'], ' |
| 36 | 37 | </div>'; |
| 37 | -} |
|
| 38 | + } |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -102,8 +104,7 @@ discard block |
||
| 102 | 104 | if (empty($context['unread_alerts'])) |
| 103 | 105 | { |
| 104 | 106 | template_alerts_all_read(); |
| 105 | - } |
|
| 106 | - else |
|
| 107 | + } else |
|
| 107 | 108 | { |
| 108 | 109 | foreach ($context['unread_alerts'] as $id_alert => $details) |
| 109 | 110 | { |
@@ -164,10 +165,11 @@ discard block |
||
| 164 | 165 | <div class="custom_fields_above_name"> |
| 165 | 166 | <ul >'; |
| 166 | 167 | |
| 167 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
| 168 | - if (!empty($field['output_html'])) |
|
| 168 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
| 169 | + if (!empty($field['output_html'])) |
|
| 169 | 170 | echo ' |
| 170 | 171 | <li>', $field['output_html'], '</li>'; |
| 172 | + } |
|
| 171 | 173 | |
| 172 | 174 | echo ' |
| 173 | 175 | </ul> |
@@ -188,10 +190,11 @@ discard block |
||
| 188 | 190 | <div class="custom_fields_below_avatar"> |
| 189 | 191 | <ul >'; |
| 190 | 192 | |
| 191 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
| 192 | - if (!empty($field['output_html'])) |
|
| 193 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
| 194 | + if (!empty($field['output_html'])) |
|
| 193 | 195 | echo ' |
| 194 | 196 | <li>', $field['output_html'], '</li>'; |
| 197 | + } |
|
| 195 | 198 | |
| 196 | 199 | echo ' |
| 197 | 200 | </ul> |
@@ -202,22 +205,25 @@ discard block |
||
| 202 | 205 | echo ' |
| 203 | 206 | <ul class="clear">'; |
| 204 | 207 | // Email is only visible if it's your profile or you have the moderate_forum permission |
| 205 | - if ($context['member']['show_email']) |
|
| 206 | - echo ' |
|
| 208 | + if ($context['member']['show_email']) { |
|
| 209 | + echo ' |
|
| 207 | 210 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
| 211 | + } |
|
| 208 | 212 | |
| 209 | 213 | // Don't show an icon if they haven't specified a website. |
| 210 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
| 211 | - echo ' |
|
| 214 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
| 215 | + echo ' |
|
| 212 | 216 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 217 | + } |
|
| 213 | 218 | |
| 214 | 219 | // Are there any custom profile fields as icons? |
| 215 | 220 | if (!empty($context['print_custom_fields']['icons'])) |
| 216 | 221 | { |
| 217 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
| 218 | - if (!empty($field['output_html'])) |
|
| 222 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
| 223 | + if (!empty($field['output_html'])) |
|
| 219 | 224 | echo ' |
| 220 | 225 | <li class="custom_field">', $field['output_html'], '</li>'; |
| 226 | + } |
|
| 221 | 227 | } |
| 222 | 228 | |
| 223 | 229 | echo ' |
@@ -225,23 +231,26 @@ discard block |
||
| 225 | 231 | <span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
| 226 | 232 | |
| 227 | 233 | // Can they add this member as a buddy? |
| 228 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
| 229 | - echo ' |
|
| 234 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
| 235 | + echo ' |
|
| 230 | 236 | <br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
| 237 | + } |
|
| 231 | 238 | |
| 232 | 239 | echo ' |
| 233 | 240 | </span>'; |
| 234 | 241 | |
| 235 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
| 236 | - echo ' |
|
| 242 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
| 243 | + echo ' |
|
| 237 | 244 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
| 245 | + } |
|
| 238 | 246 | |
| 239 | 247 | echo ' |
| 240 | 248 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
| 241 | 249 | |
| 242 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
| 243 | - echo ' |
|
| 250 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
| 251 | + echo ' |
|
| 244 | 252 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
| 253 | + } |
|
| 245 | 254 | |
| 246 | 255 | echo ' |
| 247 | 256 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -253,10 +262,11 @@ discard block |
||
| 253 | 262 | <div class="custom_fields_bottom"> |
| 254 | 263 | <ul class="nolist">'; |
| 255 | 264 | |
| 256 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
| 257 | - if (!empty($field['output_html'])) |
|
| 265 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
| 266 | + if (!empty($field['output_html'])) |
|
| 258 | 267 | echo ' |
| 259 | 268 | <li>', $field['output_html'], '</li>'; |
| 269 | + } |
|
| 260 | 270 | |
| 261 | 271 | echo ' |
| 262 | 272 | </ul> |
@@ -270,15 +280,17 @@ discard block |
||
| 270 | 280 | <div id="detailedinfo"> |
| 271 | 281 | <dl class="settings">'; |
| 272 | 282 | |
| 273 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
| 274 | - echo ' |
|
| 283 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
| 284 | + echo ' |
|
| 275 | 285 | <dt>', $txt['username'], ': </dt> |
| 276 | 286 | <dd>', $context['member']['username'], '</dd>'; |
| 287 | + } |
|
| 277 | 288 | |
| 278 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 279 | - echo ' |
|
| 289 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 290 | + echo ' |
|
| 280 | 291 | <dt>', $txt['profile_posts'], ': </dt> |
| 281 | 292 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
| 293 | + } |
|
| 282 | 294 | |
| 283 | 295 | if ($context['member']['show_email']) |
| 284 | 296 | { |
@@ -287,15 +299,17 @@ discard block |
||
| 287 | 299 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
| 288 | 300 | } |
| 289 | 301 | |
| 290 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
| 291 | - echo ' |
|
| 302 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
| 303 | + echo ' |
|
| 292 | 304 | <dt>', $txt['custom_title'], ': </dt> |
| 293 | 305 | <dd>', $context['member']['title'], '</dd>'; |
| 306 | + } |
|
| 294 | 307 | |
| 295 | - if (!empty($context['member']['blurb'])) |
|
| 296 | - echo ' |
|
| 308 | + if (!empty($context['member']['blurb'])) { |
|
| 309 | + echo ' |
|
| 297 | 310 | <dt>', $txt['personal_text'], ': </dt> |
| 298 | 311 | <dd>', $context['member']['blurb'], '</dd>'; |
| 312 | + } |
|
| 299 | 313 | |
| 300 | 314 | echo ' |
| 301 | 315 | <dt>', $txt['age'], ':</dt> |
@@ -309,19 +323,21 @@ discard block |
||
| 309 | 323 | { |
| 310 | 324 | $fields = array(); |
| 311 | 325 | |
| 312 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
| 313 | - if (!empty($field['output_html'])) |
|
| 326 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
| 327 | + if (!empty($field['output_html'])) |
|
| 314 | 328 | $fields[] = $field; |
| 329 | + } |
|
| 315 | 330 | |
| 316 | 331 | if (count($fields) > 0) |
| 317 | 332 | { |
| 318 | 333 | echo ' |
| 319 | 334 | <dl class="settings">'; |
| 320 | 335 | |
| 321 | - foreach ($fields as $field) |
|
| 322 | - echo ' |
|
| 336 | + foreach ($fields as $field) { |
|
| 337 | + echo ' |
|
| 323 | 338 | <dt>', $field['name'], ':</dt> |
| 324 | 339 | <dd>', $field['output_html'], '</dd>'; |
| 340 | + } |
|
| 325 | 341 | |
| 326 | 342 | echo ' |
| 327 | 343 | </dl>'; |
@@ -341,9 +357,10 @@ discard block |
||
| 341 | 357 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
| 342 | 358 | |
| 343 | 359 | // Can we provide information on what this means? |
| 344 | - if (!empty($context['warning_status'])) |
|
| 345 | - echo ' |
|
| 360 | + if (!empty($context['warning_status'])) { |
|
| 361 | + echo ' |
|
| 346 | 362 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
| 363 | + } |
|
| 347 | 364 | |
| 348 | 365 | echo ' |
| 349 | 366 | </dd>'; |
@@ -354,9 +371,10 @@ discard block |
||
| 354 | 371 | { |
| 355 | 372 | |
| 356 | 373 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
| 357 | - if (!empty($context['activate_message'])) |
|
| 358 | - echo ' |
|
| 374 | + if (!empty($context['activate_message'])) { |
|
| 375 | + echo ' |
|
| 359 | 376 | <dt class="clear"><span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>'; |
| 377 | + } |
|
| 360 | 378 | |
| 361 | 379 | // If the current member is banned, show a message and possibly a link to the ban. |
| 362 | 380 | if (!empty($context['member']['bans'])) |
@@ -366,9 +384,10 @@ discard block |
||
| 366 | 384 | <dt class="clear" id="ban_info" style="display: none;"> |
| 367 | 385 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
| 368 | 386 | |
| 369 | - foreach ($context['member']['bans'] as $ban) |
|
| 370 | - echo ' |
|
| 387 | + foreach ($context['member']['bans'] as $ban) { |
|
| 388 | + echo ' |
|
| 371 | 389 | <br><span class="smalltext">', $ban['explanation'], '</span>'; |
| 390 | + } |
|
| 372 | 391 | |
| 373 | 392 | echo ' |
| 374 | 393 | </dt>'; |
@@ -382,30 +401,34 @@ discard block |
||
| 382 | 401 | // If the person looking is allowed, they can check the members IP address and hostname. |
| 383 | 402 | if ($context['can_see_ip']) |
| 384 | 403 | { |
| 385 | - if (!empty($context['member']['ip'])) |
|
| 386 | - echo ' |
|
| 404 | + if (!empty($context['member']['ip'])) { |
|
| 405 | + echo ' |
|
| 387 | 406 | <dt>', $txt['ip'], ': </dt> |
| 388 | 407 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
| 408 | + } |
|
| 389 | 409 | |
| 390 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
| 391 | - echo ' |
|
| 410 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
| 411 | + echo ' |
|
| 392 | 412 | <dt>', $txt['hostname'], ': </dt> |
| 393 | 413 | <dd>', $context['member']['hostname'], '</dd>'; |
| 414 | + } |
|
| 394 | 415 | } |
| 395 | 416 | |
| 396 | 417 | echo ' |
| 397 | 418 | <dt>', $txt['local_time'], ':</dt> |
| 398 | 419 | <dd>', $context['member']['local_time'], '</dd>'; |
| 399 | 420 | |
| 400 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
| 401 | - echo ' |
|
| 421 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
| 422 | + echo ' |
|
| 402 | 423 | <dt>', $txt['language'], ':</dt> |
| 403 | 424 | <dd>', $context['member']['language'], '</dd>'; |
| 425 | + } |
|
| 404 | 426 | |
| 405 | - if ($context['member']['show_last_login']) |
|
| 406 | - echo ' |
|
| 427 | + if ($context['member']['show_last_login']) { |
|
| 428 | + echo ' |
|
| 407 | 429 | <dt>', $txt['lastLoggedIn'], ': </dt> |
| 408 | 430 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
| 431 | + } |
|
| 409 | 432 | |
| 410 | 433 | echo ' |
| 411 | 434 | </dl>'; |
@@ -417,10 +440,11 @@ discard block |
||
| 417 | 440 | <div class="custom_fields_above_signature"> |
| 418 | 441 | <ul class="nolist">'; |
| 419 | 442 | |
| 420 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
| 421 | - if (!empty($field['output_html'])) |
|
| 443 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
| 444 | + if (!empty($field['output_html'])) |
|
| 422 | 445 | echo ' |
| 423 | 446 | <li>', $field['output_html'], '</li>'; |
| 447 | + } |
|
| 424 | 448 | |
| 425 | 449 | echo ' |
| 426 | 450 | </ul> |
@@ -428,12 +452,13 @@ discard block |
||
| 428 | 452 | } |
| 429 | 453 | |
| 430 | 454 | // Show the users signature. |
| 431 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
| 432 | - echo ' |
|
| 455 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
| 456 | + echo ' |
|
| 433 | 457 | <div class="signature"> |
| 434 | 458 | <h5>', $txt['signature'], ':</h5> |
| 435 | 459 | ', $context['member']['signature'], ' |
| 436 | 460 | </div>'; |
| 461 | + } |
|
| 437 | 462 | |
| 438 | 463 | // Are there any custom profile fields for below the signature? |
| 439 | 464 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -442,10 +467,11 @@ discard block |
||
| 442 | 467 | <div class="custom_fields_below_signature"> |
| 443 | 468 | <ul class="nolist">'; |
| 444 | 469 | |
| 445 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
| 446 | - if (!empty($field['output_html'])) |
|
| 470 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
| 471 | + if (!empty($field['output_html'])) |
|
| 447 | 472 | echo ' |
| 448 | 473 | <li>', $field['output_html'], '</li>'; |
| 474 | + } |
|
| 449 | 475 | |
| 450 | 476 | echo ' |
| 451 | 477 | </ul> |
@@ -490,62 +516,70 @@ discard block |
||
| 490 | 516 | </div> |
| 491 | 517 | <div class="list_posts">'; |
| 492 | 518 | |
| 493 | - if (!$post['approved']) |
|
| 494 | - echo ' |
|
| 519 | + if (!$post['approved']) { |
|
| 520 | + echo ' |
|
| 495 | 521 | <div class="approve_post"> |
| 496 | 522 | <em>', $txt['post_awaiting_approval'], '</em> |
| 497 | 523 | </div>'; |
| 524 | + } |
|
| 498 | 525 | |
| 499 | 526 | echo ' |
| 500 | 527 | ', $post['body'], ' |
| 501 | 528 | </div>'; |
| 502 | 529 | |
| 503 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 504 | - echo ' |
|
| 530 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 531 | + echo ' |
|
| 505 | 532 | <div class="floatright"> |
| 506 | 533 | <ul class="quickbuttons">'; |
| 534 | + } |
|
| 507 | 535 | |
| 508 | 536 | // If they *can* reply? |
| 509 | - if ($post['can_reply']) |
|
| 510 | - echo ' |
|
| 537 | + if ($post['can_reply']) { |
|
| 538 | + echo ' |
|
| 511 | 539 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 540 | + } |
|
| 512 | 541 | |
| 513 | 542 | // If they *can* quote? |
| 514 | - if ($post['can_quote']) |
|
| 515 | - echo ' |
|
| 543 | + if ($post['can_quote']) { |
|
| 544 | + echo ' |
|
| 516 | 545 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 546 | + } |
|
| 517 | 547 | |
| 518 | 548 | // How about... even... remove it entirely?! |
| 519 | - if ($post['can_delete']) |
|
| 520 | - echo ' |
|
| 549 | + if ($post['can_delete']) { |
|
| 550 | + echo ' |
|
| 521 | 551 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 552 | + } |
|
| 522 | 553 | |
| 523 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 524 | - echo ' |
|
| 554 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 555 | + echo ' |
|
| 525 | 556 | </ul> |
| 526 | 557 | </div>'; |
| 558 | + } |
|
| 527 | 559 | |
| 528 | 560 | echo ' |
| 529 | 561 | </div>'; |
| 530 | 562 | } |
| 563 | + } else { |
|
| 564 | + template_show_list('attachments'); |
|
| 531 | 565 | } |
| 532 | - else |
|
| 533 | - template_show_list('attachments'); |
|
| 534 | 566 | |
| 535 | 567 | // No posts? Just end with a informative message. |
| 536 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
| 537 | - echo ' |
|
| 568 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
| 569 | + echo ' |
|
| 538 | 570 | <div class="windowbg2"> |
| 539 | 571 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
| 540 | 572 | </div>'; |
| 573 | + } |
|
| 541 | 574 | |
| 542 | 575 | // Show more page numbers. |
| 543 | - if (!empty($context['page_index'])) |
|
| 544 | - echo ' |
|
| 576 | + if (!empty($context['page_index'])) { |
|
| 577 | + echo ' |
|
| 545 | 578 | <div class="pagesection"> |
| 546 | 579 | <div class="pagelinks">', $context['page_index'], '</div> |
| 547 | 580 | </div>'; |
| 548 | -} |
|
| 581 | + } |
|
| 582 | + } |
|
| 549 | 583 | |
| 550 | 584 | /** |
| 551 | 585 | * Template for showing alerts within the alerts popup |
@@ -555,11 +589,12 @@ discard block |
||
| 555 | 589 | global $context, $txt, $scripturl; |
| 556 | 590 | |
| 557 | 591 | // Do we have an update message? |
| 558 | - if (!empty($context['update_message'])) |
|
| 559 | - echo ' |
|
| 592 | + if (!empty($context['update_message'])) { |
|
| 593 | + echo ' |
|
| 560 | 594 | <div class="infobox"> |
| 561 | 595 | ', $context['update_message'], '. |
| 562 | 596 | </div>'; |
| 597 | + } |
|
| 563 | 598 | |
| 564 | 599 | echo ' |
| 565 | 600 | <div class="cat_bar"> |
@@ -568,13 +603,12 @@ discard block |
||
| 568 | 603 | </h3> |
| 569 | 604 | </div>'; |
| 570 | 605 | |
| 571 | - if (empty($context['alerts'])) |
|
| 572 | - echo ' |
|
| 606 | + if (empty($context['alerts'])) { |
|
| 607 | + echo ' |
|
| 573 | 608 | <div class="information"> |
| 574 | 609 | ', $txt['alerts_none'], ' |
| 575 | 610 | </div>'; |
| 576 | - |
|
| 577 | - else |
|
| 611 | + } else |
|
| 578 | 612 | { |
| 579 | 613 | // Start the form. |
| 580 | 614 | echo ' |
@@ -636,12 +670,12 @@ discard block |
||
| 636 | 670 | </div>' : ''; |
| 637 | 671 | |
| 638 | 672 | // No drafts? Just show an informative message. |
| 639 | - if (empty($context['drafts'])) |
|
| 640 | - echo ' |
|
| 673 | + if (empty($context['drafts'])) { |
|
| 674 | + echo ' |
|
| 641 | 675 | <div class="windowbg2 centertext"> |
| 642 | 676 | ', $txt['draft_none'], ' |
| 643 | 677 | </div>'; |
| 644 | - else |
|
| 678 | + } else |
|
| 645 | 679 | { |
| 646 | 680 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 647 | 681 | foreach ($context['drafts'] as $draft) |
@@ -652,11 +686,13 @@ discard block |
||
| 652 | 686 | <div class="topic_details"> |
| 653 | 687 | <h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
| 654 | 688 | |
| 655 | - if (!empty($draft['sticky'])) |
|
| 656 | - echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
| 689 | + if (!empty($draft['sticky'])) { |
|
| 690 | + echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
| 691 | + } |
|
| 657 | 692 | |
| 658 | - if (!empty($draft['locked'])) |
|
| 659 | - echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
| 693 | + if (!empty($draft['locked'])) { |
|
| 694 | + echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
| 695 | + } |
|
| 660 | 696 | |
| 661 | 697 | echo ' |
| 662 | 698 | </h5> |
@@ -689,12 +725,13 @@ discard block |
||
| 689 | 725 | { |
| 690 | 726 | global $context, $scripturl, $txt; |
| 691 | 727 | |
| 692 | - if (!empty($context['saved_successful'])) |
|
| 693 | - echo ' |
|
| 728 | + if (!empty($context['saved_successful'])) { |
|
| 729 | + echo ' |
|
| 694 | 730 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 695 | - elseif (!empty($context['saved_failed'])) |
|
| 696 | - echo ' |
|
| 731 | + } elseif (!empty($context['saved_failed'])) { |
|
| 732 | + echo ' |
|
| 697 | 733 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 734 | + } |
|
| 698 | 735 | |
| 699 | 736 | echo ' |
| 700 | 737 | <div id="edit_buddies"> |
@@ -708,24 +745,27 @@ discard block |
||
| 708 | 745 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 709 | 746 | <th scope="col">', $txt['status'], '</th>'; |
| 710 | 747 | |
| 711 | - if (allowedTo('moderate_forum')) |
|
| 712 | - echo ' |
|
| 748 | + if (allowedTo('moderate_forum')) { |
|
| 749 | + echo ' |
|
| 713 | 750 | <th scope="col">', $txt['email'], '</th>'; |
| 751 | + } |
|
| 714 | 752 | |
| 715 | - if (!empty($context['custom_pf'])) |
|
| 716 | - foreach ($context['custom_pf'] as $column) |
|
| 753 | + if (!empty($context['custom_pf'])) { |
|
| 754 | + foreach ($context['custom_pf'] as $column) |
|
| 717 | 755 | echo '<th scope="col">', $column['label'], '</th>'; |
| 756 | + } |
|
| 718 | 757 | |
| 719 | 758 | echo ' |
| 720 | 759 | <th scope="col">', $txt['remove'], '</th> |
| 721 | 760 | </tr>'; |
| 722 | 761 | |
| 723 | 762 | // If they don't have any buddies don't list them! |
| 724 | - if (empty($context['buddies'])) |
|
| 725 | - echo ' |
|
| 763 | + if (empty($context['buddies'])) { |
|
| 764 | + echo ' |
|
| 726 | 765 | <tr class="windowbg"> |
| 727 | 766 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td> |
| 728 | 767 | </tr>'; |
| 768 | + } |
|
| 729 | 769 | |
| 730 | 770 | // Now loop through each buddy showing info on each. |
| 731 | 771 | else |
@@ -737,15 +777,17 @@ discard block |
||
| 737 | 777 | <td>', $buddy['link'], '</td> |
| 738 | 778 | <td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>'; |
| 739 | 779 | |
| 740 | - if ($buddy['show_email']) |
|
| 741 | - echo ' |
|
| 780 | + if ($buddy['show_email']) { |
|
| 781 | + echo ' |
|
| 742 | 782 | <td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>'; |
| 783 | + } |
|
| 743 | 784 | |
| 744 | 785 | // Show the custom profile fields for this user. |
| 745 | - if (!empty($context['custom_pf'])) |
|
| 746 | - foreach ($context['custom_pf'] as $key => $column) |
|
| 786 | + if (!empty($context['custom_pf'])) { |
|
| 787 | + foreach ($context['custom_pf'] as $key => $column) |
|
| 747 | 788 | echo ' |
| 748 | 789 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
| 790 | + } |
|
| 749 | 791 | |
| 750 | 792 | echo ' |
| 751 | 793 | <td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td> |
@@ -775,9 +817,10 @@ discard block |
||
| 775 | 817 | </dl> |
| 776 | 818 | </div>'; |
| 777 | 819 | |
| 778 | - if (!empty($context['token_check'])) |
|
| 779 | - echo ' |
|
| 820 | + if (!empty($context['token_check'])) { |
|
| 821 | + echo ' |
|
| 780 | 822 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 823 | + } |
|
| 781 | 824 | |
| 782 | 825 | echo ' |
| 783 | 826 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -803,12 +846,13 @@ discard block |
||
| 803 | 846 | { |
| 804 | 847 | global $context, $scripturl, $txt; |
| 805 | 848 | |
| 806 | - if (!empty($context['saved_successful'])) |
|
| 807 | - echo ' |
|
| 849 | + if (!empty($context['saved_successful'])) { |
|
| 850 | + echo ' |
|
| 808 | 851 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 809 | - elseif (!empty($context['saved_failed'])) |
|
| 810 | - echo ' |
|
| 852 | + } elseif (!empty($context['saved_failed'])) { |
|
| 853 | + echo ' |
|
| 811 | 854 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 855 | + } |
|
| 812 | 856 | |
| 813 | 857 | echo ' |
| 814 | 858 | <div id="edit_buddies"> |
@@ -822,20 +866,22 @@ discard block |
||
| 822 | 866 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 823 | 867 | <th scope="col">', $txt['status'], '</th>'; |
| 824 | 868 | |
| 825 | - if (allowedTo('moderate_forum')) |
|
| 826 | - echo ' |
|
| 869 | + if (allowedTo('moderate_forum')) { |
|
| 870 | + echo ' |
|
| 827 | 871 | <th scope="col">', $txt['email'], '</th>'; |
| 872 | + } |
|
| 828 | 873 | |
| 829 | 874 | echo ' |
| 830 | 875 | <th scope="col">', $txt['ignore_remove'], '</th> |
| 831 | 876 | </tr>'; |
| 832 | 877 | |
| 833 | 878 | // If they don't have anyone on their ignore list, don't list it! |
| 834 | - if (empty($context['ignore_list'])) |
|
| 835 | - echo ' |
|
| 879 | + if (empty($context['ignore_list'])) { |
|
| 880 | + echo ' |
|
| 836 | 881 | <tr class="windowbg"> |
| 837 | 882 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td> |
| 838 | 883 | </tr>'; |
| 884 | + } |
|
| 839 | 885 | |
| 840 | 886 | // Now loop through each buddy showing info on each. |
| 841 | 887 | foreach ($context['ignore_list'] as $member) |
@@ -845,9 +891,10 @@ discard block |
||
| 845 | 891 | <td>', $member['link'], '</td> |
| 846 | 892 | <td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>'; |
| 847 | 893 | |
| 848 | - if ($member['show_email']) |
|
| 849 | - echo ' |
|
| 894 | + if ($member['show_email']) { |
|
| 895 | + echo ' |
|
| 850 | 896 | <td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>'; |
| 897 | + } |
|
| 851 | 898 | echo ' |
| 852 | 899 | <td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td> |
| 853 | 900 | </tr>'; |
@@ -874,9 +921,10 @@ discard block |
||
| 874 | 921 | </dl> |
| 875 | 922 | </div>'; |
| 876 | 923 | |
| 877 | - if (!empty($context['token_check'])) |
|
| 878 | - echo ' |
|
| 924 | + if (!empty($context['token_check'])) { |
|
| 925 | + echo ' |
|
| 879 | 926 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 927 | + } |
|
| 880 | 928 | |
| 881 | 929 | echo ' |
| 882 | 930 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -921,9 +969,10 @@ discard block |
||
| 921 | 969 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
| 922 | 970 | |
| 923 | 971 | // Second address detected? |
| 924 | - if (!empty($context['last_ip2'])) |
|
| 925 | - echo ' |
|
| 972 | + if (!empty($context['last_ip2'])) { |
|
| 973 | + echo ' |
|
| 926 | 974 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
| 975 | + } |
|
| 927 | 976 | |
| 928 | 977 | echo ' |
| 929 | 978 | </dd>'; |
@@ -988,9 +1037,10 @@ discard block |
||
| 988 | 1037 | <h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3> |
| 989 | 1038 | </div> |
| 990 | 1039 | <div class="windowbg2 noup">'; |
| 991 | - foreach ($context['whois_servers'] as $server) |
|
| 992 | - echo ' |
|
| 1040 | + foreach ($context['whois_servers'] as $server) { |
|
| 1041 | + echo ' |
|
| 993 | 1042 | <a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
| 1043 | + } |
|
| 994 | 1044 | echo ' |
| 995 | 1045 | </div> |
| 996 | 1046 | <br>'; |
@@ -1001,10 +1051,10 @@ discard block |
||
| 1001 | 1051 | <div class="cat_bar"> |
| 1002 | 1052 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
| 1003 | 1053 | </div>'; |
| 1004 | - if (empty($context['ips'])) |
|
| 1005 | - echo ' |
|
| 1054 | + if (empty($context['ips'])) { |
|
| 1055 | + echo ' |
|
| 1006 | 1056 | <p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>'; |
| 1007 | - else |
|
| 1057 | + } else |
|
| 1008 | 1058 | { |
| 1009 | 1059 | echo ' |
| 1010 | 1060 | <table class="table_grid"> |
@@ -1017,12 +1067,13 @@ discard block |
||
| 1017 | 1067 | <tbody>'; |
| 1018 | 1068 | |
| 1019 | 1069 | // Loop through each of the members and display them. |
| 1020 | - foreach ($context['ips'] as $ip => $memberlist) |
|
| 1021 | - echo ' |
|
| 1070 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
| 1071 | + echo ' |
|
| 1022 | 1072 | <tr class="windowbg"> |
| 1023 | 1073 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
| 1024 | 1074 | <td>', implode(', ', $memberlist), '</td> |
| 1025 | 1075 | </tr>'; |
| 1076 | + } |
|
| 1026 | 1077 | |
| 1027 | 1078 | echo ' |
| 1028 | 1079 | </tbody> |
@@ -1068,8 +1119,7 @@ discard block |
||
| 1068 | 1119 | { |
| 1069 | 1120 | echo ' |
| 1070 | 1121 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
| 1071 | - } |
|
| 1072 | - else |
|
| 1122 | + } else |
|
| 1073 | 1123 | { |
| 1074 | 1124 | echo ' |
| 1075 | 1125 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1083,9 +1133,10 @@ discard block |
||
| 1083 | 1133 | </div> |
| 1084 | 1134 | <div class="windowbg smalltext"> |
| 1085 | 1135 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
| 1086 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
| 1087 | - echo ' |
|
| 1136 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
| 1137 | + echo ' |
|
| 1088 | 1138 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
| 1139 | + } |
|
| 1089 | 1140 | echo ' |
| 1090 | 1141 | </div>'; |
| 1091 | 1142 | } |
@@ -1117,12 +1168,13 @@ discard block |
||
| 1117 | 1168 | </td> |
| 1118 | 1169 | <td class="smalltext">'; |
| 1119 | 1170 | |
| 1120 | - if ($permission['is_denied']) |
|
| 1121 | - echo ' |
|
| 1171 | + if ($permission['is_denied']) { |
|
| 1172 | + echo ' |
|
| 1122 | 1173 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1123 | - else |
|
| 1124 | - echo ' |
|
| 1174 | + } else { |
|
| 1175 | + echo ' |
|
| 1125 | 1176 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1177 | + } |
|
| 1126 | 1178 | |
| 1127 | 1179 | echo ' |
| 1128 | 1180 | </td> |
@@ -1132,10 +1184,10 @@ discard block |
||
| 1132 | 1184 | </tbody> |
| 1133 | 1185 | </table> |
| 1134 | 1186 | </div><br>'; |
| 1135 | - } |
|
| 1136 | - else |
|
| 1137 | - echo ' |
|
| 1187 | + } else { |
|
| 1188 | + echo ' |
|
| 1138 | 1189 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
| 1190 | + } |
|
| 1139 | 1191 | |
| 1140 | 1192 | // Board permission section. |
| 1141 | 1193 | echo ' |
@@ -1145,14 +1197,16 @@ discard block |
||
| 1145 | 1197 | <a id="board_permissions"></a>', $txt['showPermissions_select'], ': |
| 1146 | 1198 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
| 1147 | 1199 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], ' </option>'; |
| 1148 | - if (!empty($context['boards'])) |
|
| 1149 | - echo ' |
|
| 1200 | + if (!empty($context['boards'])) { |
|
| 1201 | + echo ' |
|
| 1150 | 1202 | <option value="" disabled>---------------------------</option>'; |
| 1203 | + } |
|
| 1151 | 1204 | |
| 1152 | 1205 | // Fill the box with any local permission boards. |
| 1153 | - foreach ($context['boards'] as $board) |
|
| 1154 | - echo ' |
|
| 1206 | + foreach ($context['boards'] as $board) { |
|
| 1207 | + echo ' |
|
| 1155 | 1208 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
| 1209 | + } |
|
| 1156 | 1210 | |
| 1157 | 1211 | echo ' |
| 1158 | 1212 | </select> |
@@ -1183,8 +1237,7 @@ discard block |
||
| 1183 | 1237 | { |
| 1184 | 1238 | echo ' |
| 1185 | 1239 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1186 | - } |
|
| 1187 | - else |
|
| 1240 | + } else |
|
| 1188 | 1241 | { |
| 1189 | 1242 | echo ' |
| 1190 | 1243 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
@@ -1196,10 +1249,10 @@ discard block |
||
| 1196 | 1249 | echo ' |
| 1197 | 1250 | </tbody> |
| 1198 | 1251 | </table>'; |
| 1199 | - } |
|
| 1200 | - else |
|
| 1201 | - echo ' |
|
| 1252 | + } else { |
|
| 1253 | + echo ' |
|
| 1202 | 1254 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
| 1255 | + } |
|
| 1203 | 1256 | echo ' |
| 1204 | 1257 | </div> |
| 1205 | 1258 | </div>'; |
@@ -1241,9 +1294,10 @@ discard block |
||
| 1241 | 1294 | </div>'; |
| 1242 | 1295 | |
| 1243 | 1296 | // If they haven't post at all, don't draw the graph. |
| 1244 | - if (empty($context['posts_by_time'])) |
|
| 1245 | - echo ' |
|
| 1297 | + if (empty($context['posts_by_time'])) { |
|
| 1298 | + echo ' |
|
| 1246 | 1299 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1300 | + } |
|
| 1247 | 1301 | // Otherwise do! |
| 1248 | 1302 | else |
| 1249 | 1303 | { |
@@ -1282,11 +1336,10 @@ discard block |
||
| 1282 | 1336 | </h3> |
| 1283 | 1337 | </div>'; |
| 1284 | 1338 | |
| 1285 | - if (empty($context['popular_boards'])) |
|
| 1286 | - echo ' |
|
| 1339 | + if (empty($context['popular_boards'])) { |
|
| 1340 | + echo ' |
|
| 1287 | 1341 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1288 | - |
|
| 1289 | - else |
|
| 1342 | + } else |
|
| 1290 | 1343 | { |
| 1291 | 1344 | echo ' |
| 1292 | 1345 | <dl class="stats">'; |
@@ -1317,10 +1370,10 @@ discard block |
||
| 1317 | 1370 | </h3> |
| 1318 | 1371 | </div>'; |
| 1319 | 1372 | |
| 1320 | - if (empty($context['board_activity'])) |
|
| 1321 | - echo ' |
|
| 1373 | + if (empty($context['board_activity'])) { |
|
| 1374 | + echo ' |
|
| 1322 | 1375 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1323 | - else |
|
| 1376 | + } else |
|
| 1324 | 1377 | { |
| 1325 | 1378 | echo ' |
| 1326 | 1379 | <dl class="stats">'; |
@@ -1368,41 +1421,46 @@ discard block |
||
| 1368 | 1421 | <h3 class="catbg profile_hd">'; |
| 1369 | 1422 | |
| 1370 | 1423 | // Don't say "Profile" if this isn't the profile... |
| 1371 | - if (!empty($context['profile_header_text'])) |
|
| 1372 | - echo ' |
|
| 1424 | + if (!empty($context['profile_header_text'])) { |
|
| 1425 | + echo ' |
|
| 1373 | 1426 | ', $context['profile_header_text']; |
| 1374 | - else |
|
| 1375 | - echo ' |
|
| 1427 | + } else { |
|
| 1428 | + echo ' |
|
| 1376 | 1429 | ', $txt['profile']; |
| 1430 | + } |
|
| 1377 | 1431 | |
| 1378 | 1432 | echo ' |
| 1379 | 1433 | </h3> |
| 1380 | 1434 | </div>'; |
| 1381 | 1435 | |
| 1382 | 1436 | // Have we some description? |
| 1383 | - if ($context['page_desc']) |
|
| 1384 | - echo ' |
|
| 1437 | + if ($context['page_desc']) { |
|
| 1438 | + echo ' |
|
| 1385 | 1439 | <p class="information">', $context['page_desc'], '</p>'; |
| 1440 | + } |
|
| 1386 | 1441 | |
| 1387 | 1442 | echo ' |
| 1388 | 1443 | <div class="roundframe">'; |
| 1389 | 1444 | |
| 1390 | 1445 | // Any bits at the start? |
| 1391 | - if (!empty($context['profile_prehtml'])) |
|
| 1392 | - echo ' |
|
| 1446 | + if (!empty($context['profile_prehtml'])) { |
|
| 1447 | + echo ' |
|
| 1393 | 1448 | <div>', $context['profile_prehtml'], '</div>'; |
| 1449 | + } |
|
| 1394 | 1450 | |
| 1395 | - if (!empty($context['profile_fields'])) |
|
| 1396 | - echo ' |
|
| 1451 | + if (!empty($context['profile_fields'])) { |
|
| 1452 | + echo ' |
|
| 1397 | 1453 | <dl class="settings">'; |
| 1454 | + } |
|
| 1398 | 1455 | |
| 1399 | 1456 | // Start the big old loop 'of love. |
| 1400 | 1457 | $lastItem = 'hr'; |
| 1401 | 1458 | foreach ($context['profile_fields'] as $key => $field) |
| 1402 | 1459 | { |
| 1403 | 1460 | // We add a little hack to be sure we never get more than one hr in a row! |
| 1404 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
| 1405 | - continue; |
|
| 1461 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
| 1462 | + continue; |
|
| 1463 | + } |
|
| 1406 | 1464 | |
| 1407 | 1465 | $lastItem = $field['type']; |
| 1408 | 1466 | if ($field['type'] == 'hr') |
@@ -1411,48 +1469,50 @@ discard block |
||
| 1411 | 1469 | </dl> |
| 1412 | 1470 | <hr> |
| 1413 | 1471 | <dl class="settings">'; |
| 1414 | - } |
|
| 1415 | - elseif ($field['type'] == 'callback') |
|
| 1472 | + } elseif ($field['type'] == 'callback') |
|
| 1416 | 1473 | { |
| 1417 | 1474 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
| 1418 | 1475 | { |
| 1419 | 1476 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 1420 | 1477 | $callback_func(); |
| 1421 | 1478 | } |
| 1422 | - } |
|
| 1423 | - else |
|
| 1479 | + } else |
|
| 1424 | 1480 | { |
| 1425 | 1481 | echo ' |
| 1426 | 1482 | <dt> |
| 1427 | 1483 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
| 1428 | 1484 | |
| 1429 | 1485 | // Does it have any subtext to show? |
| 1430 | - if (!empty($field['subtext'])) |
|
| 1431 | - echo ' |
|
| 1486 | + if (!empty($field['subtext'])) { |
|
| 1487 | + echo ' |
|
| 1432 | 1488 | <br> |
| 1433 | 1489 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 1490 | + } |
|
| 1434 | 1491 | |
| 1435 | 1492 | echo ' |
| 1436 | 1493 | </dt> |
| 1437 | 1494 | <dd>'; |
| 1438 | 1495 | |
| 1439 | 1496 | // Want to put something infront of the box? |
| 1440 | - if (!empty($field['preinput'])) |
|
| 1441 | - echo ' |
|
| 1497 | + if (!empty($field['preinput'])) { |
|
| 1498 | + echo ' |
|
| 1442 | 1499 | ', $field['preinput']; |
| 1500 | + } |
|
| 1443 | 1501 | |
| 1444 | 1502 | // What type of data are we showing? |
| 1445 | - if ($field['type'] == 'label') |
|
| 1446 | - echo ' |
|
| 1503 | + if ($field['type'] == 'label') { |
|
| 1504 | + echo ' |
|
| 1447 | 1505 | ', $field['value']; |
| 1506 | + } |
|
| 1448 | 1507 | |
| 1449 | 1508 | // Maybe it's a text box - very likely! |
| 1450 | 1509 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
| 1451 | 1510 | { |
| 1452 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
| 1453 | - $type = 'number'; |
|
| 1454 | - else |
|
| 1455 | - $type = $field['type']; |
|
| 1511 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
| 1512 | + $type = 'number'; |
|
| 1513 | + } else { |
|
| 1514 | + $type = $field['type']; |
|
| 1515 | + } |
|
| 1456 | 1516 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
| 1457 | 1517 | |
| 1458 | 1518 | |
@@ -1460,9 +1520,10 @@ discard block |
||
| 1460 | 1520 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
| 1461 | 1521 | } |
| 1462 | 1522 | // You "checking" me out? ;) |
| 1463 | - elseif ($field['type'] == 'check') |
|
| 1464 | - echo ' |
|
| 1523 | + elseif ($field['type'] == 'check') { |
|
| 1524 | + echo ' |
|
| 1465 | 1525 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
| 1526 | + } |
|
| 1466 | 1527 | |
| 1467 | 1528 | // Always fun - select boxes! |
| 1468 | 1529 | elseif ($field['type'] == 'select') |
@@ -1473,13 +1534,15 @@ discard block |
||
| 1473 | 1534 | if (isset($field['options'])) |
| 1474 | 1535 | { |
| 1475 | 1536 | // Is this some code to generate the options? |
| 1476 | - if (!is_array($field['options'])) |
|
| 1477 | - $field['options'] = $field['options'](); |
|
| 1537 | + if (!is_array($field['options'])) { |
|
| 1538 | + $field['options'] = $field['options'](); |
|
| 1539 | + } |
|
| 1478 | 1540 | // Assuming we now have some! |
| 1479 | - if (is_array($field['options'])) |
|
| 1480 | - foreach ($field['options'] as $value => $name) |
|
| 1541 | + if (is_array($field['options'])) { |
|
| 1542 | + foreach ($field['options'] as $value => $name) |
|
| 1481 | 1543 | echo ' |
| 1482 | 1544 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 1545 | + } |
|
| 1483 | 1546 | } |
| 1484 | 1547 | |
| 1485 | 1548 | echo ' |
@@ -1487,25 +1550,28 @@ discard block |
||
| 1487 | 1550 | } |
| 1488 | 1551 | |
| 1489 | 1552 | // Something to end with? |
| 1490 | - if (!empty($field['postinput'])) |
|
| 1491 | - echo ' |
|
| 1553 | + if (!empty($field['postinput'])) { |
|
| 1554 | + echo ' |
|
| 1492 | 1555 | ', $field['postinput']; |
| 1556 | + } |
|
| 1493 | 1557 | |
| 1494 | 1558 | echo ' |
| 1495 | 1559 | </dd>'; |
| 1496 | 1560 | } |
| 1497 | 1561 | } |
| 1498 | 1562 | |
| 1499 | - if (!empty($context['profile_fields'])) |
|
| 1500 | - echo ' |
|
| 1563 | + if (!empty($context['profile_fields'])) { |
|
| 1564 | + echo ' |
|
| 1501 | 1565 | </dl>'; |
| 1566 | + } |
|
| 1502 | 1567 | |
| 1503 | 1568 | // Are there any custom profile fields - if so print them! |
| 1504 | 1569 | if (!empty($context['custom_fields'])) |
| 1505 | 1570 | { |
| 1506 | - if ($lastItem != 'hr') |
|
| 1507 | - echo ' |
|
| 1571 | + if ($lastItem != 'hr') { |
|
| 1572 | + echo ' |
|
| 1508 | 1573 | <hr>'; |
| 1574 | + } |
|
| 1509 | 1575 | |
| 1510 | 1576 | echo ' |
| 1511 | 1577 | <dl class="settings">'; |
@@ -1528,13 +1594,14 @@ discard block |
||
| 1528 | 1594 | } |
| 1529 | 1595 | |
| 1530 | 1596 | // Any closing HTML? |
| 1531 | - if (!empty($context['profile_posthtml'])) |
|
| 1532 | - echo ' |
|
| 1597 | + if (!empty($context['profile_posthtml'])) { |
|
| 1598 | + echo ' |
|
| 1533 | 1599 | <div>', $context['profile_posthtml'], '</div>'; |
| 1600 | + } |
|
| 1534 | 1601 | |
| 1535 | 1602 | // Only show the password box if it's actually needed. |
| 1536 | - if ($context['require_password']) |
|
| 1537 | - echo ' |
|
| 1603 | + if ($context['require_password']) { |
|
| 1604 | + echo ' |
|
| 1538 | 1605 | <dl class="settings"> |
| 1539 | 1606 | <dt> |
| 1540 | 1607 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1544,18 +1611,21 @@ discard block |
||
| 1544 | 1611 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20" style="margin-right: 4ex;"> |
| 1545 | 1612 | </dd> |
| 1546 | 1613 | </dl>'; |
| 1614 | + } |
|
| 1547 | 1615 | |
| 1548 | 1616 | // The button shouldn't say "Change profile" unless we're changing the profile... |
| 1549 | - if (!empty($context['submit_button_text'])) |
|
| 1550 | - echo ' |
|
| 1617 | + if (!empty($context['submit_button_text'])) { |
|
| 1618 | + echo ' |
|
| 1551 | 1619 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">'; |
| 1552 | - else |
|
| 1553 | - echo ' |
|
| 1620 | + } else { |
|
| 1621 | + echo ' |
|
| 1554 | 1622 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button">'; |
| 1623 | + } |
|
| 1555 | 1624 | |
| 1556 | - if (!empty($context['token_check'])) |
|
| 1557 | - echo ' |
|
| 1625 | + if (!empty($context['token_check'])) { |
|
| 1626 | + echo ' |
|
| 1558 | 1627 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1628 | + } |
|
| 1559 | 1629 | |
| 1560 | 1630 | echo ' |
| 1561 | 1631 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1565,10 +1635,11 @@ discard block |
||
| 1565 | 1635 | </form>'; |
| 1566 | 1636 | |
| 1567 | 1637 | // Any final spellchecking stuff? |
| 1568 | - if (!empty($context['show_spellchecking'])) |
|
| 1569 | - echo ' |
|
| 1638 | + if (!empty($context['show_spellchecking'])) { |
|
| 1639 | + echo ' |
|
| 1570 | 1640 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
| 1571 | -} |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1572 | 1643 | |
| 1573 | 1644 | /** |
| 1574 | 1645 | * Personal Message settings. |
@@ -1605,10 +1676,11 @@ discard block |
||
| 1605 | 1676 | <select name="pm_receive_from" id="pm_receive_from"> |
| 1606 | 1677 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
| 1607 | 1678 | |
| 1608 | - if (!empty($modSettings['enable_buddylist'])) |
|
| 1609 | - echo ' |
|
| 1679 | + if (!empty($modSettings['enable_buddylist'])) { |
|
| 1680 | + echo ' |
|
| 1610 | 1681 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
| 1611 | 1682 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
| 1683 | + } |
|
| 1612 | 1684 | |
| 1613 | 1685 | echo ' |
| 1614 | 1686 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1651,11 +1723,12 @@ discard block |
||
| 1651 | 1723 | if (empty($setting) || !is_array($setting)) |
| 1652 | 1724 | { |
| 1653 | 1725 | // Insert a separator (unless this is the first item in the list) |
| 1654 | - if ($i !== $first_option_key) |
|
| 1655 | - echo ' |
|
| 1726 | + if ($i !== $first_option_key) { |
|
| 1727 | + echo ' |
|
| 1656 | 1728 | </dl> |
| 1657 | 1729 | <hr> |
| 1658 | 1730 | <dl class="settings">'; |
| 1731 | + } |
|
| 1659 | 1732 | |
| 1660 | 1733 | // Should we give a name to this section? |
| 1661 | 1734 | if (is_string($setting) && !empty($setting)) |
@@ -1663,48 +1736,52 @@ discard block |
||
| 1663 | 1736 | $titled_section = true; |
| 1664 | 1737 | echo ' |
| 1665 | 1738 | <dt><strong>' . $setting . '</strong></dt><dd></dd>'; |
| 1739 | + } else { |
|
| 1740 | + $titled_section = false; |
|
| 1666 | 1741 | } |
| 1667 | - else |
|
| 1668 | - $titled_section = false; |
|
| 1669 | 1742 | |
| 1670 | 1743 | continue; |
| 1671 | 1744 | } |
| 1672 | 1745 | |
| 1673 | 1746 | // Is this disabled? |
| 1674 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
| 1675 | - continue; |
|
| 1676 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 1677 | - continue; |
|
| 1678 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
| 1679 | - continue; |
|
| 1680 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
| 1681 | - continue; |
|
| 1682 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
| 1683 | - continue; |
|
| 1684 | - elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) |
|
| 1685 | - continue; |
|
| 1686 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1687 | - continue; |
|
| 1688 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1689 | - continue; |
|
| 1747 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
| 1748 | + continue; |
|
| 1749 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1750 | + continue; |
|
| 1751 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
| 1752 | + continue; |
|
| 1753 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
| 1754 | + continue; |
|
| 1755 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
| 1756 | + continue; |
|
| 1757 | + } elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1758 | + continue; |
|
| 1759 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1760 | + continue; |
|
| 1761 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1762 | + continue; |
|
| 1763 | + } |
|
| 1690 | 1764 | |
| 1691 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 1692 | - $setting['type'] = 'checkbox'; |
|
| 1693 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 1694 | - $setting['type'] = 'number'; |
|
| 1695 | - elseif ($setting['type'] == 'string') |
|
| 1696 | - $setting['type'] = 'text'; |
|
| 1765 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 1766 | + $setting['type'] = 'checkbox'; |
|
| 1767 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 1768 | + $setting['type'] = 'number'; |
|
| 1769 | + } elseif ($setting['type'] == 'string') { |
|
| 1770 | + $setting['type'] = 'text'; |
|
| 1771 | + } |
|
| 1697 | 1772 | |
| 1698 | - if (isset($setting['options'])) |
|
| 1699 | - $setting['type'] = 'list'; |
|
| 1773 | + if (isset($setting['options'])) { |
|
| 1774 | + $setting['type'] = 'list'; |
|
| 1775 | + } |
|
| 1700 | 1776 | |
| 1701 | 1777 | echo ' |
| 1702 | 1778 | <dt> |
| 1703 | 1779 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
| 1704 | 1780 | |
| 1705 | - if (isset($setting['description'])) |
|
| 1706 | - echo ' |
|
| 1781 | + if (isset($setting['description'])) { |
|
| 1782 | + echo ' |
|
| 1707 | 1783 | <br><span class="smalltext">', $setting['description'], '</span>'; |
| 1784 | + } |
|
| 1708 | 1785 | echo ' |
| 1709 | 1786 | </dt> |
| 1710 | 1787 | <dd>'; |
@@ -1742,13 +1819,11 @@ discard block |
||
| 1742 | 1819 | |
| 1743 | 1820 | echo ' |
| 1744 | 1821 | <input type="number"', $min . $max . $step; |
| 1745 | - } |
|
| 1746 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1822 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1747 | 1823 | { |
| 1748 | 1824 | echo' |
| 1749 | 1825 | <input type="url"'; |
| 1750 | - } |
|
| 1751 | - else |
|
| 1826 | + } else |
|
| 1752 | 1827 | { |
| 1753 | 1828 | echo ' |
| 1754 | 1829 | <input type="text"'; |
@@ -1787,8 +1862,8 @@ discard block |
||
| 1787 | 1862 | <dl class="settings">'; |
| 1788 | 1863 | |
| 1789 | 1864 | // Allow notification on announcements to be disabled? |
| 1790 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
| 1791 | - echo ' |
|
| 1865 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
| 1866 | + echo ' |
|
| 1792 | 1867 | <dt> |
| 1793 | 1868 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
| 1794 | 1869 | </dt> |
@@ -1796,9 +1871,10 @@ discard block |
||
| 1796 | 1871 | <input type="hidden" name="notify_announcements" value="0"> |
| 1797 | 1872 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
| 1798 | 1873 | </dd>'; |
| 1874 | + } |
|
| 1799 | 1875 | |
| 1800 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
| 1801 | - echo ' |
|
| 1876 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
| 1877 | + echo ' |
|
| 1802 | 1878 | <dt> |
| 1803 | 1879 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
| 1804 | 1880 | </dt> |
@@ -1806,6 +1882,7 @@ discard block |
||
| 1806 | 1882 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
| 1807 | 1883 | </dd> |
| 1808 | 1884 | '; |
| 1885 | + } |
|
| 1809 | 1886 | |
| 1810 | 1887 | echo ' |
| 1811 | 1888 | </dl> |
@@ -1835,9 +1912,10 @@ discard block |
||
| 1835 | 1912 | <td colspan="3">'; |
| 1836 | 1913 | $label = $txt['alert_opt_' . $opts[1]]; |
| 1837 | 1914 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
| 1838 | - if ($label_pos == 'before') |
|
| 1839 | - echo ' |
|
| 1915 | + if ($label_pos == 'before') { |
|
| 1916 | + echo ' |
|
| 1840 | 1917 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1918 | + } |
|
| 1841 | 1919 | |
| 1842 | 1920 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
| 1843 | 1921 | switch ($opts[0]) |
@@ -1849,17 +1927,19 @@ discard block |
||
| 1849 | 1927 | case 'select': |
| 1850 | 1928 | echo ' |
| 1851 | 1929 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
| 1852 | - foreach ($opts['opts'] as $k => $v) |
|
| 1853 | - echo ' |
|
| 1930 | + foreach ($opts['opts'] as $k => $v) { |
|
| 1931 | + echo ' |
|
| 1854 | 1932 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
| 1933 | + } |
|
| 1855 | 1934 | echo ' |
| 1856 | 1935 | </select>'; |
| 1857 | 1936 | break; |
| 1858 | 1937 | } |
| 1859 | 1938 | |
| 1860 | - if ($label_pos == 'after') |
|
| 1861 | - echo ' |
|
| 1939 | + if ($label_pos == 'after') { |
|
| 1940 | + echo ' |
|
| 1862 | 1941 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1942 | + } |
|
| 1863 | 1943 | |
| 1864 | 1944 | echo ' |
| 1865 | 1945 | </td> |
@@ -1973,11 +2053,12 @@ discard block |
||
| 1973 | 2053 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
| 1974 | 2054 | |
| 1975 | 2055 | // Do we have an update message? |
| 1976 | - if (!empty($context['update_message'])) |
|
| 1977 | - echo ' |
|
| 2056 | + if (!empty($context['update_message'])) { |
|
| 2057 | + echo ' |
|
| 1978 | 2058 | <div class="infobox"> |
| 1979 | 2059 | ', $context['update_message'], '. |
| 1980 | 2060 | </div>'; |
| 2061 | + } |
|
| 1981 | 2062 | |
| 1982 | 2063 | echo ' |
| 1983 | 2064 | <div id="groups">'; |
@@ -1999,8 +2080,7 @@ discard block |
||
| 1999 | 2080 | </div> |
| 2000 | 2081 | </div> |
| 2001 | 2082 | </div>'; |
| 2002 | - } |
|
| 2003 | - else |
|
| 2083 | + } else |
|
| 2004 | 2084 | { |
| 2005 | 2085 | echo ' |
| 2006 | 2086 | <div class="title_bar"> |
@@ -2012,27 +2092,30 @@ discard block |
||
| 2012 | 2092 | echo ' |
| 2013 | 2093 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
| 2014 | 2094 | |
| 2015 | - if ($context['can_edit_primary']) |
|
| 2016 | - echo ' |
|
| 2095 | + if ($context['can_edit_primary']) { |
|
| 2096 | + echo ' |
|
| 2017 | 2097 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
| 2098 | + } |
|
| 2018 | 2099 | |
| 2019 | 2100 | echo ' |
| 2020 | 2101 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
| 2021 | 2102 | |
| 2022 | 2103 | // Can they leave their group? |
| 2023 | - if ($group['can_leave']) |
|
| 2024 | - echo ' |
|
| 2104 | + if ($group['can_leave']) { |
|
| 2105 | + echo ' |
|
| 2025 | 2106 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
| 2107 | + } |
|
| 2026 | 2108 | |
| 2027 | 2109 | echo ' |
| 2028 | 2110 | </div>'; |
| 2029 | 2111 | } |
| 2030 | 2112 | |
| 2031 | - if ($context['can_edit_primary']) |
|
| 2032 | - echo ' |
|
| 2113 | + if ($context['can_edit_primary']) { |
|
| 2114 | + echo ' |
|
| 2033 | 2115 | <div class="padding righttext"> |
| 2034 | 2116 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
| 2035 | 2117 | </div>'; |
| 2118 | + } |
|
| 2036 | 2119 | |
| 2037 | 2120 | // Any groups they can join? |
| 2038 | 2121 | if (!empty($context['groups']['available'])) |
@@ -2048,15 +2131,16 @@ discard block |
||
| 2048 | 2131 | <div class="windowbg"> |
| 2049 | 2132 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
| 2050 | 2133 | |
| 2051 | - if ($group['type'] == 3) |
|
| 2052 | - echo ' |
|
| 2134 | + if ($group['type'] == 3) { |
|
| 2135 | + echo ' |
|
| 2053 | 2136 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
| 2054 | - elseif ($group['type'] == 2 && $group['pending']) |
|
| 2055 | - echo ' |
|
| 2137 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
| 2138 | + echo ' |
|
| 2056 | 2139 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
| 2057 | - elseif ($group['type'] == 2) |
|
| 2058 | - echo ' |
|
| 2140 | + } elseif ($group['type'] == 2) { |
|
| 2141 | + echo ' |
|
| 2059 | 2142 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
| 2143 | + } |
|
| 2060 | 2144 | |
| 2061 | 2145 | echo ' |
| 2062 | 2146 | </div>'; |
@@ -2079,9 +2163,10 @@ discard block |
||
| 2079 | 2163 | |
| 2080 | 2164 | prevDiv.className = "windowbg"; |
| 2081 | 2165 | }'; |
| 2082 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
| 2083 | - echo ' |
|
| 2166 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
| 2167 | + echo ' |
|
| 2084 | 2168 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
| 2169 | + } |
|
| 2085 | 2170 | echo ' |
| 2086 | 2171 | </script>'; |
| 2087 | 2172 | } |
@@ -2089,9 +2174,10 @@ discard block |
||
| 2089 | 2174 | echo ' |
| 2090 | 2175 | </div>'; |
| 2091 | 2176 | |
| 2092 | - if (!empty($context['token_check'])) |
|
| 2093 | - echo ' |
|
| 2177 | + if (!empty($context['token_check'])) { |
|
| 2178 | + echo ' |
|
| 2094 | 2179 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2180 | + } |
|
| 2095 | 2181 | |
| 2096 | 2182 | echo ' |
| 2097 | 2183 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2138,14 +2224,15 @@ discard block |
||
| 2138 | 2224 | |
| 2139 | 2225 | foreach ($category['boards'] as $board) |
| 2140 | 2226 | { |
| 2141 | - if ($i == $limit) |
|
| 2142 | - echo ' |
|
| 2227 | + if ($i == $limit) { |
|
| 2228 | + echo ' |
|
| 2143 | 2229 | </ul> |
| 2144 | 2230 | </li> |
| 2145 | 2231 | </ul> |
| 2146 | 2232 | <ul class="ignoreboards floatright"> |
| 2147 | 2233 | <li class="category"> |
| 2148 | 2234 | <ul>'; |
| 2235 | + } |
|
| 2149 | 2236 | |
| 2150 | 2237 | echo ' |
| 2151 | 2238 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2191,10 +2278,11 @@ discard block |
||
| 2191 | 2278 | |
| 2192 | 2279 | // Work out the starting color. |
| 2193 | 2280 | $context['current_color'] = $context['colors'][0]; |
| 2194 | - foreach ($context['colors'] as $limit => $color) |
|
| 2195 | - if ($context['member']['warning'] >= $limit) |
|
| 2281 | + foreach ($context['colors'] as $limit => $color) { |
|
| 2282 | + if ($context['member']['warning'] >= $limit) |
|
| 2196 | 2283 | $context['current_color'] = $color; |
| 2197 | -} |
|
| 2284 | + } |
|
| 2285 | + } |
|
| 2198 | 2286 | |
| 2199 | 2287 | // Show all warnings of a user? |
| 2200 | 2288 | function template_viewWarning() |
@@ -2233,14 +2321,15 @@ discard block |
||
| 2233 | 2321 | </dd>'; |
| 2234 | 2322 | |
| 2235 | 2323 | // There's some impact of this? |
| 2236 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
| 2237 | - echo ' |
|
| 2324 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
| 2325 | + echo ' |
|
| 2238 | 2326 | <dt> |
| 2239 | 2327 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
| 2240 | 2328 | </dt> |
| 2241 | 2329 | <dd> |
| 2242 | 2330 | ', $context['level_effects'][$context['current_level']], ' |
| 2243 | 2331 | </dd>'; |
| 2332 | + } |
|
| 2244 | 2333 | |
| 2245 | 2334 | echo ' |
| 2246 | 2335 | </dl> |
@@ -2278,10 +2367,11 @@ discard block |
||
| 2278 | 2367 | |
| 2279 | 2368 | // Otherwise see what we can do...'; |
| 2280 | 2369 | |
| 2281 | - foreach ($context['notification_templates'] as $k => $type) |
|
| 2282 | - echo ' |
|
| 2370 | + foreach ($context['notification_templates'] as $k => $type) { |
|
| 2371 | + echo ' |
|
| 2283 | 2372 | if (index == ', $k, ') |
| 2284 | 2373 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
| 2374 | + } |
|
| 2285 | 2375 | |
| 2286 | 2376 | echo ' |
| 2287 | 2377 | } |
@@ -2291,10 +2381,11 @@ discard block |
||
| 2291 | 2381 | // Also set the right effect. |
| 2292 | 2382 | effectText = "";'; |
| 2293 | 2383 | |
| 2294 | - foreach ($context['level_effects'] as $limit => $text) |
|
| 2295 | - echo ' |
|
| 2384 | + foreach ($context['level_effects'] as $limit => $text) { |
|
| 2385 | + echo ' |
|
| 2296 | 2386 | if (slideAmount >= ', $limit, ') |
| 2297 | 2387 | effectText = "', $text, '";'; |
| 2388 | + } |
|
| 2298 | 2389 | |
| 2299 | 2390 | echo ' |
| 2300 | 2391 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2309,31 +2400,34 @@ discard block |
||
| 2309 | 2400 | </h3> |
| 2310 | 2401 | </div>'; |
| 2311 | 2402 | |
| 2312 | - if (!$context['user']['is_owner']) |
|
| 2313 | - echo ' |
|
| 2403 | + if (!$context['user']['is_owner']) { |
|
| 2404 | + echo ' |
|
| 2314 | 2405 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
| 2406 | + } |
|
| 2315 | 2407 | |
| 2316 | 2408 | echo ' |
| 2317 | 2409 | <div class="windowbg"> |
| 2318 | 2410 | <dl class="settings">'; |
| 2319 | 2411 | |
| 2320 | - if (!$context['user']['is_owner']) |
|
| 2321 | - echo ' |
|
| 2412 | + if (!$context['user']['is_owner']) { |
|
| 2413 | + echo ' |
|
| 2322 | 2414 | <dt> |
| 2323 | 2415 | <strong>', $txt['profile_warning_name'], ':</strong> |
| 2324 | 2416 | </dt> |
| 2325 | 2417 | <dd> |
| 2326 | 2418 | <strong>', $context['member']['name'], '</strong> |
| 2327 | 2419 | </dd>'; |
| 2420 | + } |
|
| 2328 | 2421 | |
| 2329 | 2422 | echo ' |
| 2330 | 2423 | <dt> |
| 2331 | 2424 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
| 2332 | 2425 | |
| 2333 | 2426 | // Is there only so much they can apply? |
| 2334 | - if ($context['warning_limit']) |
|
| 2335 | - echo ' |
|
| 2427 | + if ($context['warning_limit']) { |
|
| 2428 | + echo ' |
|
| 2336 | 2429 | <br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
| 2430 | + } |
|
| 2337 | 2431 | |
| 2338 | 2432 | echo ' |
| 2339 | 2433 | </dt> |
@@ -2386,9 +2480,10 @@ discard block |
||
| 2386 | 2480 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
| 2387 | 2481 | <option value="-1" disabled>------------------------------</option>'; |
| 2388 | 2482 | |
| 2389 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
| 2390 | - echo ' |
|
| 2483 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
| 2484 | + echo ' |
|
| 2391 | 2485 | <option value="', $id_template, '">', $template['title'], '</option>'; |
| 2486 | + } |
|
| 2392 | 2487 | |
| 2393 | 2488 | echo ' |
| 2394 | 2489 | </select> |
@@ -2400,9 +2495,10 @@ discard block |
||
| 2400 | 2495 | </dl> |
| 2401 | 2496 | <div class="righttext">'; |
| 2402 | 2497 | |
| 2403 | - if (!empty($context['token_check'])) |
|
| 2404 | - echo ' |
|
| 2498 | + if (!empty($context['token_check'])) { |
|
| 2499 | + echo ' |
|
| 2405 | 2500 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2501 | + } |
|
| 2406 | 2502 | |
| 2407 | 2503 | echo ' |
| 2408 | 2504 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2418,8 +2514,8 @@ discard block |
||
| 2418 | 2514 | echo ' |
| 2419 | 2515 | <script>'; |
| 2420 | 2516 | |
| 2421 | - if (!$context['user']['is_owner']) |
|
| 2422 | - echo ' |
|
| 2517 | + if (!$context['user']['is_owner']) { |
|
| 2518 | + echo ' |
|
| 2423 | 2519 | modifyWarnNotify(); |
| 2424 | 2520 | $(document).ready(function() { |
| 2425 | 2521 | $("#preview_button").click(function() { |
@@ -2458,6 +2554,7 @@ discard block |
||
| 2458 | 2554 | }); |
| 2459 | 2555 | return false; |
| 2460 | 2556 | }'; |
| 2557 | + } |
|
| 2461 | 2558 | |
| 2462 | 2559 | echo ' |
| 2463 | 2560 | </script>'; |
@@ -2480,16 +2577,18 @@ discard block |
||
| 2480 | 2577 | </div>'; |
| 2481 | 2578 | |
| 2482 | 2579 | // If deleting another account give them a lovely info box. |
| 2483 | - if (!$context['user']['is_owner']) |
|
| 2484 | - echo ' |
|
| 2580 | + if (!$context['user']['is_owner']) { |
|
| 2581 | + echo ' |
|
| 2485 | 2582 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
| 2583 | + } |
|
| 2486 | 2584 | echo ' |
| 2487 | 2585 | <div class="windowbg2">'; |
| 2488 | 2586 | |
| 2489 | 2587 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
| 2490 | - if ($context['needs_approval']) |
|
| 2491 | - echo ' |
|
| 2588 | + if ($context['needs_approval']) { |
|
| 2589 | + echo ' |
|
| 2492 | 2590 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
| 2591 | + } |
|
| 2493 | 2592 | |
| 2494 | 2593 | // If the user is deleting their own account warn them first - and require a password! |
| 2495 | 2594 | if ($context['user']['is_owner']) |
@@ -2501,9 +2600,10 @@ discard block |
||
| 2501 | 2600 | <input type="password" name="oldpasswrd" size="20"> |
| 2502 | 2601 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
| 2503 | 2602 | |
| 2504 | - if (!empty($context['token_check'])) |
|
| 2505 | - echo ' |
|
| 2603 | + if (!empty($context['token_check'])) { |
|
| 2604 | + echo ' |
|
| 2506 | 2605 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2606 | + } |
|
| 2507 | 2607 | |
| 2508 | 2608 | echo ' |
| 2509 | 2609 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2529,9 +2629,10 @@ discard block |
||
| 2529 | 2629 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
| 2530 | 2630 | </select>'; |
| 2531 | 2631 | |
| 2532 | - if ($context['show_perma_delete']) |
|
| 2533 | - echo ' |
|
| 2632 | + if ($context['show_perma_delete']) { |
|
| 2633 | + echo ' |
|
| 2534 | 2634 | <br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
| 2635 | + } |
|
| 2535 | 2636 | |
| 2536 | 2637 | echo ' |
| 2537 | 2638 | </div>'; |
@@ -2544,9 +2645,10 @@ discard block |
||
| 2544 | 2645 | <div> |
| 2545 | 2646 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
| 2546 | 2647 | |
| 2547 | - if (!empty($context['token_check'])) |
|
| 2548 | - echo ' |
|
| 2648 | + if (!empty($context['token_check'])) { |
|
| 2649 | + echo ' |
|
| 2549 | 2650 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2651 | + } |
|
| 2550 | 2652 | |
| 2551 | 2653 | echo ' |
| 2552 | 2654 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2572,8 +2674,8 @@ discard block |
||
| 2572 | 2674 | <hr>'; |
| 2573 | 2675 | |
| 2574 | 2676 | // Only show the password box if it's actually needed. |
| 2575 | - if ($context['require_password']) |
|
| 2576 | - echo ' |
|
| 2677 | + if ($context['require_password']) { |
|
| 2678 | + echo ' |
|
| 2577 | 2679 | <dl class="settings"> |
| 2578 | 2680 | <dt> |
| 2579 | 2681 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2583,13 +2685,15 @@ discard block |
||
| 2583 | 2685 | <input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;"> |
| 2584 | 2686 | </dd> |
| 2585 | 2687 | </dl>'; |
| 2688 | + } |
|
| 2586 | 2689 | |
| 2587 | 2690 | echo ' |
| 2588 | 2691 | <div class="righttext">'; |
| 2589 | 2692 | |
| 2590 | - if (!empty($context['token_check'])) |
|
| 2591 | - echo ' |
|
| 2693 | + if (!empty($context['token_check'])) { |
|
| 2694 | + echo ' |
|
| 2592 | 2695 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2696 | + } |
|
| 2593 | 2697 | |
| 2594 | 2698 | echo ' |
| 2595 | 2699 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2616,9 +2720,10 @@ discard block |
||
| 2616 | 2720 | <ul id="list_errors">'; |
| 2617 | 2721 | |
| 2618 | 2722 | // Cycle through each error and display an error message. |
| 2619 | - foreach ($context['post_errors'] as $error) |
|
| 2620 | - echo ' |
|
| 2723 | + foreach ($context['post_errors'] as $error) { |
|
| 2724 | + echo ' |
|
| 2621 | 2725 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
| 2726 | + } |
|
| 2622 | 2727 | |
| 2623 | 2728 | echo ' |
| 2624 | 2729 | </ul>'; |
@@ -2644,12 +2749,13 @@ discard block |
||
| 2644 | 2749 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
| 2645 | 2750 | |
| 2646 | 2751 | // Fill the select box with all primary member groups that can be assigned to a member. |
| 2647 | - foreach ($context['member_groups'] as $member_group) |
|
| 2648 | - if (!empty($member_group['can_be_primary'])) |
|
| 2752 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2753 | + if (!empty($member_group['can_be_primary'])) |
|
| 2649 | 2754 | echo ' |
| 2650 | 2755 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
| 2651 | 2756 | ', $member_group['name'], ' |
| 2652 | 2757 | </option>'; |
| 2758 | + } |
|
| 2653 | 2759 | echo ' |
| 2654 | 2760 | </select> |
| 2655 | 2761 | </dd> |
@@ -2661,10 +2767,11 @@ discard block |
||
| 2661 | 2767 | <input type="hidden" name="additional_groups[]" value="0">'; |
| 2662 | 2768 | |
| 2663 | 2769 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
| 2664 | - foreach ($context['member_groups'] as $member_group) |
|
| 2665 | - if ($member_group['can_be_additional']) |
|
| 2770 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2771 | + if ($member_group['can_be_additional']) |
|
| 2666 | 2772 | echo ' |
| 2667 | 2773 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
| 2774 | + } |
|
| 2668 | 2775 | echo ' |
| 2669 | 2776 | </span> |
| 2670 | 2777 | <a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a> |
@@ -2724,9 +2831,10 @@ discard block |
||
| 2724 | 2831 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
| 2725 | 2832 | <br>'; |
| 2726 | 2833 | |
| 2727 | - if ($context['show_spellchecking']) |
|
| 2728 | - echo ' |
|
| 2834 | + if ($context['show_spellchecking']) { |
|
| 2835 | + echo ' |
|
| 2729 | 2836 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
| 2837 | + } |
|
| 2730 | 2838 | |
| 2731 | 2839 | echo ' |
| 2732 | 2840 | </dt> |
@@ -2734,17 +2842,20 @@ discard block |
||
| 2734 | 2842 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; max-width: 99%;">', $context['member']['signature'], '</textarea><br>'; |
| 2735 | 2843 | |
| 2736 | 2844 | // If there is a limit at all! |
| 2737 | - if (!empty($context['signature_limits']['max_length'])) |
|
| 2738 | - echo ' |
|
| 2845 | + if (!empty($context['signature_limits']['max_length'])) { |
|
| 2846 | + echo ' |
|
| 2739 | 2847 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
| 2848 | + } |
|
| 2740 | 2849 | |
| 2741 | - if (!empty($context['show_preview_button'])) |
|
| 2742 | - echo ' |
|
| 2850 | + if (!empty($context['show_preview_button'])) { |
|
| 2851 | + echo ' |
|
| 2743 | 2852 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">'; |
| 2853 | + } |
|
| 2744 | 2854 | |
| 2745 | - if ($context['signature_warning']) |
|
| 2746 | - echo ' |
|
| 2855 | + if ($context['signature_warning']) { |
|
| 2856 | + echo ' |
|
| 2747 | 2857 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
| 2858 | + } |
|
| 2748 | 2859 | |
| 2749 | 2860 | // Some javascript used to count how many characters have been used so far in the signature. |
| 2750 | 2861 | echo ' |
@@ -2788,9 +2899,10 @@ discard block |
||
| 2788 | 2899 | <div> |
| 2789 | 2900 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
| 2790 | 2901 | // This lists all the file categories. |
| 2791 | - foreach ($context['avatars'] as $avatar) |
|
| 2792 | - echo ' |
|
| 2902 | + foreach ($context['avatars'] as $avatar) { |
|
| 2903 | + echo ' |
|
| 2793 | 2904 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
| 2905 | + } |
|
| 2794 | 2906 | echo ' |
| 2795 | 2907 | </select> |
| 2796 | 2908 | </div> |
@@ -2845,16 +2957,17 @@ discard block |
||
| 2845 | 2957 | <div id="avatar_gravatar"> |
| 2846 | 2958 | <img src="' . $context['member']['avatar']['href'] . '" alt="" />'; |
| 2847 | 2959 | |
| 2848 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 2849 | - echo ' |
|
| 2960 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 2961 | + echo ' |
|
| 2850 | 2962 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
| 2851 | - else |
|
| 2963 | + } else |
|
| 2852 | 2964 | { |
| 2853 | 2965 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
| 2854 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
| 2855 | - $textbox_value = ''; |
|
| 2856 | - else |
|
| 2857 | - $textbox_value = $context['member']['avatar']['external']; |
|
| 2966 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
| 2967 | + $textbox_value = ''; |
|
| 2968 | + } else { |
|
| 2969 | + $textbox_value = $context['member']['avatar']['external']; |
|
| 2970 | + } |
|
| 2858 | 2971 | |
| 2859 | 2972 | echo ' |
| 2860 | 2973 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -2926,8 +3039,9 @@ discard block |
||
| 2926 | 3039 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
| 2927 | 3040 | |
| 2928 | 3041 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
| 2929 | - if (empty($suffix)) |
|
| 2930 | - return; |
|
| 3042 | + if (empty($suffix)) { |
|
| 3043 | + return; |
|
| 3044 | + } |
|
| 2931 | 3045 | |
| 2932 | 3046 | echo ' |
| 2933 | 3047 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -2949,9 +3063,10 @@ discard block |
||
| 2949 | 3063 | <dd> |
| 2950 | 3064 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">'; |
| 2951 | 3065 | // Help the user by showing a list of common time formats. |
| 2952 | - foreach ($context['easy_timeformats'] as $time_format) |
|
| 2953 | - echo ' |
|
| 3066 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
| 3067 | + echo ' |
|
| 2954 | 3068 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
| 3069 | + } |
|
| 2955 | 3070 | echo ' |
| 2956 | 3071 | </select><br> |
| 2957 | 3072 | <input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30"> |
@@ -2987,9 +3102,10 @@ discard block |
||
| 2987 | 3102 | </dt> |
| 2988 | 3103 | <dd> |
| 2989 | 3104 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
| 2990 | - foreach ($context['smiley_sets'] as $set) |
|
| 2991 | - echo ' |
|
| 3105 | + foreach ($context['smiley_sets'] as $set) { |
|
| 3106 | + echo ' |
|
| 2992 | 3107 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
| 3108 | + } |
|
| 2993 | 3109 | echo ' |
| 2994 | 3110 | </select> <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)" style="padding-left: 20px;"> |
| 2995 | 3111 | </dd>'; |
@@ -3040,10 +3156,11 @@ discard block |
||
| 3040 | 3156 | </div> |
| 3041 | 3157 | <div class="clear"></div>'; |
| 3042 | 3158 | |
| 3043 | - if (!empty($context['from_ajax'])) |
|
| 3044 | - echo ' |
|
| 3159 | + if (!empty($context['from_ajax'])) { |
|
| 3160 | + echo ' |
|
| 3045 | 3161 | <br> |
| 3046 | 3162 | <a href="javascript:self.close();"></a>'; |
| 3163 | + } |
|
| 3047 | 3164 | |
| 3048 | 3165 | echo ' |
| 3049 | 3166 | </div> |
@@ -3082,15 +3199,16 @@ discard block |
||
| 3082 | 3199 | <br><div class="smalltext">', $txt['tfa_profile_desc'], '</div> |
| 3083 | 3200 | </dt> |
| 3084 | 3201 | <dd>'; |
| 3085 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
| 3086 | - echo ' |
|
| 3202 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
| 3203 | + echo ' |
|
| 3087 | 3204 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
| 3088 | - elseif (!$context['tfa_enabled']) |
|
| 3089 | - echo ' |
|
| 3205 | + } elseif (!$context['tfa_enabled']) { |
|
| 3206 | + echo ' |
|
| 3090 | 3207 | ', $txt['tfa_profile_disabled']; |
| 3091 | - else |
|
| 3092 | - echo ' |
|
| 3208 | + } else { |
|
| 3209 | + echo ' |
|
| 3093 | 3210 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
| 3211 | + } |
|
| 3094 | 3212 | echo ' |
| 3095 | 3213 | </dd>'; |
| 3096 | 3214 | } |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | * |
| 105 | 105 | * @param string $class The fully-qualified class name. |
| 106 | 106 | */ |
| 107 | -spl_autoload_register(function ($class) use ($sourcedir) |
|
| 107 | +spl_autoload_register(function($class) use ($sourcedir) |
|
| 108 | 108 | { |
| 109 | 109 | $classMap = array( |
| 110 | 110 | 'ReCaptcha\\' => 'ReCaptcha/', |
@@ -32,16 +32,18 @@ discard block |
||
| 32 | 32 | ob_start(); |
| 33 | 33 | |
| 34 | 34 | // Do some cleaning, just in case. |
| 35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 36 | 36 | if (isset($GLOBALS[$variable])) |
| 37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 38 | +} |
|
| 38 | 39 | |
| 39 | 40 | // Load the settings... |
| 40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 41 | 42 | |
| 42 | 43 | // Make absolutely sure the cache directory is defined. |
| 43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 44 | 45 | $cachedir = $boarddir . '/cache'; |
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | // Without those we can't go anywhere |
| 47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | require_once($sourcedir . '/Load.php'); |
| 52 | 54 | |
| 53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 54 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 55 | 57 | display_maintenance_message(); |
| 58 | +} |
|
| 56 | 59 | |
| 57 | 60 | // Create a variable to store some SMF specific functions in. |
| 58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | cleanRequest(); |
| 68 | 71 | |
| 69 | 72 | // Seed the random generator. |
| 70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 71 | 74 | smf_seed_generator(); |
| 75 | +} |
|
| 72 | 76 | |
| 73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
| 88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 89 | 93 | { |
| 90 | 94 | // If zlib is being used, turn off output compression. |
| 91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 93 | - else |
|
| 95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 97 | + } else |
|
| 94 | 98 | { |
| 95 | 99 | ob_end_clean(); |
| 96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
| 182 | 186 | loadPermissions(); |
| 183 | 187 | |
| 184 | 188 | // Attachments don't require the entire theme to be loaded. |
| 185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 186 | - detectBrowser(); |
|
| 189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 190 | + detectBrowser(); |
|
| 191 | + } |
|
| 187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 188 | - else |
|
| 189 | - loadTheme(); |
|
| 193 | + else { |
|
| 194 | + loadTheme(); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | // Check if the user should be disallowed access. |
| 192 | 198 | is_not_banned(); |
| 193 | 199 | |
| 194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 196 | - fatal_lang_error('not_a_topic', false); |
|
| 201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 202 | + fatal_lang_error('not_a_topic', false); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | writeLog(); |
| 205 | 212 | |
| 206 | 213 | // Track forum statistics and hits...? |
| 207 | - if (!empty($modSettings['hitStats'])) |
|
| 208 | - trackStats(array('hits' => '+')); |
|
| 214 | + if (!empty($modSettings['hitStats'])) { |
|
| 215 | + trackStats(array('hits' => '+')); |
|
| 216 | + } |
|
| 209 | 217 | } |
| 210 | 218 | unset($no_stat_actions); |
| 211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
| 219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 220 | 228 | } |
| 221 | 229 | // Don't even try it, sonny. |
| 222 | - else |
|
| 223 | - return 'InMaintenance'; |
|
| 230 | + else { |
|
| 231 | + return 'InMaintenance'; |
|
| 232 | + } |
|
| 224 | 233 | } |
| 225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
| 226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 227 | - return 'KickGuest'; |
|
| 228 | - elseif (empty($_REQUEST['action'])) |
|
| 235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 236 | + return 'KickGuest'; |
|
| 237 | + } elseif (empty($_REQUEST['action'])) |
|
| 229 | 238 | { |
| 230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
| 239 | 248 | |
| 240 | 249 | $call = call_helper($defaultAction, true); |
| 241 | 250 | |
| 242 | - if (!empty($call)) |
|
| 243 | - return $call; |
|
| 251 | + if (!empty($call)) { |
|
| 252 | + return $call; |
|
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | |
| 371 | 381 | $call = call_helper($fallbackAction, true); |
| 372 | 382 | |
| 373 | - if (!empty($call)) |
|
| 374 | - return $call; |
|
| 383 | + if (!empty($call)) { |
|
| 384 | + return $call; |
|
| 385 | + } |
|
| 375 | 386 | } |
| 376 | 387 | |
| 377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // Otherwise, it was set - so let's go to that action. |
| 385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
| 386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
| 397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 398 | + } |
|
| 387 | 399 | |
| 388 | 400 | // Do the right thing. |
| 389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |
@@ -1542,7 +1542,7 @@ discard block |
||
| 1542 | 1542 | 'no_msg' => 0, |
| 1543 | 1543 | 'substep' => $_GET['substep'], |
| 1544 | 1544 | 'ignore_ids' => $ignore_ids, |
| 1545 | - 'attach_thumb' => array(0,3), |
|
| 1545 | + 'attach_thumb' => array(0, 3), |
|
| 1546 | 1546 | ) |
| 1547 | 1547 | ); |
| 1548 | 1548 | |
@@ -1572,7 +1572,7 @@ discard block |
||
| 1572 | 1572 | array( |
| 1573 | 1573 | 'to_remove' => $to_remove, |
| 1574 | 1574 | 'no_member' => 0, |
| 1575 | - 'attach_thumb' => array(0,3), |
|
| 1575 | + 'attach_thumb' => array(0, 3), |
|
| 1576 | 1576 | ) |
| 1577 | 1577 | ); |
| 1578 | 1578 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * The main 'Attachments and Avatars' management function. |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | call_integration_hook('integrate_manage_attachments', array(&$subActions)); |
| 64 | 65 | |
| 65 | 66 | // Pick the correct sub-action. |
| 66 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 67 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 68 | - else |
|
| 69 | - $context['sub_action'] = 'browse'; |
|
| 67 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 68 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 69 | + } else { |
|
| 70 | + $context['sub_action'] = 'browse'; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | // Default page title is good. |
| 72 | 74 | $context['page_title'] = $txt['attachments_avatars']; |
@@ -94,20 +96,20 @@ discard block |
||
| 94 | 96 | $context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
| 95 | 97 | |
| 96 | 98 | // If not set, show a default path for the base directory |
| 97 | - if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) |
|
| 98 | - if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
| 99 | + if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) { |
|
| 100 | + if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
| 99 | 101 | $modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1]; |
| 100 | - |
|
| 101 | - else |
|
| 102 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
| 102 | + } else { |
|
| 103 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
| 105 | 107 | |
| 106 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - $context['valid_basedirectory'] = true; |
|
| 108 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 109 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 110 | + } else { |
|
| 111 | + $context['valid_basedirectory'] = true; |
|
| 112 | + } |
|
| 111 | 113 | |
| 112 | 114 | // A bit of razzle dazzle with the $txt strings. :) |
| 113 | 115 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
@@ -185,8 +187,9 @@ discard block |
||
| 185 | 187 | |
| 186 | 188 | call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); |
| 187 | 189 | |
| 188 | - if ($return_config) |
|
| 189 | - return $config_vars; |
|
| 190 | + if ($return_config) { |
|
| 191 | + return $config_vars; |
|
| 192 | + } |
|
| 190 | 193 | |
| 191 | 194 | // These are very likely to come in handy! (i.e. without them we're doomed!) |
| 192 | 195 | require_once($sourcedir . '/ManagePermissions.php'); |
@@ -197,21 +200,24 @@ discard block |
||
| 197 | 200 | { |
| 198 | 201 | checkSession(); |
| 199 | 202 | |
| 200 | - if (isset($_POST['attachmentUploadDir'])) |
|
| 201 | - unset($_POST['attachmentUploadDir']); |
|
| 203 | + if (isset($_POST['attachmentUploadDir'])) { |
|
| 204 | + unset($_POST['attachmentUploadDir']); |
|
| 205 | + } |
|
| 202 | 206 | |
| 203 | 207 | if (!empty($_POST['use_subdirectories_for_attachments'])) |
| 204 | 208 | { |
| 205 | - if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) |
|
| 206 | - $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
| 209 | + if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) { |
|
| 210 | + $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
| 211 | + } |
|
| 207 | 212 | |
| 208 | 213 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) |
| 209 | 214 | { |
| 210 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
| 211 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 216 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 217 | + } |
|
| 218 | + } else { |
|
| 219 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 212 | 220 | } |
| 213 | - else |
|
| 214 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 215 | 221 | |
| 216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
| 217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
| 219 | 225 | |
| 220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
| 221 | 227 | { |
| 222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
| 223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
| 229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 230 | + } |
|
| 224 | 231 | } |
| 225 | 232 | |
| 226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
| 336 | 343 | |
| 337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
| 338 | 345 | |
| 339 | - if ($return_config) |
|
| 340 | - return $config_vars; |
|
| 346 | + if ($return_config) { |
|
| 347 | + return $config_vars; |
|
| 348 | + } |
|
| 341 | 349 | |
| 342 | 350 | // We need this file for the settings template. |
| 343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
| 348 | 356 | checkSession(); |
| 349 | 357 | |
| 350 | 358 | // These settings cannot be left empty! |
| 351 | - if (empty($_POST['custom_avatar_dir'])) |
|
| 352 | - $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
| 359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
| 360 | + $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
| 361 | + } |
|
| 353 | 362 | |
| 354 | - if (empty($_POST['custom_avatar_url'])) |
|
| 355 | - $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
| 363 | + if (empty($_POST['custom_avatar_url'])) { |
|
| 364 | + $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
| 365 | + } |
|
| 356 | 366 | |
| 357 | - if (empty($_POST['avatar_directory'])) |
|
| 358 | - $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
| 367 | + if (empty($_POST['avatar_directory'])) { |
|
| 368 | + $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
| 369 | + } |
|
| 359 | 370 | |
| 360 | - if (empty($_POST['avatar_url'])) |
|
| 361 | - $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
| 371 | + if (empty($_POST['avatar_url'])) { |
|
| 372 | + $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
| 373 | + } |
|
| 362 | 374 | |
| 363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
| 364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
| 406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
| 407 | 419 | foreach ($titles as $browse_type => $details) |
| 408 | 420 | { |
| 409 | - if ($browse_type != 'attachments') |
|
| 410 | - $list_title .= ' | '; |
|
| 421 | + if ($browse_type != 'attachments') { |
|
| 422 | + $list_title .= ' | '; |
|
| 423 | + } |
|
| 411 | 424 | |
| 412 | - if ($context['browse_type'] == $browse_type) |
|
| 413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 425 | + if ($context['browse_type'] == $browse_type) { |
|
| 426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 427 | + } |
|
| 414 | 428 | |
| 415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
| 416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
| 446 | 460 | $link = '<a href="'; |
| 447 | 461 | |
| 448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
| 449 | - if ($rowData['attachment_type'] == 1) |
|
| 450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 463 | + if ($rowData['attachment_type'] == 1) { |
|
| 464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 465 | + } |
|
| 451 | 466 | |
| 452 | 467 | // By default avatars are downloaded almost as attachments. |
| 453 | - elseif ($context['browse_type'] == 'avatars') |
|
| 454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 468 | + elseif ($context['browse_type'] == 'avatars') { |
|
| 469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 470 | + } |
|
| 455 | 471 | |
| 456 | 472 | // Normal attachments are always linked to a topic ID. |
| 457 | - else |
|
| 458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 473 | + else { |
|
| 474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 475 | + } |
|
| 459 | 476 | |
| 460 | 477 | $link .= '"'; |
| 461 | 478 | |
| 462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
| 463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 482 | + } |
|
| 465 | 483 | |
| 466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
| 467 | 485 | |
| 468 | 486 | // Show the dimensions. |
| 469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 489 | + } |
|
| 471 | 490 | |
| 472 | 491 | return $link; |
| 473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
| 500 | 519 | 'function' => function($rowData) use ($scripturl, $smcFunc) |
| 501 | 520 | { |
| 502 | 521 | // In case of an attachment, return the poster of the attachment. |
| 503 | - if (empty($rowData['id_member'])) |
|
| 504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 522 | + if (empty($rowData['id_member'])) { |
|
| 523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 524 | + } |
|
| 505 | 525 | |
| 506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
| 507 | - else |
|
| 508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 527 | + else { |
|
| 528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 529 | + } |
|
| 509 | 530 | }, |
| 510 | 531 | ), |
| 511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
| 524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
| 525 | 546 | |
| 526 | 547 | // Add a link to the topic in case of an attachment. |
| 527 | - if ($context['browse_type'] !== 'avatars') |
|
| 528 | - $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 548 | + if ($context['browse_type'] !== 'avatars') { |
|
| 549 | + $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 550 | + } |
|
| 529 | 551 | |
| 530 | 552 | return $date; |
| 531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
| 610 | 632 | global $smcFunc, $txt; |
| 611 | 633 | |
| 612 | 634 | // Choose a query depending on what we are viewing. |
| 613 | - if ($browse_type === 'avatars') |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 635 | + if ($browse_type === 'avatars') { |
|
| 636 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 637 | SELECT |
| 616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
| 617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
| 630 | 652 | 'per_page' => $items_per_page, |
| 631 | 653 | ) |
| 632 | 654 | ); |
| 633 | - else |
|
| 634 | - $request = $smcFunc['db_query']('', ' |
|
| 655 | + } else { |
|
| 656 | + $request = $smcFunc['db_query']('', ' |
|
| 635 | 657 | SELECT |
| 636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
| 637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
| 650 | 672 | 'per_page' => $items_per_page, |
| 651 | 673 | ) |
| 652 | 674 | ); |
| 675 | + } |
|
| 653 | 676 | $files = array(); |
| 654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 655 | - $files[] = $row; |
|
| 677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 678 | + $files[] = $row; |
|
| 679 | + } |
|
| 656 | 680 | $smcFunc['db_free_result']($request); |
| 657 | 681 | |
| 658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
| 670 | 694 | global $smcFunc; |
| 671 | 695 | |
| 672 | 696 | // Depending on the type of file, different queries are used. |
| 673 | - if ($browse_type === 'avatars') |
|
| 674 | - $request = $smcFunc['db_query']('', ' |
|
| 697 | + if ($browse_type === 'avatars') { |
|
| 698 | + $request = $smcFunc['db_query']('', ' |
|
| 675 | 699 | SELECT COUNT(*) |
| 676 | 700 | FROM {db_prefix}attachments |
| 677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
| 679 | 703 | 'guest_id_member' => 0, |
| 680 | 704 | ) |
| 681 | 705 | ); |
| 682 | - else |
|
| 683 | - $request = $smcFunc['db_query']('', ' |
|
| 706 | + } else { |
|
| 707 | + $request = $smcFunc['db_query']('', ' |
|
| 684 | 708 | SELECT COUNT(*) AS num_attach |
| 685 | 709 | FROM {db_prefix}attachments AS a |
| 686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
| 693 | 717 | 'guest_id_member' => 0, |
| 694 | 718 | ) |
| 695 | 719 | ); |
| 720 | + } |
|
| 696 | 721 | |
| 697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
| 698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
| 775 | 800 | $current_dir_size /= 1024; |
| 776 | 801 | |
| 777 | 802 | // If they specified a limit only.... |
| 778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
| 779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
| 804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 805 | + } |
|
| 780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
| 781 | 807 | |
| 782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
| 783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
| 809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 810 | + } |
|
| 784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
| 785 | 812 | |
| 786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
| 817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
| 818 | 845 | |
| 819 | 846 | // Update the messages to reflect the change. |
| 820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 821 | - $smcFunc['db_query']('', ' |
|
| 847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 848 | + $smcFunc['db_query']('', ' |
|
| 822 | 849 | UPDATE {db_prefix}messages |
| 823 | 850 | SET body = CONCAT(body, {string:notice}) |
| 824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
| 827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
| 828 | 855 | ) |
| 829 | 856 | ); |
| 830 | - } |
|
| 831 | - else |
|
| 857 | + } |
|
| 858 | + } else |
|
| 832 | 859 | { |
| 833 | 860 | // Remove all the old avatars. |
| 834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
| 853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
| 854 | 881 | |
| 855 | 882 | // And make a note on the post. |
| 856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 857 | - $smcFunc['db_query']('', ' |
|
| 883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 884 | + $smcFunc['db_query']('', ' |
|
| 858 | 885 | UPDATE {db_prefix}messages |
| 859 | 886 | SET body = CONCAT(body, {string:notice}) |
| 860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
| 863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
| 864 | 891 | ) |
| 865 | 892 | ); |
| 893 | + } |
|
| 866 | 894 | |
| 867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
| 882 | 910 | { |
| 883 | 911 | $attachments = array(); |
| 884 | 912 | // There must be a quicker way to pass this safety test?? |
| 885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
| 886 | - $attachments[] = (int) $removeID; |
|
| 913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
| 914 | + $attachments[] = (int) $removeID; |
|
| 915 | + } |
|
| 887 | 916 | |
| 888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
| 889 | 918 | $filesRemoved = false; |
| 890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
| 891 | 920 | |
| 892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
| 893 | - removeAttachments(array('id_attach' => $attachments)); |
|
| 894 | - else if (!empty($attachments)) |
|
| 921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
| 922 | + removeAttachments(array('id_attach' => $attachments)); |
|
| 923 | + } else if (!empty($attachments)) |
|
| 895 | 924 | { |
| 896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
| 897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
| 930 | 959 | |
| 931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
| 932 | 961 | |
| 933 | - if (!isset($_POST['notice'])) |
|
| 934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 962 | + if (!isset($_POST['notice'])) { |
|
| 963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 964 | + } |
|
| 935 | 965 | |
| 936 | 966 | // Add the notice on the end of the changed messages. |
| 937 | - if (!empty($messages)) |
|
| 938 | - $smcFunc['db_query']('', ' |
|
| 967 | + if (!empty($messages)) { |
|
| 968 | + $smcFunc['db_query']('', ' |
|
| 939 | 969 | UPDATE {db_prefix}messages |
| 940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
| 941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
| 944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
| 945 | 975 | ) |
| 946 | 976 | ); |
| 977 | + } |
|
| 947 | 978 | |
| 948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
| 982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
| 983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
| 984 | 1015 | |
| 985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
| 986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 987 | - elseif ($type == 'attachment_type') |
|
| 988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 989 | - elseif ($type == 'poster_time') |
|
| 990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 991 | - elseif ($type == 'last_login') |
|
| 992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 993 | - elseif ($type == 'size') |
|
| 994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 995 | - elseif ($type == 'id_topic') |
|
| 996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
| 1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1018 | + } elseif ($type == 'attachment_type') { |
|
| 1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 1020 | + } elseif ($type == 'poster_time') { |
|
| 1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 1022 | + } elseif ($type == 'last_login') { |
|
| 1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 1024 | + } elseif ($type == 'size') { |
|
| 1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 1026 | + } elseif ($type == 'id_topic') { |
|
| 1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1028 | + } |
|
| 997 | 1029 | |
| 998 | 1030 | // Add the parameter! |
| 999 | 1031 | $query_parameter[$real_type] = $restriction; |
| 1000 | 1032 | |
| 1001 | - if ($type == 'do_logging') |
|
| 1002 | - $do_logging = $condition['id_attach']; |
|
| 1033 | + if ($type == 'do_logging') { |
|
| 1034 | + $do_logging = $condition['id_attach']; |
|
| 1035 | + } |
|
| 1003 | 1036 | } |
| 1004 | 1037 | $condition = implode(' AND ', $new_condition); |
| 1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
| 1031 | 1064 | // wasn't it obvious? :P |
| 1032 | 1065 | // @todo look again at this. |
| 1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1067 | + } else |
|
| 1036 | 1068 | { |
| 1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
| 1038 | 1070 | @unlink($filename); |
| 1039 | 1071 | |
| 1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
| 1041 | - if (!empty($row['id_parent'])) |
|
| 1042 | - $parents[] = $row['id_parent']; |
|
| 1073 | + if (!empty($row['id_parent'])) { |
|
| 1074 | + $parents[] = $row['id_parent']; |
|
| 1075 | + } |
|
| 1043 | 1076 | |
| 1044 | 1077 | // If this attachments has a thumb, remove it as well. |
| 1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
| 1051 | 1084 | } |
| 1052 | 1085 | |
| 1053 | 1086 | // Make a list. |
| 1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
| 1055 | - $msgs[] = $row['id_msg']; |
|
| 1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
| 1088 | + $msgs[] = $row['id_msg']; |
|
| 1089 | + } |
|
| 1056 | 1090 | |
| 1057 | 1091 | $attach[] = $row['id_attach']; |
| 1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
| 1060 | 1094 | |
| 1061 | 1095 | // Removed attachments don't have to be updated anymore. |
| 1062 | 1096 | $parents = array_diff($parents, $attach); |
| 1063 | - if (!empty($parents)) |
|
| 1064 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if (!empty($parents)) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1065 | 1099 | UPDATE {db_prefix}attachments |
| 1066 | 1100 | SET id_thumb = {int:no_thumb} |
| 1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
| 1070 | 1104 | 'no_thumb' => 0, |
| 1071 | 1105 | ) |
| 1072 | 1106 | ); |
| 1107 | + } |
|
| 1073 | 1108 | |
| 1074 | 1109 | if (!empty($do_logging)) |
| 1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
| 1086 | 1121 | ) |
| 1087 | 1122 | ); |
| 1088 | 1123 | |
| 1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1090 | - logAction( |
|
| 1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1125 | + logAction( |
|
| 1091 | 1126 | 'remove_attach', |
| 1092 | 1127 | array( |
| 1093 | 1128 | 'message' => $row['id_msg'], |
| 1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1095 | 1130 | ) |
| 1096 | 1131 | ); |
| 1132 | + } |
|
| 1097 | 1133 | $smcFunc['db_free_result']($request); |
| 1098 | 1134 | } |
| 1099 | 1135 | |
| 1100 | - if (!empty($attach)) |
|
| 1101 | - $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($attach)) { |
|
| 1137 | + $smcFunc['db_query']('', ' |
|
| 1102 | 1138 | DELETE FROM {db_prefix}attachments |
| 1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
| 1104 | 1140 | array( |
| 1105 | 1141 | 'attachment_list' => $attach, |
| 1106 | 1142 | ) |
| 1107 | 1143 | ); |
| 1144 | + } |
|
| 1108 | 1145 | |
| 1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
| 1110 | 1147 | |
| 1111 | - if ($return_affected_messages) |
|
| 1112 | - return array_unique($msgs); |
|
| 1113 | -} |
|
| 1148 | + if ($return_affected_messages) { |
|
| 1149 | + return array_unique($msgs); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1114 | 1152 | |
| 1115 | 1153 | /** |
| 1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
| 1122 | 1160 | checkSession('get'); |
| 1123 | 1161 | |
| 1124 | 1162 | // If we choose cancel, redirect right back. |
| 1125 | - if (isset($_POST['cancel'])) |
|
| 1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1163 | + if (isset($_POST['cancel'])) { |
|
| 1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1165 | + } |
|
| 1127 | 1166 | |
| 1128 | 1167 | // Try give us a while to sort this out... |
| 1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
| 1140 | 1179 | if (isset($_GET['fixErrors'])) |
| 1141 | 1180 | { |
| 1142 | 1181 | // Nothing? |
| 1143 | - if (empty($_POST['to_fix'])) |
|
| 1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1182 | + if (empty($_POST['to_fix'])) { |
|
| 1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1184 | + } |
|
| 1145 | 1185 | |
| 1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
| 1147 | 1187 | // @todo No need to do this I think. |
| 1148 | - foreach ($_POST['to_fix'] as $value) |
|
| 1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
| 1188 | + foreach ($_POST['to_fix'] as $value) { |
|
| 1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
| 1190 | + } |
|
| 1150 | 1191 | } |
| 1151 | 1192 | } |
| 1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
| 1213 | 1254 | } |
| 1214 | 1255 | } |
| 1215 | 1256 | } |
| 1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1259 | + } |
|
| 1218 | 1260 | $smcFunc['db_free_result']($result); |
| 1219 | 1261 | |
| 1220 | 1262 | // Do we need to delete what we have? |
| 1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
| 1222 | - $smcFunc['db_query']('', ' |
|
| 1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
| 1264 | + $smcFunc['db_query']('', ' |
|
| 1223 | 1265 | DELETE FROM {db_prefix}attachments |
| 1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
| 1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
| 1228 | 1270 | 'attachment_type' => 3, |
| 1229 | 1271 | ) |
| 1230 | 1272 | ); |
| 1273 | + } |
|
| 1231 | 1274 | |
| 1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
| 1272 | 1315 | $to_update[] = $row['id_attach']; |
| 1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
| 1274 | 1317 | } |
| 1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1320 | + } |
|
| 1277 | 1321 | $smcFunc['db_free_result']($result); |
| 1278 | 1322 | |
| 1279 | 1323 | // Do we need to delete what we have? |
| 1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
| 1281 | - $smcFunc['db_query']('', ' |
|
| 1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
| 1325 | + $smcFunc['db_query']('', ' |
|
| 1282 | 1326 | UPDATE {db_prefix}attachments |
| 1283 | 1327 | SET id_thumb = {int:no_thumb} |
| 1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
| 1287 | 1331 | 'no_thumb' => 0, |
| 1288 | 1332 | ) |
| 1289 | 1333 | ); |
| 1334 | + } |
|
| 1290 | 1335 | |
| 1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
| 1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1325 | 1370 | { |
| 1326 | 1371 | // Get the filename. |
| 1327 | - if ($row['attachment_type'] == 1) |
|
| 1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1329 | - else |
|
| 1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1372 | + if ($row['attachment_type'] == 1) { |
|
| 1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1374 | + } else { |
|
| 1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1376 | + } |
|
| 1331 | 1377 | |
| 1332 | 1378 | // File doesn't exist? |
| 1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
| 1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat'; |
| 1340 | 1386 | |
| 1341 | 1387 | // Loop through the other folders. |
| 1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
| 1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
| 1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
| 1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
| 1344 | 1390 | { |
| 1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
| 1392 | + } |
|
| 1346 | 1393 | $errors_found[] = 'wrong_folder'; |
| 1347 | 1394 | |
| 1348 | 1395 | // Are we going to fix this now? |
| 1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
| 1350 | - $smcFunc['db_query']('', ' |
|
| 1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
| 1397 | + $smcFunc['db_query']('', ' |
|
| 1351 | 1398 | UPDATE {db_prefix}attachments |
| 1352 | 1399 | SET id_folder = {int:new_folder} |
| 1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
| 1356 | 1403 | 'id_attach' => $row['id_attach'], |
| 1357 | 1404 | ) |
| 1358 | 1405 | ); |
| 1406 | + } |
|
| 1359 | 1407 | |
| 1360 | 1408 | continue 2; |
| 1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
| 1364 | 1412 | $to_remove[] = $row['id_attach']; |
| 1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
| 1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
| 1367 | - } |
|
| 1368 | - elseif (filesize($filename) == 0) |
|
| 1415 | + } elseif (filesize($filename) == 0) |
|
| 1369 | 1416 | { |
| 1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
| 1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
| 1376 | 1423 | $to_remove[] = $row['id_attach']; |
| 1377 | 1424 | @unlink($filename); |
| 1378 | 1425 | } |
| 1379 | - } |
|
| 1380 | - elseif (filesize($filename) != $row['size']) |
|
| 1426 | + } elseif (filesize($filename) != $row['size']) |
|
| 1381 | 1427 | { |
| 1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
| 1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
| 1398 | 1444 | } |
| 1399 | 1445 | } |
| 1400 | 1446 | |
| 1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
| 1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
| 1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
| 1404 | - $to_fix[] = 'file_size_of_zero'; |
|
| 1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
| 1406 | - $to_fix[] = 'file_wrong_size'; |
|
| 1407 | - if (in_array('wrong_folder', $errors_found)) |
|
| 1408 | - $to_fix[] = 'wrong_folder'; |
|
| 1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
| 1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
| 1449 | + } |
|
| 1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
| 1451 | + $to_fix[] = 'file_size_of_zero'; |
|
| 1452 | + } |
|
| 1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
| 1454 | + $to_fix[] = 'file_wrong_size'; |
|
| 1455 | + } |
|
| 1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
| 1457 | + $to_fix[] = 'wrong_folder'; |
|
| 1458 | + } |
|
| 1409 | 1459 | $smcFunc['db_free_result']($result); |
| 1410 | 1460 | |
| 1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
| 1475 | 1525 | // If we are repairing remove the file from disk now. |
| 1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
| 1477 | 1527 | { |
| 1478 | - if ($row['attachment_type'] == 1) |
|
| 1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1480 | - else |
|
| 1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1528 | + if ($row['attachment_type'] == 1) { |
|
| 1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1530 | + } else { |
|
| 1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1532 | + } |
|
| 1482 | 1533 | @unlink($filename); |
| 1483 | 1534 | } |
| 1484 | 1535 | } |
| 1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1486 | - $to_fix[] = 'avatar_no_member'; |
|
| 1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1537 | + $to_fix[] = 'avatar_no_member'; |
|
| 1538 | + } |
|
| 1487 | 1539 | $smcFunc['db_free_result']($result); |
| 1488 | 1540 | |
| 1489 | 1541 | // Do we need to delete what we have? |
| 1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
| 1491 | - $smcFunc['db_query']('', ' |
|
| 1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
| 1543 | + $smcFunc['db_query']('', ' |
|
| 1492 | 1544 | DELETE FROM {db_prefix}attachments |
| 1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
| 1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
| 1499 | 1551 | 'no_msg' => 0, |
| 1500 | 1552 | ) |
| 1501 | 1553 | ); |
| 1554 | + } |
|
| 1502 | 1555 | |
| 1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1504 | 1557 | } |
@@ -1558,13 +1611,14 @@ discard block |
||
| 1558 | 1611 | @unlink($filename); |
| 1559 | 1612 | } |
| 1560 | 1613 | } |
| 1561 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1562 | - $to_fix[] = 'attachment_no_msg'; |
|
| 1614 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1615 | + $to_fix[] = 'attachment_no_msg'; |
|
| 1616 | + } |
|
| 1563 | 1617 | $smcFunc['db_free_result']($result); |
| 1564 | 1618 | |
| 1565 | 1619 | // Do we need to delete what we have? |
| 1566 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
| 1567 | - $smcFunc['db_query']('', ' |
|
| 1620 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
| 1621 | + $smcFunc['db_query']('', ' |
|
| 1568 | 1622 | DELETE FROM {db_prefix}attachments |
| 1569 | 1623 | WHERE id_attach IN ({array_int:to_remove}) |
| 1570 | 1624 | AND id_member = {int:no_member} |
@@ -1575,6 +1629,7 @@ discard block |
||
| 1575 | 1629 | 'attach_thumb' => array(0,3), |
| 1576 | 1630 | ) |
| 1577 | 1631 | ); |
| 1632 | + } |
|
| 1578 | 1633 | |
| 1579 | 1634 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1580 | 1635 | } |
@@ -1598,8 +1653,9 @@ discard block |
||
| 1598 | 1653 | { |
| 1599 | 1654 | while ($file = readdir($dir)) |
| 1600 | 1655 | { |
| 1601 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 1602 | - continue; |
|
| 1656 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 1657 | + continue; |
|
| 1658 | + } |
|
| 1603 | 1659 | |
| 1604 | 1660 | if ($files_checked <= $current_check) |
| 1605 | 1661 | { |
@@ -1607,8 +1663,9 @@ discard block |
||
| 1607 | 1663 | if (strpos($file, 'post_tmp_') !== false) |
| 1608 | 1664 | { |
| 1609 | 1665 | // Temp file is more than 5 hours old! |
| 1610 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1611 | - @unlink($attach_dir . '/' . $file); |
|
| 1666 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1667 | + @unlink($attach_dir . '/' . $file); |
|
| 1668 | + } |
|
| 1612 | 1669 | } |
| 1613 | 1670 | // That should be an attachment, let's check if we have it in the database |
| 1614 | 1671 | elseif (strpos($file, '_') !== false) |
@@ -1630,8 +1687,7 @@ discard block |
||
| 1630 | 1687 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1631 | 1688 | { |
| 1632 | 1689 | @unlink($attach_dir . '/' . $file); |
| 1633 | - } |
|
| 1634 | - else |
|
| 1690 | + } else |
|
| 1635 | 1691 | { |
| 1636 | 1692 | $context['repair_errors']['files_without_attachment']++; |
| 1637 | 1693 | $to_fix[] = 'files_without_attachment'; |
@@ -1639,14 +1695,12 @@ discard block |
||
| 1639 | 1695 | } |
| 1640 | 1696 | $smcFunc['db_free_result']($request); |
| 1641 | 1697 | } |
| 1642 | - } |
|
| 1643 | - else |
|
| 1698 | + } else |
|
| 1644 | 1699 | { |
| 1645 | 1700 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1646 | 1701 | { |
| 1647 | 1702 | @unlink($attach_dir . '/' . $file); |
| 1648 | - } |
|
| 1649 | - else |
|
| 1703 | + } else |
|
| 1650 | 1704 | { |
| 1651 | 1705 | $context['repair_errors']['files_without_attachment']++; |
| 1652 | 1706 | $to_fix[] = 'files_without_attachment'; |
@@ -1655,8 +1709,9 @@ discard block |
||
| 1655 | 1709 | } |
| 1656 | 1710 | $current_check++; |
| 1657 | 1711 | $_GET['substep'] = $current_check; |
| 1658 | - if ($current_check - $files_checked >= $max_checks) |
|
| 1659 | - pauseAttachmentMaintenance($to_fix); |
|
| 1712 | + if ($current_check - $files_checked >= $max_checks) { |
|
| 1713 | + pauseAttachmentMaintenance($to_fix); |
|
| 1714 | + } |
|
| 1660 | 1715 | } |
| 1661 | 1716 | closedir($dir); |
| 1662 | 1717 | } |
@@ -1692,12 +1747,14 @@ discard block |
||
| 1692 | 1747 | |
| 1693 | 1748 | // Try get more time... |
| 1694 | 1749 | @set_time_limit(600); |
| 1695 | - if (function_exists('apache_reset_timeout')) |
|
| 1696 | - @apache_reset_timeout(); |
|
| 1750 | + if (function_exists('apache_reset_timeout')) { |
|
| 1751 | + @apache_reset_timeout(); |
|
| 1752 | + } |
|
| 1697 | 1753 | |
| 1698 | 1754 | // Have we already used our maximum time? |
| 1699 | - if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
| 1700 | - return; |
|
| 1755 | + if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
| 1756 | + return; |
|
| 1757 | + } |
|
| 1701 | 1758 | |
| 1702 | 1759 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1703 | 1760 | $context['page_title'] = $txt['not_done_title']; |
@@ -1709,10 +1766,11 @@ discard block |
||
| 1709 | 1766 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
| 1710 | 1767 | |
| 1711 | 1768 | // Change these two if more steps are added! |
| 1712 | - if (empty($max_substep)) |
|
| 1713 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1714 | - else |
|
| 1715 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1769 | + if (empty($max_substep)) { |
|
| 1770 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1771 | + } else { |
|
| 1772 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1773 | + } |
|
| 1716 | 1774 | |
| 1717 | 1775 | // Never more than 100%! |
| 1718 | 1776 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1754,15 +1812,17 @@ discard block |
||
| 1754 | 1812 | 'attachment_type' => 0, |
| 1755 | 1813 | ) |
| 1756 | 1814 | ); |
| 1757 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1758 | - $attachments[] = $row['id_attach']; |
|
| 1815 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1816 | + $attachments[] = $row['id_attach']; |
|
| 1817 | + } |
|
| 1759 | 1818 | $smcFunc['db_free_result']($request); |
| 1819 | + } elseif (!empty($_GET['aid'])) { |
|
| 1820 | + $attachments[] = (int) $_GET['aid']; |
|
| 1760 | 1821 | } |
| 1761 | - elseif (!empty($_GET['aid'])) |
|
| 1762 | - $attachments[] = (int) $_GET['aid']; |
|
| 1763 | 1822 | |
| 1764 | - if (empty($attachments)) |
|
| 1765 | - fatal_lang_error('no_access', false); |
|
| 1823 | + if (empty($attachments)) { |
|
| 1824 | + fatal_lang_error('no_access', false); |
|
| 1825 | + } |
|
| 1766 | 1826 | |
| 1767 | 1827 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
| 1768 | 1828 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1795,17 +1855,18 @@ discard block |
||
| 1795 | 1855 | } |
| 1796 | 1856 | $smcFunc['db_free_result']($request); |
| 1797 | 1857 | |
| 1798 | - if (empty($attachments)) |
|
| 1799 | - fatal_lang_error('no_access', false); |
|
| 1858 | + if (empty($attachments)) { |
|
| 1859 | + fatal_lang_error('no_access', false); |
|
| 1860 | + } |
|
| 1800 | 1861 | |
| 1801 | 1862 | // Finally, we are there. Follow through! |
| 1802 | 1863 | if ($is_approve) |
| 1803 | 1864 | { |
| 1804 | 1865 | // Checked and deemed worthy. |
| 1805 | 1866 | ApproveAttachments($attachments); |
| 1867 | + } else { |
|
| 1868 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1806 | 1869 | } |
| 1807 | - else |
|
| 1808 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1809 | 1870 | |
| 1810 | 1871 | // Return to the topic.... |
| 1811 | 1872 | redirectexit($redirect); |
@@ -1821,8 +1882,9 @@ discard block |
||
| 1821 | 1882 | { |
| 1822 | 1883 | global $smcFunc; |
| 1823 | 1884 | |
| 1824 | - if (empty($attachments)) |
|
| 1825 | - return 0; |
|
| 1885 | + if (empty($attachments)) { |
|
| 1886 | + return 0; |
|
| 1887 | + } |
|
| 1826 | 1888 | |
| 1827 | 1889 | // For safety, check for thumbnails... |
| 1828 | 1890 | $request = $smcFunc['db_query']('', ' |
@@ -1841,15 +1903,17 @@ discard block |
||
| 1841 | 1903 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1842 | 1904 | { |
| 1843 | 1905 | // Update the thumbnail too... |
| 1844 | - if (!empty($row['id_thumb'])) |
|
| 1845 | - $attachments[] = $row['id_thumb']; |
|
| 1906 | + if (!empty($row['id_thumb'])) { |
|
| 1907 | + $attachments[] = $row['id_thumb']; |
|
| 1908 | + } |
|
| 1846 | 1909 | |
| 1847 | 1910 | $attachments[] = $row['id_attach']; |
| 1848 | 1911 | } |
| 1849 | 1912 | $smcFunc['db_free_result']($request); |
| 1850 | 1913 | |
| 1851 | - if (empty($attachments)) |
|
| 1852 | - return 0; |
|
| 1914 | + if (empty($attachments)) { |
|
| 1915 | + return 0; |
|
| 1916 | + } |
|
| 1853 | 1917 | |
| 1854 | 1918 | // Approving an attachment is not hard - it's easy. |
| 1855 | 1919 | $smcFunc['db_query']('', ' |
@@ -1875,14 +1939,15 @@ discard block |
||
| 1875 | 1939 | ) |
| 1876 | 1940 | ); |
| 1877 | 1941 | |
| 1878 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1879 | - logAction( |
|
| 1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1943 | + logAction( |
|
| 1880 | 1944 | 'approve_attach', |
| 1881 | 1945 | array( |
| 1882 | 1946 | 'message' => $row['id_msg'], |
| 1883 | 1947 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1884 | 1948 | ) |
| 1885 | 1949 | ); |
| 1950 | + } |
|
| 1886 | 1951 | $smcFunc['db_free_result']($request); |
| 1887 | 1952 | |
| 1888 | 1953 | // Remove from the approval queue. |
@@ -1905,11 +1970,11 @@ discard block |
||
| 1905 | 1970 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
| 1906 | 1971 | |
| 1907 | 1972 | // Since this needs to be done eventually. |
| 1908 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
| 1909 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 1910 | - |
|
| 1911 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
| 1912 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 1973 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
| 1974 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 1975 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 1976 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 1977 | + } |
|
| 1913 | 1978 | |
| 1914 | 1979 | $errors = array(); |
| 1915 | 1980 | |
@@ -1924,8 +1989,9 @@ discard block |
||
| 1924 | 1989 | { |
| 1925 | 1990 | $error = ''; |
| 1926 | 1991 | $id = (int) $id; |
| 1927 | - if ($id < 1) |
|
| 1928 | - continue; |
|
| 1992 | + if ($id < 1) { |
|
| 1993 | + continue; |
|
| 1994 | + } |
|
| 1929 | 1995 | |
| 1930 | 1996 | // Sorry, these dirs are NOT valid |
| 1931 | 1997 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1944,8 +2010,7 @@ discard block |
||
| 1944 | 2010 | { |
| 1945 | 2011 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
| 1946 | 2012 | continue; |
| 1947 | - } |
|
| 1948 | - elseif (empty($path)) |
|
| 2013 | + } elseif (empty($path)) |
|
| 1949 | 2014 | { |
| 1950 | 2015 | // Ignore this and set $id to one less |
| 1951 | 2016 | continue; |
@@ -1953,10 +2018,11 @@ discard block |
||
| 1953 | 2018 | |
| 1954 | 2019 | // OK, so let's try to create it then. |
| 1955 | 2020 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1956 | - if (automanage_attachments_create_directory($path)) |
|
| 1957 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 1958 | - else |
|
| 1959 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2021 | + if (automanage_attachments_create_directory($path)) { |
|
| 2022 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2023 | + } else { |
|
| 2024 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2025 | + } |
|
| 1960 | 2026 | } |
| 1961 | 2027 | |
| 1962 | 2028 | // Changing a directory name? |
@@ -1969,8 +2035,7 @@ discard block |
||
| 1969 | 2035 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
| 1970 | 2036 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1971 | 2037 | } |
| 1972 | - } |
|
| 1973 | - else |
|
| 2038 | + } else |
|
| 1974 | 2039 | { |
| 1975 | 2040 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
| 1976 | 2041 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1995,12 +2060,13 @@ discard block |
||
| 1995 | 2060 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1996 | 2061 | |
| 1997 | 2062 | // It's not a good idea to delete the current directory. |
| 1998 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
| 1999 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2063 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
| 2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2065 | + } |
|
| 2000 | 2066 | // Or the current base directory |
| 2001 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
| 2002 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 2003 | - else |
|
| 2067 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
| 2068 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 2069 | + } else |
|
| 2004 | 2070 | { |
| 2005 | 2071 | // Let's not try to delete a path with files in it. |
| 2006 | 2072 | $request = $smcFunc['db_query']('', ' |
@@ -2019,17 +2085,18 @@ discard block |
||
| 2019 | 2085 | if (!empty($modSettings['attachment_basedirectories'])) |
| 2020 | 2086 | { |
| 2021 | 2087 | // Count any sub-folders. |
| 2022 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
| 2023 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2088 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
| 2089 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2024 | 2090 | $num_attach++; |
| 2091 | + } |
|
| 2025 | 2092 | } |
| 2026 | 2093 | |
| 2027 | 2094 | // It's safe to delete. So try to delete the folder also |
| 2028 | 2095 | if ($num_attach == 0) |
| 2029 | 2096 | { |
| 2030 | - if (is_dir($path)) |
|
| 2031 | - $doit = true; |
|
| 2032 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2097 | + if (is_dir($path)) { |
|
| 2098 | + $doit = true; |
|
| 2099 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2033 | 2100 | { |
| 2034 | 2101 | $doit = true; |
| 2035 | 2102 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2039,8 +2106,9 @@ discard block |
||
| 2039 | 2106 | { |
| 2040 | 2107 | unlink($path . '/.htaccess'); |
| 2041 | 2108 | unlink($path . '/index.php'); |
| 2042 | - if (!@rmdir($path)) |
|
| 2043 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2109 | + if (!@rmdir($path)) { |
|
| 2110 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2111 | + } |
|
| 2044 | 2112 | } |
| 2045 | 2113 | |
| 2046 | 2114 | // Remove it from the base directory list. |
@@ -2050,14 +2118,15 @@ discard block |
||
| 2050 | 2118 | updateSettings(array('attachment_basedirectories' => $smcFunc['json_encode']($modSettings['attachment_basedirectories']))); |
| 2051 | 2119 | $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
| 2052 | 2120 | } |
| 2121 | + } else { |
|
| 2122 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2053 | 2123 | } |
| 2054 | - else |
|
| 2055 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2056 | 2124 | |
| 2057 | - if (empty($error)) |
|
| 2058 | - continue; |
|
| 2059 | - else |
|
| 2060 | - $errors[] = $error; |
|
| 2125 | + if (empty($error)) { |
|
| 2126 | + continue; |
|
| 2127 | + } else { |
|
| 2128 | + $errors[] = $error; |
|
| 2129 | + } |
|
| 2061 | 2130 | } |
| 2062 | 2131 | } |
| 2063 | 2132 | |
@@ -2065,23 +2134,26 @@ discard block |
||
| 2065 | 2134 | } |
| 2066 | 2135 | |
| 2067 | 2136 | // We need to make sure the current directory is right. |
| 2068 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
| 2069 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2137 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 2138 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2139 | + } |
|
| 2070 | 2140 | |
| 2071 | 2141 | // Find the current directory if there's no value carried, |
| 2072 | 2142 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
| 2073 | 2143 | { |
| 2074 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
| 2075 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2076 | - else |
|
| 2077 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2144 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
| 2145 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2146 | + } else { |
|
| 2147 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2148 | + } |
|
| 2078 | 2149 | } |
| 2079 | 2150 | |
| 2080 | 2151 | // If the user wishes to go back, update the last_dir array |
| 2081 | 2152 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
| 2082 | 2153 | { |
| 2083 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
| 2084 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
| 2154 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
| 2155 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
| 2156 | + } |
|
| 2085 | 2157 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
| 2086 | 2158 | |
| 2087 | 2159 | if (is_numeric($num)) |
@@ -2089,16 +2161,18 @@ discard block |
||
| 2089 | 2161 | // Need to find the base folder. |
| 2090 | 2162 | $bid = -1; |
| 2091 | 2163 | $use_subdirectories_for_attachments = 0; |
| 2092 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2093 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2164 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2165 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2094 | 2166 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false) |
| 2095 | 2167 | { |
| 2096 | 2168 | $use_subdirectories_for_attachments = 1; |
| 2169 | + } |
|
| 2097 | 2170 | break; |
| 2098 | 2171 | } |
| 2099 | 2172 | |
| 2100 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
| 2101 | - $bid = 0; |
|
| 2173 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
| 2174 | + $bid = 0; |
|
| 2175 | + } |
|
| 2102 | 2176 | |
| 2103 | 2177 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
| 2104 | 2178 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2117,8 +2191,8 @@ discard block |
||
| 2117 | 2191 | // We might need to reset the paths. This loop will just loop through once. |
| 2118 | 2192 | foreach ($new_dirs as $id => $dir) |
| 2119 | 2193 | { |
| 2120 | - if ($id != 1) |
|
| 2121 | - $smcFunc['db_query']('', ' |
|
| 2194 | + if ($id != 1) { |
|
| 2195 | + $smcFunc['db_query']('', ' |
|
| 2122 | 2196 | UPDATE {db_prefix}attachments |
| 2123 | 2197 | SET id_folder = {int:default_folder} |
| 2124 | 2198 | WHERE id_folder = {int:current_folder}', |
@@ -2127,14 +2201,14 @@ discard block |
||
| 2127 | 2201 | 'current_folder' => $id, |
| 2128 | 2202 | ) |
| 2129 | 2203 | ); |
| 2204 | + } |
|
| 2130 | 2205 | |
| 2131 | 2206 | $update = array( |
| 2132 | 2207 | 'currentAttachmentUploadDir' => 1, |
| 2133 | 2208 | 'attachmentUploadDir' => $smcFunc['json_encode'](array(1 => $dir)), |
| 2134 | 2209 | ); |
| 2135 | 2210 | } |
| 2136 | - } |
|
| 2137 | - else |
|
| 2211 | + } else |
|
| 2138 | 2212 | { |
| 2139 | 2213 | // Save it to the database. |
| 2140 | 2214 | $update = array( |
@@ -2143,11 +2217,13 @@ discard block |
||
| 2143 | 2217 | ); |
| 2144 | 2218 | } |
| 2145 | 2219 | |
| 2146 | - if (!empty($update)) |
|
| 2147 | - updateSettings($update); |
|
| 2220 | + if (!empty($update)) { |
|
| 2221 | + updateSettings($update); |
|
| 2222 | + } |
|
| 2148 | 2223 | |
| 2149 | - if (!empty($errors)) |
|
| 2150 | - $_SESSION['errors']['dir'] = $errors; |
|
| 2224 | + if (!empty($errors)) { |
|
| 2225 | + $_SESSION['errors']['dir'] = $errors; |
|
| 2226 | + } |
|
| 2151 | 2227 | |
| 2152 | 2228 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2153 | 2229 | } |
@@ -2161,10 +2237,11 @@ discard block |
||
| 2161 | 2237 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
| 2162 | 2238 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
| 2163 | 2239 | { |
| 2164 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
| 2165 | - $update = (array( |
|
| 2240 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
| 2241 | + $update = (array( |
|
| 2166 | 2242 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
| 2167 | 2243 | )); |
| 2244 | + } |
|
| 2168 | 2245 | } |
| 2169 | 2246 | |
| 2170 | 2247 | if (isset($_POST['base_dir'])) |
@@ -2212,13 +2289,15 @@ discard block |
||
| 2212 | 2289 | |
| 2213 | 2290 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
| 2214 | 2291 | { |
| 2215 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
| 2216 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2292 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
| 2293 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2294 | + } |
|
| 2217 | 2295 | } |
| 2218 | 2296 | |
| 2219 | 2297 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
| 2220 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
| 2221 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2298 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
| 2299 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2300 | + } |
|
| 2222 | 2301 | ksort($modSettings['attachment_basedirectories']); |
| 2223 | 2302 | |
| 2224 | 2303 | $update = (array( |
@@ -2228,11 +2307,13 @@ discard block |
||
| 2228 | 2307 | )); |
| 2229 | 2308 | } |
| 2230 | 2309 | |
| 2231 | - if (!empty($errors)) |
|
| 2232 | - $_SESSION['errors']['base'] = $errors; |
|
| 2310 | + if (!empty($errors)) { |
|
| 2311 | + $_SESSION['errors']['base'] = $errors; |
|
| 2312 | + } |
|
| 2233 | 2313 | |
| 2234 | - if (!empty($update)) |
|
| 2235 | - updateSettings($update); |
|
| 2314 | + if (!empty($update)) { |
|
| 2315 | + updateSettings($update); |
|
| 2316 | + } |
|
| 2236 | 2317 | |
| 2237 | 2318 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2238 | 2319 | } |
@@ -2242,13 +2323,15 @@ discard block |
||
| 2242 | 2323 | if (is_array($_SESSION['errors'])) |
| 2243 | 2324 | { |
| 2244 | 2325 | $errors = array(); |
| 2245 | - if (!empty($_SESSION['errors']['dir'])) |
|
| 2246 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2326 | + if (!empty($_SESSION['errors']['dir'])) { |
|
| 2327 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2247 | 2328 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2329 | + } |
|
| 2248 | 2330 | |
| 2249 | - if (!empty($_SESSION['errors']['base'])) |
|
| 2250 | - foreach ($_SESSION['errors']['base'] as $error) |
|
| 2331 | + if (!empty($_SESSION['errors']['base'])) { |
|
| 2332 | + foreach ($_SESSION['errors']['base'] as $error) |
|
| 2251 | 2333 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2334 | + } |
|
| 2252 | 2335 | } |
| 2253 | 2336 | unset($_SESSION['errors']); |
| 2254 | 2337 | } |
@@ -2458,8 +2541,9 @@ discard block |
||
| 2458 | 2541 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
| 2459 | 2542 | { |
| 2460 | 2543 | // If there aren't any attachments in this directory this won't exist. |
| 2461 | - if (!isset($expected_files[$id])) |
|
| 2462 | - $expected_files[$id] = 0; |
|
| 2544 | + if (!isset($expected_files[$id])) { |
|
| 2545 | + $expected_files[$id] = 0; |
|
| 2546 | + } |
|
| 2463 | 2547 | |
| 2464 | 2548 | // Check if the directory is doing okay. |
| 2465 | 2549 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2472,10 +2556,11 @@ discard block |
||
| 2472 | 2556 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
| 2473 | 2557 | |
| 2474 | 2558 | // Count any sub-folders. |
| 2475 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2476 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2559 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2560 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2477 | 2561 | { |
| 2478 | 2562 | $expected_files[$id]++; |
| 2563 | + } |
|
| 2479 | 2564 | $sub_dirs++; |
| 2480 | 2565 | } |
| 2481 | 2566 | } |
@@ -2493,8 +2578,8 @@ discard block |
||
| 2493 | 2578 | } |
| 2494 | 2579 | |
| 2495 | 2580 | // Just stick a new directory on at the bottom. |
| 2496 | - if (isset($_REQUEST['new_path'])) |
|
| 2497 | - $attachdirs[] = array( |
|
| 2581 | + if (isset($_REQUEST['new_path'])) { |
|
| 2582 | + $attachdirs[] = array( |
|
| 2498 | 2583 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
| 2499 | 2584 | 'current' => false, |
| 2500 | 2585 | 'path' => '', |
@@ -2502,6 +2587,7 @@ discard block |
||
| 2502 | 2587 | 'num_files' => '', |
| 2503 | 2588 | 'status' => '', |
| 2504 | 2589 | ); |
| 2590 | + } |
|
| 2505 | 2591 | |
| 2506 | 2592 | return $attachdirs; |
| 2507 | 2593 | } |
@@ -2514,8 +2600,9 @@ discard block |
||
| 2514 | 2600 | { |
| 2515 | 2601 | global $modSettings, $txt; |
| 2516 | 2602 | |
| 2517 | - if (empty($modSettings['attachment_basedirectories'])) |
|
| 2518 | - return; |
|
| 2603 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
| 2604 | + return; |
|
| 2605 | + } |
|
| 2519 | 2606 | |
| 2520 | 2607 | $basedirs = array(); |
| 2521 | 2608 | // Get a list of the base directories. |
@@ -2523,16 +2610,18 @@ discard block |
||
| 2523 | 2610 | { |
| 2524 | 2611 | // Loop through the attach directory array to count any sub-directories |
| 2525 | 2612 | $expected_dirs = 0; |
| 2526 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2527 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2613 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2614 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2528 | 2615 | $expected_dirs++; |
| 2616 | + } |
|
| 2529 | 2617 | |
| 2530 | - if (!is_dir($dir)) |
|
| 2531 | - $status = 'does_not_exist'; |
|
| 2532 | - elseif (!is_writeable($dir)) |
|
| 2533 | - $status = 'not_writable'; |
|
| 2534 | - else |
|
| 2535 | - $status = 'ok'; |
|
| 2618 | + if (!is_dir($dir)) { |
|
| 2619 | + $status = 'does_not_exist'; |
|
| 2620 | + } elseif (!is_writeable($dir)) { |
|
| 2621 | + $status = 'not_writable'; |
|
| 2622 | + } else { |
|
| 2623 | + $status = 'ok'; |
|
| 2624 | + } |
|
| 2536 | 2625 | |
| 2537 | 2626 | $basedirs[] = array( |
| 2538 | 2627 | 'id' => $id, |
@@ -2543,14 +2632,15 @@ discard block |
||
| 2543 | 2632 | ); |
| 2544 | 2633 | } |
| 2545 | 2634 | |
| 2546 | - if (isset($_REQUEST['new_base_path'])) |
|
| 2547 | - $basedirs[] = array( |
|
| 2635 | + if (isset($_REQUEST['new_base_path'])) { |
|
| 2636 | + $basedirs[] = array( |
|
| 2548 | 2637 | 'id' => '', |
| 2549 | 2638 | 'current' => false, |
| 2550 | 2639 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
| 2551 | 2640 | 'num_dirs' => '', |
| 2552 | 2641 | 'status' => '', |
| 2553 | 2642 | ); |
| 2643 | + } |
|
| 2554 | 2644 | |
| 2555 | 2645 | return $basedirs; |
| 2556 | 2646 | } |
@@ -2566,10 +2656,11 @@ discard block |
||
| 2566 | 2656 | */ |
| 2567 | 2657 | function attachDirStatus($dir, $expected_files) |
| 2568 | 2658 | { |
| 2569 | - if (!is_dir($dir)) |
|
| 2570 | - return array('does_not_exist', true, ''); |
|
| 2571 | - elseif (!is_writable($dir)) |
|
| 2572 | - return array('not_writable', true, ''); |
|
| 2659 | + if (!is_dir($dir)) { |
|
| 2660 | + return array('does_not_exist', true, ''); |
|
| 2661 | + } elseif (!is_writable($dir)) { |
|
| 2662 | + return array('not_writable', true, ''); |
|
| 2663 | + } |
|
| 2573 | 2664 | |
| 2574 | 2665 | // Everything is okay so far, start to scan through the directory. |
| 2575 | 2666 | $num_files = 0; |
@@ -2577,22 +2668,26 @@ discard block |
||
| 2577 | 2668 | while ($file = $dir_handle->read()) |
| 2578 | 2669 | { |
| 2579 | 2670 | // Now do we have a real file here? |
| 2580 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 2581 | - continue; |
|
| 2671 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 2672 | + continue; |
|
| 2673 | + } |
|
| 2582 | 2674 | |
| 2583 | 2675 | $num_files++; |
| 2584 | 2676 | } |
| 2585 | 2677 | $dir_handle->close(); |
| 2586 | 2678 | |
| 2587 | - if ($num_files < $expected_files) |
|
| 2588 | - return array('files_missing', true, $num_files); |
|
| 2679 | + if ($num_files < $expected_files) { |
|
| 2680 | + return array('files_missing', true, $num_files); |
|
| 2681 | + } |
|
| 2589 | 2682 | // Empty? |
| 2590 | - elseif ($expected_files == 0) |
|
| 2591 | - return array('unused', false, $num_files); |
|
| 2683 | + elseif ($expected_files == 0) { |
|
| 2684 | + return array('unused', false, $num_files); |
|
| 2685 | + } |
|
| 2592 | 2686 | // All good! |
| 2593 | - else |
|
| 2594 | - return array('ok', false, $num_files); |
|
| 2595 | -} |
|
| 2687 | + else { |
|
| 2688 | + return array('ok', false, $num_files); |
|
| 2689 | + } |
|
| 2690 | + } |
|
| 2596 | 2691 | |
| 2597 | 2692 | /** |
| 2598 | 2693 | * Maintance function to move attachments from one directory to another |
@@ -2604,10 +2699,11 @@ discard block |
||
| 2604 | 2699 | checkSession(); |
| 2605 | 2700 | |
| 2606 | 2701 | $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
| 2607 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2608 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 2609 | - else |
|
| 2610 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2702 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2703 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 2704 | + } else { |
|
| 2705 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2706 | + } |
|
| 2611 | 2707 | |
| 2612 | 2708 | $_POST['from'] = (int) $_POST['from']; |
| 2613 | 2709 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2621,11 +2717,13 @@ discard block |
||
| 2621 | 2717 | $total_moved = 0; |
| 2622 | 2718 | $total_not_moved = 0; |
| 2623 | 2719 | |
| 2624 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
| 2625 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2720 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
| 2721 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2722 | + } |
|
| 2626 | 2723 | |
| 2627 | - if ($_POST['from'] == $_POST['to']) |
|
| 2628 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2724 | + if ($_POST['from'] == $_POST['to']) { |
|
| 2725 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2726 | + } |
|
| 2629 | 2727 | |
| 2630 | 2728 | if (empty($results)) |
| 2631 | 2729 | { |
@@ -2644,8 +2742,9 @@ discard block |
||
| 2644 | 2742 | $smcFunc['db_free_result']($request); |
| 2645 | 2743 | $total_progress -= $start; |
| 2646 | 2744 | |
| 2647 | - if ($total_progress < 1) |
|
| 2648 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2745 | + if ($total_progress < 1) { |
|
| 2746 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2747 | + } |
|
| 2649 | 2748 | } |
| 2650 | 2749 | |
| 2651 | 2750 | if (empty($results)) |
@@ -2661,9 +2760,9 @@ discard block |
||
| 2661 | 2760 | |
| 2662 | 2761 | automanage_attachments_check_directory(); |
| 2663 | 2762 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
| 2763 | + } else { |
|
| 2764 | + $new_dir = $_POST['to']; |
|
| 2664 | 2765 | } |
| 2665 | - else |
|
| 2666 | - $new_dir = $_POST['to']; |
|
| 2667 | 2766 | |
| 2668 | 2767 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
| 2669 | 2768 | |
@@ -2671,8 +2770,9 @@ discard block |
||
| 2671 | 2770 | while ($break == false) |
| 2672 | 2771 | { |
| 2673 | 2772 | @set_time_limit(300); |
| 2674 | - if (function_exists('apache_reset_timeout')) |
|
| 2675 | - @apache_reset_timeout(); |
|
| 2773 | + if (function_exists('apache_reset_timeout')) { |
|
| 2774 | + @apache_reset_timeout(); |
|
| 2775 | + } |
|
| 2676 | 2776 | |
| 2677 | 2777 | // If limits are set, get the file count and size for the destination folder |
| 2678 | 2778 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2708,13 +2808,15 @@ discard block |
||
| 2708 | 2808 | |
| 2709 | 2809 | if ($smcFunc['db_num_rows']($request) === 0) |
| 2710 | 2810 | { |
| 2711 | - if (empty($current_progress)) |
|
| 2712 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2811 | + if (empty($current_progress)) { |
|
| 2812 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2813 | + } |
|
| 2713 | 2814 | break; |
| 2714 | 2815 | } |
| 2715 | 2816 | |
| 2716 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
| 2717 | - $break = true; |
|
| 2817 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
| 2818 | + $break = true; |
|
| 2819 | + } |
|
| 2718 | 2820 | |
| 2719 | 2821 | // Move them |
| 2720 | 2822 | $moved = array(); |
@@ -2738,8 +2840,9 @@ discard block |
||
| 2738 | 2840 | automanage_attachments_by_space(); |
| 2739 | 2841 | |
| 2740 | 2842 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2741 | - if (!empty($total_not_moved)) |
|
| 2742 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2843 | + if (!empty($total_not_moved)) { |
|
| 2844 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2845 | + } |
|
| 2743 | 2846 | |
| 2744 | 2847 | $dir_files = 0; |
| 2745 | 2848 | $total_moved = 0; |
@@ -2747,8 +2850,7 @@ discard block |
||
| 2747 | 2850 | |
| 2748 | 2851 | $break = false; |
| 2749 | 2852 | break; |
| 2750 | - } |
|
| 2751 | - else |
|
| 2853 | + } else |
|
| 2752 | 2854 | { |
| 2753 | 2855 | // Hmm, not in auto. Time to bail out then... |
| 2754 | 2856 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2763,9 +2865,9 @@ discard block |
||
| 2763 | 2865 | $total_moved++; |
| 2764 | 2866 | $current_progress++; |
| 2765 | 2867 | $moved[] = $row['id_attach']; |
| 2868 | + } else { |
|
| 2869 | + $total_not_moved++; |
|
| 2766 | 2870 | } |
| 2767 | - else |
|
| 2768 | - $total_not_moved++; |
|
| 2769 | 2871 | } |
| 2770 | 2872 | $smcFunc['db_free_result']($request); |
| 2771 | 2873 | |
@@ -2803,13 +2905,15 @@ discard block |
||
| 2803 | 2905 | } |
| 2804 | 2906 | |
| 2805 | 2907 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2806 | - if (!empty($total_not_moved)) |
|
| 2807 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2908 | + if (!empty($total_not_moved)) { |
|
| 2909 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2910 | + } |
|
| 2808 | 2911 | } |
| 2809 | 2912 | |
| 2810 | 2913 | $_SESSION['results'] = $results; |
| 2811 | - if (file_exists($boarddir . '/progress.php')) |
|
| 2812 | - unlink($boarddir . '/progress.php'); |
|
| 2914 | + if (file_exists($boarddir . '/progress.php')) { |
|
| 2915 | + unlink($boarddir . '/progress.php'); |
|
| 2916 | + } |
|
| 2813 | 2917 | |
| 2814 | 2918 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
| 2815 | 2919 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
| 233 | 233 | WHERE t.id_topic IS NULL |
| 234 | 234 | GROUP BY m.id_topic, m.id_board', |
| 235 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
| 235 | + 'fix_processing' => function($row) use ($smcFunc) |
|
| 236 | 236 | { |
| 237 | 237 | global $salvageBoardID; |
| 238 | 238 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | // Remove all topics that have zero messages in the messages table. |
| 319 | 319 | 'fix_collect' => array( |
| 320 | 320 | 'index' => 'id_topic', |
| 321 | - 'process' => function ($topics) use ($smcFunc) |
|
| 321 | + 'process' => function($topics) use ($smcFunc) |
|
| 322 | 322 | { |
| 323 | 323 | $smcFunc['db_query']('', ' |
| 324 | 324 | DELETE FROM {db_prefix}topics |
@@ -356,21 +356,21 @@ discard block |
||
| 356 | 356 | AND p.id_poll IS NULL |
| 357 | 357 | GROUP BY o.id_poll |
| 358 | 358 | ', |
| 359 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
| 359 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
| 360 | 360 | { |
| 361 | 361 | global $salvageBoardID; |
| 362 | 362 | |
| 363 | 363 | $row['poster_name'] = !empty($row['poster_name']) ? $row['poster_name'] : $txt['guest']; |
| 364 | 364 | $row['id_poster'] = !empty($row['id_poster']) ? $row['id_poster'] : 0; |
| 365 | 365 | |
| 366 | - if(empty($row['id_board'])) |
|
| 366 | + if (empty($row['id_board'])) |
|
| 367 | 367 | { |
| 368 | 368 | // Only if we don't have a reasonable idea of where to put it. |
| 369 | 369 | createSalvageArea(); |
| 370 | - $row['id_board'] = (int)$salvageBoardID; |
|
| 370 | + $row['id_board'] = (int) $salvageBoardID; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if(empty($row['id_topic'])) { |
|
| 373 | + if (empty($row['id_topic'])) { |
|
| 374 | 374 | $newMessageID = $smcFunc['db_insert']('', |
| 375 | 375 | '{db_prefix}messages', |
| 376 | 376 | array( |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
| 493 | 493 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 494 | 494 | AND t.id_poll IS NULL', |
| 495 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
| 495 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
| 496 | 496 | { |
| 497 | 497 | global $salvageBoardID; |
| 498 | 498 | |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 606 | 606 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
| 607 | 607 | ORDER BY t.id_topic', |
| 608 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
| 608 | + 'fix_processing' => function($row) use ($smcFunc) |
|
| 609 | 609 | { |
| 610 | 610 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
| 611 | 611 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | ) |
| 635 | 635 | ); |
| 636 | 636 | }, |
| 637 | - 'message_function' => function ($row) use ($txt, &$context) |
|
| 637 | + 'message_function' => function($row) use ($txt, &$context) |
|
| 638 | 638 | { |
| 639 | 639 | // A pretend error? |
| 640 | 640 | if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 669 | 669 | GROUP BY t.id_topic, t.num_replies, mf.approved |
| 670 | 670 | ORDER BY t.id_topic', |
| 671 | - 'fix_processing' => function ($row) |
|
| 671 | + 'fix_processing' => function($row) |
|
| 672 | 672 | { |
| 673 | 673 | |
| 674 | 674 | global $smcFunc; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | 691 | }, |
| 692 | - 'message_function' => function ($row) |
|
| 692 | + 'message_function' => function($row) |
|
| 693 | 693 | { |
| 694 | 694 | |
| 695 | 695 | global $txt, $context; |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | GROUP BY t.id_topic, t.unapproved_posts |
| 723 | 723 | HAVING unapproved_posts != COUNT(mu.id_msg) |
| 724 | 724 | ORDER BY t.id_topic', |
| 725 | - 'fix_processing' => function ($row) |
|
| 725 | + 'fix_processing' => function($row) |
|
| 726 | 726 | { |
| 727 | 727 | |
| 728 | 728 | global $smcFunc; |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | WHERE b.id_board IS NULL |
| 765 | 765 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 766 | 766 | GROUP BY t.id_board', |
| 767 | - 'fix_processing' => function ($row) |
|
| 767 | + 'fix_processing' => function($row) |
|
| 768 | 768 | { |
| 769 | 769 | |
| 770 | 770 | global $smcFunc, $salvageCatID, $txt; |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | ORDER BY b.id_cat, b.id_board', |
| 814 | 814 | 'fix_collect' => array( |
| 815 | 815 | 'index' => 'id_cat', |
| 816 | - 'process' => function ($cats) |
|
| 816 | + 'process' => function($cats) |
|
| 817 | 817 | { |
| 818 | 818 | global $smcFunc, $salvageCatID; |
| 819 | 819 | createSalvageArea(); |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | // Last step-make sure all non-guest posters still exist. |
| 850 | 850 | 'fix_collect' => array( |
| 851 | 851 | 'index' => 'id_msg', |
| 852 | - 'process' => function ($msgs) |
|
| 852 | + 'process' => function($msgs) |
|
| 853 | 853 | { |
| 854 | 854 | |
| 855 | 855 | global $smcFunc; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | ORDER BY b.id_parent, b.id_board', |
| 879 | 879 | 'fix_collect' => array( |
| 880 | 880 | 'index' => 'id_parent', |
| 881 | - 'process' => function ($parents) |
|
| 881 | + 'process' => function($parents) |
|
| 882 | 882 | { |
| 883 | 883 | global $smcFunc, $salvageBoardID, $salvageCatID; |
| 884 | 884 | createSalvageArea(); |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | AND p.id_poll IS NULL', |
| 913 | 913 | 'fix_collect' => array( |
| 914 | 914 | 'index' => 'id_poll', |
| 915 | - 'process' => function ($polls) |
|
| 915 | + 'process' => function($polls) |
|
| 916 | 916 | { |
| 917 | 917 | |
| 918 | 918 | global $smcFunc; |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | ORDER BY cal.id_topic', |
| 947 | 947 | 'fix_collect' => array( |
| 948 | 948 | 'index' => 'id_topic', |
| 949 | - 'process' => function ($events) |
|
| 949 | + 'process' => function($events) |
|
| 950 | 950 | { |
| 951 | 951 | |
| 952 | 952 | global $smcFunc; |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
| 979 | 979 | 'fix_collect' => array( |
| 980 | 980 | 'index' => 'id_topic', |
| 981 | - 'process' => function ($topics) |
|
| 981 | + 'process' => function($topics) |
|
| 982 | 982 | { |
| 983 | 983 | |
| 984 | 984 | global $smcFunc; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | GROUP BY lt.id_member', |
| 1011 | 1011 | 'fix_collect' => array( |
| 1012 | 1012 | 'index' => 'id_member', |
| 1013 | - 'process' => function ($members) |
|
| 1013 | + 'process' => function($members) |
|
| 1014 | 1014 | { |
| 1015 | 1015 | |
| 1016 | 1016 | global $smcFunc; |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | GROUP BY lb.id_board', |
| 1043 | 1043 | 'fix_collect' => array( |
| 1044 | 1044 | 'index' => 'id_board', |
| 1045 | - 'process' => function ($boards) |
|
| 1045 | + 'process' => function($boards) |
|
| 1046 | 1046 | { |
| 1047 | 1047 | |
| 1048 | 1048 | global $smcFunc; |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | GROUP BY lb.id_member', |
| 1075 | 1075 | 'fix_collect' => array( |
| 1076 | 1076 | 'index' => 'id_member', |
| 1077 | - 'process' => function ($members) use ($smcFunc) |
|
| 1077 | + 'process' => function($members) use ($smcFunc) |
|
| 1078 | 1078 | { |
| 1079 | 1079 | $smcFunc['db_query']('', ' |
| 1080 | 1080 | DELETE FROM {db_prefix}log_boards |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | GROUP BY lmr.id_board', |
| 1104 | 1104 | 'fix_collect' => array( |
| 1105 | 1105 | 'index' => 'id_board', |
| 1106 | - 'process' => function ($boards) use ($smcFunc) |
|
| 1106 | + 'process' => function($boards) use ($smcFunc) |
|
| 1107 | 1107 | { |
| 1108 | 1108 | $smcFunc['db_query']('', ' |
| 1109 | 1109 | DELETE FROM {db_prefix}log_mark_read |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | GROUP BY lmr.id_member', |
| 1133 | 1133 | 'fix_collect' => array( |
| 1134 | 1134 | 'index' => 'id_member', |
| 1135 | - 'process' => function ($members) use ($smcFunc) |
|
| 1135 | + 'process' => function($members) use ($smcFunc) |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $smcFunc['db_query']('', ' |
| 1138 | 1138 | DELETE FROM {db_prefix}log_mark_read |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | GROUP BY pmr.id_pm', |
| 1162 | 1162 | 'fix_collect' => array( |
| 1163 | 1163 | 'index' => 'id_pm', |
| 1164 | - 'process' => function ($pms) use ($smcFunc) |
|
| 1164 | + 'process' => function($pms) use ($smcFunc) |
|
| 1165 | 1165 | { |
| 1166 | 1166 | $smcFunc['db_query']('', ' |
| 1167 | 1167 | DELETE FROM {db_prefix}pm_recipients |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | GROUP BY pmr.id_member', |
| 1192 | 1192 | 'fix_collect' => array( |
| 1193 | 1193 | 'index' => 'id_member', |
| 1194 | - 'process' => function ($members) |
|
| 1194 | + 'process' => function($members) |
|
| 1195 | 1195 | { |
| 1196 | 1196 | |
| 1197 | 1197 | global $smcFunc; |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | AND mem.id_member IS NULL', |
| 1224 | 1224 | 'fix_collect' => array( |
| 1225 | 1225 | 'index' => 'id_pm', |
| 1226 | - 'process' => function ($guestMessages) |
|
| 1226 | + 'process' => function($guestMessages) |
|
| 1227 | 1227 | { |
| 1228 | 1228 | |
| 1229 | 1229 | global $smcFunc; |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | GROUP BY ln.id_member', |
| 1256 | 1256 | 'fix_collect' => array( |
| 1257 | 1257 | 'index' => 'id_member', |
| 1258 | - 'process' => function ($members) use ($smcFunc) |
|
| 1258 | + 'process' => function($members) use ($smcFunc) |
|
| 1259 | 1259 | { |
| 1260 | 1260 | $smcFunc['db_query']('', ' |
| 1261 | 1261 | DELETE FROM {db_prefix}log_notify |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
| 1283 | 1283 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 1284 | 1284 | AND lss.id_topic IS NULL', |
| 1285 | - 'fix_full_processing' => function ($result) |
|
| 1285 | + 'fix_full_processing' => function($result) |
|
| 1286 | 1286 | { |
| 1287 | 1287 | |
| 1288 | 1288 | global $smcFunc; |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | ); |
| 1315 | 1315 | |
| 1316 | 1316 | }, |
| 1317 | - 'message_function' => function ($row) |
|
| 1317 | + 'message_function' => function($row) |
|
| 1318 | 1318 | { |
| 1319 | 1319 | |
| 1320 | 1320 | global $txt, $context; |
@@ -1344,7 +1344,7 @@ discard block |
||
| 1344 | 1344 | AND t.id_topic IS NULL', |
| 1345 | 1345 | 'fix_collect' => array( |
| 1346 | 1346 | 'index' => 'id_topic', |
| 1347 | - 'process' => function ($deleteTopics) |
|
| 1347 | + 'process' => function($deleteTopics) |
|
| 1348 | 1348 | { |
| 1349 | 1349 | |
| 1350 | 1350 | global $smcFunc; |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | AND mem.id_member IS NULL', |
| 1377 | 1377 | 'fix_collect' => array( |
| 1378 | 1378 | 'index' => 'id_member', |
| 1379 | - 'process' => function ($members) |
|
| 1379 | + 'process' => function($members) |
|
| 1380 | 1380 | { |
| 1381 | 1381 | |
| 1382 | 1382 | global $smcFunc; |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | AND p.id_poll IS NULL', |
| 1408 | 1408 | 'fix_collect' => array( |
| 1409 | 1409 | 'index' => 'id_poll', |
| 1410 | - 'process' => function ($polls) |
|
| 1410 | + 'process' => function($polls) |
|
| 1411 | 1411 | { |
| 1412 | 1412 | |
| 1413 | 1413 | global $smcFunc; |
@@ -1438,7 +1438,7 @@ discard block |
||
| 1438 | 1438 | AND lrc.id_report IS NULL', |
| 1439 | 1439 | 'fix_collect' => array( |
| 1440 | 1440 | 'index' => 'id_report', |
| 1441 | - 'process' => function ($reports) |
|
| 1441 | + 'process' => function($reports) |
|
| 1442 | 1442 | { |
| 1443 | 1443 | |
| 1444 | 1444 | global $smcFunc; |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | AND lr.id_report IS NULL', |
| 1470 | 1470 | 'fix_collect' => array( |
| 1471 | 1471 | 'index' => 'id_report', |
| 1472 | - 'process' => function ($reports) |
|
| 1472 | + 'process' => function($reports) |
|
| 1473 | 1473 | { |
| 1474 | 1474 | global $smcFunc; |
| 1475 | 1475 | $smcFunc['db_query']('', ' |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | GROUP BY lgr.id_member', |
| 1500 | 1500 | 'fix_collect' => array( |
| 1501 | 1501 | 'index' => 'id_member', |
| 1502 | - 'process' => function ($members) |
|
| 1502 | + 'process' => function($members) |
|
| 1503 | 1503 | { |
| 1504 | 1504 | global $smcFunc; |
| 1505 | 1505 | $smcFunc['db_query']('', ' |
@@ -1529,7 +1529,7 @@ discard block |
||
| 1529 | 1529 | GROUP BY lgr.id_group', |
| 1530 | 1530 | 'fix_collect' => array( |
| 1531 | 1531 | 'index' => 'id_group', |
| 1532 | - 'process' => function ($groups) |
|
| 1532 | + 'process' => function($groups) |
|
| 1533 | 1533 | { |
| 1534 | 1534 | global $smcFunc; |
| 1535 | 1535 | $smcFunc['db_query']('', ' |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | // Start displaying errors without fixing them. |
| 53 | - if (isset($_GET['fixErrors'])) |
|
| 54 | - checkSession('get'); |
|
| 54 | + if (isset($_GET['fixErrors'])) { |
|
| 55 | + checkSession('get'); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // Will want this. |
| 57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
| 69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
| 70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
| 71 | 73 | |
| 72 | - if (empty($context['repair_errors'])) |
|
| 73 | - $context['repair_errors'][] = '???'; |
|
| 74 | + if (empty($context['repair_errors'])) { |
|
| 75 | + $context['repair_errors'][] = '???'; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | - } |
|
| 76 | - else |
|
| 78 | + } else |
|
| 77 | 79 | { |
| 78 | 80 | $context['error_search'] = false; |
| 79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | // More time, I need more time! |
| 122 | 124 | @set_time_limit(600); |
| 123 | - if (function_exists('apache_reset_timeout')) |
|
| 124 | - @apache_reset_timeout(); |
|
| 125 | + if (function_exists('apache_reset_timeout')) { |
|
| 126 | + @apache_reset_timeout(); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | // Errr, wait. How much time has this taken already? |
| 127 | - if (!$force && (time() - $time_start) < 3) |
|
| 128 | - return; |
|
| 130 | + if (!$force && (time() - $time_start) < 3) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Restore the query cache if interested. |
| 131 | - if (!empty($db_temp_cache)) |
|
| 132 | - $db_cache = $db_temp_cache; |
|
| 135 | + if (!empty($db_temp_cache)) { |
|
| 136 | + $db_cache = $db_temp_cache; |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
| 138 | 143 | $context['sub_template'] = 'not_done'; |
| 139 | 144 | |
| 140 | 145 | // Change these two if more steps are added! |
| 141 | - if (empty($max_substep)) |
|
| 142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 143 | - else |
|
| 144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 146 | + if (empty($max_substep)) { |
|
| 147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 148 | + } else { |
|
| 149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | // Never more than 100%! |
| 147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
| 612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 613 | 619 | |
| 614 | 620 | // Not really a problem? |
| 615 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 616 | - return false; |
|
| 621 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 617 | 624 | |
| 618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
| 637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
| 638 | 645 | { |
| 639 | 646 | // A pretend error? |
| 640 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 641 | - return false; |
|
| 647 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 642 | 650 | |
| 643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 653 | + } |
|
| 654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 656 | + } |
|
| 657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 659 | + } |
|
| 649 | 660 | |
| 650 | 661 | return true; |
| 651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
| 675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 676 | 687 | |
| 677 | 688 | // Not really a problem? |
| 678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 679 | - return false; |
|
| 689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 680 | 692 | |
| 681 | 693 | $smcFunc['db_query']('', ' |
| 682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
| 695 | 707 | global $txt, $context; |
| 696 | 708 | |
| 697 | 709 | // Just joking? |
| 698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 699 | - return false; |
|
| 710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 700 | 713 | |
| 701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 716 | + } |
|
| 703 | 717 | |
| 704 | 718 | return true; |
| 705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
| 1290 | 1304 | $inserts = array(); |
| 1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1292 | 1306 | { |
| 1293 | - foreach (text2words($row['subject']) as $word) |
|
| 1294 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1307 | + foreach (text2words($row['subject']) as $word) { |
|
| 1308 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1309 | + } |
|
| 1295 | 1310 | if (count($inserts) > 500) |
| 1296 | 1311 | { |
| 1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
| 1305 | 1320 | |
| 1306 | 1321 | } |
| 1307 | 1322 | |
| 1308 | - if (!empty($inserts)) |
|
| 1309 | - $smcFunc['db_insert']('ignore', |
|
| 1323 | + if (!empty($inserts)) { |
|
| 1324 | + $smcFunc['db_insert']('ignore', |
|
| 1310 | 1325 | '{db_prefix}log_search_subjects', |
| 1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
| 1312 | 1327 | $inserts, |
| 1313 | 1328 | array('word', 'id_topic') |
| 1314 | 1329 | ); |
| 1330 | + } |
|
| 1315 | 1331 | |
| 1316 | 1332 | }, |
| 1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
| 1581 | 1597 | $current_step++; |
| 1582 | 1598 | |
| 1583 | 1599 | // Already done this? |
| 1584 | - if ($_GET['step'] > $current_step) |
|
| 1585 | - continue; |
|
| 1600 | + if ($_GET['step'] > $current_step) { |
|
| 1601 | + continue; |
|
| 1602 | + } |
|
| 1586 | 1603 | |
| 1587 | 1604 | // If we're fixing it but it ain't broke why try? |
| 1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
| 1611 | 1628 | while (!$done) |
| 1612 | 1629 | { |
| 1613 | 1630 | // Make sure there's at least one ID to test. |
| 1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1615 | - break; |
|
| 1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1632 | + break; |
|
| 1633 | + } |
|
| 1616 | 1634 | |
| 1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
| 1618 | - if (!$do_fix) |
|
| 1619 | - $test_query = 'check_query'; |
|
| 1620 | - else |
|
| 1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1636 | + if (!$do_fix) { |
|
| 1637 | + $test_query = 'check_query'; |
|
| 1638 | + } else { |
|
| 1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1640 | + } |
|
| 1622 | 1641 | |
| 1623 | 1642 | // Do the test... |
| 1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
| 1628 | 1647 | ); |
| 1629 | 1648 | |
| 1630 | 1649 | // Does it need a fix? |
| 1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1633 | - else |
|
| 1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1652 | + } else { |
|
| 1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1654 | + } |
|
| 1635 | 1655 | |
| 1636 | 1656 | $total_queries++; |
| 1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
| 1643 | 1663 | // Assume need to fix. |
| 1644 | 1664 | $found_errors = true; |
| 1645 | 1665 | |
| 1646 | - if (isset($test['message'])) |
|
| 1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1666 | + if (isset($test['message'])) { |
|
| 1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1668 | + } |
|
| 1648 | 1669 | |
| 1649 | 1670 | // One per row! |
| 1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
| 1654 | 1675 | $variables = $test['messages']; |
| 1655 | 1676 | foreach ($variables as $k => $v) |
| 1656 | 1677 | { |
| 1657 | - if ($k == 0 && isset($txt[$v])) |
|
| 1658 | - $variables[$k] = $txt[$v]; |
|
| 1659 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1660 | - $variables[$k] = $row[$v]; |
|
| 1678 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1679 | + $variables[$k] = $txt[$v]; |
|
| 1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1681 | + $variables[$k] = $row[$v]; |
|
| 1682 | + } |
|
| 1661 | 1683 | } |
| 1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
| 1668 | 1690 | { |
| 1669 | 1691 | // Find out if there are actually errors. |
| 1670 | 1692 | $found_errors = false; |
| 1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1672 | - $found_errors |= $test['message_function']($row); |
|
| 1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1694 | + $found_errors |= $test['message_function']($row); |
|
| 1695 | + } |
|
| 1673 | 1696 | } |
| 1674 | 1697 | |
| 1675 | 1698 | // Actually have something to fix? |
| 1676 | - if ($found_errors) |
|
| 1677 | - $to_fix[] = $error_type; |
|
| 1699 | + if ($found_errors) { |
|
| 1700 | + $to_fix[] = $error_type; |
|
| 1701 | + } |
|
| 1678 | 1702 | } |
| 1679 | 1703 | |
| 1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
| 1684 | 1708 | if (isset($test['fix_collect'])) |
| 1685 | 1709 | { |
| 1686 | 1710 | $ids = array(); |
| 1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1713 | + } |
|
| 1689 | 1714 | if (!empty($ids)) |
| 1690 | 1715 | { |
| 1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
| 1694 | 1719 | } |
| 1695 | 1720 | |
| 1696 | 1721 | // Simply executing a fix it query? |
| 1697 | - elseif (isset($test['fix_it_query'])) |
|
| 1698 | - $smcFunc['db_query']('', |
|
| 1722 | + elseif (isset($test['fix_it_query'])) { |
|
| 1723 | + $smcFunc['db_query']('', |
|
| 1699 | 1724 | $test['fix_it_query'], |
| 1700 | 1725 | array( |
| 1701 | 1726 | ) |
| 1702 | 1727 | ); |
| 1728 | + } |
|
| 1703 | 1729 | |
| 1704 | 1730 | // Do we have some processing to do? |
| 1705 | 1731 | elseif (isset($test['fix_processing'])) |
| 1706 | 1732 | { |
| 1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1708 | - $test['fix_processing']($row); |
|
| 1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1734 | + $test['fix_processing']($row); |
|
| 1735 | + } |
|
| 1709 | 1736 | } |
| 1710 | 1737 | |
| 1711 | 1738 | // What about the full set of processing? |
| 1712 | - elseif (isset($test['fix_full_processing'])) |
|
| 1713 | - $test['fix_full_processing']($request); |
|
| 1739 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1740 | + $test['fix_full_processing']($request); |
|
| 1741 | + } |
|
| 1714 | 1742 | |
| 1715 | 1743 | // Do we have other things we need to fix as a result? |
| 1716 | 1744 | if (!empty($test['force_fix'])) |
| 1717 | 1745 | { |
| 1718 | - foreach ($test['force_fix'] as $item) |
|
| 1719 | - if (!in_array($item, $to_fix)) |
|
| 1746 | + foreach ($test['force_fix'] as $item) { |
|
| 1747 | + if (!in_array($item, $to_fix)) |
|
| 1720 | 1748 | $to_fix[] = $item; |
| 1749 | + } |
|
| 1721 | 1750 | } |
| 1722 | 1751 | } |
| 1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
| 1735 | 1764 | if ($_GET['substep'] <= $step_max) |
| 1736 | 1765 | { |
| 1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1767 | + } else { |
|
| 1768 | + $done = true; |
|
| 1738 | 1769 | } |
| 1739 | - else |
|
| 1740 | - $done = true; |
|
| 1770 | + } else { |
|
| 1771 | + $done = true; |
|
| 1741 | 1772 | } |
| 1742 | - else |
|
| 1743 | - $done = true; |
|
| 1744 | 1773 | |
| 1745 | 1774 | // Don't allow more than 1000 queries at a time. |
| 1746 | - if ($total_queries >= 1000) |
|
| 1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1775 | + if ($total_queries >= 1000) { |
|
| 1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1777 | + } |
|
| 1748 | 1778 | } |
| 1749 | 1779 | |
| 1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
| 1757 | 1787 | if ($do_fix) |
| 1758 | 1788 | { |
| 1759 | 1789 | $key = array_search($error_type, $to_fix); |
| 1760 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1761 | - unset($to_fix[$key]); |
|
| 1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1791 | + unset($to_fix[$key]); |
|
| 1792 | + } |
|
| 1762 | 1793 | } |
| 1763 | 1794 | |
| 1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
| 1781 | 1812 | static $createOnce = false; |
| 1782 | 1813 | |
| 1783 | 1814 | // Have we already created it? |
| 1784 | - if ($createOnce) |
|
| 1785 | - return; |
|
| 1786 | - else |
|
| 1787 | - $createOnce = true; |
|
| 1815 | + if ($createOnce) { |
|
| 1816 | + return; |
|
| 1817 | + } else { |
|
| 1818 | + $createOnce = true; |
|
| 1819 | + } |
|
| 1788 | 1820 | |
| 1789 | 1821 | // Back to the forum's default language. |
| 1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
| 1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
| 1800 | 1832 | ) |
| 1801 | 1833 | ); |
| 1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1836 | + } |
|
| 1804 | 1837 | $smcFunc['db_free_result']($result); |
| 1805 | 1838 | |
| 1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
| 1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
| 1833 | 1866 | ) |
| 1834 | 1867 | ); |
| 1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1870 | + } |
|
| 1837 | 1871 | $smcFunc['db_free_result']($result); |
| 1838 | 1872 | |
| 1839 | 1873 | if (empty($salvageBoardID)) |
@@ -670,7 +670,7 @@ |
||
| 670 | 670 | // Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified! |
| 671 | 671 | // Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it. |
| 672 | 672 | echo ' |
| 673 | - <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
|
| 673 | + <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">'; |
|
| 674 | 674 | |
| 675 | 675 | if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
| 676 | 676 | echo |
@@ -51,11 +51,13 @@ discard block |
||
| 51 | 51 | <p>'; |
| 52 | 52 | |
| 53 | 53 | // Show just numbers...? |
| 54 | - if ($settings['display_who_viewing'] == 1) |
|
| 55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 54 | + if ($settings['display_who_viewing'] == 1) { |
|
| 55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + } |
|
| 56 | 57 | // Or show the actual people viewing the topic? |
| 57 | - else |
|
| 58 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 58 | + else { |
|
| 59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | // Now show how many guests are here too. |
| 61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
| 93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 95 | 97 | |
| 96 | - if ($context['allow_results_view']) |
|
| 97 | - echo ' |
|
| 98 | + if ($context['allow_results_view']) { |
|
| 99 | + echo ' |
|
| 98 | 100 | ', $option['bar_ndt'], ' |
| 99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | echo ' |
| 102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
| 105 | 108 | echo ' |
| 106 | 109 | </dl>'; |
| 107 | 110 | |
| 108 | - if ($context['allow_results_view']) |
|
| 109 | - echo ' |
|
| 111 | + if ($context['allow_results_view']) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 114 | + } |
|
| 111 | 115 | } |
| 112 | 116 | // They are allowed to vote! Go to it! |
| 113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
| 116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 117 | 121 | |
| 118 | 122 | // Show a warning if they are allowed more than one option. |
| 119 | - if ($context['poll']['allowed_warning']) |
|
| 120 | - echo ' |
|
| 123 | + if ($context['poll']['allowed_warning']) { |
|
| 124 | + echo ' |
|
| 121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | echo ' |
| 124 | 129 | <ul class="options">'; |
| 125 | 130 | |
| 126 | 131 | // Show each option with its button - a radio likely. |
| 127 | - foreach ($context['poll']['options'] as $option) |
|
| 128 | - echo ' |
|
| 132 | + foreach ($context['poll']['options'] as $option) { |
|
| 133 | + echo ' |
|
| 129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | echo ' |
| 132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
| 138 | 144 | } |
| 139 | 145 | |
| 140 | 146 | // Is the clock ticking? |
| 141 | - if (!empty($context['poll']['expire_time'])) |
|
| 142 | - echo ' |
|
| 147 | + if (!empty($context['poll']['expire_time'])) { |
|
| 148 | + echo ' |
|
| 143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 150 | + } |
|
| 144 | 151 | |
| 145 | 152 | echo ' |
| 146 | 153 | </div> |
@@ -170,11 +177,13 @@ discard block |
||
| 170 | 177 | <li> |
| 171 | 178 | <strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>'; |
| 172 | 179 | |
| 173 | - if ($event['can_edit']) |
|
| 174 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 180 | + if ($event['can_edit']) { |
|
| 181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 182 | + } |
|
| 175 | 183 | |
| 176 | - if ($event['can_export']) |
|
| 177 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 184 | + if ($event['can_export']) { |
|
| 185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | 188 | echo ' |
| 180 | 189 | <br>'; |
@@ -182,14 +191,14 @@ discard block |
||
| 182 | 191 | if (!empty($event['allday'])) |
| 183 | 192 | { |
| 184 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 185 | - } |
|
| 186 | - else |
|
| 194 | + } else |
|
| 187 | 195 | { |
| 188 | 196 | // Display event info relative to user's local timezone |
| 189 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 190 | 198 | |
| 191 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 192 | - echo trim($event['end_date_local']) . ', '; |
|
| 199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 200 | + echo trim($event['end_date_local']) . ', '; |
|
| 201 | + } |
|
| 193 | 202 | |
| 194 | 203 | echo trim($event['end_time_local']); |
| 195 | 204 | |
@@ -198,23 +207,27 @@ discard block |
||
| 198 | 207 | { |
| 199 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 200 | 209 | |
| 201 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 202 | - echo trim($event['start_date_orig']), ', '; |
|
| 210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 211 | + echo trim($event['start_date_orig']), ', '; |
|
| 212 | + } |
|
| 203 | 213 | |
| 204 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 205 | 215 | |
| 206 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 207 | - echo trim($event['end_date_orig']) . ', '; |
|
| 216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 217 | + echo trim($event['end_date_orig']) . ', '; |
|
| 218 | + } |
|
| 208 | 219 | |
| 209 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 210 | 221 | } |
| 211 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 212 | - else |
|
| 213 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 223 | + else { |
|
| 224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 225 | + } |
|
| 214 | 226 | } |
| 215 | 227 | |
| 216 | - if (!empty($event['location'])) |
|
| 217 | - echo '<br>', $event['location']; |
|
| 228 | + if (!empty($event['location'])) { |
|
| 229 | + echo '<br>', $event['location']; |
|
| 230 | + } |
|
| 218 | 231 | |
| 219 | 232 | echo ' |
| 220 | 233 | </li>'; |
@@ -253,8 +266,9 @@ discard block |
||
| 253 | 266 | $context['removableMessageIDs'] = array(); |
| 254 | 267 | |
| 255 | 268 | // Get all the messages... |
| 256 | - while ($message = $context['get_message']()) |
|
| 257 | - template_single_post($message); |
|
| 269 | + while ($message = $context['get_message']()) { |
|
| 270 | + template_single_post($message); |
|
| 271 | + } |
|
| 258 | 272 | |
| 259 | 273 | echo ' |
| 260 | 274 | </form> |
@@ -292,8 +306,9 @@ discard block |
||
| 292 | 306 | <div id="display_jump_to"> </div>'; |
| 293 | 307 | |
| 294 | 308 | // Show quickreply |
| 295 | - if ($context['can_reply']) |
|
| 296 | - template_quickreply(); |
|
| 309 | + if ($context['can_reply']) { |
|
| 310 | + template_quickreply(); |
|
| 311 | + } |
|
| 297 | 312 | |
| 298 | 313 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 299 | 314 | echo ' |
@@ -306,8 +321,8 @@ discard block |
||
| 306 | 321 | </div>'; |
| 307 | 322 | |
| 308 | 323 | // Show the moderation button & pop only if user can moderate |
| 309 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 310 | - echo ' |
|
| 324 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 325 | + echo ' |
|
| 311 | 326 | <div id="mobile_moderation" class="popup_container"> |
| 312 | 327 | <div class="popup_window description"> |
| 313 | 328 | <div class="popup_heading">', $txt['mobile_moderation'], ' |
@@ -317,6 +332,7 @@ discard block |
||
| 317 | 332 | </div> |
| 318 | 333 | </div> |
| 319 | 334 | </div>'; |
| 335 | + } |
|
| 320 | 336 | |
| 321 | 337 | echo ' |
| 322 | 338 | <script>'; |
@@ -440,9 +456,10 @@ discard block |
||
| 440 | 456 | }); |
| 441 | 457 | }'; |
| 442 | 458 | |
| 443 | - if (!empty($context['ignoredMsgs'])) |
|
| 444 | - echo ' |
|
| 459 | + if (!empty($context['ignoredMsgs'])) { |
|
| 460 | + echo ' |
|
| 445 | 461 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 462 | + } |
|
| 446 | 463 | |
| 447 | 464 | echo ' |
| 448 | 465 | </script>'; |
@@ -459,8 +476,9 @@ discard block |
||
| 459 | 476 | |
| 460 | 477 | $ignoring = false; |
| 461 | 478 | |
| 462 | - if ($message['can_remove']) |
|
| 463 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 479 | + if ($message['can_remove']) { |
|
| 480 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 481 | + } |
|
| 464 | 482 | |
| 465 | 483 | // Are we ignoring this message? |
| 466 | 484 | if (!empty($message['is_ignored'])) |
@@ -486,9 +504,10 @@ discard block |
||
| 486 | 504 | <div class="custom_fields_above_member"> |
| 487 | 505 | <ul class="nolist">'; |
| 488 | 506 | |
| 489 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 490 | - echo ' |
|
| 507 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 508 | + echo ' |
|
| 491 | 509 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 510 | + } |
|
| 492 | 511 | |
| 493 | 512 | echo ' |
| 494 | 513 | </ul> |
@@ -499,9 +518,10 @@ discard block |
||
| 499 | 518 | <h4>'; |
| 500 | 519 | |
| 501 | 520 | // Show online and offline buttons? |
| 502 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 503 | - echo ' |
|
| 521 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 522 | + echo ' |
|
| 504 | 523 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 524 | + } |
|
| 505 | 525 | |
| 506 | 526 | |
| 507 | 527 | // Show a link to the member's profile. |
@@ -514,51 +534,59 @@ discard block |
||
| 514 | 534 | |
| 515 | 535 | |
| 516 | 536 | // Show the user's avatar. |
| 517 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 518 | - echo ' |
|
| 537 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 538 | + echo ' |
|
| 519 | 539 | <li class="avatar"> |
| 520 | 540 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 521 | 541 | </li>'; |
| 542 | + } |
|
| 522 | 543 | |
| 523 | 544 | // Are there any custom fields below the avatar? |
| 524 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 525 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 545 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 546 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 526 | 547 | echo ' |
| 527 | 548 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 549 | + } |
|
| 528 | 550 | |
| 529 | 551 | // Show the post group icons, but not for guests. |
| 530 | - if (!$message['member']['is_guest']) |
|
| 531 | - echo ' |
|
| 552 | + if (!$message['member']['is_guest']) { |
|
| 553 | + echo ' |
|
| 532 | 554 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 555 | + } |
|
| 533 | 556 | |
| 534 | 557 | // Show the member's primary group (like 'Administrator') if they have one. |
| 535 | - if (!empty($message['member']['group'])) |
|
| 536 | - echo ' |
|
| 558 | + if (!empty($message['member']['group'])) { |
|
| 559 | + echo ' |
|
| 537 | 560 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 561 | + } |
|
| 538 | 562 | |
| 539 | 563 | // Show the member's custom title, if they have one. |
| 540 | - if (!empty($message['member']['title'])) |
|
| 541 | - echo ' |
|
| 564 | + if (!empty($message['member']['title'])) { |
|
| 565 | + echo ' |
|
| 542 | 566 | <li class="title">', $message['member']['title'], '</li>'; |
| 567 | + } |
|
| 543 | 568 | |
| 544 | 569 | // Don't show these things for guests. |
| 545 | 570 | if (!$message['member']['is_guest']) |
| 546 | 571 | { |
| 547 | 572 | |
| 548 | 573 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 549 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 550 | - echo ' |
|
| 574 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 575 | + echo ' |
|
| 551 | 576 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 577 | + } |
|
| 552 | 578 | |
| 553 | 579 | // Show how many posts they have made. |
| 554 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 555 | - echo ' |
|
| 580 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 581 | + echo ' |
|
| 556 | 582 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 583 | + } |
|
| 557 | 584 | |
| 558 | 585 | // Show their personal text? |
| 559 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 560 | - echo ' |
|
| 586 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 587 | + echo ' |
|
| 561 | 588 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 589 | + } |
|
| 562 | 590 | |
| 563 | 591 | // Any custom fields to show as icons? |
| 564 | 592 | if (!empty($message['custom_fields']['icons'])) |
@@ -567,9 +595,10 @@ discard block |
||
| 567 | 595 | <li class="im_icons"> |
| 568 | 596 | <ol>'; |
| 569 | 597 | |
| 570 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 571 | - echo ' |
|
| 598 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 599 | + echo ' |
|
| 572 | 600 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 601 | + } |
|
| 573 | 602 | |
| 574 | 603 | echo ' |
| 575 | 604 | </ol> |
@@ -584,19 +613,22 @@ discard block |
||
| 584 | 613 | <ol class="profile_icons">'; |
| 585 | 614 | |
| 586 | 615 | // Don't show an icon if they haven't specified a website. |
| 587 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 588 | - echo ' |
|
| 616 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 617 | + echo ' |
|
| 589 | 618 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 619 | + } |
|
| 590 | 620 | |
| 591 | 621 | // Since we know this person isn't a guest, you *can* message them. |
| 592 | - if ($context['can_send_pm']) |
|
| 593 | - echo ' |
|
| 622 | + if ($context['can_send_pm']) { |
|
| 623 | + echo ' |
|
| 594 | 624 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 625 | + } |
|
| 595 | 626 | |
| 596 | 627 | // Show the email if necessary |
| 597 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 598 | - echo ' |
|
| 628 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 629 | + echo ' |
|
| 599 | 630 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 631 | + } |
|
| 600 | 632 | |
| 601 | 633 | echo ' |
| 602 | 634 | </ol> |
@@ -604,48 +636,56 @@ discard block |
||
| 604 | 636 | } |
| 605 | 637 | |
| 606 | 638 | // Any custom fields for standard placement? |
| 607 | - if (!empty($message['custom_fields']['standard'])) |
|
| 608 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 639 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 640 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 609 | 641 | echo ' |
| 610 | 642 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 643 | + } |
|
| 611 | 644 | |
| 612 | 645 | } |
| 613 | 646 | // Otherwise, show the guest's email. |
| 614 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 615 | - echo ' |
|
| 647 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 648 | + echo ' |
|
| 616 | 649 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 650 | + } |
|
| 617 | 651 | |
| 618 | 652 | // Show the IP to this user for this post - because you can moderate? |
| 619 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 620 | - echo ' |
|
| 653 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 654 | + echo ' |
|
| 621 | 655 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 656 | + } |
|
| 622 | 657 | |
| 623 | 658 | // Or, should we show it because this is you? |
| 624 | - elseif ($message['can_see_ip']) |
|
| 625 | - echo ' |
|
| 659 | + elseif ($message['can_see_ip']) { |
|
| 660 | + echo ' |
|
| 626 | 661 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 662 | + } |
|
| 627 | 663 | |
| 628 | 664 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 629 | - elseif (!$context['user']['is_guest']) |
|
| 630 | - echo ' |
|
| 665 | + elseif (!$context['user']['is_guest']) { |
|
| 666 | + echo ' |
|
| 631 | 667 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 668 | + } |
|
| 632 | 669 | |
| 633 | 670 | // Otherwise, you see NOTHING! |
| 634 | - else |
|
| 635 | - echo ' |
|
| 671 | + else { |
|
| 672 | + echo ' |
|
| 636 | 673 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 674 | + } |
|
| 637 | 675 | |
| 638 | 676 | // Are we showing the warning status? |
| 639 | 677 | // Don't show these things for guests. |
| 640 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 641 | - echo ' |
|
| 678 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 679 | + echo ' |
|
| 642 | 680 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 681 | + } |
|
| 643 | 682 | |
| 644 | 683 | // Are there any custom fields to show at the bottom of the poster info? |
| 645 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 646 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 684 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 685 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 647 | 686 | echo ' |
| 648 | 687 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 688 | + } |
|
| 649 | 689 | |
| 650 | 690 | // Poster info ends. |
| 651 | 691 | echo ' |
@@ -674,9 +714,10 @@ discard block |
||
| 674 | 714 | echo ' |
| 675 | 715 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
| 676 | 716 | |
| 677 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 678 | - echo |
|
| 717 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 718 | + echo |
|
| 679 | 719 | $message['modified']['last_edit_text']; |
| 720 | + } |
|
| 680 | 721 | |
| 681 | 722 | echo ' |
| 682 | 723 | </span> |
@@ -685,22 +726,24 @@ discard block |
||
| 685 | 726 | </div>'; |
| 686 | 727 | |
| 687 | 728 | // Ignoring this user? Hide the post. |
| 688 | - if ($ignoring) |
|
| 689 | - echo ' |
|
| 729 | + if ($ignoring) { |
|
| 730 | + echo ' |
|
| 690 | 731 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 691 | 732 | ', $txt['ignoring_user'], ' |
| 692 | 733 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 693 | 734 | </div>'; |
| 735 | + } |
|
| 694 | 736 | |
| 695 | 737 | // Show the post itself, finally! |
| 696 | 738 | echo ' |
| 697 | 739 | <div class="post">'; |
| 698 | 740 | |
| 699 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 700 | - echo ' |
|
| 741 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 742 | + echo ' |
|
| 701 | 743 | <div class="approve_post"> |
| 702 | 744 | ', $txt['post_awaiting_approval'], ' |
| 703 | 745 | </div>'; |
| 746 | + } |
|
| 704 | 747 | echo ' |
| 705 | 748 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
| 706 | 749 | </div>'; |
@@ -717,9 +760,9 @@ discard block |
||
| 717 | 760 | foreach ($message['attachment'] as $attachment) |
| 718 | 761 | { |
| 719 | 762 | // Do we want this attachment to not be showed here? |
| 720 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 721 | - continue; |
|
| 722 | - elseif (!$div_output) |
|
| 763 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 764 | + continue; |
|
| 765 | + } elseif (!$div_output) |
|
| 723 | 766 | { |
| 724 | 767 | $div_output = true; |
| 725 | 768 | |
@@ -735,9 +778,10 @@ discard block |
||
| 735 | 778 | <fieldset> |
| 736 | 779 | <legend>', $txt['attach_awaiting_approve']; |
| 737 | 780 | |
| 738 | - if ($context['can_approve']) |
|
| 739 | - echo ' |
|
| 781 | + if ($context['can_approve']) { |
|
| 782 | + echo ' |
|
| 740 | 783 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 784 | + } |
|
| 741 | 785 | |
| 742 | 786 | echo ' |
| 743 | 787 | </legend>'; |
@@ -751,12 +795,13 @@ discard block |
||
| 751 | 795 | echo ' |
| 752 | 796 | <div class="attachments_top">'; |
| 753 | 797 | |
| 754 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 755 | - echo ' |
|
| 798 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 799 | + echo ' |
|
| 756 | 800 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 757 | - else |
|
| 758 | - echo ' |
|
| 801 | + } else { |
|
| 802 | + echo ' |
|
| 759 | 803 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 804 | + } |
|
| 760 | 805 | |
| 761 | 806 | echo ' |
| 762 | 807 | </div>'; |
@@ -766,9 +811,10 @@ discard block |
||
| 766 | 811 | <div class="attachments_bot"> |
| 767 | 812 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 768 | 813 | |
| 769 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 770 | - echo ' |
|
| 814 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 815 | + echo ' |
|
| 771 | 816 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 817 | + } |
|
| 772 | 818 | echo ' |
| 773 | 819 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 774 | 820 | </div>'; |
@@ -777,33 +823,38 @@ discard block |
||
| 777 | 823 | </div>'; |
| 778 | 824 | |
| 779 | 825 | // Next attachment line ? |
| 780 | - if (++$i % $attachments_per_line === 0) |
|
| 781 | - echo ' |
|
| 826 | + if (++$i % $attachments_per_line === 0) { |
|
| 827 | + echo ' |
|
| 782 | 828 | <br>'; |
| 829 | + } |
|
| 783 | 830 | } |
| 784 | 831 | |
| 785 | 832 | // If we had unapproved attachments clean up. |
| 786 | - if ($last_approved_state == 0) |
|
| 787 | - echo ' |
|
| 833 | + if ($last_approved_state == 0) { |
|
| 834 | + echo ' |
|
| 788 | 835 | </fieldset>'; |
| 836 | + } |
|
| 789 | 837 | |
| 790 | 838 | // Only do this if we output a div above - otherwise it'll break things |
| 791 | - if ($div_output) |
|
| 792 | - echo ' |
|
| 839 | + if ($div_output) { |
|
| 840 | + echo ' |
|
| 793 | 841 | </div>'; |
| 842 | + } |
|
| 794 | 843 | } |
| 795 | 844 | |
| 796 | 845 | // And stuff below the attachments. |
| 797 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 798 | - echo ' |
|
| 846 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 847 | + echo ' |
|
| 799 | 848 | <div class="under_message">'; |
| 849 | + } |
|
| 800 | 850 | |
| 801 | 851 | // Maybe they want to report this post to the moderator(s)? |
| 802 | - if ($context['can_report_moderator']) |
|
| 803 | - echo ' |
|
| 852 | + if ($context['can_report_moderator']) { |
|
| 853 | + echo ' |
|
| 804 | 854 | <ul class="floatright smalltext"> |
| 805 | 855 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
| 806 | 856 | </ul>'; |
| 857 | + } |
|
| 807 | 858 | |
| 808 | 859 | // What about likes? |
| 809 | 860 | if (!empty($modSettings['enable_likes'])) |
@@ -844,78 +895,91 @@ discard block |
||
| 844 | 895 | <ul class="quickbuttons">'; |
| 845 | 896 | |
| 846 | 897 | // Can they quote? if so they can select and quote as well! |
| 847 | - if ($context['can_quote']) |
|
| 848 | - echo ' |
|
| 898 | + if ($context['can_quote']) { |
|
| 899 | + echo ' |
|
| 849 | 900 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 850 | 901 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>'; |
| 902 | + } |
|
| 851 | 903 | |
| 852 | 904 | // Can the user modify the contents of this post? Show the modify inline image. |
| 853 | - if ($message['can_modify']) |
|
| 854 | - echo ' |
|
| 905 | + if ($message['can_modify']) { |
|
| 906 | + echo ' |
|
| 855 | 907 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
| 908 | + } |
|
| 856 | 909 | |
| 857 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 858 | - echo ' |
|
| 910 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 911 | + echo ' |
|
| 859 | 912 | <li class="post_options">', $txt['post_options']; |
| 913 | + } |
|
| 860 | 914 | |
| 861 | 915 | echo ' |
| 862 | 916 | <ul>'; |
| 863 | 917 | |
| 864 | 918 | // Can the user modify the contents of this post? |
| 865 | - if ($message['can_modify']) |
|
| 866 | - echo ' |
|
| 919 | + if ($message['can_modify']) { |
|
| 920 | + echo ' |
|
| 867 | 921 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 922 | + } |
|
| 868 | 923 | |
| 869 | 924 | // How about... even... remove it entirely?! |
| 870 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 871 | - echo ' |
|
| 925 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 926 | + echo ' |
|
| 872 | 927 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
| 873 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 874 | - echo ' |
|
| 928 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 929 | + echo ' |
|
| 875 | 930 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 931 | + } |
|
| 876 | 932 | |
| 877 | 933 | // What about splitting it off the rest of the topic? |
| 878 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 879 | - echo ' |
|
| 934 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 935 | + echo ' |
|
| 880 | 936 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 937 | + } |
|
| 881 | 938 | |
| 882 | 939 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 883 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 884 | - echo ' |
|
| 940 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 941 | + echo ' |
|
| 885 | 942 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 943 | + } |
|
| 886 | 944 | |
| 887 | 945 | // Can we restore topics? |
| 888 | - if ($context['can_restore_msg']) |
|
| 889 | - echo ' |
|
| 946 | + if ($context['can_restore_msg']) { |
|
| 947 | + echo ' |
|
| 890 | 948 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 949 | + } |
|
| 891 | 950 | |
| 892 | 951 | // Maybe we can approve it, maybe we should? |
| 893 | - if ($message['can_approve']) |
|
| 894 | - echo ' |
|
| 952 | + if ($message['can_approve']) { |
|
| 953 | + echo ' |
|
| 895 | 954 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 955 | + } |
|
| 896 | 956 | |
| 897 | 957 | // Maybe we can unapprove it? |
| 898 | - if ($message['can_unapprove']) |
|
| 899 | - echo ' |
|
| 958 | + if ($message['can_unapprove']) { |
|
| 959 | + echo ' |
|
| 900 | 960 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 961 | + } |
|
| 901 | 962 | |
| 902 | 963 | echo ' |
| 903 | 964 | </ul> |
| 904 | 965 | </li>'; |
| 905 | 966 | |
| 906 | 967 | // Show a checkbox for quick moderation? |
| 907 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 908 | - echo ' |
|
| 968 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 969 | + echo ' |
|
| 909 | 970 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 971 | + } |
|
| 910 | 972 | |
| 911 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 912 | - echo ' |
|
| 973 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 974 | + echo ' |
|
| 913 | 975 | </ul>'; |
| 976 | + } |
|
| 914 | 977 | } |
| 915 | 978 | |
| 916 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 917 | - echo ' |
|
| 979 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 980 | + echo ' |
|
| 918 | 981 | </div>'; |
| 982 | + } |
|
| 919 | 983 | |
| 920 | 984 | echo ' |
| 921 | 985 | </div> |
@@ -928,9 +992,10 @@ discard block |
||
| 928 | 992 | <div class="custom_fields_above_signature"> |
| 929 | 993 | <ul class="nolist">'; |
| 930 | 994 | |
| 931 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 932 | - echo ' |
|
| 995 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 996 | + echo ' |
|
| 933 | 997 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 998 | + } |
|
| 934 | 999 | |
| 935 | 1000 | echo ' |
| 936 | 1001 | </ul> |
@@ -938,9 +1003,10 @@ discard block |
||
| 938 | 1003 | } |
| 939 | 1004 | |
| 940 | 1005 | // Show the member's signature? |
| 941 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 942 | - echo ' |
|
| 1006 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 1007 | + echo ' |
|
| 943 | 1008 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
| 1009 | + } |
|
| 944 | 1010 | |
| 945 | 1011 | |
| 946 | 1012 | // Are there any custom profile fields for below the signature? |
@@ -950,9 +1016,10 @@ discard block |
||
| 950 | 1016 | <div class="custom_fields_below_signature"> |
| 951 | 1017 | <ul class="nolist">'; |
| 952 | 1018 | |
| 953 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 954 | - echo ' |
|
| 1019 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 1020 | + echo ' |
|
| 955 | 1021 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1022 | + } |
|
| 956 | 1023 | |
| 957 | 1024 | echo ' |
| 958 | 1025 | </ul> |
@@ -1000,8 +1067,8 @@ discard block |
||
| 1000 | 1067 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 1001 | 1068 | |
| 1002 | 1069 | // Guests just need more. |
| 1003 | - if ($context['user']['is_guest']) |
|
| 1004 | - echo ' |
|
| 1070 | + if ($context['user']['is_guest']) { |
|
| 1071 | + echo ' |
|
| 1005 | 1072 | <dl id="post_header"> |
| 1006 | 1073 | <dt> |
| 1007 | 1074 | ', $txt['name'], ': |
@@ -1016,6 +1083,7 @@ discard block |
||
| 1016 | 1083 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required> |
| 1017 | 1084 | </dd> |
| 1018 | 1085 | </dl>'; |
| 1086 | + } |
|
| 1019 | 1087 | |
| 1020 | 1088 | echo ' |
| 1021 | 1089 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1063,8 +1131,8 @@ discard block |
||
| 1063 | 1131 | <br class="clear">'; |
| 1064 | 1132 | |
| 1065 | 1133 | // draft autosave available and the user has it enabled? |
| 1066 | - if (!empty($context['drafts_autosave'])) |
|
| 1067 | - echo ' |
|
| 1134 | + if (!empty($context['drafts_autosave'])) { |
|
| 1135 | + echo ' |
|
| 1068 | 1136 | <script> |
| 1069 | 1137 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1070 | 1138 | sSelf: \'oDraftAutoSave\', |
@@ -1076,10 +1144,12 @@ discard block |
||
| 1076 | 1144 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1077 | 1145 | }); |
| 1078 | 1146 | </script>'; |
| 1147 | + } |
|
| 1079 | 1148 | |
| 1080 | - if ($context['show_spellchecking']) |
|
| 1081 | - echo ' |
|
| 1149 | + if ($context['show_spellchecking']) { |
|
| 1150 | + echo ' |
|
| 1082 | 1151 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
| 1152 | + } |
|
| 1083 | 1153 | |
| 1084 | 1154 | echo ' |
| 1085 | 1155 | <script> |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | |
| 1626 | 1626 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1627 | 1627 | set_error_handler( |
| 1628 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1628 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1629 | 1629 | { |
| 1630 | 1630 | if ($support_js) |
| 1631 | 1631 | return true; |
@@ -2610,94 +2610,94 @@ discard block |
||
| 2610 | 2610 | // Translation table for the character sets not native for MySQL. |
| 2611 | 2611 | $translation_tables = array( |
| 2612 | 2612 | 'windows-1255' => array( |
| 2613 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2614 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2615 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2616 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2617 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2618 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2619 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2620 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2621 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2622 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2623 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2624 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2625 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2626 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2627 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2628 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2629 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2630 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2631 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2632 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2633 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2634 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2635 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2636 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2637 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2638 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2639 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2640 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2641 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2642 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2643 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2644 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2645 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2646 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2647 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2648 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2649 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2650 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2651 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2652 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2653 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2654 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2613 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2614 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2615 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2616 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2617 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2618 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2619 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2620 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2621 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2622 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2623 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2624 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2625 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2626 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2627 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2628 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2629 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2630 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2631 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2632 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2633 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2634 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2635 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2636 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2637 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2638 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2639 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2640 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2641 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2642 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2643 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2644 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2645 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2646 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2647 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2648 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2649 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2650 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2651 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2652 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2653 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2654 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2655 | 2655 | '0xFA' => '0xD7AA', |
| 2656 | 2656 | ), |
| 2657 | 2657 | 'windows-1253' => array( |
| 2658 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2659 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2660 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2661 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2662 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2663 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2664 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2665 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2666 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2667 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2668 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2669 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2670 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2671 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2672 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2673 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2674 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2675 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2676 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2677 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2678 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2679 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2680 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2681 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2682 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2683 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2684 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2685 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2686 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2687 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2688 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2689 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2690 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2691 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2692 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2693 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2694 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2695 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2696 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2697 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2698 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2699 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2700 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2658 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2659 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2660 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2661 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2662 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2663 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2664 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2665 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2666 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2667 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2668 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2669 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2670 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2671 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2672 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2673 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2674 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2675 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2676 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2677 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2678 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2679 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2680 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2681 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2682 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2683 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2684 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2685 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2686 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2687 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2688 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2689 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2690 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2691 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2692 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2693 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2694 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2695 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2696 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2697 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2698 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2699 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2700 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2701 | 2701 | ), |
| 2702 | 2702 | ); |
| 2703 | 2703 | |
@@ -3799,7 +3799,7 @@ discard block |
||
| 3799 | 3799 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 3800 | 3800 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
| 3801 | 3801 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
| 3802 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
| 3802 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
| 3803 | 3803 | <span id="debuginfo"></span> |
| 3804 | 3804 | </div>'; |
| 3805 | 3805 | |
@@ -4300,7 +4300,7 @@ discard block |
||
| 4300 | 4300 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 4301 | 4301 | <input type="hidden" name="utf8_done" id="utf8_done" value="0"> |
| 4302 | 4302 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
| 4303 | - <div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;"> |
|
| 4303 | + <div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;"> |
|
| 4304 | 4304 | <span id="debuginfo"></span> |
| 4305 | 4305 | </div>'; |
| 4306 | 4306 | |
@@ -4401,7 +4401,7 @@ discard block |
||
| 4401 | 4401 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 4402 | 4402 | <input type="hidden" name="json_done" id="json_done" value="0"> |
| 4403 | 4403 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
| 4404 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
| 4404 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
| 4405 | 4405 | <span id="debuginfo"></span> |
| 4406 | 4406 | </div>'; |
| 4407 | 4407 | |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -197,8 +204,9 @@ discard block |
||
| 197 | 204 | 'db_error_skip' => true, |
| 198 | 205 | ) |
| 199 | 206 | ); |
| 200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 201 | - $modSettings[$row['variable']] = $row['value']; |
|
| 207 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 208 | + $modSettings[$row['variable']] = $row['value']; |
|
| 209 | + } |
|
| 202 | 210 | $smcFunc['db_free_result']($request); |
| 203 | 211 | } |
| 204 | 212 | |
@@ -208,10 +216,12 @@ discard block |
||
| 208 | 216 | $modSettings['theme_url'] = 'Themes/default'; |
| 209 | 217 | $modSettings['images_url'] = 'Themes/default/images'; |
| 210 | 218 | } |
| 211 | -if (!isset($settings['default_theme_url'])) |
|
| 219 | +if (!isset($settings['default_theme_url'])) { |
|
| 212 | 220 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 213 | -if (!isset($settings['default_theme_dir'])) |
|
| 221 | +} |
|
| 222 | +if (!isset($settings['default_theme_dir'])) { |
|
| 214 | 223 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 224 | +} |
|
| 215 | 225 | |
| 216 | 226 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 217 | 227 | // Default title... |
@@ -229,13 +239,15 @@ discard block |
||
| 229 | 239 | $support_js = $upcontext['upgrade_status']['js']; |
| 230 | 240 | |
| 231 | 241 | // Only set this if the upgrader status says so. |
| 232 | - if (empty($is_debug)) |
|
| 233 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 242 | + if (empty($is_debug)) { |
|
| 243 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // Load the language. |
| 236 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 237 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 238 | -} |
|
| 247 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 248 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | + } |
|
| 250 | + } |
|
| 239 | 251 | // Set the defaults. |
| 240 | 252 | else |
| 241 | 253 | { |
@@ -253,15 +265,18 @@ discard block |
||
| 253 | 265 | } |
| 254 | 266 | |
| 255 | 267 | // If this isn't the first stage see whether they are logging in and resuming. |
| 256 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 268 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 257 | 269 | checkLogin(); |
| 270 | +} |
|
| 258 | 271 | |
| 259 | -if ($command_line) |
|
| 272 | +if ($command_line) { |
|
| 260 | 273 | cmdStep0(); |
| 274 | +} |
|
| 261 | 275 | |
| 262 | 276 | // Don't error if we're using xml. |
| 263 | -if (isset($_GET['xml'])) |
|
| 277 | +if (isset($_GET['xml'])) { |
|
| 264 | 278 | $upcontext['return_error'] = true; |
| 279 | +} |
|
| 265 | 280 | |
| 266 | 281 | // Loop through all the steps doing each one as required. |
| 267 | 282 | $upcontext['overall_percent'] = 0; |
@@ -282,9 +297,9 @@ discard block |
||
| 282 | 297 | } |
| 283 | 298 | |
| 284 | 299 | // Call the step and if it returns false that means pause! |
| 285 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 286 | - break; |
|
| 287 | - elseif (function_exists($step[2])) { |
|
| 300 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 301 | + break; |
|
| 302 | + } elseif (function_exists($step[2])) { |
|
| 288 | 303 | //Start each new step with this unset, so the 'normal' template is called first |
| 289 | 304 | unset($_GET['xml']); |
| 290 | 305 | //Clear out warnings at the start of each step |
@@ -330,17 +345,18 @@ discard block |
||
| 330 | 345 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 331 | 346 | if (!empty($command_line)) |
| 332 | 347 | { |
| 333 | - if (function_exists('debug_print_backtrace')) |
|
| 334 | - debug_print_backtrace(); |
|
| 348 | + if (function_exists('debug_print_backtrace')) { |
|
| 349 | + debug_print_backtrace(); |
|
| 350 | + } |
|
| 335 | 351 | |
| 336 | 352 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 337 | 353 | flush(); |
| 338 | 354 | die(); |
| 339 | 355 | } |
| 340 | 356 | |
| 341 | - if (!isset($_GET['xml'])) |
|
| 342 | - template_upgrade_above(); |
|
| 343 | - else |
|
| 357 | + if (!isset($_GET['xml'])) { |
|
| 358 | + template_upgrade_above(); |
|
| 359 | + } else |
|
| 344 | 360 | { |
| 345 | 361 | header('Content-Type: text/xml; charset=UTF-8'); |
| 346 | 362 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -362,25 +378,29 @@ discard block |
||
| 362 | 378 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 363 | 379 | |
| 364 | 380 | // Custom stuff to pass back? |
| 365 | - if (!empty($upcontext['query_string'])) |
|
| 366 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 381 | + if (!empty($upcontext['query_string'])) { |
|
| 382 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | // Call the appropriate subtemplate |
| 369 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 370 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 371 | - else |
|
| 372 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 386 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 387 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 388 | + } else { |
|
| 389 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 390 | + } |
|
| 373 | 391 | } |
| 374 | 392 | |
| 375 | 393 | // Was there an error? |
| 376 | - if (!empty($upcontext['forced_error_message'])) |
|
| 377 | - echo $upcontext['forced_error_message']; |
|
| 394 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 395 | + echo $upcontext['forced_error_message']; |
|
| 396 | + } |
|
| 378 | 397 | |
| 379 | 398 | // Show the footer. |
| 380 | - if (!isset($_GET['xml'])) |
|
| 381 | - template_upgrade_below(); |
|
| 382 | - else |
|
| 383 | - template_xml_below(); |
|
| 399 | + if (!isset($_GET['xml'])) { |
|
| 400 | + template_upgrade_below(); |
|
| 401 | + } else { |
|
| 402 | + template_xml_below(); |
|
| 403 | + } |
|
| 384 | 404 | } |
| 385 | 405 | |
| 386 | 406 | |
@@ -392,15 +412,19 @@ discard block |
||
| 392 | 412 | $seconds = intval($active % 60); |
| 393 | 413 | |
| 394 | 414 | $totalTime = ''; |
| 395 | - if ($hours > 0) |
|
| 396 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 397 | - if ($minutes > 0) |
|
| 398 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 399 | - if ($seconds > 0) |
|
| 400 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 415 | + if ($hours > 0) { |
|
| 416 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 417 | + } |
|
| 418 | + if ($minutes > 0) { |
|
| 419 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 420 | + } |
|
| 421 | + if ($seconds > 0) { |
|
| 422 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 423 | + } |
|
| 401 | 424 | |
| 402 | - if (!empty($totalTime)) |
|
| 403 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 425 | + if (!empty($totalTime)) { |
|
| 426 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 427 | + } |
|
| 404 | 428 | } |
| 405 | 429 | |
| 406 | 430 | // Bang - gone! |
@@ -413,8 +437,9 @@ discard block |
||
| 413 | 437 | global $upgradeurl, $upcontext, $command_line; |
| 414 | 438 | |
| 415 | 439 | // Command line users can't be redirected. |
| 416 | - if ($command_line) |
|
| 417 | - upgradeExit(true); |
|
| 440 | + if ($command_line) { |
|
| 441 | + upgradeExit(true); |
|
| 442 | + } |
|
| 418 | 443 | |
| 419 | 444 | // Are we providing the core info? |
| 420 | 445 | if ($addForm) |
@@ -440,12 +465,14 @@ discard block |
||
| 440 | 465 | define('SMF', 1); |
| 441 | 466 | |
| 442 | 467 | // Start the session. |
| 443 | - if (@ini_get('session.save_handler') == 'user') |
|
| 444 | - @ini_set('session.save_handler', 'files'); |
|
| 468 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 469 | + @ini_set('session.save_handler', 'files'); |
|
| 470 | + } |
|
| 445 | 471 | @session_start(); |
| 446 | 472 | |
| 447 | - if (empty($smcFunc)) |
|
| 448 | - $smcFunc = array(); |
|
| 473 | + if (empty($smcFunc)) { |
|
| 474 | + $smcFunc = array(); |
|
| 475 | + } |
|
| 449 | 476 | |
| 450 | 477 | // We need this for authentication and some upgrade code |
| 451 | 478 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -472,24 +499,27 @@ discard block |
||
| 472 | 499 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 473 | 500 | |
| 474 | 501 | // Make the connection... |
| 475 | - if (empty($db_connection)) |
|
| 476 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 477 | - else |
|
| 478 | - // If we've returned here, ping/reconnect to be safe |
|
| 502 | + if (empty($db_connection)) { |
|
| 503 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 504 | + } else { |
|
| 505 | + // If we've returned here, ping/reconnect to be safe |
|
| 479 | 506 | $smcFunc['db_ping']($db_connection); |
| 507 | + } |
|
| 480 | 508 | |
| 481 | 509 | // Oh dear god!! |
| 482 | - if ($db_connection === null) |
|
| 483 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 510 | + if ($db_connection === null) { |
|
| 511 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 512 | + } |
|
| 484 | 513 | |
| 485 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 486 | - $smcFunc['db_query']('', ' |
|
| 514 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 515 | + $smcFunc['db_query']('', ' |
|
| 487 | 516 | SET NAMES {string:db_character_set}', |
| 488 | 517 | array( |
| 489 | 518 | 'db_error_skip' => true, |
| 490 | 519 | 'db_character_set' => $db_character_set, |
| 491 | 520 | ) |
| 492 | 521 | ); |
| 522 | + } |
|
| 493 | 523 | |
| 494 | 524 | // Load the modSettings data... |
| 495 | 525 | $request = $smcFunc['db_query']('', ' |
@@ -500,11 +530,11 @@ discard block |
||
| 500 | 530 | ) |
| 501 | 531 | ); |
| 502 | 532 | $modSettings = array(); |
| 503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 504 | - $modSettings[$row['variable']] = $row['value']; |
|
| 533 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 534 | + $modSettings[$row['variable']] = $row['value']; |
|
| 535 | + } |
|
| 505 | 536 | $smcFunc['db_free_result']($request); |
| 506 | - } |
|
| 507 | - else |
|
| 537 | + } else |
|
| 508 | 538 | { |
| 509 | 539 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 510 | 540 | } |
@@ -518,9 +548,10 @@ discard block |
||
| 518 | 548 | cleanRequest(); |
| 519 | 549 | } |
| 520 | 550 | |
| 521 | - if (!isset($_GET['substep'])) |
|
| 522 | - $_GET['substep'] = 0; |
|
| 523 | -} |
|
| 551 | + if (!isset($_GET['substep'])) { |
|
| 552 | + $_GET['substep'] = 0; |
|
| 553 | + } |
|
| 554 | + } |
|
| 524 | 555 | |
| 525 | 556 | function initialize_inputs() |
| 526 | 557 | { |
@@ -550,8 +581,9 @@ discard block |
||
| 550 | 581 | $dh = opendir(dirname(__FILE__)); |
| 551 | 582 | while ($file = readdir($dh)) |
| 552 | 583 | { |
| 553 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 554 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 584 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 585 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 586 | + } |
|
| 555 | 587 | } |
| 556 | 588 | closedir($dh); |
| 557 | 589 | |
@@ -580,8 +612,9 @@ discard block |
||
| 580 | 612 | $temp = 'upgrade_php?step'; |
| 581 | 613 | while (strlen($temp) > 4) |
| 582 | 614 | { |
| 583 | - if (isset($_GET[$temp])) |
|
| 584 | - unset($_GET[$temp]); |
|
| 615 | + if (isset($_GET[$temp])) { |
|
| 616 | + unset($_GET[$temp]); |
|
| 617 | + } |
|
| 585 | 618 | $temp = substr($temp, 1); |
| 586 | 619 | } |
| 587 | 620 | |
@@ -608,32 +641,39 @@ discard block |
||
| 608 | 641 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 609 | 642 | |
| 610 | 643 | // Need legacy scripts? |
| 611 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 612 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 644 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 645 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 646 | + } |
|
| 647 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 648 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 649 | + } |
|
| 650 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 651 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 652 | + } |
|
| 617 | 653 | |
| 618 | 654 | // We don't need "-utf8" files anymore... |
| 619 | 655 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 620 | 656 | |
| 621 | 657 | // This needs to exist! |
| 622 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 623 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 624 | - else |
|
| 625 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 658 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 659 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 660 | + } else { |
|
| 661 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 662 | + } |
|
| 626 | 663 | |
| 627 | - if (!$check) |
|
| 628 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 664 | + if (!$check) { |
|
| 665 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 629 | 666 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 667 | + } |
|
| 630 | 668 | |
| 631 | 669 | // Do they meet the install requirements? |
| 632 | - if (!php_version_check()) |
|
| 633 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 670 | + if (!php_version_check()) { |
|
| 671 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 672 | + } |
|
| 634 | 673 | |
| 635 | - if (!db_version_check()) |
|
| 636 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 674 | + if (!db_version_check()) { |
|
| 675 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 676 | + } |
|
| 637 | 677 | |
| 638 | 678 | // Do some checks to make sure they have proper privileges |
| 639 | 679 | db_extend('packages'); |
@@ -648,14 +688,16 @@ discard block |
||
| 648 | 688 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 649 | 689 | |
| 650 | 690 | // Sorry... we need CREATE, ALTER and DROP |
| 651 | - if (!$create || !$alter || !$drop) |
|
| 652 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 691 | + if (!$create || !$alter || !$drop) { |
|
| 692 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Do a quick version spot check. |
| 655 | 696 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 656 | 697 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 657 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 658 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 698 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 699 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 700 | + } |
|
| 659 | 701 | |
| 660 | 702 | // What absolutely needs to be writable? |
| 661 | 703 | $writable_files = array( |
@@ -677,12 +719,13 @@ discard block |
||
| 677 | 719 | quickFileWritable($custom_av_dir); |
| 678 | 720 | |
| 679 | 721 | // Are we good now? |
| 680 | - if (!is_writable($custom_av_dir)) |
|
| 681 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 682 | - elseif ($need_settings_update) |
|
| 722 | + if (!is_writable($custom_av_dir)) { |
|
| 723 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 724 | + } elseif ($need_settings_update) |
|
| 683 | 725 | { |
| 684 | - if (!function_exists('cache_put_data')) |
|
| 685 | - require_once($sourcedir . '/Load.php'); |
|
| 726 | + if (!function_exists('cache_put_data')) { |
|
| 727 | + require_once($sourcedir . '/Load.php'); |
|
| 728 | + } |
|
| 686 | 729 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 687 | 730 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 688 | 731 | } |
@@ -691,28 +734,33 @@ discard block |
||
| 691 | 734 | |
| 692 | 735 | // Check the cache directory. |
| 693 | 736 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 694 | - if (!file_exists($cachedir_temp)) |
|
| 695 | - @mkdir($cachedir_temp); |
|
| 696 | - if (!file_exists($cachedir_temp)) |
|
| 697 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 698 | - |
|
| 699 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 700 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 701 | - elseif (!isset($_GET['skiplang'])) |
|
| 737 | + if (!file_exists($cachedir_temp)) { |
|
| 738 | + @mkdir($cachedir_temp); |
|
| 739 | + } |
|
| 740 | + if (!file_exists($cachedir_temp)) { |
|
| 741 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 745 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 746 | + } elseif (!isset($_GET['skiplang'])) |
|
| 702 | 747 | { |
| 703 | 748 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 704 | 749 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 705 | 750 | |
| 706 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 707 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 751 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 752 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 753 | + } |
|
| 708 | 754 | } |
| 709 | 755 | |
| 710 | - if (!makeFilesWritable($writable_files)) |
|
| 711 | - return false; |
|
| 756 | + if (!makeFilesWritable($writable_files)) { |
|
| 757 | + return false; |
|
| 758 | + } |
|
| 712 | 759 | |
| 713 | 760 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 714 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 715 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 761 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 762 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 763 | + } |
|
| 716 | 764 | |
| 717 | 765 | // Upgrade the agreement. |
| 718 | 766 | elseif (isset($modSettings['agreement'])) |
@@ -723,8 +771,8 @@ discard block |
||
| 723 | 771 | } |
| 724 | 772 | |
| 725 | 773 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 726 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 727 | - $upcontext['warning'] = ' |
|
| 774 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 775 | + $upcontext['warning'] = ' |
|
| 728 | 776 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 729 | 777 | <ul> |
| 730 | 778 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -732,19 +780,23 @@ discard block |
||
| 732 | 780 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 733 | 781 | </ul> |
| 734 | 782 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 783 | + } |
|
| 735 | 784 | |
| 736 | 785 | // Confirm mbstring is loaded... |
| 737 | - if (!extension_loaded('mbstring')) |
|
| 738 | - return throw_error($txt['install_no_mbstring']); |
|
| 786 | + if (!extension_loaded('mbstring')) { |
|
| 787 | + return throw_error($txt['install_no_mbstring']); |
|
| 788 | + } |
|
| 739 | 789 | |
| 740 | 790 | // Check for https stream support. |
| 741 | 791 | $supported_streams = stream_get_wrappers(); |
| 742 | - if (!in_array('https', $supported_streams)) |
|
| 743 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 792 | + if (!in_array('https', $supported_streams)) { |
|
| 793 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 794 | + } |
|
| 744 | 795 | |
| 745 | 796 | // Either we're logged in or we're going to present the login. |
| 746 | - if (checkLogin()) |
|
| 747 | - return true; |
|
| 797 | + if (checkLogin()) { |
|
| 798 | + return true; |
|
| 799 | + } |
|
| 748 | 800 | |
| 749 | 801 | $upcontext += createToken('login'); |
| 750 | 802 | |
@@ -758,15 +810,17 @@ discard block |
||
| 758 | 810 | global $smcFunc, $db_type, $support_js; |
| 759 | 811 | |
| 760 | 812 | // Don't bother if the security is disabled. |
| 761 | - if ($disable_security) |
|
| 762 | - return true; |
|
| 813 | + if ($disable_security) { |
|
| 814 | + return true; |
|
| 815 | + } |
|
| 763 | 816 | |
| 764 | 817 | // Are we trying to login? |
| 765 | 818 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 766 | 819 | { |
| 767 | 820 | // If we've disabled security pick a suitable name! |
| 768 | - if (empty($_POST['user'])) |
|
| 769 | - $_POST['user'] = 'Administrator'; |
|
| 821 | + if (empty($_POST['user'])) { |
|
| 822 | + $_POST['user'] = 'Administrator'; |
|
| 823 | + } |
|
| 770 | 824 | |
| 771 | 825 | // Before 2.0 these column names were different! |
| 772 | 826 | $oldDB = false; |
@@ -781,16 +835,17 @@ discard block |
||
| 781 | 835 | 'db_error_skip' => true, |
| 782 | 836 | ) |
| 783 | 837 | ); |
| 784 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 785 | - $oldDB = true; |
|
| 838 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 839 | + $oldDB = true; |
|
| 840 | + } |
|
| 786 | 841 | $smcFunc['db_free_result']($request); |
| 787 | 842 | } |
| 788 | 843 | |
| 789 | 844 | // Get what we believe to be their details. |
| 790 | 845 | if (!$disable_security) |
| 791 | 846 | { |
| 792 | - if ($oldDB) |
|
| 793 | - $request = $smcFunc['db_query']('', ' |
|
| 847 | + if ($oldDB) { |
|
| 848 | + $request = $smcFunc['db_query']('', ' |
|
| 794 | 849 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 795 | 850 | additionalGroups AS additional_groups, lngfile |
| 796 | 851 | FROM {db_prefix}members |
@@ -800,8 +855,8 @@ discard block |
||
| 800 | 855 | 'db_error_skip' => true, |
| 801 | 856 | ) |
| 802 | 857 | ); |
| 803 | - else |
|
| 804 | - $request = $smcFunc['db_query']('', ' |
|
| 858 | + } else { |
|
| 859 | + $request = $smcFunc['db_query']('', ' |
|
| 805 | 860 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 806 | 861 | FROM {db_prefix}members |
| 807 | 862 | WHERE member_name = {string:member_name}', |
@@ -810,6 +865,7 @@ discard block |
||
| 810 | 865 | 'db_error_skip' => true, |
| 811 | 866 | ) |
| 812 | 867 | ); |
| 868 | + } |
|
| 813 | 869 | if ($smcFunc['db_num_rows']($request) != 0) |
| 814 | 870 | { |
| 815 | 871 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -817,16 +873,17 @@ discard block |
||
| 817 | 873 | $groups = explode(',', $addGroups); |
| 818 | 874 | $groups[] = $id_group; |
| 819 | 875 | |
| 820 | - foreach ($groups as $k => $v) |
|
| 821 | - $groups[$k] = (int) $v; |
|
| 876 | + foreach ($groups as $k => $v) { |
|
| 877 | + $groups[$k] = (int) $v; |
|
| 878 | + } |
|
| 822 | 879 | |
| 823 | 880 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 824 | 881 | |
| 825 | 882 | // We don't use "-utf8" anymore... |
| 826 | 883 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 884 | + } else { |
|
| 885 | + $upcontext['username_incorrect'] = true; |
|
| 827 | 886 | } |
| 828 | - else |
|
| 829 | - $upcontext['username_incorrect'] = true; |
|
| 830 | 887 | $smcFunc['db_free_result']($request); |
| 831 | 888 | } |
| 832 | 889 | $upcontext['username'] = $_POST['user']; |
@@ -836,13 +893,14 @@ discard block |
||
| 836 | 893 | { |
| 837 | 894 | $upcontext['upgrade_status']['js'] = 1; |
| 838 | 895 | $support_js = 1; |
| 896 | + } else { |
|
| 897 | + $support_js = 0; |
|
| 839 | 898 | } |
| 840 | - else |
|
| 841 | - $support_js = 0; |
|
| 842 | 899 | |
| 843 | 900 | // Note down the version we are coming from. |
| 844 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 845 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 901 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 902 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 903 | + } |
|
| 846 | 904 | |
| 847 | 905 | // Didn't get anywhere? |
| 848 | 906 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -876,15 +934,15 @@ discard block |
||
| 876 | 934 | 'db_error_skip' => true, |
| 877 | 935 | ) |
| 878 | 936 | ); |
| 879 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 880 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 937 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 938 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 939 | + } |
|
| 881 | 940 | $smcFunc['db_free_result']($request); |
| 882 | 941 | } |
| 883 | 942 | |
| 884 | 943 | $upcontext['user']['id'] = $id_member; |
| 885 | 944 | $upcontext['user']['name'] = $name; |
| 886 | - } |
|
| 887 | - else |
|
| 945 | + } else |
|
| 888 | 946 | { |
| 889 | 947 | $upcontext['user']['id'] = 1; |
| 890 | 948 | $upcontext['user']['name'] = 'Administrator'; |
@@ -900,11 +958,11 @@ discard block |
||
| 900 | 958 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 901 | 959 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 902 | 960 | |
| 903 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 904 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 905 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 906 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 907 | - else |
|
| 961 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 962 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 963 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 964 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 965 | + } else |
|
| 908 | 966 | { |
| 909 | 967 | // Set this as the new language. |
| 910 | 968 | $upcontext['language'] = $user_language; |
@@ -948,8 +1006,9 @@ discard block |
||
| 948 | 1006 | unset($member_columns); |
| 949 | 1007 | |
| 950 | 1008 | // If we've not submitted then we're done. |
| 951 | - if (empty($_POST['upcont'])) |
|
| 952 | - return false; |
|
| 1009 | + if (empty($_POST['upcont'])) { |
|
| 1010 | + return false; |
|
| 1011 | + } |
|
| 953 | 1012 | |
| 954 | 1013 | // Firstly, if they're enabling SM stat collection just do it. |
| 955 | 1014 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -969,16 +1028,17 @@ discard block |
||
| 969 | 1028 | fwrite($fp, $out); |
| 970 | 1029 | |
| 971 | 1030 | $return_data = ''; |
| 972 | - while (!feof($fp)) |
|
| 973 | - $return_data .= fgets($fp, 128); |
|
| 1031 | + while (!feof($fp)) { |
|
| 1032 | + $return_data .= fgets($fp, 128); |
|
| 1033 | + } |
|
| 974 | 1034 | |
| 975 | 1035 | fclose($fp); |
| 976 | 1036 | |
| 977 | 1037 | // Get the unique site ID. |
| 978 | 1038 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 979 | 1039 | |
| 980 | - if (!empty($ID[1])) |
|
| 981 | - $smcFunc['db_insert']('replace', |
|
| 1040 | + if (!empty($ID[1])) { |
|
| 1041 | + $smcFunc['db_insert']('replace', |
|
| 982 | 1042 | $db_prefix . 'settings', |
| 983 | 1043 | array('variable' => 'string', 'value' => 'string'), |
| 984 | 1044 | array( |
@@ -987,9 +1047,9 @@ discard block |
||
| 987 | 1047 | ), |
| 988 | 1048 | array('variable') |
| 989 | 1049 | ); |
| 1050 | + } |
|
| 990 | 1051 | } |
| 991 | - } |
|
| 992 | - else |
|
| 1052 | + } else |
|
| 993 | 1053 | { |
| 994 | 1054 | $smcFunc['db_insert']('replace', |
| 995 | 1055 | $db_prefix . 'settings', |
@@ -1000,8 +1060,8 @@ discard block |
||
| 1000 | 1060 | } |
| 1001 | 1061 | } |
| 1002 | 1062 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1003 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1004 | - $smcFunc['db_query']('', ' |
|
| 1063 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1064 | + $smcFunc['db_query']('', ' |
|
| 1005 | 1065 | DELETE FROM {db_prefix}settings |
| 1006 | 1066 | WHERE variable = {string:enable_sm_stats}', |
| 1007 | 1067 | array( |
@@ -1009,6 +1069,7 @@ discard block |
||
| 1009 | 1069 | 'db_error_skip' => true, |
| 1010 | 1070 | ) |
| 1011 | 1071 | ); |
| 1072 | + } |
|
| 1012 | 1073 | |
| 1013 | 1074 | // Deleting old karma stuff? |
| 1014 | 1075 | if (!empty($_POST['delete_karma'])) |
@@ -1023,20 +1084,22 @@ discard block |
||
| 1023 | 1084 | ); |
| 1024 | 1085 | |
| 1025 | 1086 | // Cleaning up old karma member settings. |
| 1026 | - if ($upcontext['karma_installed']['good']) |
|
| 1027 | - $smcFunc['db_query']('', ' |
|
| 1087 | + if ($upcontext['karma_installed']['good']) { |
|
| 1088 | + $smcFunc['db_query']('', ' |
|
| 1028 | 1089 | ALTER TABLE {db_prefix}members |
| 1029 | 1090 | DROP karma_good', |
| 1030 | 1091 | array() |
| 1031 | 1092 | ); |
| 1093 | + } |
|
| 1032 | 1094 | |
| 1033 | 1095 | // Does karma bad was enable? |
| 1034 | - if ($upcontext['karma_installed']['bad']) |
|
| 1035 | - $smcFunc['db_query']('', ' |
|
| 1096 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1097 | + $smcFunc['db_query']('', ' |
|
| 1036 | 1098 | ALTER TABLE {db_prefix}members |
| 1037 | 1099 | DROP karma_bad', |
| 1038 | 1100 | array() |
| 1039 | 1101 | ); |
| 1102 | + } |
|
| 1040 | 1103 | |
| 1041 | 1104 | // Cleaning up old karma permissions. |
| 1042 | 1105 | $smcFunc['db_query']('', ' |
@@ -1049,32 +1112,37 @@ discard block |
||
| 1049 | 1112 | } |
| 1050 | 1113 | |
| 1051 | 1114 | // Emptying the error log? |
| 1052 | - if (!empty($_POST['empty_error'])) |
|
| 1053 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1115 | + if (!empty($_POST['empty_error'])) { |
|
| 1116 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1054 | 1117 | TRUNCATE {db_prefix}log_errors', |
| 1055 | 1118 | array( |
| 1056 | 1119 | ) |
| 1057 | 1120 | ); |
| 1121 | + } |
|
| 1058 | 1122 | |
| 1059 | 1123 | $changes = array(); |
| 1060 | 1124 | |
| 1061 | 1125 | // Add proxy settings. |
| 1062 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1063 | - $changes += array( |
|
| 1126 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1127 | + $changes += array( |
|
| 1064 | 1128 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1065 | 1129 | 'image_proxy_maxsize' => 5190, |
| 1066 | 1130 | 'image_proxy_enabled' => 0, |
| 1067 | 1131 | ); |
| 1132 | + } |
|
| 1068 | 1133 | |
| 1069 | 1134 | // If $boardurl reflects https, set force_ssl |
| 1070 | - if (!function_exists('cache_put_data')) |
|
| 1071 | - require_once($sourcedir . '/Load.php'); |
|
| 1072 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1073 | - updateSettings(array('force_ssl' => '2')); |
|
| 1135 | + if (!function_exists('cache_put_data')) { |
|
| 1136 | + require_once($sourcedir . '/Load.php'); |
|
| 1137 | + } |
|
| 1138 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1139 | + updateSettings(array('force_ssl' => '2')); |
|
| 1140 | + } |
|
| 1074 | 1141 | |
| 1075 | 1142 | // If we're overriding the language follow it through. |
| 1076 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1077 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1143 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1144 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1145 | + } |
|
| 1078 | 1146 | |
| 1079 | 1147 | if (!empty($_POST['maint'])) |
| 1080 | 1148 | { |
@@ -1086,26 +1154,29 @@ discard block |
||
| 1086 | 1154 | { |
| 1087 | 1155 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1088 | 1156 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1089 | - } |
|
| 1090 | - else |
|
| 1157 | + } else |
|
| 1091 | 1158 | { |
| 1092 | 1159 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1093 | 1160 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1094 | 1161 | } |
| 1095 | 1162 | } |
| 1096 | 1163 | |
| 1097 | - if ($command_line) |
|
| 1098 | - echo ' * Updating Settings.php...'; |
|
| 1164 | + if ($command_line) { |
|
| 1165 | + echo ' * Updating Settings.php...'; |
|
| 1166 | + } |
|
| 1099 | 1167 | |
| 1100 | 1168 | // Fix some old paths. |
| 1101 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1102 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1169 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1170 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1171 | + } |
|
| 1103 | 1172 | |
| 1104 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1105 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1173 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1174 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1175 | + } |
|
| 1106 | 1176 | |
| 1107 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1108 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1177 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1178 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1179 | + } |
|
| 1109 | 1180 | |
| 1110 | 1181 | // If they have a "host:port" setup for the host, split that into separate values |
| 1111 | 1182 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1116,32 +1187,36 @@ discard block |
||
| 1116 | 1187 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1117 | 1188 | |
| 1118 | 1189 | // Only set this if we're not using the default port |
| 1119 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1120 | - $changes['db_port'] = (int) $db_port; |
|
| 1121 | - } |
|
| 1122 | - elseif (!empty($db_port)) |
|
| 1190 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1191 | + $changes['db_port'] = (int) $db_port; |
|
| 1192 | + } |
|
| 1193 | + } elseif (!empty($db_port)) |
|
| 1123 | 1194 | { |
| 1124 | 1195 | // If db_port is set and is the same as the default, set it to '' |
| 1125 | 1196 | if ($db_type == 'mysql') |
| 1126 | 1197 | { |
| 1127 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1128 | - $changes['db_port'] = '\'\''; |
|
| 1129 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1130 | - $changes['db_port'] = '\'\''; |
|
| 1198 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1199 | + $changes['db_port'] = '\'\''; |
|
| 1200 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1201 | + $changes['db_port'] = '\'\''; |
|
| 1202 | + } |
|
| 1131 | 1203 | } |
| 1132 | 1204 | } |
| 1133 | 1205 | |
| 1134 | 1206 | // Maybe we haven't had this option yet? |
| 1135 | - if (empty($packagesdir)) |
|
| 1136 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1207 | + if (empty($packagesdir)) { |
|
| 1208 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1209 | + } |
|
| 1137 | 1210 | |
| 1138 | 1211 | // Add support for $tasksdir var. |
| 1139 | - if (empty($tasksdir)) |
|
| 1140 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1212 | + if (empty($tasksdir)) { |
|
| 1213 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1214 | + } |
|
| 1141 | 1215 | |
| 1142 | 1216 | // Make sure we fix the language as well. |
| 1143 | - if (stristr($language, '-utf8')) |
|
| 1144 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1217 | + if (stristr($language, '-utf8')) { |
|
| 1218 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1219 | + } |
|
| 1145 | 1220 | |
| 1146 | 1221 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1147 | 1222 | |
@@ -1149,8 +1224,9 @@ discard block |
||
| 1149 | 1224 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1150 | 1225 | updateSettingsFile($changes); |
| 1151 | 1226 | |
| 1152 | - if ($command_line) |
|
| 1153 | - echo ' Successful.' . "\n"; |
|
| 1227 | + if ($command_line) { |
|
| 1228 | + echo ' Successful.' . "\n"; |
|
| 1229 | + } |
|
| 1154 | 1230 | |
| 1155 | 1231 | // Are we doing debug? |
| 1156 | 1232 | if (isset($_POST['debug'])) |
@@ -1160,8 +1236,9 @@ discard block |
||
| 1160 | 1236 | } |
| 1161 | 1237 | |
| 1162 | 1238 | // If we're not backing up then jump one. |
| 1163 | - if (empty($_POST['backup'])) |
|
| 1164 | - $upcontext['current_step']++; |
|
| 1239 | + if (empty($_POST['backup'])) { |
|
| 1240 | + $upcontext['current_step']++; |
|
| 1241 | + } |
|
| 1165 | 1242 | |
| 1166 | 1243 | // If we've got here then let's proceed to the next step! |
| 1167 | 1244 | return true; |
@@ -1176,8 +1253,9 @@ discard block |
||
| 1176 | 1253 | $upcontext['page_title'] = 'Backup Database'; |
| 1177 | 1254 | |
| 1178 | 1255 | // Done it already - js wise? |
| 1179 | - if (!empty($_POST['backup_done'])) |
|
| 1180 | - return true; |
|
| 1256 | + if (!empty($_POST['backup_done'])) { |
|
| 1257 | + return true; |
|
| 1258 | + } |
|
| 1181 | 1259 | |
| 1182 | 1260 | // Some useful stuff here. |
| 1183 | 1261 | db_extend(); |
@@ -1191,9 +1269,10 @@ discard block |
||
| 1191 | 1269 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1192 | 1270 | |
| 1193 | 1271 | $table_names = array(); |
| 1194 | - foreach ($tables as $table) |
|
| 1195 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1272 | + foreach ($tables as $table) { |
|
| 1273 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1196 | 1274 | $table_names[] = $table; |
| 1275 | + } |
|
| 1197 | 1276 | |
| 1198 | 1277 | $upcontext['table_count'] = count($table_names); |
| 1199 | 1278 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1203,12 +1282,14 @@ discard block |
||
| 1203 | 1282 | $file_steps = $upcontext['table_count']; |
| 1204 | 1283 | |
| 1205 | 1284 | // What ones have we already done? |
| 1206 | - foreach ($table_names as $id => $table) |
|
| 1207 | - if ($id < $_GET['substep']) |
|
| 1285 | + foreach ($table_names as $id => $table) { |
|
| 1286 | + if ($id < $_GET['substep']) |
|
| 1208 | 1287 | $upcontext['previous_tables'][] = $table; |
| 1288 | + } |
|
| 1209 | 1289 | |
| 1210 | - if ($command_line) |
|
| 1211 | - echo 'Backing Up Tables.'; |
|
| 1290 | + if ($command_line) { |
|
| 1291 | + echo 'Backing Up Tables.'; |
|
| 1292 | + } |
|
| 1212 | 1293 | |
| 1213 | 1294 | // If we don't support javascript we backup here. |
| 1214 | 1295 | if (!$support_js || isset($_GET['xml'])) |
@@ -1227,8 +1308,9 @@ discard block |
||
| 1227 | 1308 | backupTable($table_names[$substep]); |
| 1228 | 1309 | |
| 1229 | 1310 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1230 | - if (isset($_GET['xml'])) |
|
| 1231 | - return upgradeExit(); |
|
| 1311 | + if (isset($_GET['xml'])) { |
|
| 1312 | + return upgradeExit(); |
|
| 1313 | + } |
|
| 1232 | 1314 | } |
| 1233 | 1315 | |
| 1234 | 1316 | if ($command_line) |
@@ -1261,9 +1343,10 @@ discard block |
||
| 1261 | 1343 | |
| 1262 | 1344 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1263 | 1345 | |
| 1264 | - if ($command_line) |
|
| 1265 | - echo ' done.'; |
|
| 1266 | -} |
|
| 1346 | + if ($command_line) { |
|
| 1347 | + echo ' done.'; |
|
| 1348 | + } |
|
| 1349 | + } |
|
| 1267 | 1350 | |
| 1268 | 1351 | // Step 2: Everything. |
| 1269 | 1352 | function DatabaseChanges() |
@@ -1272,8 +1355,9 @@ discard block |
||
| 1272 | 1355 | global $upcontext, $support_js, $db_type; |
| 1273 | 1356 | |
| 1274 | 1357 | // Have we just completed this? |
| 1275 | - if (!empty($_POST['database_done'])) |
|
| 1276 | - return true; |
|
| 1358 | + if (!empty($_POST['database_done'])) { |
|
| 1359 | + return true; |
|
| 1360 | + } |
|
| 1277 | 1361 | |
| 1278 | 1362 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1279 | 1363 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1288,15 +1372,16 @@ discard block |
||
| 1288 | 1372 | ); |
| 1289 | 1373 | |
| 1290 | 1374 | // How many files are there in total? |
| 1291 | - if (isset($_GET['filecount'])) |
|
| 1292 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1293 | - else |
|
| 1375 | + if (isset($_GET['filecount'])) { |
|
| 1376 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1377 | + } else |
|
| 1294 | 1378 | { |
| 1295 | 1379 | $upcontext['file_count'] = 0; |
| 1296 | 1380 | foreach ($files as $file) |
| 1297 | 1381 | { |
| 1298 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1299 | - $upcontext['file_count']++; |
|
| 1382 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1383 | + $upcontext['file_count']++; |
|
| 1384 | + } |
|
| 1300 | 1385 | } |
| 1301 | 1386 | } |
| 1302 | 1387 | |
@@ -1306,9 +1391,9 @@ discard block |
||
| 1306 | 1391 | $upcontext['cur_file_num'] = 0; |
| 1307 | 1392 | foreach ($files as $file) |
| 1308 | 1393 | { |
| 1309 | - if ($did_not_do) |
|
| 1310 | - $did_not_do--; |
|
| 1311 | - else |
|
| 1394 | + if ($did_not_do) { |
|
| 1395 | + $did_not_do--; |
|
| 1396 | + } else |
|
| 1312 | 1397 | { |
| 1313 | 1398 | $upcontext['cur_file_num']++; |
| 1314 | 1399 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1335,12 +1420,13 @@ discard block |
||
| 1335 | 1420 | // Flag to move on to the next. |
| 1336 | 1421 | $upcontext['completed_step'] = true; |
| 1337 | 1422 | // Did we complete the whole file? |
| 1338 | - if ($nextFile) |
|
| 1339 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1423 | + if ($nextFile) { |
|
| 1424 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1425 | + } |
|
| 1340 | 1426 | return upgradeExit(); |
| 1427 | + } elseif ($support_js) { |
|
| 1428 | + break; |
|
| 1341 | 1429 | } |
| 1342 | - elseif ($support_js) |
|
| 1343 | - break; |
|
| 1344 | 1430 | } |
| 1345 | 1431 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1346 | 1432 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1365,8 +1451,9 @@ discard block |
||
| 1365 | 1451 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1366 | 1452 | |
| 1367 | 1453 | // Now it's nice to have some of the basic SMF source files. |
| 1368 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1369 | - redirectLocation('&ssi=1'); |
|
| 1454 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1455 | + redirectLocation('&ssi=1'); |
|
| 1456 | + } |
|
| 1370 | 1457 | |
| 1371 | 1458 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1372 | 1459 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1382,14 +1469,16 @@ discard block |
||
| 1382 | 1469 | // Are we in maintenance mode? |
| 1383 | 1470 | if (isset($upcontext['user']['main'])) |
| 1384 | 1471 | { |
| 1385 | - if ($command_line) |
|
| 1386 | - echo ' * '; |
|
| 1472 | + if ($command_line) { |
|
| 1473 | + echo ' * '; |
|
| 1474 | + } |
|
| 1387 | 1475 | $upcontext['removed_maintenance'] = true; |
| 1388 | 1476 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1389 | 1477 | } |
| 1390 | 1478 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1391 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1392 | - $changes['maintenance'] = 1; |
|
| 1479 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1480 | + $changes['maintenance'] = 1; |
|
| 1481 | + } |
|
| 1393 | 1482 | |
| 1394 | 1483 | // Wipe this out... |
| 1395 | 1484 | $upcontext['user'] = array(); |
@@ -1404,9 +1493,9 @@ discard block |
||
| 1404 | 1493 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1405 | 1494 | |
| 1406 | 1495 | // Now is the perfect time to fetch the SM files. |
| 1407 | - if ($command_line) |
|
| 1408 | - cli_scheduled_fetchSMfiles(); |
|
| 1409 | - else |
|
| 1496 | + if ($command_line) { |
|
| 1497 | + cli_scheduled_fetchSMfiles(); |
|
| 1498 | + } else |
|
| 1410 | 1499 | { |
| 1411 | 1500 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1412 | 1501 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1414,8 +1503,9 @@ discard block |
||
| 1414 | 1503 | } |
| 1415 | 1504 | |
| 1416 | 1505 | // Log what we've done. |
| 1417 | - if (empty($user_info['id'])) |
|
| 1418 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1506 | + if (empty($user_info['id'])) { |
|
| 1507 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1508 | + } |
|
| 1419 | 1509 | |
| 1420 | 1510 | // Log the action manually, so CLI still works. |
| 1421 | 1511 | $smcFunc['db_insert']('', |
@@ -1434,8 +1524,9 @@ discard block |
||
| 1434 | 1524 | |
| 1435 | 1525 | // Save the current database version. |
| 1436 | 1526 | $server_version = $smcFunc['db_server_info'](); |
| 1437 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1438 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1527 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1528 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1529 | + } |
|
| 1439 | 1530 | |
| 1440 | 1531 | if ($command_line) |
| 1441 | 1532 | { |
@@ -1447,8 +1538,9 @@ discard block |
||
| 1447 | 1538 | |
| 1448 | 1539 | // Make sure it says we're done. |
| 1449 | 1540 | $upcontext['overall_percent'] = 100; |
| 1450 | - if (isset($upcontext['step_progress'])) |
|
| 1451 | - unset($upcontext['step_progress']); |
|
| 1541 | + if (isset($upcontext['step_progress'])) { |
|
| 1542 | + unset($upcontext['step_progress']); |
|
| 1543 | + } |
|
| 1452 | 1544 | |
| 1453 | 1545 | $_GET['substep'] = 0; |
| 1454 | 1546 | return false; |
@@ -1459,8 +1551,9 @@ discard block |
||
| 1459 | 1551 | { |
| 1460 | 1552 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1461 | 1553 | |
| 1462 | - if (empty($modSettings['time_format'])) |
|
| 1463 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1554 | + if (empty($modSettings['time_format'])) { |
|
| 1555 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1556 | + } |
|
| 1464 | 1557 | |
| 1465 | 1558 | // What files do we want to get |
| 1466 | 1559 | $request = $smcFunc['db_query']('', ' |
@@ -1494,8 +1587,9 @@ discard block |
||
| 1494 | 1587 | $file_data = fetch_web_data($url); |
| 1495 | 1588 | |
| 1496 | 1589 | // If we got an error - give up - the site might be down. |
| 1497 | - if ($file_data === false) |
|
| 1498 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1590 | + if ($file_data === false) { |
|
| 1591 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1592 | + } |
|
| 1499 | 1593 | |
| 1500 | 1594 | // Save the file to the database. |
| 1501 | 1595 | $smcFunc['db_query']('substring', ' |
@@ -1537,8 +1631,9 @@ discard block |
||
| 1537 | 1631 | $themeData = array(); |
| 1538 | 1632 | foreach ($values as $variable => $value) |
| 1539 | 1633 | { |
| 1540 | - if (!isset($value) || $value === null) |
|
| 1541 | - $value = 0; |
|
| 1634 | + if (!isset($value) || $value === null) { |
|
| 1635 | + $value = 0; |
|
| 1636 | + } |
|
| 1542 | 1637 | |
| 1543 | 1638 | $themeData[] = array(0, 1, $variable, $value); |
| 1544 | 1639 | } |
@@ -1567,8 +1662,9 @@ discard block |
||
| 1567 | 1662 | |
| 1568 | 1663 | foreach ($values as $variable => $value) |
| 1569 | 1664 | { |
| 1570 | - if (empty($modSettings[$value[0]])) |
|
| 1571 | - continue; |
|
| 1665 | + if (empty($modSettings[$value[0]])) { |
|
| 1666 | + continue; |
|
| 1667 | + } |
|
| 1572 | 1668 | |
| 1573 | 1669 | $smcFunc['db_query']('', ' |
| 1574 | 1670 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1654,19 +1750,21 @@ discard block |
||
| 1654 | 1750 | set_error_handler( |
| 1655 | 1751 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1656 | 1752 | { |
| 1657 | - if ($support_js) |
|
| 1658 | - return true; |
|
| 1659 | - else |
|
| 1660 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1753 | + if ($support_js) { |
|
| 1754 | + return true; |
|
| 1755 | + } else { |
|
| 1756 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1757 | + } |
|
| 1661 | 1758 | } |
| 1662 | 1759 | ); |
| 1663 | 1760 | |
| 1664 | 1761 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1665 | 1762 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1666 | - if ($db_type == 'mysql') |
|
| 1667 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1668 | - else |
|
| 1669 | - $db_collation = ''; |
|
| 1763 | + if ($db_type == 'mysql') { |
|
| 1764 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1765 | + } else { |
|
| 1766 | + $db_collation = ''; |
|
| 1767 | + } |
|
| 1670 | 1768 | |
| 1671 | 1769 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1672 | 1770 | |
@@ -1678,8 +1776,9 @@ discard block |
||
| 1678 | 1776 | $last_step = ''; |
| 1679 | 1777 | |
| 1680 | 1778 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1681 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1682 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1779 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1780 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1781 | + } |
|
| 1683 | 1782 | |
| 1684 | 1783 | // Count the total number of steps within this file - for progress. |
| 1685 | 1784 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1699,15 +1798,18 @@ discard block |
||
| 1699 | 1798 | $do_current = $substep >= $_GET['substep']; |
| 1700 | 1799 | |
| 1701 | 1800 | // Get rid of any comments in the beginning of the line... |
| 1702 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1703 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1801 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1802 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1803 | + } |
|
| 1704 | 1804 | |
| 1705 | 1805 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1706 | - if ($is_debug && !$support_js && $command_line) |
|
| 1707 | - flush(); |
|
| 1806 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1807 | + flush(); |
|
| 1808 | + } |
|
| 1708 | 1809 | |
| 1709 | - if (trim($line) === '') |
|
| 1710 | - continue; |
|
| 1810 | + if (trim($line) === '') { |
|
| 1811 | + continue; |
|
| 1812 | + } |
|
| 1711 | 1813 | |
| 1712 | 1814 | if (trim(substr($line, 0, 3)) === '---') |
| 1713 | 1815 | { |
@@ -1717,8 +1819,9 @@ discard block |
||
| 1717 | 1819 | if (trim($current_data) != '' && $type !== '}') |
| 1718 | 1820 | { |
| 1719 | 1821 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1720 | - if ($command_line) |
|
| 1721 | - echo $upcontext['error_message']; |
|
| 1822 | + if ($command_line) { |
|
| 1823 | + echo $upcontext['error_message']; |
|
| 1824 | + } |
|
| 1722 | 1825 | } |
| 1723 | 1826 | |
| 1724 | 1827 | if ($type == ' ') |
@@ -1736,17 +1839,18 @@ discard block |
||
| 1736 | 1839 | if ($do_current) |
| 1737 | 1840 | { |
| 1738 | 1841 | $upcontext['actioned_items'][] = $last_step; |
| 1739 | - if ($command_line) |
|
| 1740 | - echo ' * '; |
|
| 1842 | + if ($command_line) { |
|
| 1843 | + echo ' * '; |
|
| 1844 | + } |
|
| 1741 | 1845 | } |
| 1742 | - } |
|
| 1743 | - elseif ($type == '#') |
|
| 1846 | + } elseif ($type == '#') |
|
| 1744 | 1847 | { |
| 1745 | 1848 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1746 | 1849 | |
| 1747 | 1850 | $upcontext['current_debug_item_num']++; |
| 1748 | - if (trim($line) != '---#') |
|
| 1749 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1851 | + if (trim($line) != '---#') { |
|
| 1852 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1853 | + } |
|
| 1750 | 1854 | |
| 1751 | 1855 | // Have we already done something? |
| 1752 | 1856 | if (isset($_GET['xml']) && $done_something) |
@@ -1757,34 +1861,36 @@ discard block |
||
| 1757 | 1861 | |
| 1758 | 1862 | if ($do_current) |
| 1759 | 1863 | { |
| 1760 | - if (trim($line) == '---#' && $command_line) |
|
| 1761 | - echo ' done.', $endl; |
|
| 1762 | - elseif ($command_line) |
|
| 1763 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1764 | - elseif (trim($line) != '---#') |
|
| 1864 | + if (trim($line) == '---#' && $command_line) { |
|
| 1865 | + echo ' done.', $endl; |
|
| 1866 | + } elseif ($command_line) { |
|
| 1867 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1868 | + } elseif (trim($line) != '---#') |
|
| 1765 | 1869 | { |
| 1766 | - if ($is_debug) |
|
| 1767 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1870 | + if ($is_debug) { |
|
| 1871 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1872 | + } |
|
| 1768 | 1873 | } |
| 1769 | 1874 | } |
| 1770 | 1875 | |
| 1771 | 1876 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1772 | 1877 | { |
| 1773 | - if ($command_line) |
|
| 1774 | - echo ' * '; |
|
| 1775 | - else |
|
| 1776 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1878 | + if ($command_line) { |
|
| 1879 | + echo ' * '; |
|
| 1880 | + } else { |
|
| 1881 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1882 | + } |
|
| 1777 | 1883 | } |
| 1778 | 1884 | |
| 1779 | 1885 | // Small step - only if we're actually doing stuff. |
| 1780 | - if ($do_current) |
|
| 1781 | - nextSubstep(++$substep); |
|
| 1782 | - else |
|
| 1783 | - $substep++; |
|
| 1784 | - } |
|
| 1785 | - elseif ($type == '{') |
|
| 1786 | - $current_type = 'code'; |
|
| 1787 | - elseif ($type == '}') |
|
| 1886 | + if ($do_current) { |
|
| 1887 | + nextSubstep(++$substep); |
|
| 1888 | + } else { |
|
| 1889 | + $substep++; |
|
| 1890 | + } |
|
| 1891 | + } elseif ($type == '{') { |
|
| 1892 | + $current_type = 'code'; |
|
| 1893 | + } elseif ($type == '}') |
|
| 1788 | 1894 | { |
| 1789 | 1895 | $current_type = 'sql'; |
| 1790 | 1896 | |
@@ -1797,8 +1903,9 @@ discard block |
||
| 1797 | 1903 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1798 | 1904 | { |
| 1799 | 1905 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1800 | - if ($command_line) |
|
| 1801 | - echo $upcontext['error_message']; |
|
| 1906 | + if ($command_line) { |
|
| 1907 | + echo $upcontext['error_message']; |
|
| 1908 | + } |
|
| 1802 | 1909 | } |
| 1803 | 1910 | |
| 1804 | 1911 | // Done with code! |
@@ -1878,8 +1985,9 @@ discard block |
||
| 1878 | 1985 | $db_unbuffered = false; |
| 1879 | 1986 | |
| 1880 | 1987 | // Failure?! |
| 1881 | - if ($result !== false) |
|
| 1882 | - return $result; |
|
| 1988 | + if ($result !== false) { |
|
| 1989 | + return $result; |
|
| 1990 | + } |
|
| 1883 | 1991 | |
| 1884 | 1992 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1885 | 1993 | // If MySQL we do something more clever. |
@@ -1907,54 +2015,61 @@ discard block |
||
| 1907 | 2015 | { |
| 1908 | 2016 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1909 | 2017 | $result = mysqli_query($db_connection, $string); |
| 1910 | - if ($result !== false) |
|
| 1911 | - return $result; |
|
| 2018 | + if ($result !== false) { |
|
| 2019 | + return $result; |
|
| 2020 | + } |
|
| 1912 | 2021 | } |
| 1913 | - } |
|
| 1914 | - elseif ($mysqli_errno == 2013) |
|
| 2022 | + } elseif ($mysqli_errno == 2013) |
|
| 1915 | 2023 | { |
| 1916 | 2024 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1917 | 2025 | mysqli_select_db($db_connection, $db_name); |
| 1918 | 2026 | if ($db_connection) |
| 1919 | 2027 | { |
| 1920 | 2028 | $result = mysqli_query($db_connection, $string); |
| 1921 | - if ($result !== false) |
|
| 1922 | - return $result; |
|
| 2029 | + if ($result !== false) { |
|
| 2030 | + return $result; |
|
| 2031 | + } |
|
| 1923 | 2032 | } |
| 1924 | 2033 | } |
| 1925 | 2034 | // Duplicate column name... should be okay ;). |
| 1926 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1927 | - return false; |
|
| 2035 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2036 | + return false; |
|
| 2037 | + } |
|
| 1928 | 2038 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1929 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1930 | - return false; |
|
| 2039 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2040 | + return false; |
|
| 2041 | + } |
|
| 1931 | 2042 | // Creating an index on a non-existent column. |
| 1932 | - elseif ($mysqli_errno == 1072) |
|
| 1933 | - return false; |
|
| 1934 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1935 | - return false; |
|
| 2043 | + elseif ($mysqli_errno == 1072) { |
|
| 2044 | + return false; |
|
| 2045 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2046 | + return false; |
|
| 2047 | + } |
|
| 1936 | 2048 | } |
| 1937 | 2049 | // If a table already exists don't go potty. |
| 1938 | 2050 | else |
| 1939 | 2051 | { |
| 1940 | 2052 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1941 | 2053 | { |
| 1942 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1943 | - return true; |
|
| 1944 | - } |
|
| 1945 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2054 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2055 | + return true; |
|
| 2056 | + } |
|
| 2057 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1946 | 2058 | { |
| 1947 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1948 | - return true; |
|
| 2059 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2060 | + return true; |
|
| 2061 | + } |
|
| 1949 | 2062 | } |
| 1950 | 2063 | } |
| 1951 | 2064 | |
| 1952 | 2065 | // Get the query string so we pass everything. |
| 1953 | 2066 | $query_string = ''; |
| 1954 | - foreach ($_GET as $k => $v) |
|
| 1955 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1956 | - if (strlen($query_string) != 0) |
|
| 1957 | - $query_string = '?' . substr($query_string, 1); |
|
| 2067 | + foreach ($_GET as $k => $v) { |
|
| 2068 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2069 | + } |
|
| 2070 | + if (strlen($query_string) != 0) { |
|
| 2071 | + $query_string = '?' . substr($query_string, 1); |
|
| 2072 | + } |
|
| 1958 | 2073 | |
| 1959 | 2074 | if ($command_line) |
| 1960 | 2075 | { |
@@ -2009,16 +2124,18 @@ discard block |
||
| 2009 | 2124 | { |
| 2010 | 2125 | $found |= 1; |
| 2011 | 2126 | // Do some checks on the data if we have it set. |
| 2012 | - if (isset($change['col_type'])) |
|
| 2013 | - $found &= $change['col_type'] === $column['type']; |
|
| 2014 | - if (isset($change['null_allowed'])) |
|
| 2015 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2016 | - if (isset($change['default'])) |
|
| 2017 | - $found &= $change['default'] === $column['default']; |
|
| 2127 | + if (isset($change['col_type'])) { |
|
| 2128 | + $found &= $change['col_type'] === $column['type']; |
|
| 2129 | + } |
|
| 2130 | + if (isset($change['null_allowed'])) { |
|
| 2131 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2132 | + } |
|
| 2133 | + if (isset($change['default'])) { |
|
| 2134 | + $found &= $change['default'] === $column['default']; |
|
| 2135 | + } |
|
| 2018 | 2136 | } |
| 2019 | 2137 | } |
| 2020 | - } |
|
| 2021 | - elseif ($change['type'] === 'index') |
|
| 2138 | + } elseif ($change['type'] === 'index') |
|
| 2022 | 2139 | { |
| 2023 | 2140 | $request = upgrade_query(' |
| 2024 | 2141 | SHOW INDEX |
@@ -2027,9 +2144,10 @@ discard block |
||
| 2027 | 2144 | { |
| 2028 | 2145 | $cur_index = array(); |
| 2029 | 2146 | |
| 2030 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2031 | - if ($row['Key_name'] === $change['name']) |
|
| 2147 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2148 | + if ($row['Key_name'] === $change['name']) |
|
| 2032 | 2149 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2150 | + } |
|
| 2033 | 2151 | |
| 2034 | 2152 | ksort($cur_index, SORT_NUMERIC); |
| 2035 | 2153 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2039,14 +2157,17 @@ discard block |
||
| 2039 | 2157 | } |
| 2040 | 2158 | |
| 2041 | 2159 | // If we're trying to add and it's added, we're done. |
| 2042 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2043 | - return true; |
|
| 2160 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2161 | + return true; |
|
| 2162 | + } |
|
| 2044 | 2163 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2045 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2046 | - return true; |
|
| 2164 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2165 | + return true; |
|
| 2166 | + } |
|
| 2047 | 2167 | // Otherwise is it just a test? |
| 2048 | - elseif ($is_test) |
|
| 2049 | - return false; |
|
| 2168 | + elseif ($is_test) { |
|
| 2169 | + return false; |
|
| 2170 | + } |
|
| 2050 | 2171 | |
| 2051 | 2172 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2052 | 2173 | $running = false; |
@@ -2057,8 +2178,9 @@ discard block |
||
| 2057 | 2178 | SHOW FULL PROCESSLIST'); |
| 2058 | 2179 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2059 | 2180 | { |
| 2060 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2061 | - $found = true; |
|
| 2181 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2182 | + $found = true; |
|
| 2183 | + } |
|
| 2062 | 2184 | } |
| 2063 | 2185 | |
| 2064 | 2186 | // Can't find it? Then we need to run it fools! |
@@ -2070,8 +2192,9 @@ discard block |
||
| 2070 | 2192 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2071 | 2193 | ' . $change['text'], true) !== false; |
| 2072 | 2194 | |
| 2073 | - if (!$success) |
|
| 2074 | - return false; |
|
| 2195 | + if (!$success) { |
|
| 2196 | + return false; |
|
| 2197 | + } |
|
| 2075 | 2198 | |
| 2076 | 2199 | // Return |
| 2077 | 2200 | $running = true; |
@@ -2113,8 +2236,9 @@ discard block |
||
| 2113 | 2236 | 'db_error_skip' => true, |
| 2114 | 2237 | ) |
| 2115 | 2238 | ); |
| 2116 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2117 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2239 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2240 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2241 | + } |
|
| 2118 | 2242 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2119 | 2243 | $smcFunc['db_free_result']($request); |
| 2120 | 2244 | |
@@ -2136,18 +2260,19 @@ discard block |
||
| 2136 | 2260 | ) |
| 2137 | 2261 | ); |
| 2138 | 2262 | // No results? Just forget it all together. |
| 2139 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2140 | - unset($table_row['Collation']); |
|
| 2141 | - else |
|
| 2142 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2263 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2264 | + unset($table_row['Collation']); |
|
| 2265 | + } else { |
|
| 2266 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2267 | + } |
|
| 2143 | 2268 | $smcFunc['db_free_result']($request); |
| 2144 | 2269 | } |
| 2145 | 2270 | |
| 2146 | 2271 | if ($column_fix) |
| 2147 | 2272 | { |
| 2148 | 2273 | // Make sure there are no NULL's left. |
| 2149 | - if ($null_fix) |
|
| 2150 | - $smcFunc['db_query']('', ' |
|
| 2274 | + if ($null_fix) { |
|
| 2275 | + $smcFunc['db_query']('', ' |
|
| 2151 | 2276 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2152 | 2277 | SET ' . $change['column'] . ' = {string:default} |
| 2153 | 2278 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2156,6 +2281,7 @@ discard block |
||
| 2156 | 2281 | 'db_error_skip' => true, |
| 2157 | 2282 | ) |
| 2158 | 2283 | ); |
| 2284 | + } |
|
| 2159 | 2285 | |
| 2160 | 2286 | // Do the actual alteration. |
| 2161 | 2287 | $smcFunc['db_query']('', ' |
@@ -2184,8 +2310,9 @@ discard block |
||
| 2184 | 2310 | } |
| 2185 | 2311 | |
| 2186 | 2312 | // Not a column we need to check on? |
| 2187 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2188 | - return; |
|
| 2313 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2314 | + return; |
|
| 2315 | + } |
|
| 2189 | 2316 | |
| 2190 | 2317 | // Break it up you (six|seven). |
| 2191 | 2318 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2204,13 +2331,13 @@ discard block |
||
| 2204 | 2331 | 'new_name' => $temp[2], |
| 2205 | 2332 | )); |
| 2206 | 2333 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2207 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2208 | - return; |
|
| 2334 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2335 | + return; |
|
| 2336 | + } |
|
| 2209 | 2337 | |
| 2210 | 2338 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2211 | 2339 | $smcFunc['db_free_result']($request); |
| 2212 | - } |
|
| 2213 | - else |
|
| 2340 | + } else |
|
| 2214 | 2341 | { |
| 2215 | 2342 | // Do this the old fashion, sure method way. |
| 2216 | 2343 | $request = $smcFunc['db_query']('', ' |
@@ -2221,21 +2348,24 @@ discard block |
||
| 2221 | 2348 | )); |
| 2222 | 2349 | // Mayday! |
| 2223 | 2350 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2224 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2225 | - return; |
|
| 2351 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2352 | + return; |
|
| 2353 | + } |
|
| 2226 | 2354 | |
| 2227 | 2355 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2228 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2229 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2356 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2357 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2230 | 2358 | { |
| 2231 | 2359 | $current_type = $row['Type']; |
| 2360 | + } |
|
| 2232 | 2361 | break; |
| 2233 | 2362 | } |
| 2234 | 2363 | } |
| 2235 | 2364 | |
| 2236 | 2365 | // If this doesn't match, the column may of been altered for a reason. |
| 2237 | - if (trim($current_type) != trim($temp[3])) |
|
| 2238 | - $temp[3] = $current_type; |
|
| 2366 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2367 | + $temp[3] = $current_type; |
|
| 2368 | + } |
|
| 2239 | 2369 | |
| 2240 | 2370 | // Piece this back together. |
| 2241 | 2371 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2247,8 +2377,9 @@ discard block |
||
| 2247 | 2377 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2248 | 2378 | global $step_progress, $is_debug, $upcontext; |
| 2249 | 2379 | |
| 2250 | - if ($_GET['substep'] < $substep) |
|
| 2251 | - $_GET['substep'] = $substep; |
|
| 2380 | + if ($_GET['substep'] < $substep) { |
|
| 2381 | + $_GET['substep'] = $substep; |
|
| 2382 | + } |
|
| 2252 | 2383 | |
| 2253 | 2384 | if ($command_line) |
| 2254 | 2385 | { |
@@ -2261,29 +2392,33 @@ discard block |
||
| 2261 | 2392 | } |
| 2262 | 2393 | |
| 2263 | 2394 | @set_time_limit(300); |
| 2264 | - if (function_exists('apache_reset_timeout')) |
|
| 2265 | - @apache_reset_timeout(); |
|
| 2395 | + if (function_exists('apache_reset_timeout')) { |
|
| 2396 | + @apache_reset_timeout(); |
|
| 2397 | + } |
|
| 2266 | 2398 | |
| 2267 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2268 | - return; |
|
| 2399 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2400 | + return; |
|
| 2401 | + } |
|
| 2269 | 2402 | |
| 2270 | 2403 | // Do we have some custom step progress stuff? |
| 2271 | 2404 | if (!empty($step_progress)) |
| 2272 | 2405 | { |
| 2273 | 2406 | $upcontext['substep_progress'] = 0; |
| 2274 | 2407 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2275 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2276 | - $upcontext['substep_progress'] = 99.9; |
|
| 2277 | - else |
|
| 2278 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2408 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2409 | + $upcontext['substep_progress'] = 99.9; |
|
| 2410 | + } else { |
|
| 2411 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2412 | + } |
|
| 2279 | 2413 | |
| 2280 | 2414 | // Make it nicely rounded. |
| 2281 | 2415 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2282 | 2416 | } |
| 2283 | 2417 | |
| 2284 | 2418 | // If this is XML we just exit right away! |
| 2285 | - if (isset($_GET['xml'])) |
|
| 2286 | - return upgradeExit(); |
|
| 2419 | + if (isset($_GET['xml'])) { |
|
| 2420 | + return upgradeExit(); |
|
| 2421 | + } |
|
| 2287 | 2422 | |
| 2288 | 2423 | // We're going to pause after this! |
| 2289 | 2424 | $upcontext['pause'] = true; |
@@ -2291,13 +2426,15 @@ discard block |
||
| 2291 | 2426 | $upcontext['query_string'] = ''; |
| 2292 | 2427 | foreach ($_GET as $k => $v) |
| 2293 | 2428 | { |
| 2294 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2295 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2429 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2430 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2431 | + } |
|
| 2296 | 2432 | } |
| 2297 | 2433 | |
| 2298 | 2434 | // Custom warning? |
| 2299 | - if (!empty($custom_warning)) |
|
| 2300 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2435 | + if (!empty($custom_warning)) { |
|
| 2436 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2437 | + } |
|
| 2301 | 2438 | |
| 2302 | 2439 | upgradeExit(); |
| 2303 | 2440 | } |
@@ -2312,25 +2449,26 @@ discard block |
||
| 2312 | 2449 | ob_implicit_flush(true); |
| 2313 | 2450 | @set_time_limit(600); |
| 2314 | 2451 | |
| 2315 | - if (!isset($_SERVER['argv'])) |
|
| 2316 | - $_SERVER['argv'] = array(); |
|
| 2452 | + if (!isset($_SERVER['argv'])) { |
|
| 2453 | + $_SERVER['argv'] = array(); |
|
| 2454 | + } |
|
| 2317 | 2455 | $_GET['maint'] = 1; |
| 2318 | 2456 | |
| 2319 | 2457 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2320 | 2458 | { |
| 2321 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2322 | - $_GET['lang'] = $match[1]; |
|
| 2323 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2324 | - continue; |
|
| 2325 | - elseif ($arg == '--no-maintenance') |
|
| 2326 | - $_GET['maint'] = 0; |
|
| 2327 | - elseif ($arg == '--debug') |
|
| 2328 | - $is_debug = true; |
|
| 2329 | - elseif ($arg == '--backup') |
|
| 2330 | - $_POST['backup'] = 1; |
|
| 2331 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2332 | - $_GET['conv'] = 1; |
|
| 2333 | - elseif ($i != 0) |
|
| 2459 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2460 | + $_GET['lang'] = $match[1]; |
|
| 2461 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2462 | + continue; |
|
| 2463 | + } elseif ($arg == '--no-maintenance') { |
|
| 2464 | + $_GET['maint'] = 0; |
|
| 2465 | + } elseif ($arg == '--debug') { |
|
| 2466 | + $is_debug = true; |
|
| 2467 | + } elseif ($arg == '--backup') { |
|
| 2468 | + $_POST['backup'] = 1; |
|
| 2469 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2470 | + $_GET['conv'] = 1; |
|
| 2471 | + } elseif ($i != 0) |
|
| 2334 | 2472 | { |
| 2335 | 2473 | echo 'SMF Command-line Upgrader |
| 2336 | 2474 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2344,10 +2482,12 @@ discard block |
||
| 2344 | 2482 | } |
| 2345 | 2483 | } |
| 2346 | 2484 | |
| 2347 | - if (!php_version_check()) |
|
| 2348 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2349 | - if (!db_version_check()) |
|
| 2350 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2485 | + if (!php_version_check()) { |
|
| 2486 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2487 | + } |
|
| 2488 | + if (!db_version_check()) { |
|
| 2489 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2490 | + } |
|
| 2351 | 2491 | |
| 2352 | 2492 | // Do some checks to make sure they have proper privileges |
| 2353 | 2493 | db_extend('packages'); |
@@ -2362,39 +2502,45 @@ discard block |
||
| 2362 | 2502 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2363 | 2503 | |
| 2364 | 2504 | // Sorry... we need CREATE, ALTER and DROP |
| 2365 | - if (!$create || !$alter || !$drop) |
|
| 2366 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2505 | + if (!$create || !$alter || !$drop) { |
|
| 2506 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2507 | + } |
|
| 2367 | 2508 | |
| 2368 | 2509 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2369 | 2510 | && @file_exists($sourcedir . '/QueryString.php') |
| 2370 | 2511 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2371 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2372 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2512 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2513 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2514 | + } |
|
| 2373 | 2515 | |
| 2374 | 2516 | // Do a quick version spot check. |
| 2375 | 2517 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2376 | 2518 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2377 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2378 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2519 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2520 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2521 | + } |
|
| 2379 | 2522 | |
| 2380 | 2523 | // Make sure Settings.php is writable. |
| 2381 | 2524 | quickFileWritable($boarddir . '/Settings.php'); |
| 2382 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2383 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2525 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2526 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2527 | + } |
|
| 2384 | 2528 | |
| 2385 | 2529 | // Make sure Settings_bak.php is writable. |
| 2386 | 2530 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2387 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2388 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2531 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2532 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2533 | + } |
|
| 2389 | 2534 | |
| 2390 | 2535 | // Make sure db_last_error.php is writable. |
| 2391 | 2536 | quickFileWritable($boarddir . '/db_last_error.php'); |
| 2392 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
| 2393 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2537 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
| 2538 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2539 | + } |
|
| 2394 | 2540 | |
| 2395 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2396 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2397 | - elseif (isset($modSettings['agreement'])) |
|
| 2541 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2542 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2543 | + } elseif (isset($modSettings['agreement'])) |
|
| 2398 | 2544 | { |
| 2399 | 2545 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2400 | 2546 | fwrite($fp, $modSettings['agreement']); |
@@ -2404,31 +2550,36 @@ discard block |
||
| 2404 | 2550 | // Make sure Themes is writable. |
| 2405 | 2551 | quickFileWritable($modSettings['theme_dir']); |
| 2406 | 2552 | |
| 2407 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2408 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2553 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2554 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2555 | + } |
|
| 2409 | 2556 | |
| 2410 | 2557 | // Make sure cache directory exists and is writable! |
| 2411 | 2558 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2412 | - if (!file_exists($cachedir_temp)) |
|
| 2413 | - @mkdir($cachedir_temp); |
|
| 2559 | + if (!file_exists($cachedir_temp)) { |
|
| 2560 | + @mkdir($cachedir_temp); |
|
| 2561 | + } |
|
| 2414 | 2562 | |
| 2415 | 2563 | // Make sure the cache temp dir is writable. |
| 2416 | 2564 | quickFileWritable($cachedir_temp); |
| 2417 | 2565 | |
| 2418 | - if (!is_writable($cachedir_temp)) |
|
| 2419 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2566 | + if (!is_writable($cachedir_temp)) { |
|
| 2567 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2568 | + } |
|
| 2420 | 2569 | |
| 2421 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2422 | - print_error('Error: Unable to find language files!', true); |
|
| 2423 | - else |
|
| 2570 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2571 | + print_error('Error: Unable to find language files!', true); |
|
| 2572 | + } else |
|
| 2424 | 2573 | { |
| 2425 | 2574 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2426 | 2575 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2427 | 2576 | |
| 2428 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2429 | - print_error('Error: Language files out of date.', true); |
|
| 2430 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2431 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2577 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2578 | + print_error('Error: Language files out of date.', true); |
|
| 2579 | + } |
|
| 2580 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2581 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2582 | + } |
|
| 2432 | 2583 | |
| 2433 | 2584 | // Otherwise include it! |
| 2434 | 2585 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2447,8 +2598,9 @@ discard block |
||
| 2447 | 2598 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2448 | 2599 | |
| 2449 | 2600 | // Done it already? |
| 2450 | - if (!empty($_POST['utf8_done'])) |
|
| 2451 | - return true; |
|
| 2601 | + if (!empty($_POST['utf8_done'])) { |
|
| 2602 | + return true; |
|
| 2603 | + } |
|
| 2452 | 2604 | |
| 2453 | 2605 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2454 | 2606 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2461,8 +2613,7 @@ discard block |
||
| 2461 | 2613 | ); |
| 2462 | 2614 | |
| 2463 | 2615 | return true; |
| 2464 | - } |
|
| 2465 | - else |
|
| 2616 | + } else |
|
| 2466 | 2617 | { |
| 2467 | 2618 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2468 | 2619 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2506,8 +2657,9 @@ discard block |
||
| 2506 | 2657 | ) |
| 2507 | 2658 | ); |
| 2508 | 2659 | $db_charsets = array(); |
| 2509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2510 | - $db_charsets[] = $row['Charset']; |
|
| 2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2661 | + $db_charsets[] = $row['Charset']; |
|
| 2662 | + } |
|
| 2511 | 2663 | |
| 2512 | 2664 | $smcFunc['db_free_result']($request); |
| 2513 | 2665 | |
@@ -2543,13 +2695,15 @@ discard block |
||
| 2543 | 2695 | // If there's a fulltext index, we need to drop it first... |
| 2544 | 2696 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2545 | 2697 | { |
| 2546 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2547 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2699 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2548 | 2700 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2701 | + } |
|
| 2549 | 2702 | $smcFunc['db_free_result']($request); |
| 2550 | 2703 | |
| 2551 | - if (isset($upcontext['fulltext_index'])) |
|
| 2552 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2704 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2705 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2706 | + } |
|
| 2553 | 2707 | } |
| 2554 | 2708 | |
| 2555 | 2709 | // Drop it and make a note... |
@@ -2739,8 +2893,9 @@ discard block |
||
| 2739 | 2893 | $replace = '%field%'; |
| 2740 | 2894 | |
| 2741 | 2895 | // Build a huge REPLACE statement... |
| 2742 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2743 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2896 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2897 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2898 | + } |
|
| 2744 | 2899 | } |
| 2745 | 2900 | |
| 2746 | 2901 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2750,9 +2905,10 @@ discard block |
||
| 2750 | 2905 | $upcontext['table_count'] = count($queryTables); |
| 2751 | 2906 | |
| 2752 | 2907 | // What ones have we already done? |
| 2753 | - foreach ($queryTables as $id => $table) |
|
| 2754 | - if ($id < $_GET['substep']) |
|
| 2908 | + foreach ($queryTables as $id => $table) { |
|
| 2909 | + if ($id < $_GET['substep']) |
|
| 2755 | 2910 | $upcontext['previous_tables'][] = $table; |
| 2911 | + } |
|
| 2756 | 2912 | |
| 2757 | 2913 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2758 | 2914 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2789,8 +2945,9 @@ discard block |
||
| 2789 | 2945 | nextSubstep($substep); |
| 2790 | 2946 | |
| 2791 | 2947 | // Just to make sure it doesn't time out. |
| 2792 | - if (function_exists('apache_reset_timeout')) |
|
| 2793 | - @apache_reset_timeout(); |
|
| 2948 | + if (function_exists('apache_reset_timeout')) { |
|
| 2949 | + @apache_reset_timeout(); |
|
| 2950 | + } |
|
| 2794 | 2951 | |
| 2795 | 2952 | $table_charsets = array(); |
| 2796 | 2953 | |
@@ -2813,8 +2970,9 @@ discard block |
||
| 2813 | 2970 | |
| 2814 | 2971 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2815 | 2972 | if ($charset != 'utf8') { |
| 2816 | - if (!isset($table_charsets[$charset])) |
|
| 2817 | - $table_charsets[$charset] = array(); |
|
| 2973 | + if (!isset($table_charsets[$charset])) { |
|
| 2974 | + $table_charsets[$charset] = array(); |
|
| 2975 | + } |
|
| 2818 | 2976 | |
| 2819 | 2977 | $table_charsets[$charset][] = $column_info; |
| 2820 | 2978 | } |
@@ -2855,10 +3013,11 @@ discard block |
||
| 2855 | 3013 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2856 | 3014 | { |
| 2857 | 3015 | $update = ''; |
| 2858 | - foreach ($table_charsets as $charset => $columns) |
|
| 2859 | - foreach ($columns as $column) |
|
| 3016 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3017 | + foreach ($columns as $column) |
|
| 2860 | 3018 | $update .= ' |
| 2861 | 3019 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3020 | + } |
|
| 2862 | 3021 | |
| 2863 | 3022 | $smcFunc['db_query']('', ' |
| 2864 | 3023 | UPDATE {raw:table_name} |
@@ -2883,8 +3042,9 @@ discard block |
||
| 2883 | 3042 | // Now do the actual conversion (if still needed). |
| 2884 | 3043 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2885 | 3044 | { |
| 2886 | - if ($command_line) |
|
| 2887 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3045 | + if ($command_line) { |
|
| 3046 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3047 | + } |
|
| 2888 | 3048 | |
| 2889 | 3049 | $smcFunc['db_query']('', ' |
| 2890 | 3050 | ALTER TABLE {raw:table_name} |
@@ -2894,12 +3054,14 @@ discard block |
||
| 2894 | 3054 | ) |
| 2895 | 3055 | ); |
| 2896 | 3056 | |
| 2897 | - if ($command_line) |
|
| 2898 | - echo " done.\n"; |
|
| 3057 | + if ($command_line) { |
|
| 3058 | + echo " done.\n"; |
|
| 3059 | + } |
|
| 2899 | 3060 | } |
| 2900 | 3061 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2901 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 2902 | - return upgradeExit(); |
|
| 3062 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3063 | + return upgradeExit(); |
|
| 3064 | + } |
|
| 2903 | 3065 | } |
| 2904 | 3066 | |
| 2905 | 3067 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2928,8 +3090,8 @@ discard block |
||
| 2928 | 3090 | ); |
| 2929 | 3091 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2930 | 3092 | { |
| 2931 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 2932 | - $smcFunc['db_query']('', ' |
|
| 3093 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3094 | + $smcFunc['db_query']('', ' |
|
| 2933 | 3095 | UPDATE {db_prefix}log_actions |
| 2934 | 3096 | SET extra = {string:extra} |
| 2935 | 3097 | WHERE id_action = {int:current_action}', |
@@ -2938,6 +3100,7 @@ discard block |
||
| 2938 | 3100 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2939 | 3101 | ) |
| 2940 | 3102 | ); |
| 3103 | + } |
|
| 2941 | 3104 | } |
| 2942 | 3105 | $smcFunc['db_free_result']($request); |
| 2943 | 3106 | |
@@ -2959,15 +3122,17 @@ discard block |
||
| 2959 | 3122 | // First thing's first - did we already do this? |
| 2960 | 3123 | if (!empty($modSettings['json_done'])) |
| 2961 | 3124 | { |
| 2962 | - if ($command_line) |
|
| 2963 | - return DeleteUpgrade(); |
|
| 2964 | - else |
|
| 2965 | - return true; |
|
| 3125 | + if ($command_line) { |
|
| 3126 | + return DeleteUpgrade(); |
|
| 3127 | + } else { |
|
| 3128 | + return true; |
|
| 3129 | + } |
|
| 2966 | 3130 | } |
| 2967 | 3131 | |
| 2968 | 3132 | // Done it already - js wise? |
| 2969 | - if (!empty($_POST['json_done'])) |
|
| 2970 | - return true; |
|
| 3133 | + if (!empty($_POST['json_done'])) { |
|
| 3134 | + return true; |
|
| 3135 | + } |
|
| 2971 | 3136 | |
| 2972 | 3137 | // List of tables affected by this function |
| 2973 | 3138 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2999,12 +3164,14 @@ discard block |
||
| 2999 | 3164 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3000 | 3165 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3001 | 3166 | |
| 3002 | - foreach ($keys as $id => $table) |
|
| 3003 | - if ($id < $_GET['substep']) |
|
| 3167 | + foreach ($keys as $id => $table) { |
|
| 3168 | + if ($id < $_GET['substep']) |
|
| 3004 | 3169 | $upcontext['previous_tables'][] = $table; |
| 3170 | + } |
|
| 3005 | 3171 | |
| 3006 | - if ($command_line) |
|
| 3007 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3172 | + if ($command_line) { |
|
| 3173 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3174 | + } |
|
| 3008 | 3175 | |
| 3009 | 3176 | if (!$support_js || isset($_GET['xml'])) |
| 3010 | 3177 | { |
@@ -3044,8 +3211,9 @@ discard block |
||
| 3044 | 3211 | |
| 3045 | 3212 | // Loop through and fix these... |
| 3046 | 3213 | $new_settings = array(); |
| 3047 | - if ($command_line) |
|
| 3048 | - echo "\n" . 'Fixing some settings...'; |
|
| 3214 | + if ($command_line) { |
|
| 3215 | + echo "\n" . 'Fixing some settings...'; |
|
| 3216 | + } |
|
| 3049 | 3217 | |
| 3050 | 3218 | foreach ($serialized_settings as $var) |
| 3051 | 3219 | { |
@@ -3053,22 +3221,24 @@ discard block |
||
| 3053 | 3221 | { |
| 3054 | 3222 | // Attempt to unserialize the setting |
| 3055 | 3223 | $temp = @safe_unserialize($modSettings[$var]); |
| 3056 | - if (!$temp && $command_line) |
|
| 3057 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3058 | - elseif ($temp !== false) |
|
| 3059 | - $new_settings[$var] = json_encode($temp); |
|
| 3224 | + if (!$temp && $command_line) { |
|
| 3225 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3226 | + } elseif ($temp !== false) { |
|
| 3227 | + $new_settings[$var] = json_encode($temp); |
|
| 3228 | + } |
|
| 3060 | 3229 | } |
| 3061 | 3230 | } |
| 3062 | 3231 | |
| 3063 | 3232 | // Update everything at once |
| 3064 | - if (!function_exists('cache_put_data')) |
|
| 3065 | - require_once($sourcedir . '/Load.php'); |
|
| 3233 | + if (!function_exists('cache_put_data')) { |
|
| 3234 | + require_once($sourcedir . '/Load.php'); |
|
| 3235 | + } |
|
| 3066 | 3236 | updateSettings($new_settings, true); |
| 3067 | 3237 | |
| 3068 | - if ($command_line) |
|
| 3069 | - echo ' done.'; |
|
| 3070 | - } |
|
| 3071 | - elseif ($table == 'themes') |
|
| 3238 | + if ($command_line) { |
|
| 3239 | + echo ' done.'; |
|
| 3240 | + } |
|
| 3241 | + } elseif ($table == 'themes') |
|
| 3072 | 3242 | { |
| 3073 | 3243 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3074 | 3244 | $query = $smcFunc['db_query']('', ' |
@@ -3087,10 +3257,11 @@ discard block |
||
| 3087 | 3257 | |
| 3088 | 3258 | if ($command_line) |
| 3089 | 3259 | { |
| 3090 | - if ($temp === false) |
|
| 3091 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3092 | - else |
|
| 3093 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3260 | + if ($temp === false) { |
|
| 3261 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3262 | + } else { |
|
| 3263 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3264 | + } |
|
| 3094 | 3265 | } |
| 3095 | 3266 | |
| 3096 | 3267 | if ($temp !== false) |
@@ -3112,15 +3283,15 @@ discard block |
||
| 3112 | 3283 | ) |
| 3113 | 3284 | ); |
| 3114 | 3285 | |
| 3115 | - if ($command_line) |
|
| 3116 | - echo ' done.'; |
|
| 3286 | + if ($command_line) { |
|
| 3287 | + echo ' done.'; |
|
| 3288 | + } |
|
| 3117 | 3289 | } |
| 3118 | 3290 | } |
| 3119 | 3291 | |
| 3120 | 3292 | $smcFunc['db_free_result']($query); |
| 3121 | 3293 | } |
| 3122 | - } |
|
| 3123 | - else |
|
| 3294 | + } else |
|
| 3124 | 3295 | { |
| 3125 | 3296 | // First item is always the key... |
| 3126 | 3297 | $key = $info[0]; |
@@ -3131,8 +3302,7 @@ discard block |
||
| 3131 | 3302 | { |
| 3132 | 3303 | $col_select = $info[1]; |
| 3133 | 3304 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3134 | - } |
|
| 3135 | - else |
|
| 3305 | + } else |
|
| 3136 | 3306 | { |
| 3137 | 3307 | $col_select = implode(', ', $info); |
| 3138 | 3308 | } |
@@ -3165,8 +3335,7 @@ discard block |
||
| 3165 | 3335 | if ($temp === false && $command_line) |
| 3166 | 3336 | { |
| 3167 | 3337 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3168 | - } |
|
| 3169 | - else |
|
| 3338 | + } else |
|
| 3170 | 3339 | { |
| 3171 | 3340 | $row[$col] = json_encode($temp); |
| 3172 | 3341 | |
@@ -3191,16 +3360,18 @@ discard block |
||
| 3191 | 3360 | } |
| 3192 | 3361 | } |
| 3193 | 3362 | |
| 3194 | - if ($command_line) |
|
| 3195 | - echo ' done.'; |
|
| 3363 | + if ($command_line) { |
|
| 3364 | + echo ' done.'; |
|
| 3365 | + } |
|
| 3196 | 3366 | |
| 3197 | 3367 | // Free up some memory... |
| 3198 | 3368 | $smcFunc['db_free_result']($query); |
| 3199 | 3369 | } |
| 3200 | 3370 | } |
| 3201 | 3371 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3202 | - if (isset($_GET['xml'])) |
|
| 3203 | - return upgradeExit(); |
|
| 3372 | + if (isset($_GET['xml'])) { |
|
| 3373 | + return upgradeExit(); |
|
| 3374 | + } |
|
| 3204 | 3375 | } |
| 3205 | 3376 | |
| 3206 | 3377 | if ($command_line) |
@@ -3215,8 +3386,9 @@ discard block |
||
| 3215 | 3386 | |
| 3216 | 3387 | $_GET['substep'] = 0; |
| 3217 | 3388 | // Make sure we move on! |
| 3218 | - if ($command_line) |
|
| 3219 | - return DeleteUpgrade(); |
|
| 3389 | + if ($command_line) { |
|
| 3390 | + return DeleteUpgrade(); |
|
| 3391 | + } |
|
| 3220 | 3392 | |
| 3221 | 3393 | return true; |
| 3222 | 3394 | } |
@@ -3236,14 +3408,16 @@ discard block |
||
| 3236 | 3408 | global $upcontext, $txt, $settings; |
| 3237 | 3409 | |
| 3238 | 3410 | // Don't call me twice! |
| 3239 | - if (!empty($upcontext['chmod_called'])) |
|
| 3240 | - return; |
|
| 3411 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3412 | + return; |
|
| 3413 | + } |
|
| 3241 | 3414 | |
| 3242 | 3415 | $upcontext['chmod_called'] = true; |
| 3243 | 3416 | |
| 3244 | 3417 | // Nothing? |
| 3245 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3246 | - return; |
|
| 3418 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3419 | + return; |
|
| 3420 | + } |
|
| 3247 | 3421 | |
| 3248 | 3422 | // Was it a problem with Windows? |
| 3249 | 3423 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3275,11 +3449,12 @@ discard block |
||
| 3275 | 3449 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3276 | 3450 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3277 | 3451 | |
| 3278 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3279 | - echo ' |
|
| 3452 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3453 | + echo ' |
|
| 3280 | 3454 | content.write(\'<hr>\n\t\t\t\'); |
| 3281 | 3455 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3282 | 3456 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3457 | + } |
|
| 3283 | 3458 | |
| 3284 | 3459 | echo ' |
| 3285 | 3460 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3287,17 +3462,19 @@ discard block |
||
| 3287 | 3462 | } |
| 3288 | 3463 | </script>'; |
| 3289 | 3464 | |
| 3290 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3291 | - echo ' |
|
| 3465 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3466 | + echo ' |
|
| 3292 | 3467 | <div class="error_message red"> |
| 3293 | 3468 | The following error was encountered when trying to connect:<br><br> |
| 3294 | 3469 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3295 | 3470 | </div> |
| 3296 | 3471 | <br>'; |
| 3472 | + } |
|
| 3297 | 3473 | |
| 3298 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3299 | - echo ' |
|
| 3474 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3475 | + echo ' |
|
| 3300 | 3476 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3477 | + } |
|
| 3301 | 3478 | |
| 3302 | 3479 | echo ' |
| 3303 | 3480 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3332,10 +3509,11 @@ discard block |
||
| 3332 | 3509 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3333 | 3510 | </div>'; |
| 3334 | 3511 | |
| 3335 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3336 | - echo ' |
|
| 3512 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3513 | + echo ' |
|
| 3337 | 3514 | </form>'; |
| 3338 | -} |
|
| 3515 | + } |
|
| 3516 | + } |
|
| 3339 | 3517 | |
| 3340 | 3518 | function template_upgrade_above() |
| 3341 | 3519 | { |
@@ -3395,9 +3573,10 @@ discard block |
||
| 3395 | 3573 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3396 | 3574 | <ul>'; |
| 3397 | 3575 | |
| 3398 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3399 | - echo ' |
|
| 3576 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3577 | + echo ' |
|
| 3400 | 3578 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3579 | + } |
|
| 3401 | 3580 | |
| 3402 | 3581 | echo ' |
| 3403 | 3582 | </ul> |
@@ -3410,8 +3589,8 @@ discard block |
||
| 3410 | 3589 | </div> |
| 3411 | 3590 | </div>'; |
| 3412 | 3591 | |
| 3413 | - if (isset($upcontext['step_progress'])) |
|
| 3414 | - echo ' |
|
| 3592 | + if (isset($upcontext['step_progress'])) { |
|
| 3593 | + echo ' |
|
| 3415 | 3594 | <br> |
| 3416 | 3595 | <br> |
| 3417 | 3596 | <div id="progress_bar_step"> |
@@ -3420,6 +3599,7 @@ discard block |
||
| 3420 | 3599 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3421 | 3600 | </div> |
| 3422 | 3601 | </div>'; |
| 3602 | + } |
|
| 3423 | 3603 | |
| 3424 | 3604 | echo ' |
| 3425 | 3605 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3450,32 +3630,36 @@ discard block |
||
| 3450 | 3630 | { |
| 3451 | 3631 | global $upcontext, $txt; |
| 3452 | 3632 | |
| 3453 | - if (!empty($upcontext['pause'])) |
|
| 3454 | - echo ' |
|
| 3633 | + if (!empty($upcontext['pause'])) { |
|
| 3634 | + echo ' |
|
| 3455 | 3635 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3456 | 3636 | |
| 3457 | 3637 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3458 | 3638 | <h3> |
| 3459 | 3639 | ', $txt['upgrade_paused_overload'], ' |
| 3460 | 3640 | </h3>'; |
| 3641 | + } |
|
| 3461 | 3642 | |
| 3462 | - if (!empty($upcontext['custom_warning'])) |
|
| 3463 | - echo ' |
|
| 3643 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3644 | + echo ' |
|
| 3464 | 3645 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3465 | 3646 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3466 | 3647 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3467 | 3648 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3468 | 3649 | </div>'; |
| 3650 | + } |
|
| 3469 | 3651 | |
| 3470 | 3652 | echo ' |
| 3471 | 3653 | <div class="righttext" style="margin: 1ex;">'; |
| 3472 | 3654 | |
| 3473 | - if (!empty($upcontext['continue'])) |
|
| 3474 | - echo ' |
|
| 3655 | + if (!empty($upcontext['continue'])) { |
|
| 3656 | + echo ' |
|
| 3475 | 3657 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3476 | - if (!empty($upcontext['skip'])) |
|
| 3477 | - echo ' |
|
| 3658 | + } |
|
| 3659 | + if (!empty($upcontext['skip'])) { |
|
| 3660 | + echo ' |
|
| 3478 | 3661 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3662 | + } |
|
| 3479 | 3663 | |
| 3480 | 3664 | echo ' |
| 3481 | 3665 | </div> |
@@ -3525,11 +3709,12 @@ discard block |
||
| 3525 | 3709 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3526 | 3710 | <smf>'; |
| 3527 | 3711 | |
| 3528 | - if (!empty($upcontext['get_data'])) |
|
| 3529 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3712 | + if (!empty($upcontext['get_data'])) { |
|
| 3713 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3530 | 3714 | echo ' |
| 3531 | 3715 | <get key="', $k, '">', $v, '</get>'; |
| 3532 | -} |
|
| 3716 | + } |
|
| 3717 | + } |
|
| 3533 | 3718 | |
| 3534 | 3719 | function template_xml_below() |
| 3535 | 3720 | { |
@@ -3570,8 +3755,8 @@ discard block |
||
| 3570 | 3755 | template_chmod(); |
| 3571 | 3756 | |
| 3572 | 3757 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3573 | - if ($upcontext['is_large_forum']) |
|
| 3574 | - echo ' |
|
| 3758 | + if ($upcontext['is_large_forum']) { |
|
| 3759 | + echo ' |
|
| 3575 | 3760 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3576 | 3761 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3577 | 3762 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3579,10 +3764,11 @@ discard block |
||
| 3579 | 3764 | ', $txt['upgrade_warning_lots_data'], ' |
| 3580 | 3765 | </div> |
| 3581 | 3766 | </div>'; |
| 3767 | + } |
|
| 3582 | 3768 | |
| 3583 | 3769 | // A warning message? |
| 3584 | - if (!empty($upcontext['warning'])) |
|
| 3585 | - echo ' |
|
| 3770 | + if (!empty($upcontext['warning'])) { |
|
| 3771 | + echo ' |
|
| 3586 | 3772 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3587 | 3773 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3588 | 3774 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3590,6 +3776,7 @@ discard block |
||
| 3590 | 3776 | ', $upcontext['warning'], ' |
| 3591 | 3777 | </div> |
| 3592 | 3778 | </div>'; |
| 3779 | + } |
|
| 3593 | 3780 | |
| 3594 | 3781 | // Paths are incorrect? |
| 3595 | 3782 | echo ' |
@@ -3605,20 +3792,22 @@ discard block |
||
| 3605 | 3792 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3606 | 3793 | { |
| 3607 | 3794 | $ago = time() - $upcontext['started']; |
| 3608 | - if ($ago < 60) |
|
| 3609 | - $ago = $ago . ' seconds'; |
|
| 3610 | - elseif ($ago < 3600) |
|
| 3611 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3612 | - else |
|
| 3613 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3795 | + if ($ago < 60) { |
|
| 3796 | + $ago = $ago . ' seconds'; |
|
| 3797 | + } elseif ($ago < 3600) { |
|
| 3798 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3799 | + } else { |
|
| 3800 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3801 | + } |
|
| 3614 | 3802 | |
| 3615 | 3803 | $active = time() - $upcontext['updated']; |
| 3616 | - if ($active < 60) |
|
| 3617 | - $updated = $active . ' seconds'; |
|
| 3618 | - elseif ($active < 3600) |
|
| 3619 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3620 | - else |
|
| 3621 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3804 | + if ($active < 60) { |
|
| 3805 | + $updated = $active . ' seconds'; |
|
| 3806 | + } elseif ($active < 3600) { |
|
| 3807 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3808 | + } else { |
|
| 3809 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3810 | + } |
|
| 3622 | 3811 | |
| 3623 | 3812 | echo ' |
| 3624 | 3813 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3627,16 +3816,18 @@ discard block |
||
| 3627 | 3816 | <div style="padding-left: 6ex;"> |
| 3628 | 3817 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3629 | 3818 | |
| 3630 | - if ($active < 600) |
|
| 3631 | - echo ' |
|
| 3819 | + if ($active < 600) { |
|
| 3820 | + echo ' |
|
| 3632 | 3821 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3822 | + } |
|
| 3633 | 3823 | |
| 3634 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3635 | - echo ' |
|
| 3824 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3825 | + echo ' |
|
| 3636 | 3826 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3637 | - else |
|
| 3638 | - echo ' |
|
| 3827 | + } else { |
|
| 3828 | + echo ' |
|
| 3639 | 3829 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3830 | + } |
|
| 3640 | 3831 | |
| 3641 | 3832 | echo ' |
| 3642 | 3833 | </div> |
@@ -3652,9 +3843,10 @@ discard block |
||
| 3652 | 3843 | <td> |
| 3653 | 3844 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3654 | 3845 | |
| 3655 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3656 | - echo ' |
|
| 3846 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3847 | + echo ' |
|
| 3657 | 3848 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3849 | + } |
|
| 3658 | 3850 | |
| 3659 | 3851 | echo ' |
| 3660 | 3852 | </td> |
@@ -3665,9 +3857,10 @@ discard block |
||
| 3665 | 3857 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3666 | 3858 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3667 | 3859 | |
| 3668 | - if (!empty($upcontext['password_failed'])) |
|
| 3669 | - echo ' |
|
| 3860 | + if (!empty($upcontext['password_failed'])) { |
|
| 3861 | + echo ' |
|
| 3670 | 3862 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3863 | + } |
|
| 3671 | 3864 | |
| 3672 | 3865 | echo ' |
| 3673 | 3866 | </td> |
@@ -3738,8 +3931,8 @@ discard block |
||
| 3738 | 3931 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3739 | 3932 | |
| 3740 | 3933 | // Warning message? |
| 3741 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3742 | - echo ' |
|
| 3934 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3935 | + echo ' |
|
| 3743 | 3936 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3744 | 3937 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3745 | 3938 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3747,6 +3940,7 @@ discard block |
||
| 3747 | 3940 | ', $upcontext['upgrade_options_warning'], ' |
| 3748 | 3941 | </div> |
| 3749 | 3942 | </div>'; |
| 3943 | + } |
|
| 3750 | 3944 | |
| 3751 | 3945 | echo ' |
| 3752 | 3946 | <table> |
@@ -3789,8 +3983,8 @@ discard block |
||
| 3789 | 3983 | </td> |
| 3790 | 3984 | </tr>'; |
| 3791 | 3985 | |
| 3792 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3793 | - echo ' |
|
| 3986 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3987 | + echo ' |
|
| 3794 | 3988 | <tr valign="top"> |
| 3795 | 3989 | <td width="2%"> |
| 3796 | 3990 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3799,6 +3993,7 @@ discard block |
||
| 3799 | 3993 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3800 | 3994 | </td> |
| 3801 | 3995 | </tr>'; |
| 3996 | + } |
|
| 3802 | 3997 | |
| 3803 | 3998 | echo ' |
| 3804 | 3999 | <tr valign="top"> |
@@ -3836,10 +4031,11 @@ discard block |
||
| 3836 | 4031 | </div>'; |
| 3837 | 4032 | |
| 3838 | 4033 | // Dont any tables so far? |
| 3839 | - if (!empty($upcontext['previous_tables'])) |
|
| 3840 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4034 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4035 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3841 | 4036 | echo ' |
| 3842 | 4037 | <br>Completed Table: "', $table, '".'; |
| 4038 | + } |
|
| 3843 | 4039 | |
| 3844 | 4040 | echo ' |
| 3845 | 4041 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3876,12 +4072,13 @@ discard block |
||
| 3876 | 4072 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3877 | 4073 | |
| 3878 | 4074 | // If debug flood the screen. |
| 3879 | - if ($is_debug) |
|
| 3880 | - echo ' |
|
| 4075 | + if ($is_debug) { |
|
| 4076 | + echo ' |
|
| 3881 | 4077 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3882 | 4078 | |
| 3883 | 4079 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3884 | 4080 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4081 | + } |
|
| 3885 | 4082 | |
| 3886 | 4083 | echo ' |
| 3887 | 4084 | // Get the next update... |
@@ -3914,8 +4111,9 @@ discard block |
||
| 3914 | 4111 | { |
| 3915 | 4112 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3916 | 4113 | |
| 3917 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3918 | - $is_debug = true; |
|
| 4114 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4115 | + $is_debug = true; |
|
| 4116 | + } |
|
| 3919 | 4117 | |
| 3920 | 4118 | echo ' |
| 3921 | 4119 | <h3>Executing database changes</h3> |
@@ -3930,8 +4128,9 @@ discard block |
||
| 3930 | 4128 | { |
| 3931 | 4129 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3932 | 4130 | { |
| 3933 | - if ($num != 0) |
|
| 3934 | - echo ' Successful!'; |
|
| 4131 | + if ($num != 0) { |
|
| 4132 | + echo ' Successful!'; |
|
| 4133 | + } |
|
| 3935 | 4134 | echo '<br>' . $item; |
| 3936 | 4135 | } |
| 3937 | 4136 | if (!empty($upcontext['changes_complete'])) |
@@ -3944,28 +4143,32 @@ discard block |
||
| 3944 | 4143 | $seconds = intval($active % 60); |
| 3945 | 4144 | |
| 3946 | 4145 | $totalTime = ''; |
| 3947 | - if ($hours > 0) |
|
| 3948 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3949 | - if ($minutes > 0) |
|
| 3950 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3951 | - if ($seconds > 0) |
|
| 3952 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4146 | + if ($hours > 0) { |
|
| 4147 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4148 | + } |
|
| 4149 | + if ($minutes > 0) { |
|
| 4150 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4151 | + } |
|
| 4152 | + if ($seconds > 0) { |
|
| 4153 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4154 | + } |
|
| 3953 | 4155 | } |
| 3954 | 4156 | |
| 3955 | - if ($is_debug && !empty($totalTime)) |
|
| 3956 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3957 | - else |
|
| 3958 | - echo ' Successful!<br><br>'; |
|
| 4157 | + if ($is_debug && !empty($totalTime)) { |
|
| 4158 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4159 | + } else { |
|
| 4160 | + echo ' Successful!<br><br>'; |
|
| 4161 | + } |
|
| 3959 | 4162 | |
| 3960 | 4163 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3961 | 4164 | } |
| 3962 | - } |
|
| 3963 | - else |
|
| 4165 | + } else |
|
| 3964 | 4166 | { |
| 3965 | 4167 | // Tell them how many files we have in total. |
| 3966 | - if ($upcontext['file_count'] > 1) |
|
| 3967 | - echo ' |
|
| 4168 | + if ($upcontext['file_count'] > 1) { |
|
| 4169 | + echo ' |
|
| 3968 | 4170 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4171 | + } |
|
| 3969 | 4172 | |
| 3970 | 4173 | echo ' |
| 3971 | 4174 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3981,19 +4184,23 @@ discard block |
||
| 3981 | 4184 | $seconds = intval($active % 60); |
| 3982 | 4185 | |
| 3983 | 4186 | $totalTime = ''; |
| 3984 | - if ($hours > 0) |
|
| 3985 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3986 | - if ($minutes > 0) |
|
| 3987 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3988 | - if ($seconds > 0) |
|
| 3989 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4187 | + if ($hours > 0) { |
|
| 4188 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4189 | + } |
|
| 4190 | + if ($minutes > 0) { |
|
| 4191 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4192 | + } |
|
| 4193 | + if ($seconds > 0) { |
|
| 4194 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4195 | + } |
|
| 3990 | 4196 | } |
| 3991 | 4197 | |
| 3992 | 4198 | echo ' |
| 3993 | 4199 | <br><span id="upgradeCompleted">'; |
| 3994 | 4200 | |
| 3995 | - if (!empty($totalTime)) |
|
| 3996 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4201 | + if (!empty($totalTime)) { |
|
| 4202 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4203 | + } |
|
| 3997 | 4204 | |
| 3998 | 4205 | echo '</span> |
| 3999 | 4206 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4030,9 +4237,10 @@ discard block |
||
| 4030 | 4237 | var getData = ""; |
| 4031 | 4238 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4032 | 4239 | |
| 4033 | - if ($is_debug) |
|
| 4034 | - echo ' |
|
| 4240 | + if ($is_debug) { |
|
| 4241 | + echo ' |
|
| 4035 | 4242 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4243 | + } |
|
| 4036 | 4244 | |
| 4037 | 4245 | echo ' |
| 4038 | 4246 | function getNextItem() |
@@ -4072,9 +4280,10 @@ discard block |
||
| 4072 | 4280 | document.getElementById("error_block").style.display = ""; |
| 4073 | 4281 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4074 | 4282 | |
| 4075 | - if ($is_debug) |
|
| 4076 | - echo ' |
|
| 4283 | + if ($is_debug) { |
|
| 4284 | + echo ' |
|
| 4077 | 4285 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4286 | + } |
|
| 4078 | 4287 | |
| 4079 | 4288 | echo ' |
| 4080 | 4289 | } |
@@ -4095,9 +4304,10 @@ discard block |
||
| 4095 | 4304 | document.getElementById("error_block").style.display = ""; |
| 4096 | 4305 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4097 | 4306 | |
| 4098 | - if ($is_debug) |
|
| 4099 | - echo ' |
|
| 4307 | + if ($is_debug) { |
|
| 4308 | + echo ' |
|
| 4100 | 4309 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4310 | + } |
|
| 4101 | 4311 | |
| 4102 | 4312 | echo ' |
| 4103 | 4313 | } |
@@ -4156,8 +4366,8 @@ discard block |
||
| 4156 | 4366 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4157 | 4367 | {'; |
| 4158 | 4368 | |
| 4159 | - if ($is_debug) |
|
| 4160 | - echo ' |
|
| 4369 | + if ($is_debug) { |
|
| 4370 | + echo ' |
|
| 4161 | 4371 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4162 | 4372 | |
| 4163 | 4373 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4175,6 +4385,7 @@ discard block |
||
| 4175 | 4385 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4176 | 4386 | |
| 4177 | 4387 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4388 | + } |
|
| 4178 | 4389 | |
| 4179 | 4390 | echo ' |
| 4180 | 4391 | |
@@ -4182,9 +4393,10 @@ discard block |
||
| 4182 | 4393 | document.getElementById(\'contbutt\').disabled = 0; |
| 4183 | 4394 | document.getElementById(\'database_done\').value = 1;'; |
| 4184 | 4395 | |
| 4185 | - if ($upcontext['file_count'] > 1) |
|
| 4186 | - echo ' |
|
| 4396 | + if ($upcontext['file_count'] > 1) { |
|
| 4397 | + echo ' |
|
| 4187 | 4398 | document.getElementById(\'info1\').style.display = "none";'; |
| 4399 | + } |
|
| 4188 | 4400 | |
| 4189 | 4401 | echo ' |
| 4190 | 4402 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4197,9 +4409,10 @@ discard block |
||
| 4197 | 4409 | lastItem = 0; |
| 4198 | 4410 | prevFile = curFile;'; |
| 4199 | 4411 | |
| 4200 | - if ($is_debug) |
|
| 4201 | - echo ' |
|
| 4412 | + if ($is_debug) { |
|
| 4413 | + echo ' |
|
| 4202 | 4414 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4415 | + } |
|
| 4203 | 4416 | |
| 4204 | 4417 | echo ' |
| 4205 | 4418 | getNextItem(); |
@@ -4207,8 +4420,8 @@ discard block |
||
| 4207 | 4420 | }'; |
| 4208 | 4421 | |
| 4209 | 4422 | // If debug scroll the screen. |
| 4210 | - if ($is_debug) |
|
| 4211 | - echo ' |
|
| 4423 | + if ($is_debug) { |
|
| 4424 | + echo ' |
|
| 4212 | 4425 | if (iLastSubStepProgress == -1) |
| 4213 | 4426 | { |
| 4214 | 4427 | // Give it consistent dots. |
@@ -4227,6 +4440,7 @@ discard block |
||
| 4227 | 4440 | |
| 4228 | 4441 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4229 | 4442 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4443 | + } |
|
| 4230 | 4444 | |
| 4231 | 4445 | echo ' |
| 4232 | 4446 | // Update the page. |
@@ -4287,9 +4501,10 @@ discard block |
||
| 4287 | 4501 | }'; |
| 4288 | 4502 | |
| 4289 | 4503 | // Start things off assuming we've not errored. |
| 4290 | - if (empty($upcontext['error_message'])) |
|
| 4291 | - echo ' |
|
| 4504 | + if (empty($upcontext['error_message'])) { |
|
| 4505 | + echo ' |
|
| 4292 | 4506 | getNextItem();'; |
| 4507 | + } |
|
| 4293 | 4508 | |
| 4294 | 4509 | echo ' |
| 4295 | 4510 | //# sourceURL=dynamicScript-dbch.js |
@@ -4307,18 +4522,21 @@ discard block |
||
| 4307 | 4522 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4308 | 4523 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4309 | 4524 | |
| 4310 | - if (!empty($upcontext['error_message'])) |
|
| 4311 | - echo ' |
|
| 4525 | + if (!empty($upcontext['error_message'])) { |
|
| 4526 | + echo ' |
|
| 4312 | 4527 | <error>', $upcontext['error_message'], '</error>'; |
| 4528 | + } |
|
| 4313 | 4529 | |
| 4314 | - if (!empty($upcontext['error_string'])) |
|
| 4315 | - echo ' |
|
| 4530 | + if (!empty($upcontext['error_string'])) { |
|
| 4531 | + echo ' |
|
| 4316 | 4532 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4533 | + } |
|
| 4317 | 4534 | |
| 4318 | - if ($is_debug) |
|
| 4319 | - echo ' |
|
| 4535 | + if ($is_debug) { |
|
| 4536 | + echo ' |
|
| 4320 | 4537 | <curtime>', time(), '</curtime>'; |
| 4321 | -} |
|
| 4538 | + } |
|
| 4539 | + } |
|
| 4322 | 4540 | |
| 4323 | 4541 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4324 | 4542 | function template_convert_utf8() |
@@ -4337,18 +4555,20 @@ discard block |
||
| 4337 | 4555 | </div>'; |
| 4338 | 4556 | |
| 4339 | 4557 | // Done any tables so far? |
| 4340 | - if (!empty($upcontext['previous_tables'])) |
|
| 4341 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4558 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4559 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4342 | 4560 | echo ' |
| 4343 | 4561 | <br>Completed Table: "', $table, '".'; |
| 4562 | + } |
|
| 4344 | 4563 | |
| 4345 | 4564 | echo ' |
| 4346 | 4565 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4347 | 4566 | |
| 4348 | 4567 | // If we dropped their index, let's let them know |
| 4349 | - if ($upcontext['dropping_index']) |
|
| 4350 | - echo ' |
|
| 4568 | + if ($upcontext['dropping_index']) { |
|
| 4569 | + echo ' |
|
| 4351 | 4570 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4571 | + } |
|
| 4352 | 4572 | |
| 4353 | 4573 | // Completion notification |
| 4354 | 4574 | echo ' |
@@ -4385,12 +4605,13 @@ discard block |
||
| 4385 | 4605 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4386 | 4606 | |
| 4387 | 4607 | // If debug flood the screen. |
| 4388 | - if ($is_debug) |
|
| 4389 | - echo ' |
|
| 4608 | + if ($is_debug) { |
|
| 4609 | + echo ' |
|
| 4390 | 4610 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4391 | 4611 | |
| 4392 | 4612 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4393 | 4613 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4614 | + } |
|
| 4394 | 4615 | |
| 4395 | 4616 | echo ' |
| 4396 | 4617 | // Get the next update... |
@@ -4438,19 +4659,21 @@ discard block |
||
| 4438 | 4659 | </div>'; |
| 4439 | 4660 | |
| 4440 | 4661 | // Dont any tables so far? |
| 4441 | - if (!empty($upcontext['previous_tables'])) |
|
| 4442 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4662 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4663 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4443 | 4664 | echo ' |
| 4444 | 4665 | <br>Completed Table: "', $table, '".'; |
| 4666 | + } |
|
| 4445 | 4667 | |
| 4446 | 4668 | echo ' |
| 4447 | 4669 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4448 | 4670 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4449 | 4671 | |
| 4450 | 4672 | // Try to make sure substep was reset. |
| 4451 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4452 | - echo ' |
|
| 4673 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4674 | + echo ' |
|
| 4453 | 4675 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4676 | + } |
|
| 4454 | 4677 | |
| 4455 | 4678 | // Continue please! |
| 4456 | 4679 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4483,12 +4706,13 @@ discard block |
||
| 4483 | 4706 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4484 | 4707 | |
| 4485 | 4708 | // If debug flood the screen. |
| 4486 | - if ($is_debug) |
|
| 4487 | - echo ' |
|
| 4709 | + if ($is_debug) { |
|
| 4710 | + echo ' |
|
| 4488 | 4711 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4489 | 4712 | |
| 4490 | 4713 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4491 | 4714 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4715 | + } |
|
| 4492 | 4716 | |
| 4493 | 4717 | echo ' |
| 4494 | 4718 | // Get the next update... |
@@ -4524,8 +4748,8 @@ discard block |
||
| 4524 | 4748 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4525 | 4749 | <form action="', $boardurl, '/index.php">'; |
| 4526 | 4750 | |
| 4527 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4528 | - echo ' |
|
| 4751 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4752 | + echo ' |
|
| 4529 | 4753 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4530 | 4754 | <script> |
| 4531 | 4755 | function doTheDelete(theCheck) |
@@ -4537,6 +4761,7 @@ discard block |
||
| 4537 | 4761 | } |
| 4538 | 4762 | </script> |
| 4539 | 4763 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4764 | + } |
|
| 4540 | 4765 | |
| 4541 | 4766 | $active = time() - $upcontext['started']; |
| 4542 | 4767 | $hours = floor($active / 3600); |
@@ -4546,16 +4771,20 @@ discard block |
||
| 4546 | 4771 | if ($is_debug) |
| 4547 | 4772 | { |
| 4548 | 4773 | $totalTime = ''; |
| 4549 | - if ($hours > 0) |
|
| 4550 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4551 | - if ($minutes > 0) |
|
| 4552 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4553 | - if ($seconds > 0) |
|
| 4554 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4774 | + if ($hours > 0) { |
|
| 4775 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4776 | + } |
|
| 4777 | + if ($minutes > 0) { |
|
| 4778 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4779 | + } |
|
| 4780 | + if ($seconds > 0) { |
|
| 4781 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4782 | + } |
|
| 4555 | 4783 | } |
| 4556 | 4784 | |
| 4557 | - if ($is_debug && !empty($totalTime)) |
|
| 4558 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4785 | + if ($is_debug && !empty($totalTime)) { |
|
| 4786 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4787 | + } |
|
| 4559 | 4788 | |
| 4560 | 4789 | echo '<br> |
| 4561 | 4790 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4582,8 +4811,9 @@ discard block |
||
| 4582 | 4811 | |
| 4583 | 4812 | $current_substep = $_GET['substep']; |
| 4584 | 4813 | |
| 4585 | - if (empty($_GET['a'])) |
|
| 4586 | - $_GET['a'] = 0; |
|
| 4814 | + if (empty($_GET['a'])) { |
|
| 4815 | + $_GET['a'] = 0; |
|
| 4816 | + } |
|
| 4587 | 4817 | $step_progress['name'] = 'Converting ips'; |
| 4588 | 4818 | $step_progress['current'] = $_GET['a']; |
| 4589 | 4819 | |
@@ -4626,16 +4856,19 @@ discard block |
||
| 4626 | 4856 | 'empty' => '', |
| 4627 | 4857 | 'limit' => $limit, |
| 4628 | 4858 | )); |
| 4629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4630 | - $arIp[] = $row[$oldCol]; |
|
| 4859 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4860 | + $arIp[] = $row[$oldCol]; |
|
| 4861 | + } |
|
| 4631 | 4862 | $smcFunc['db_free_result']($request); |
| 4632 | 4863 | |
| 4633 | 4864 | // Special case, null ip could keep us in a loop. |
| 4634 | - if (is_null($arIp[0])) |
|
| 4635 | - unset($arIp[0]); |
|
| 4865 | + if (is_null($arIp[0])) { |
|
| 4866 | + unset($arIp[0]); |
|
| 4867 | + } |
|
| 4636 | 4868 | |
| 4637 | - if (empty($arIp)) |
|
| 4638 | - $is_done = true; |
|
| 4869 | + if (empty($arIp)) { |
|
| 4870 | + $is_done = true; |
|
| 4871 | + } |
|
| 4639 | 4872 | |
| 4640 | 4873 | $updates = array(); |
| 4641 | 4874 | $cases = array(); |
@@ -4644,16 +4877,18 @@ discard block |
||
| 4644 | 4877 | { |
| 4645 | 4878 | $arIp[$i] = trim($arIp[$i]); |
| 4646 | 4879 | |
| 4647 | - if (empty($arIp[$i])) |
|
| 4648 | - continue; |
|
| 4880 | + if (empty($arIp[$i])) { |
|
| 4881 | + continue; |
|
| 4882 | + } |
|
| 4649 | 4883 | |
| 4650 | 4884 | $updates['ip' . $i] = $arIp[$i]; |
| 4651 | 4885 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4652 | 4886 | |
| 4653 | 4887 | if ($setSize > 0 && $i % $setSize === 0) |
| 4654 | 4888 | { |
| 4655 | - if (count($updates) == 1) |
|
| 4656 | - continue; |
|
| 4889 | + if (count($updates) == 1) { |
|
| 4890 | + continue; |
|
| 4891 | + } |
|
| 4657 | 4892 | |
| 4658 | 4893 | $updates['whereSet'] = array_values($updates); |
| 4659 | 4894 | $smcFunc['db_query']('', ' |
@@ -4687,8 +4922,7 @@ discard block |
||
| 4687 | 4922 | 'ip' => $ip |
| 4688 | 4923 | )); |
| 4689 | 4924 | } |
| 4690 | - } |
|
| 4691 | - else |
|
| 4925 | + } else |
|
| 4692 | 4926 | { |
| 4693 | 4927 | $updates['whereSet'] = array_values($updates); |
| 4694 | 4928 | $smcFunc['db_query']('', ' |
@@ -4702,9 +4936,9 @@ discard block |
||
| 4702 | 4936 | $updates |
| 4703 | 4937 | ); |
| 4704 | 4938 | } |
| 4939 | + } else { |
|
| 4940 | + $is_done = true; |
|
| 4705 | 4941 | } |
| 4706 | - else |
|
| 4707 | - $is_done = true; |
|
| 4708 | 4942 | |
| 4709 | 4943 | $_GET['a'] += $limit; |
| 4710 | 4944 | $step_progress['current'] = $_GET['a']; |
@@ -4730,10 +4964,11 @@ discard block |
||
| 4730 | 4964 | |
| 4731 | 4965 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4732 | 4966 | |
| 4733 | - if (isset($columns[$column])) |
|
| 4734 | - return $columns[$column]; |
|
| 4735 | - else |
|
| 4736 | - return null; |
|
| 4737 | -} |
|
| 4967 | + if (isset($columns[$column])) { |
|
| 4968 | + return $columns[$column]; |
|
| 4969 | + } else { |
|
| 4970 | + return null; |
|
| 4971 | + } |
|
| 4972 | + } |
|
| 4738 | 4973 | |
| 4739 | 4974 | ?> |
| 4740 | 4975 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | case 'datetime': |
| 255 | 255 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
| 256 | - return 'str_to_date('. |
|
| 257 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
| 256 | + return 'str_to_date(' . |
|
| 257 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
| 258 | 258 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 259 | 259 | else |
| 260 | 260 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | { |
| 839 | 839 | $count = count($insertRows); |
| 840 | 840 | $ai = 0; |
| 841 | - for($i = 0; $i < $count; $i++) |
|
| 841 | + for ($i = 0; $i < $count; $i++) |
|
| 842 | 842 | { |
| 843 | 843 | $old_id = $smcFunc['db_insert_id'](); |
| 844 | 844 | |
@@ -864,13 +864,13 @@ discard block |
||
| 864 | 864 | $count2 = count($indexed_columns); |
| 865 | 865 | for ($x = 0; $x < $count2; $x++) |
| 866 | 866 | { |
| 867 | - $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
|
| 867 | + $where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x]; |
|
| 868 | 868 | if (($x + 1) < $count2) |
| 869 | 869 | $where_string += ' AND '; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - $request = $smcFunc['db_query']('',' |
|
| 873 | - SELECT `'. $keys[0] . '` FROM ' . $table .' |
|
| 872 | + $request = $smcFunc['db_query']('', ' |
|
| 873 | + SELECT `'. $keys[0] . '` FROM ' . $table . ' |
|
| 874 | 874 | WHERE ' . $where_string . ' LIMIT 1', |
| 875 | 875 | array() |
| 876 | 876 | ); |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | $return_var = array(); |
| 900 | 900 | $count = count($insertRows); |
| 901 | 901 | $start = smf_db_insert_id($table, $keys[0]); |
| 902 | - for ($i = 0; $i < $count; $i++ ) |
|
| 902 | + for ($i = 0; $i < $count; $i++) |
|
| 903 | 903 | $return_var[] = $start + $i; |
| 904 | 904 | } |
| 905 | 905 | return $return_var; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -61,9 +62,11 @@ discard block |
||
| 61 | 62 | 'db_ping' => 'mysqli_ping', |
| 62 | 63 | 'db_fetch_all' => 'smf_db_fetch_all', |
| 63 | 64 | ); |
| 65 | + } |
|
| 64 | 66 | |
| 65 | - if (!empty($db_options['persist'])) |
|
| 66 | - $db_server = 'p:' . $db_server; |
|
| 67 | + if (!empty($db_options['persist'])) { |
|
| 68 | + $db_server = 'p:' . $db_server; |
|
| 69 | + } |
|
| 67 | 70 | |
| 68 | 71 | $connection = mysqli_init(); |
| 69 | 72 | |
@@ -72,24 +75,27 @@ discard block |
||
| 72 | 75 | $success = false; |
| 73 | 76 | |
| 74 | 77 | if ($connection) { |
| 75 | - if (!empty($db_options['port'])) |
|
| 76 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 77 | - else |
|
| 78 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 78 | + if (!empty($db_options['port'])) { |
|
| 79 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 80 | + } else { |
|
| 81 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 82 | + } |
|
| 79 | 83 | } |
| 80 | 84 | |
| 81 | 85 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 82 | 86 | if ($success === false) |
| 83 | 87 | { |
| 84 | - if (!empty($db_options['non_fatal'])) |
|
| 85 | - return null; |
|
| 86 | - else |
|
| 87 | - display_db_error(); |
|
| 88 | + if (!empty($db_options['non_fatal'])) { |
|
| 89 | + return null; |
|
| 90 | + } else { |
|
| 91 | + display_db_error(); |
|
| 92 | + } |
|
| 88 | 93 | } |
| 89 | 94 | |
| 90 | 95 | // Select the database, unless told not to |
| 91 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
| 92 | - display_db_error(); |
|
| 96 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
| 97 | + display_db_error(); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | 100 | $smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'', |
| 95 | 101 | array(), |
@@ -165,34 +171,42 @@ discard block |
||
| 165 | 171 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
| 166 | 172 | |
| 167 | 173 | list ($values, $connection) = $db_callback; |
| 168 | - if (!is_object($connection)) |
|
| 169 | - display_db_error(); |
|
| 174 | + if (!is_object($connection)) { |
|
| 175 | + display_db_error(); |
|
| 176 | + } |
|
| 170 | 177 | |
| 171 | - if ($matches[1] === 'db_prefix') |
|
| 172 | - return $db_prefix; |
|
| 178 | + if ($matches[1] === 'db_prefix') { |
|
| 179 | + return $db_prefix; |
|
| 180 | + } |
|
| 173 | 181 | |
| 174 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 175 | - return $user_info[$matches[1]]; |
|
| 182 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 183 | + return $user_info[$matches[1]]; |
|
| 184 | + } |
|
| 176 | 185 | |
| 177 | - if ($matches[1] === 'empty') |
|
| 178 | - return '\'\''; |
|
| 186 | + if ($matches[1] === 'empty') { |
|
| 187 | + return '\'\''; |
|
| 188 | + } |
|
| 179 | 189 | |
| 180 | - if (!isset($matches[2])) |
|
| 181 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 190 | + if (!isset($matches[2])) { |
|
| 191 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 192 | + } |
|
| 182 | 193 | |
| 183 | - if ($matches[1] === 'literal') |
|
| 184 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 194 | + if ($matches[1] === 'literal') { |
|
| 195 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 196 | + } |
|
| 185 | 197 | |
| 186 | - if (!isset($values[$matches[2]])) |
|
| 187 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 198 | + if (!isset($values[$matches[2]])) { |
|
| 199 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 200 | + } |
|
| 188 | 201 | |
| 189 | 202 | $replacement = $values[$matches[2]]; |
| 190 | 203 | |
| 191 | 204 | switch ($matches[1]) |
| 192 | 205 | { |
| 193 | 206 | case 'int': |
| 194 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 195 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 207 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 208 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 209 | + } |
|
| 196 | 210 | return (string) (int) $replacement; |
| 197 | 211 | break; |
| 198 | 212 | |
@@ -204,65 +218,73 @@ discard block |
||
| 204 | 218 | case 'array_int': |
| 205 | 219 | if (is_array($replacement)) |
| 206 | 220 | { |
| 207 | - if (empty($replacement)) |
|
| 208 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 221 | + if (empty($replacement)) { |
|
| 222 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 223 | + } |
|
| 209 | 224 | |
| 210 | 225 | foreach ($replacement as $key => $value) |
| 211 | 226 | { |
| 212 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 213 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 227 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 228 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 229 | + } |
|
| 214 | 230 | |
| 215 | 231 | $replacement[$key] = (string) (int) $value; |
| 216 | 232 | } |
| 217 | 233 | |
| 218 | 234 | return implode(', ', $replacement); |
| 235 | + } else { |
|
| 236 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 219 | 237 | } |
| 220 | - else |
|
| 221 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 222 | 238 | |
| 223 | 239 | break; |
| 224 | 240 | |
| 225 | 241 | case 'array_string': |
| 226 | 242 | if (is_array($replacement)) |
| 227 | 243 | { |
| 228 | - if (empty($replacement)) |
|
| 229 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 244 | + if (empty($replacement)) { |
|
| 245 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 246 | + } |
|
| 230 | 247 | |
| 231 | - foreach ($replacement as $key => $value) |
|
| 232 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 248 | + foreach ($replacement as $key => $value) { |
|
| 249 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 250 | + } |
|
| 233 | 251 | |
| 234 | 252 | return implode(', ', $replacement); |
| 253 | + } else { |
|
| 254 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 235 | 255 | } |
| 236 | - else |
|
| 237 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 238 | 256 | break; |
| 239 | 257 | |
| 240 | 258 | case 'date': |
| 241 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 242 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 243 | - else |
|
| 244 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 259 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 260 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 261 | + } else { |
|
| 262 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 263 | + } |
|
| 245 | 264 | break; |
| 246 | 265 | |
| 247 | 266 | case 'time': |
| 248 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 249 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 250 | - else |
|
| 251 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 267 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 268 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 269 | + } else { |
|
| 270 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 271 | + } |
|
| 252 | 272 | break; |
| 253 | 273 | |
| 254 | 274 | case 'datetime': |
| 255 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 256 | - return 'str_to_date('. |
|
| 275 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 276 | + return 'str_to_date('. |
|
| 257 | 277 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 258 | 278 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 259 | - else |
|
| 260 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 279 | + } else { |
|
| 280 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 281 | + } |
|
| 261 | 282 | break; |
| 262 | 283 | |
| 263 | 284 | case 'float': |
| 264 | - if (!is_numeric($replacement)) |
|
| 265 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 285 | + if (!is_numeric($replacement)) { |
|
| 286 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 287 | + } |
|
| 266 | 288 | return (string) (float) $replacement; |
| 267 | 289 | break; |
| 268 | 290 | |
@@ -276,32 +298,37 @@ discard block |
||
| 276 | 298 | break; |
| 277 | 299 | |
| 278 | 300 | case 'inet': |
| 279 | - if ($replacement == 'null' || $replacement == '') |
|
| 280 | - return 'null'; |
|
| 281 | - if (!isValidIP($replacement)) |
|
| 282 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 301 | + if ($replacement == 'null' || $replacement == '') { |
|
| 302 | + return 'null'; |
|
| 303 | + } |
|
| 304 | + if (!isValidIP($replacement)) { |
|
| 305 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 306 | + } |
|
| 283 | 307 | //we don't use the native support of mysql > 5.6.2 |
| 284 | 308 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 285 | 309 | |
| 286 | 310 | case 'array_inet': |
| 287 | 311 | if (is_array($replacement)) |
| 288 | 312 | { |
| 289 | - if (empty($replacement)) |
|
| 290 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 313 | + if (empty($replacement)) { |
|
| 314 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 315 | + } |
|
| 291 | 316 | |
| 292 | 317 | foreach ($replacement as $key => $value) |
| 293 | 318 | { |
| 294 | - if ($replacement == 'null' || $replacement == '') |
|
| 295 | - $replacement[$key] = 'null'; |
|
| 296 | - if (!isValidIP($value)) |
|
| 297 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 319 | + if ($replacement == 'null' || $replacement == '') { |
|
| 320 | + $replacement[$key] = 'null'; |
|
| 321 | + } |
|
| 322 | + if (!isValidIP($value)) { |
|
| 323 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 324 | + } |
|
| 298 | 325 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 299 | 326 | } |
| 300 | 327 | |
| 301 | 328 | return implode(', ', $replacement); |
| 329 | + } else { |
|
| 330 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 302 | 331 | } |
| 303 | - else |
|
| 304 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 305 | 332 | break; |
| 306 | 333 | |
| 307 | 334 | default: |
@@ -377,22 +404,25 @@ discard block |
||
| 377 | 404 | // Are we in SSI mode? If so try that username and password first |
| 378 | 405 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 379 | 406 | { |
| 380 | - if (empty($db_persist)) |
|
| 381 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 382 | - else |
|
| 383 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 407 | + if (empty($db_persist)) { |
|
| 408 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 409 | + } else { |
|
| 410 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 411 | + } |
|
| 384 | 412 | } |
| 385 | 413 | // Fall back to the regular username and password if need be |
| 386 | 414 | if (!$db_connection) |
| 387 | 415 | { |
| 388 | - if (empty($db_persist)) |
|
| 389 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 390 | - else |
|
| 391 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 416 | + if (empty($db_persist)) { |
|
| 417 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 418 | + } else { |
|
| 419 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 420 | + } |
|
| 392 | 421 | } |
| 393 | 422 | |
| 394 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 395 | - $db_connection = false; |
|
| 423 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 424 | + $db_connection = false; |
|
| 425 | + } |
|
| 396 | 426 | |
| 397 | 427 | $connection = $db_connection; |
| 398 | 428 | } |
@@ -400,18 +430,20 @@ discard block |
||
| 400 | 430 | // One more query.... |
| 401 | 431 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 402 | 432 | |
| 403 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 404 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 433 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 434 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 435 | + } |
|
| 405 | 436 | |
| 406 | 437 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 407 | 438 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 408 | 439 | { |
| 409 | 440 | // Add before LIMIT |
| 410 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 411 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 412 | - else |
|
| 413 | - // Append it. |
|
| 441 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 442 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 443 | + } else { |
|
| 444 | + // Append it. |
|
| 414 | 445 | $db_string .= "\n\t\t\tORDER BY null"; |
| 446 | + } |
|
| 415 | 447 | } |
| 416 | 448 | |
| 417 | 449 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -433,8 +465,9 @@ discard block |
||
| 433 | 465 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 434 | 466 | |
| 435 | 467 | // Initialize $db_cache if not already initialized. |
| 436 | - if (!isset($db_cache)) |
|
| 437 | - $db_cache = array(); |
|
| 468 | + if (!isset($db_cache)) { |
|
| 469 | + $db_cache = array(); |
|
| 470 | + } |
|
| 438 | 471 | |
| 439 | 472 | if (!empty($_SESSION['debug_redirect'])) |
| 440 | 473 | { |
@@ -460,17 +493,18 @@ discard block |
||
| 460 | 493 | while (true) |
| 461 | 494 | { |
| 462 | 495 | $pos = strpos($db_string, '\'', $pos + 1); |
| 463 | - if ($pos === false) |
|
| 464 | - break; |
|
| 496 | + if ($pos === false) { |
|
| 497 | + break; |
|
| 498 | + } |
|
| 465 | 499 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 466 | 500 | |
| 467 | 501 | while (true) |
| 468 | 502 | { |
| 469 | 503 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 470 | 504 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 471 | - if ($pos1 === false) |
|
| 472 | - break; |
|
| 473 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 505 | + if ($pos1 === false) { |
|
| 506 | + break; |
|
| 507 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 474 | 508 | { |
| 475 | 509 | $pos = $pos1; |
| 476 | 510 | break; |
@@ -486,29 +520,35 @@ discard block |
||
| 486 | 520 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 487 | 521 | |
| 488 | 522 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 489 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 490 | - $fail = true; |
|
| 523 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 524 | + $fail = true; |
|
| 525 | + } |
|
| 491 | 526 | // Trying to change passwords, slow us down, or something? |
| 492 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 493 | - $fail = true; |
|
| 494 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 495 | - $fail = true; |
|
| 527 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 528 | + $fail = true; |
|
| 529 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 530 | + $fail = true; |
|
| 531 | + } |
|
| 496 | 532 | |
| 497 | - if (!empty($fail) && function_exists('log_error')) |
|
| 498 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 533 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 534 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 535 | + } |
|
| 499 | 536 | } |
| 500 | 537 | |
| 501 | - if (empty($db_unbuffered)) |
|
| 502 | - $ret = @mysqli_query($connection, $db_string); |
|
| 503 | - else |
|
| 504 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 538 | + if (empty($db_unbuffered)) { |
|
| 539 | + $ret = @mysqli_query($connection, $db_string); |
|
| 540 | + } else { |
|
| 541 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 542 | + } |
|
| 505 | 543 | |
| 506 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 507 | - $ret = smf_db_error($db_string, $connection); |
|
| 544 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 545 | + $ret = smf_db_error($db_string, $connection); |
|
| 546 | + } |
|
| 508 | 547 | |
| 509 | 548 | // Debugging. |
| 510 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 511 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 549 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 550 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 551 | + } |
|
| 512 | 552 | |
| 513 | 553 | return $ret; |
| 514 | 554 | } |
@@ -555,12 +595,13 @@ discard block |
||
| 555 | 595 | // Decide which connection to use |
| 556 | 596 | $connection = $connection === null ? $db_connection : $connection; |
| 557 | 597 | |
| 558 | - if ($type == 'begin') |
|
| 559 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 560 | - elseif ($type == 'rollback') |
|
| 561 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 562 | - elseif ($type == 'commit') |
|
| 563 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 598 | + if ($type == 'begin') { |
|
| 599 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 600 | + } elseif ($type == 'rollback') { |
|
| 601 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 602 | + } elseif ($type == 'commit') { |
|
| 603 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 604 | + } |
|
| 564 | 605 | |
| 565 | 606 | return false; |
| 566 | 607 | } |
@@ -600,8 +641,9 @@ discard block |
||
| 600 | 641 | // 2013: Lost connection to server during query. |
| 601 | 642 | |
| 602 | 643 | // Log the error. |
| 603 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 604 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 644 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 645 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 646 | + } |
|
| 605 | 647 | |
| 606 | 648 | // Database error auto fixing ;). |
| 607 | 649 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -610,8 +652,9 @@ discard block |
||
| 610 | 652 | $old_cache = @$modSettings['cache_enable']; |
| 611 | 653 | $modSettings['cache_enable'] = '1'; |
| 612 | 654 | |
| 613 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 614 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 655 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 656 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 657 | + } |
|
| 615 | 658 | |
| 616 | 659 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 617 | 660 | { |
@@ -627,8 +670,9 @@ discard block |
||
| 627 | 670 | foreach ($tables as $table) |
| 628 | 671 | { |
| 629 | 672 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 630 | - if (trim($table) != '') |
|
| 631 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 673 | + if (trim($table) != '') { |
|
| 674 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 675 | + } |
|
| 632 | 676 | } |
| 633 | 677 | } |
| 634 | 678 | |
@@ -637,8 +681,9 @@ discard block |
||
| 637 | 681 | // Table crashed. Let's try to fix it. |
| 638 | 682 | elseif ($query_errno == 1016) |
| 639 | 683 | { |
| 640 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 641 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 684 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 685 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 686 | + } |
|
| 642 | 687 | } |
| 643 | 688 | // Indexes crashed. Should be easy to fix! |
| 644 | 689 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -657,13 +702,15 @@ discard block |
||
| 657 | 702 | |
| 658 | 703 | // Make a note of the REPAIR... |
| 659 | 704 | cache_put_data('db_last_error', time(), 600); |
| 660 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 661 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 705 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 706 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 707 | + } |
|
| 662 | 708 | |
| 663 | 709 | // Attempt to find and repair the broken table. |
| 664 | - foreach ($fix_tables as $table) |
|
| 665 | - $smcFunc['db_query']('', " |
|
| 710 | + foreach ($fix_tables as $table) { |
|
| 711 | + $smcFunc['db_query']('', " |
|
| 666 | 712 | REPAIR TABLE $table", false, false); |
| 713 | + } |
|
| 667 | 714 | |
| 668 | 715 | // And send off an email! |
| 669 | 716 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -672,11 +719,12 @@ discard block |
||
| 672 | 719 | |
| 673 | 720 | // Try the query again...? |
| 674 | 721 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 675 | - if ($ret !== false) |
|
| 676 | - return $ret; |
|
| 722 | + if ($ret !== false) { |
|
| 723 | + return $ret; |
|
| 724 | + } |
|
| 725 | + } else { |
|
| 726 | + $modSettings['cache_enable'] = $old_cache; |
|
| 677 | 727 | } |
| 678 | - else |
|
| 679 | - $modSettings['cache_enable'] = $old_cache; |
|
| 680 | 728 | |
| 681 | 729 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 682 | 730 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -686,22 +734,25 @@ discard block |
||
| 686 | 734 | // Are we in SSI mode? If so try that username and password first |
| 687 | 735 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 688 | 736 | { |
| 689 | - if (empty($db_persist)) |
|
| 690 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 691 | - else |
|
| 692 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 737 | + if (empty($db_persist)) { |
|
| 738 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 739 | + } else { |
|
| 740 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 741 | + } |
|
| 693 | 742 | } |
| 694 | 743 | // Fall back to the regular username and password if need be |
| 695 | 744 | if (!$db_connection) |
| 696 | 745 | { |
| 697 | - if (empty($db_persist)) |
|
| 698 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 699 | - else |
|
| 700 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 746 | + if (empty($db_persist)) { |
|
| 747 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 748 | + } else { |
|
| 749 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 750 | + } |
|
| 701 | 751 | } |
| 702 | 752 | |
| 703 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 704 | - $db_connection = false; |
|
| 753 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 754 | + $db_connection = false; |
|
| 755 | + } |
|
| 705 | 756 | } |
| 706 | 757 | |
| 707 | 758 | if ($db_connection) |
@@ -712,24 +763,27 @@ discard block |
||
| 712 | 763 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 713 | 764 | |
| 714 | 765 | $new_errno = mysqli_errno($db_connection); |
| 715 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 716 | - break; |
|
| 766 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 767 | + break; |
|
| 768 | + } |
|
| 717 | 769 | } |
| 718 | 770 | |
| 719 | 771 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 720 | - if ($ret !== false) |
|
| 721 | - return $ret; |
|
| 772 | + if ($ret !== false) { |
|
| 773 | + return $ret; |
|
| 774 | + } |
|
| 722 | 775 | } |
| 723 | 776 | } |
| 724 | 777 | // Are they out of space, perhaps? |
| 725 | 778 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 726 | 779 | { |
| 727 | - if (!isset($txt)) |
|
| 728 | - $query_error .= ' - check database storage space.'; |
|
| 729 | - else |
|
| 780 | + if (!isset($txt)) { |
|
| 781 | + $query_error .= ' - check database storage space.'; |
|
| 782 | + } else |
|
| 730 | 783 | { |
| 731 | - if (!isset($txt['mysql_error_space'])) |
|
| 732 | - loadLanguage('Errors'); |
|
| 784 | + if (!isset($txt['mysql_error_space'])) { |
|
| 785 | + loadLanguage('Errors'); |
|
| 786 | + } |
|
| 733 | 787 | |
| 734 | 788 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 735 | 789 | } |
@@ -737,15 +791,17 @@ discard block |
||
| 737 | 791 | } |
| 738 | 792 | |
| 739 | 793 | // Nothing's defined yet... just die with it. |
| 740 | - if (empty($context) || empty($txt)) |
|
| 741 | - die($query_error); |
|
| 794 | + if (empty($context) || empty($txt)) { |
|
| 795 | + die($query_error); |
|
| 796 | + } |
|
| 742 | 797 | |
| 743 | 798 | // Show an error message, if possible. |
| 744 | 799 | $context['error_title'] = $txt['database_error']; |
| 745 | - if (allowedTo('admin_forum')) |
|
| 746 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 747 | - else |
|
| 748 | - $context['error_message'] = $txt['try_again']; |
|
| 800 | + if (allowedTo('admin_forum')) { |
|
| 801 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 802 | + } else { |
|
| 803 | + $context['error_message'] = $txt['try_again']; |
|
| 804 | + } |
|
| 749 | 805 | |
| 750 | 806 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 751 | 807 | { |
@@ -777,8 +833,9 @@ discard block |
||
| 777 | 833 | $return_var = null; |
| 778 | 834 | |
| 779 | 835 | // With nothing to insert, simply return. |
| 780 | - if (empty($data)) |
|
| 781 | - return; |
|
| 836 | + if (empty($data)) { |
|
| 837 | + return; |
|
| 838 | + } |
|
| 782 | 839 | |
| 783 | 840 | // Replace the prefix holder with the actual prefix. |
| 784 | 841 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -788,23 +845,26 @@ discard block |
||
| 788 | 845 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
| 789 | 846 | { |
| 790 | 847 | $with_returning = true; |
| 791 | - if ($returnmode == 2) |
|
| 792 | - $return_var = array(); |
|
| 848 | + if ($returnmode == 2) { |
|
| 849 | + $return_var = array(); |
|
| 850 | + } |
|
| 793 | 851 | } |
| 794 | 852 | |
| 795 | 853 | // Inserting data as a single row can be done as a single array. |
| 796 | - if (!is_array($data[array_rand($data)])) |
|
| 797 | - $data = array($data); |
|
| 854 | + if (!is_array($data[array_rand($data)])) { |
|
| 855 | + $data = array($data); |
|
| 856 | + } |
|
| 798 | 857 | |
| 799 | 858 | // Create the mold for a single row insert. |
| 800 | 859 | $insertData = '('; |
| 801 | 860 | foreach ($columns as $columnName => $type) |
| 802 | 861 | { |
| 803 | 862 | // Are we restricting the length? |
| 804 | - if (strpos($type, 'string-') !== false) |
|
| 805 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 806 | - else |
|
| 807 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 863 | + if (strpos($type, 'string-') !== false) { |
|
| 864 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 865 | + } else { |
|
| 866 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 867 | + } |
|
| 808 | 868 | } |
| 809 | 869 | $insertData = substr($insertData, 0, -2) . ')'; |
| 810 | 870 | |
@@ -813,8 +873,9 @@ discard block |
||
| 813 | 873 | |
| 814 | 874 | // Here's where the variables are injected to the query. |
| 815 | 875 | $insertRows = array(); |
| 816 | - foreach ($data as $dataRow) |
|
| 817 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 876 | + foreach ($data as $dataRow) { |
|
| 877 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 878 | + } |
|
| 818 | 879 | |
| 819 | 880 | // Determine the method of insertion. |
| 820 | 881 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -833,8 +894,7 @@ discard block |
||
| 833 | 894 | ), |
| 834 | 895 | $connection |
| 835 | 896 | ); |
| 836 | - } |
|
| 837 | - else //special way for ignore method with returning |
|
| 897 | + } else //special way for ignore method with returning |
|
| 838 | 898 | { |
| 839 | 899 | $count = count($insertRows); |
| 840 | 900 | $ai = 0; |
@@ -854,19 +914,21 @@ discard block |
||
| 854 | 914 | ); |
| 855 | 915 | $new_id = $smcFunc['db_insert_id'](); |
| 856 | 916 | |
| 857 | - if ($last_id != $new_id) //the inserted value was new |
|
| 917 | + if ($last_id != $new_id) { |
|
| 918 | + //the inserted value was new |
|
| 858 | 919 | { |
| 859 | 920 | $ai = $new_id; |
| 860 | 921 | } |
| 861 | - else // the inserted value already exists we need to find the pk |
|
| 922 | + } else // the inserted value already exists we need to find the pk |
|
| 862 | 923 | { |
| 863 | 924 | $where_string = ''; |
| 864 | 925 | $count2 = count($indexed_columns); |
| 865 | 926 | for ($x = 0; $x < $count2; $x++) |
| 866 | 927 | { |
| 867 | 928 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
| 868 | - if (($x + 1) < $count2) |
|
| 869 | - $where_string += ' AND '; |
|
| 929 | + if (($x + 1) < $count2) { |
|
| 930 | + $where_string += ' AND '; |
|
| 931 | + } |
|
| 870 | 932 | } |
| 871 | 933 | |
| 872 | 934 | $request = $smcFunc['db_query']('',' |
@@ -882,25 +944,27 @@ discard block |
||
| 882 | 944 | } |
| 883 | 945 | } |
| 884 | 946 | |
| 885 | - if ($returnmode == 1) |
|
| 886 | - $return_var = $ai; |
|
| 887 | - else if ($returnmode == 2) |
|
| 888 | - $return_var[] = $ai; |
|
| 947 | + if ($returnmode == 1) { |
|
| 948 | + $return_var = $ai; |
|
| 949 | + } else if ($returnmode == 2) { |
|
| 950 | + $return_var[] = $ai; |
|
| 951 | + } |
|
| 889 | 952 | } |
| 890 | 953 | } |
| 891 | 954 | |
| 892 | 955 | |
| 893 | 956 | if ($with_returning) |
| 894 | 957 | { |
| 895 | - if ($returnmode == 1 && empty($return_var)) |
|
| 896 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 897 | - else if ($returnmode == 2 && empty($return_var)) |
|
| 958 | + if ($returnmode == 1 && empty($return_var)) { |
|
| 959 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 960 | + } else if ($returnmode == 2 && empty($return_var)) |
|
| 898 | 961 | { |
| 899 | 962 | $return_var = array(); |
| 900 | 963 | $count = count($insertRows); |
| 901 | 964 | $start = smf_db_insert_id($table, $keys[0]); |
| 902 | - for ($i = 0; $i < $count; $i++ ) |
|
| 903 | - $return_var[] = $start + $i; |
|
| 965 | + for ($i = 0; $i < $count; $i++ ) { |
|
| 966 | + $return_var[] = $start + $i; |
|
| 967 | + } |
|
| 904 | 968 | } |
| 905 | 969 | return $return_var; |
| 906 | 970 | } |
@@ -918,8 +982,9 @@ discard block |
||
| 918 | 982 | */ |
| 919 | 983 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 920 | 984 | { |
| 921 | - if (empty($log_message)) |
|
| 922 | - $log_message = $error_message; |
|
| 985 | + if (empty($log_message)) { |
|
| 986 | + $log_message = $error_message; |
|
| 987 | + } |
|
| 923 | 988 | |
| 924 | 989 | foreach (debug_backtrace() as $step) |
| 925 | 990 | { |
@@ -938,12 +1003,14 @@ discard block |
||
| 938 | 1003 | } |
| 939 | 1004 | |
| 940 | 1005 | // A special case - we want the file and line numbers for debugging. |
| 941 | - if ($error_type == 'return') |
|
| 942 | - return array($file, $line); |
|
| 1006 | + if ($error_type == 'return') { |
|
| 1007 | + return array($file, $line); |
|
| 1008 | + } |
|
| 943 | 1009 | |
| 944 | 1010 | // Is always a critical error. |
| 945 | - if (function_exists('log_error')) |
|
| 946 | - log_error($log_message, 'critical', $file, $line); |
|
| 1011 | + if (function_exists('log_error')) { |
|
| 1012 | + log_error($log_message, 'critical', $file, $line); |
|
| 1013 | + } |
|
| 947 | 1014 | |
| 948 | 1015 | if (function_exists('fatal_error')) |
| 949 | 1016 | { |
@@ -951,12 +1018,12 @@ discard block |
||
| 951 | 1018 | |
| 952 | 1019 | // Cannot continue... |
| 953 | 1020 | exit; |
| 1021 | + } elseif ($error_type) { |
|
| 1022 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 1023 | + } else { |
|
| 1024 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 1025 | + } |
|
| 954 | 1026 | } |
| 955 | - elseif ($error_type) |
|
| 956 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 957 | - else |
|
| 958 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 959 | -} |
|
| 960 | 1027 | |
| 961 | 1028 | /** |
| 962 | 1029 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -973,10 +1040,11 @@ discard block |
||
| 973 | 1040 | '\\' => '\\\\', |
| 974 | 1041 | ); |
| 975 | 1042 | |
| 976 | - if ($translate_human_wildcards) |
|
| 977 | - $replacements += array( |
|
| 1043 | + if ($translate_human_wildcards) { |
|
| 1044 | + $replacements += array( |
|
| 978 | 1045 | '*' => '%', |
| 979 | 1046 | ); |
| 1047 | + } |
|
| 980 | 1048 | |
| 981 | 1049 | return strtr($string, $replacements); |
| 982 | 1050 | } |
@@ -990,8 +1058,9 @@ discard block |
||
| 990 | 1058 | */ |
| 991 | 1059 | function smf_is_resource($result) |
| 992 | 1060 | { |
| 993 | - if ($result instanceof mysqli_result) |
|
| 994 | - return true; |
|
| 1061 | + if ($result instanceof mysqli_result) { |
|
| 1062 | + return true; |
|
| 1063 | + } |
|
| 995 | 1064 | |
| 996 | 1065 | return false; |
| 997 | 1066 | } |