@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * SQLite Cache API class |
@@ -153,8 +154,7 @@ discard block |
||
| 153 | 154 | if (is_null($dir) || !is_writable($dir)) |
| 154 | 155 | { |
| 155 | 156 | $this->cachedir = $cachedir_sqlite; |
| 156 | - } |
|
| 157 | - else |
|
| 157 | + } else |
|
| 158 | 158 | { |
| 159 | 159 | $this->cachedir = $dir; |
| 160 | 160 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
| 47 | 48 | 'post' => 'CalendarPost', |
| 48 | 49 | ); |
| 49 | 50 | |
| 50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
| 51 | - return call_helper($subActions[$_GET['sa']]); |
|
| 51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
| 52 | + return call_helper($subActions[$_GET['sa']]); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | // You can't do anything if the calendar is off. |
| 54 | - if (empty($modSettings['cal_enabled'])) |
|
| 55 | - fatal_lang_error('calendar_off', false); |
|
| 56 | + if (empty($modSettings['cal_enabled'])) { |
|
| 57 | + fatal_lang_error('calendar_off', false); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | // This is gonna be needed... |
| 58 | 61 | loadTemplate('Calendar'); |
@@ -80,8 +83,9 @@ discard block |
||
| 80 | 83 | $_REQUEST['month'] = (int) $_REQUEST['month']; |
| 81 | 84 | |
| 82 | 85 | // We want month view. |
| 83 | - if (empty($_GET['viewmonth'])) |
|
| 84 | - $_GET['viewmonth'] = true; |
|
| 86 | + if (empty($_GET['viewmonth'])) { |
|
| 87 | + $_GET['viewmonth'] = true; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | // And we definitely don't want weekly view. |
| 87 | 91 | unset ($_GET['viewweek']); |
@@ -98,22 +102,25 @@ discard block |
||
| 98 | 102 | $context['page_title'] = $txt['calendar']; |
| 99 | 103 | |
| 100 | 104 | // Ensure a default view is defined |
| 101 | - if (empty($modSettings['calendar_default_view'])) |
|
| 102 | - $modSettings['calendar_default_view'] = 'view_list'; |
|
| 105 | + if (empty($modSettings['calendar_default_view'])) { |
|
| 106 | + $modSettings['calendar_default_view'] = 'view_list'; |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // What view do we want? |
| 105 | - if (isset($_GET['viewweek'])) |
|
| 106 | - $context['calendar_view'] = 'view_week'; |
|
| 107 | - elseif (isset($_GET['viewmonth'])) |
|
| 108 | - $context['calendar_view'] = 'view_month'; |
|
| 109 | - elseif (isset($_GET['viewlist'])) |
|
| 110 | - $context['calendar_view'] = 'view_list'; |
|
| 111 | - else |
|
| 112 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 110 | + if (isset($_GET['viewweek'])) { |
|
| 111 | + $context['calendar_view'] = 'view_week'; |
|
| 112 | + } elseif (isset($_GET['viewmonth'])) { |
|
| 113 | + $context['calendar_view'] = 'view_month'; |
|
| 114 | + } elseif (isset($_GET['viewlist'])) { |
|
| 115 | + $context['calendar_view'] = 'view_list'; |
|
| 116 | + } else { |
|
| 117 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 118 | + } |
|
| 113 | 119 | |
| 114 | 120 | // Don't let search engines index the non-default calendar pages |
| 115 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
| 116 | - $context['robot_no_index'] = true; |
|
| 121 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
| 122 | + $context['robot_no_index'] = true; |
|
| 123 | + } |
|
| 117 | 124 | |
| 118 | 125 | // Get the current day of month... |
| 119 | 126 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -174,16 +181,19 @@ discard block |
||
| 174 | 181 | ); |
| 175 | 182 | |
| 176 | 183 | // Make sure the year and month are in valid ranges. |
| 177 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
| 178 | - fatal_lang_error('invalid_month', false); |
|
| 179 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
| 180 | - fatal_lang_error('invalid_year', false); |
|
| 184 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
| 185 | + fatal_lang_error('invalid_month', false); |
|
| 186 | + } |
|
| 187 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
| 188 | + fatal_lang_error('invalid_year', false); |
|
| 189 | + } |
|
| 181 | 190 | // If we have a day clean that too. |
| 182 | 191 | if ($context['calendar_view'] != 'view_month') |
| 183 | 192 | { |
| 184 | 193 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
| 185 | - if (!$isValid) |
|
| 186 | - fatal_lang_error('invalid_day', false); |
|
| 194 | + if (!$isValid) { |
|
| 195 | + fatal_lang_error('invalid_day', false); |
|
| 196 | + } |
|
| 187 | 197 | } |
| 188 | 198 | |
| 189 | 199 | // Load all the context information needed to show the calendar grid. |
@@ -205,23 +215,26 @@ discard block |
||
| 205 | 215 | ); |
| 206 | 216 | |
| 207 | 217 | // Load up the main view. |
| 208 | - if ($context['calendar_view'] == 'view_list') |
|
| 209 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 210 | - elseif ($context['calendar_view'] == 'view_week') |
|
| 211 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 212 | - else |
|
| 213 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 218 | + if ($context['calendar_view'] == 'view_list') { |
|
| 219 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 220 | + } elseif ($context['calendar_view'] == 'view_week') { |
|
| 221 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 222 | + } else { |
|
| 223 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 224 | + } |
|
| 214 | 225 | |
| 215 | 226 | // Load up the previous and next months. |
| 216 | 227 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
| 217 | 228 | |
| 218 | 229 | // Only show previous month if it isn't pre-January of the min-year |
| 219 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
| 220 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 230 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
| 231 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 232 | + } |
|
| 221 | 233 | |
| 222 | 234 | // Only show next month if it isn't post-December of the max-year |
| 223 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
| 224 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 235 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
| 236 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 237 | + } |
|
| 225 | 238 | |
| 226 | 239 | // Basic template stuff. |
| 227 | 240 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -241,8 +254,9 @@ discard block |
||
| 241 | 254 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
| 242 | 255 | |
| 243 | 256 | // Set the page title to mention the month or week, too |
| 244 | - if ($context['calendar_view'] != 'view_list') |
|
| 245 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 257 | + if ($context['calendar_view'] != 'view_list') { |
|
| 258 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 259 | + } |
|
| 246 | 260 | |
| 247 | 261 | // Load up the linktree! |
| 248 | 262 | $context['linktree'][] = array( |
@@ -255,17 +269,19 @@ discard block |
||
| 255 | 269 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
| 256 | 270 | ); |
| 257 | 271 | // If applicable, add the current week to the linktree. |
| 258 | - if ($context['calendar_view'] == 'view_week') |
|
| 259 | - $context['linktree'][] = array( |
|
| 272 | + if ($context['calendar_view'] == 'view_week') { |
|
| 273 | + $context['linktree'][] = array( |
|
| 260 | 274 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 261 | 275 | 'name' => $context['calendar_grid_main']['week_title'], |
| 262 | 276 | ); |
| 277 | + } |
|
| 263 | 278 | |
| 264 | 279 | // Build the calendar button array. |
| 265 | 280 | $context['calendar_buttons'] = array(); |
| 266 | 281 | |
| 267 | - if ($context['can_post']) |
|
| 268 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 282 | + if ($context['can_post']) { |
|
| 283 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 284 | + } |
|
| 269 | 285 | |
| 270 | 286 | // Allow mods to add additional buttons here |
| 271 | 287 | call_integration_hook('integrate_calendar_buttons'); |
@@ -294,14 +310,16 @@ discard block |
||
| 294 | 310 | require_once($sourcedir . '/Subs.php'); |
| 295 | 311 | |
| 296 | 312 | // Cast this for safety... |
| 297 | - if (isset($_REQUEST['eventid'])) |
|
| 298 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 313 | + if (isset($_REQUEST['eventid'])) { |
|
| 314 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 315 | + } |
|
| 299 | 316 | |
| 300 | 317 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 301 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 302 | - $time_string = '%k:%M'; |
|
| 303 | - else |
|
| 304 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 318 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 319 | + $time_string = '%k:%M'; |
|
| 320 | + } else { |
|
| 321 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 322 | + } |
|
| 305 | 323 | |
| 306 | 324 | $js_time_string = str_replace( |
| 307 | 325 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -315,12 +333,14 @@ discard block |
||
| 315 | 333 | checkSession(); |
| 316 | 334 | |
| 317 | 335 | // Validate the post... |
| 318 | - if (!isset($_POST['link_to_board'])) |
|
| 319 | - validateEventPost(); |
|
| 336 | + if (!isset($_POST['link_to_board'])) { |
|
| 337 | + validateEventPost(); |
|
| 338 | + } |
|
| 320 | 339 | |
| 321 | 340 | // If you're not allowed to edit any events, you have to be the poster. |
| 322 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
| 323 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 341 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
| 342 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 343 | + } |
|
| 324 | 344 | |
| 325 | 345 | // New - and directing? |
| 326 | 346 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -343,8 +363,9 @@ discard block |
||
| 343 | 363 | } |
| 344 | 364 | |
| 345 | 365 | // Deleting... |
| 346 | - elseif (isset($_REQUEST['deleteevent'])) |
|
| 347 | - removeEvent($_REQUEST['eventid']); |
|
| 366 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
| 367 | + removeEvent($_REQUEST['eventid']); |
|
| 368 | + } |
|
| 348 | 369 | |
| 349 | 370 | // ... or just update it? |
| 350 | 371 | else |
@@ -366,14 +387,12 @@ discard block |
||
| 366 | 387 | $d = date_parse($_POST['start_date']); |
| 367 | 388 | $year = $d['year']; |
| 368 | 389 | $month = $d['month']; |
| 369 | - } |
|
| 370 | - elseif (isset($_POST['start_datetime'])) |
|
| 390 | + } elseif (isset($_POST['start_datetime'])) |
|
| 371 | 391 | { |
| 372 | 392 | $d = date_parse($_POST['start_datetime']); |
| 373 | 393 | $year = $d['year']; |
| 374 | 394 | $month = $d['month']; |
| 375 | - } |
|
| 376 | - else |
|
| 395 | + } else |
|
| 377 | 396 | { |
| 378 | 397 | $today = getdate(); |
| 379 | 398 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -406,13 +425,13 @@ discard block |
||
| 406 | 425 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
| 407 | 426 | |
| 408 | 427 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
| 409 | - } |
|
| 410 | - else |
|
| 428 | + } else |
|
| 411 | 429 | { |
| 412 | 430 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
| 413 | 431 | |
| 414 | - if ($context['event'] === false) |
|
| 415 | - fatal_lang_error('no_access', false); |
|
| 432 | + if ($context['event'] === false) { |
|
| 433 | + fatal_lang_error('no_access', false); |
|
| 434 | + } |
|
| 416 | 435 | |
| 417 | 436 | // If it has a board, then they should be editing it within the topic. |
| 418 | 437 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -423,10 +442,11 @@ discard block |
||
| 423 | 442 | } |
| 424 | 443 | |
| 425 | 444 | // Make sure the user is allowed to edit this event. |
| 426 | - if ($context['event']['member'] != $user_info['id']) |
|
| 427 | - isAllowedTo('calendar_edit_any'); |
|
| 428 | - elseif (!allowedTo('calendar_edit_any')) |
|
| 429 | - isAllowedTo('calendar_edit_own'); |
|
| 445 | + if ($context['event']['member'] != $user_info['id']) { |
|
| 446 | + isAllowedTo('calendar_edit_any'); |
|
| 447 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
| 448 | + isAllowedTo('calendar_edit_own'); |
|
| 449 | + } |
|
| 430 | 450 | } |
| 431 | 451 | |
| 432 | 452 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -460,8 +480,7 @@ discard block |
||
| 460 | 480 | { |
| 461 | 481 | // You can post new events but can't link them to anything... |
| 462 | 482 | $context['event']['categories'] = array(); |
| 463 | - } |
|
| 464 | - else |
|
| 483 | + } else |
|
| 465 | 484 | { |
| 466 | 485 | // Load the list of boards and categories in the context. |
| 467 | 486 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -548,12 +567,14 @@ discard block |
||
| 548 | 567 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
| 549 | 568 | |
| 550 | 569 | // You can't export if the calendar export feature is off. |
| 551 | - if (empty($modSettings['cal_export'])) |
|
| 552 | - fatal_lang_error('calendar_export_off', false); |
|
| 570 | + if (empty($modSettings['cal_export'])) { |
|
| 571 | + fatal_lang_error('calendar_export_off', false); |
|
| 572 | + } |
|
| 553 | 573 | |
| 554 | 574 | // Goes without saying that this is required. |
| 555 | - if (!isset($_REQUEST['eventid'])) |
|
| 556 | - fatal_lang_error('no_access', false); |
|
| 575 | + if (!isset($_REQUEST['eventid'])) { |
|
| 576 | + fatal_lang_error('no_access', false); |
|
| 577 | + } |
|
| 557 | 578 | |
| 558 | 579 | // This is kinda wanted. |
| 559 | 580 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -561,15 +582,17 @@ discard block |
||
| 561 | 582 | // Load up the event in question and check it exists. |
| 562 | 583 | $event = getEventProperties($_REQUEST['eventid']); |
| 563 | 584 | |
| 564 | - if ($event === false) |
|
| 565 | - fatal_lang_error('no_access', false); |
|
| 585 | + if ($event === false) { |
|
| 586 | + fatal_lang_error('no_access', false); |
|
| 587 | + } |
|
| 566 | 588 | |
| 567 | 589 | // Check the title isn't too long - iCal requires some formatting if so. |
| 568 | 590 | $title = str_split($event['title'], 30); |
| 569 | 591 | foreach ($title as $id => $line) |
| 570 | 592 | { |
| 571 | - if ($id != 0) |
|
| 572 | - $title[$id] = ' ' . $title[$id]; |
|
| 593 | + if ($id != 0) { |
|
| 594 | + $title[$id] = ' ' . $title[$id]; |
|
| 595 | + } |
|
| 573 | 596 | $title[$id] .= "\n"; |
| 574 | 597 | } |
| 575 | 598 | |
@@ -582,8 +605,7 @@ discard block |
||
| 582 | 605 | { |
| 583 | 606 | $datestart = date_format($start_date, 'Ymd\THis'); |
| 584 | 607 | $dateend = date_format($end_date, 'Ymd\THis'); |
| 585 | - } |
|
| 586 | - else |
|
| 608 | + } else |
|
| 587 | 609 | { |
| 588 | 610 | $datestart = date_format($start_date, 'Ymd'); |
| 589 | 611 | |
@@ -604,15 +626,18 @@ discard block |
||
| 604 | 626 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
| 605 | 627 | |
| 606 | 628 | // event has a duration |
| 607 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
| 608 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 629 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
| 630 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 631 | + } |
|
| 609 | 632 | |
| 610 | 633 | // event has changed? advance the sequence for this UID |
| 611 | - if ($event['sequence'] > 0) |
|
| 612 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 634 | + if ($event['sequence'] > 0) { |
|
| 635 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 636 | + } |
|
| 613 | 637 | |
| 614 | - if (!empty($event['location'])) |
|
| 615 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 638 | + if (!empty($event['location'])) { |
|
| 639 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 640 | + } |
|
| 616 | 641 | |
| 617 | 642 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 618 | 643 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -621,23 +646,26 @@ discard block |
||
| 621 | 646 | |
| 622 | 647 | // Send some standard headers. |
| 623 | 648 | ob_end_clean(); |
| 624 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 625 | - @ob_start('ob_gzhandler'); |
|
| 626 | - else |
|
| 627 | - ob_start(); |
|
| 649 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 650 | + @ob_start('ob_gzhandler'); |
|
| 651 | + } else { |
|
| 652 | + ob_start(); |
|
| 653 | + } |
|
| 628 | 654 | |
| 629 | 655 | // Send the file headers |
| 630 | 656 | header('Pragma: '); |
| 631 | 657 | header('Cache-Control: no-cache'); |
| 632 | - if (!isBrowser('gecko')) |
|
| 633 | - header('Content-Transfer-Encoding: binary'); |
|
| 658 | + if (!isBrowser('gecko')) { |
|
| 659 | + header('Content-Transfer-Encoding: binary'); |
|
| 660 | + } |
|
| 634 | 661 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 635 | 662 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
| 636 | 663 | header('Accept-Ranges: bytes'); |
| 637 | 664 | header('Connection: close'); |
| 638 | 665 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 639 | - if (empty($modSettings['enableCompressedOutput'])) |
|
| 640 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 666 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
| 667 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 668 | + } |
|
| 641 | 669 | |
| 642 | 670 | // This is a calendar item! |
| 643 | 671 | header('Content-Type: text/calendar'); |
@@ -676,20 +704,17 @@ discard block |
||
| 676 | 704 | $context['sub_template'] = 'bcd'; |
| 677 | 705 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
| 678 | 706 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ==')); |
| 679 | - } |
|
| 680 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 707 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 681 | 708 | { |
| 682 | 709 | $context['sub_template'] = 'hms'; |
| 683 | 710 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
| 684 | 711 | $context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); |
| 685 | - } |
|
| 686 | - elseif ($omfg) |
|
| 712 | + } elseif ($omfg) |
|
| 687 | 713 | { |
| 688 | 714 | $context['sub_template'] = 'omfg'; |
| 689 | 715 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
| 690 | 716 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ==')); |
| 691 | - } |
|
| 692 | - elseif (isset($_REQUEST['time'])) |
|
| 717 | + } elseif (isset($_REQUEST['time'])) |
|
| 693 | 718 | { |
| 694 | 719 | $context['sub_template'] = 'thetime'; |
| 695 | 720 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -749,12 +774,13 @@ discard block |
||
| 749 | 774 | ), |
| 750 | 775 | ); |
| 751 | 776 | |
| 752 | - foreach ($context['clockicons'] as $t => $vs) |
|
| 753 | - foreach ($vs as $v => $dumb) |
|
| 777 | + foreach ($context['clockicons'] as $t => $vs) { |
|
| 778 | + foreach ($vs as $v => $dumb) |
|
| 754 | 779 | { |
| 755 | 780 | if ($$t >= $v) |
| 756 | 781 | { |
| 757 | 782 | $$t -= $v; |
| 783 | + } |
|
| 758 | 784 | $context['clockicons'][$t][$v] = true; |
| 759 | 785 | } |
| 760 | 786 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
| 96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
| 97 | 98 | |
| 98 | 99 | // Yep, sub-action time! |
| 99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 100 | - $subAction = $_REQUEST['sa']; |
|
| 101 | - else |
|
| 102 | - $subAction = 'routine'; |
|
| 100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 101 | + $subAction = $_REQUEST['sa']; |
|
| 102 | + } else { |
|
| 103 | + $subAction = 'routine'; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | // Doing something special? |
| 105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
| 106 | - $activity = $_REQUEST['activity']; |
|
| 107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
| 108 | + $activity = $_REQUEST['activity']; |
|
| 109 | + } |
|
| 107 | 110 | |
| 108 | 111 | // Set a few things. |
| 109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
| 114 | 117 | call_helper($subActions[$subAction]['function']); |
| 115 | 118 | |
| 116 | 119 | // Any special activity? |
| 117 | - if (isset($activity)) |
|
| 118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 120 | + if (isset($activity)) { |
|
| 121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | //converted to UTF-8? show a small maintenance info |
| 121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
| 122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
| 126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 127 | + } |
|
| 123 | 128 | |
| 124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
| 125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
| 141 | 146 | db_extend('packages'); |
| 142 | 147 | |
| 143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 144 | - foreach ($colData as $column) |
|
| 145 | - if ($column['name'] == 'body') |
|
| 149 | + foreach ($colData as $column) { |
|
| 150 | + if ($column['name'] == 'body') |
|
| 146 | 151 | $body_type = $column['type']; |
| 152 | + } |
|
| 147 | 153 | |
| 148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 150 | 156 | } |
| 151 | 157 | |
| 152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
| 153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
| 155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 156 | -} |
|
| 158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
| 159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 160 | + } |
|
| 161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
| 162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 163 | + } |
|
| 164 | + } |
|
| 157 | 165 | |
| 158 | 166 | /** |
| 159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
| 162 | 170 | { |
| 163 | 171 | global $context, $txt; |
| 164 | 172 | |
| 165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
| 166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 167 | -} |
|
| 173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
| 174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 175 | + } |
|
| 176 | + } |
|
| 168 | 177 | |
| 169 | 178 | /** |
| 170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
| 195 | 204 | } |
| 196 | 205 | $smcFunc['db_free_result']($result); |
| 197 | 206 | |
| 198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
| 199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
| 208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 209 | + } |
|
| 200 | 210 | |
| 201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
| 222 | 232 | $context['categories'] = array(); |
| 223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 224 | 234 | { |
| 225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 226 | - $context['categories'][$row['id_cat']] = array( |
|
| 235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 236 | + $context['categories'][$row['id_cat']] = array( |
|
| 227 | 237 | 'name' => $row['cat_name'], |
| 228 | 238 | 'boards' => array() |
| 229 | 239 | ); |
| 240 | + } |
|
| 230 | 241 | |
| 231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
| 232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
| 239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
| 240 | 251 | sortCategories($context['categories']); |
| 241 | 252 | |
| 242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
| 243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
| 245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 246 | -} |
|
| 253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
| 254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
| 256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 257 | + } |
|
| 258 | + } |
|
| 247 | 259 | |
| 248 | 260 | /** |
| 249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
| 351 | 363 | // Show me your badge! |
| 352 | 364 | isAllowedTo('admin_forum'); |
| 353 | 365 | |
| 354 | - if ($db_type != 'mysql') |
|
| 355 | - return; |
|
| 366 | + if ($db_type != 'mysql') { |
|
| 367 | + return; |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | db_extend('packages'); |
| 358 | 371 | |
| 359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 360 | - foreach ($colData as $column) |
|
| 361 | - if ($column['name'] == 'body') |
|
| 373 | + foreach ($colData as $column) { |
|
| 374 | + if ($column['name'] == 'body') |
|
| 362 | 375 | $body_type = $column['type']; |
| 376 | + } |
|
| 363 | 377 | |
| 364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 365 | 379 | |
@@ -369,33 +383,36 @@ discard block |
||
| 369 | 383 | validateToken('admin-maint'); |
| 370 | 384 | |
| 371 | 385 | // Make it longer so we can do their limit. |
| 372 | - if ($body_type == 'text') |
|
| 373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 386 | + if ($body_type == 'text') { |
|
| 387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 388 | + } |
|
| 374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
| 375 | - else |
|
| 376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 390 | + else { |
|
| 391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 392 | + } |
|
| 377 | 393 | |
| 378 | 394 | // 3rd party integrations may be interested in knowning about this. |
| 379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
| 380 | 396 | |
| 381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 382 | - foreach ($colData as $column) |
|
| 383 | - if ($column['name'] == 'body') |
|
| 398 | + foreach ($colData as $column) { |
|
| 399 | + if ($column['name'] == 'body') |
|
| 384 | 400 | $body_type = $column['type']; |
| 401 | + } |
|
| 385 | 402 | |
| 386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
| 387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 388 | 405 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 389 | 406 | |
| 390 | 407 | return; |
| 391 | - } |
|
| 392 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 408 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 393 | 409 | { |
| 394 | 410 | checkSession(); |
| 395 | - if (empty($_REQUEST['start'])) |
|
| 396 | - validateToken('admin-maint'); |
|
| 397 | - else |
|
| 398 | - validateToken('admin-convertMsg'); |
|
| 411 | + if (empty($_REQUEST['start'])) { |
|
| 412 | + validateToken('admin-maint'); |
|
| 413 | + } else { |
|
| 414 | + validateToken('admin-convertMsg'); |
|
| 415 | + } |
|
| 399 | 416 | |
| 400 | 417 | $context['page_title'] = $txt['not_done_title']; |
| 401 | 418 | $context['continue_post_data'] = ''; |
@@ -427,8 +444,9 @@ discard block |
||
| 427 | 444 | 'increment' => $increment - 1, |
| 428 | 445 | ) |
| 429 | 446 | ); |
| 430 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 431 | - $id_msg_exceeding[] = $row['id_msg']; |
|
| 447 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 448 | + $id_msg_exceeding[] = $row['id_msg']; |
|
| 449 | + } |
|
| 432 | 450 | $smcFunc['db_free_result']($request); |
| 433 | 451 | |
| 434 | 452 | $_REQUEST['start'] += $increment; |
@@ -457,9 +475,9 @@ discard block |
||
| 457 | 475 | { |
| 458 | 476 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
| 459 | 477 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
| 478 | + } else { |
|
| 479 | + $query_msg = $id_msg_exceeding; |
|
| 460 | 480 | } |
| 461 | - else |
|
| 462 | - $query_msg = $id_msg_exceeding; |
|
| 463 | 481 | |
| 464 | 482 | $context['exceeding_messages'] = array(); |
| 465 | 483 | $request = $smcFunc['db_query']('', ' |
@@ -470,8 +488,9 @@ discard block |
||
| 470 | 488 | 'messages' => $query_msg, |
| 471 | 489 | ) |
| 472 | 490 | ); |
| 473 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 474 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 491 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 492 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 493 | + } |
|
| 475 | 494 | $smcFunc['db_free_result']($request); |
| 476 | 495 | } |
| 477 | 496 | } |
@@ -495,8 +514,9 @@ discard block |
||
| 495 | 514 | isAllowedTo('admin_forum'); |
| 496 | 515 | |
| 497 | 516 | // Check to see if UTF-8 is currently the default character set. |
| 498 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
| 499 | - fatal_lang_error('entity_convert_only_utf8'); |
|
| 517 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
| 518 | + fatal_lang_error('entity_convert_only_utf8'); |
|
| 519 | + } |
|
| 500 | 520 | |
| 501 | 521 | // Some starting values. |
| 502 | 522 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -558,8 +578,9 @@ discard block |
||
| 558 | 578 | // Make sure we keep stuff unique! |
| 559 | 579 | $primary_keys = array(); |
| 560 | 580 | |
| 561 | - if (function_exists('apache_reset_timeout')) |
|
| 562 | - @apache_reset_timeout(); |
|
| 581 | + if (function_exists('apache_reset_timeout')) { |
|
| 582 | + @apache_reset_timeout(); |
|
| 583 | + } |
|
| 563 | 584 | |
| 564 | 585 | // Get a list of text columns. |
| 565 | 586 | $columns = array(); |
@@ -570,9 +591,10 @@ discard block |
||
| 570 | 591 | 'cur_table' => $cur_table, |
| 571 | 592 | ) |
| 572 | 593 | ); |
| 573 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
| 574 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 594 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
| 595 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 575 | 596 | $columns[] = strtolower($column_info['Field']); |
| 597 | + } |
|
| 576 | 598 | |
| 577 | 599 | // Get the column with the (first) primary key. |
| 578 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +608,9 @@ discard block |
||
| 586 | 608 | { |
| 587 | 609 | if ($row['Key_name'] === 'PRIMARY') |
| 588 | 610 | { |
| 589 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
| 590 | - $primary_key = $row['Column_name']; |
|
| 611 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
| 612 | + $primary_key = $row['Column_name']; |
|
| 613 | + } |
|
| 591 | 614 | |
| 592 | 615 | $primary_keys[] = $row['Column_name']; |
| 593 | 616 | } |
@@ -596,8 +619,9 @@ discard block |
||
| 596 | 619 | |
| 597 | 620 | // No primary key, no glory. |
| 598 | 621 | // Same for columns. Just to be sure we've work to do! |
| 599 | - if (empty($primary_key) || empty($columns)) |
|
| 600 | - continue; |
|
| 622 | + if (empty($primary_key) || empty($columns)) { |
|
| 623 | + continue; |
|
| 624 | + } |
|
| 601 | 625 | |
| 602 | 626 | // Get the maximum value for the primary key. |
| 603 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -611,8 +635,9 @@ discard block |
||
| 611 | 635 | list($max_value) = $smcFunc['db_fetch_row']($request); |
| 612 | 636 | $smcFunc['db_free_result']($request); |
| 613 | 637 | |
| 614 | - if (empty($max_value)) |
|
| 615 | - continue; |
|
| 638 | + if (empty($max_value)) { |
|
| 639 | + continue; |
|
| 640 | + } |
|
| 616 | 641 | |
| 617 | 642 | while ($context['start'] <= $max_value) |
| 618 | 643 | { |
@@ -636,10 +661,11 @@ discard block |
||
| 636 | 661 | { |
| 637 | 662 | $insertion_variables = array(); |
| 638 | 663 | $changes = array(); |
| 639 | - foreach ($row as $column_name => $column_value) |
|
| 640 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 664 | + foreach ($row as $column_name => $column_value) { |
|
| 665 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 641 | 666 | { |
| 642 | 667 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
| 668 | + } |
|
| 643 | 669 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value); |
| 644 | 670 | } |
| 645 | 671 | |
@@ -651,8 +677,8 @@ discard block |
||
| 651 | 677 | } |
| 652 | 678 | |
| 653 | 679 | // Update the row. |
| 654 | - if (!empty($changes)) |
|
| 655 | - $smcFunc['db_query']('', ' |
|
| 680 | + if (!empty($changes)) { |
|
| 681 | + $smcFunc['db_query']('', ' |
|
| 656 | 682 | UPDATE {db_prefix}' . $cur_table . ' |
| 657 | 683 | SET |
| 658 | 684 | ' . implode(', |
@@ -660,6 +686,7 @@ discard block |
||
| 660 | 686 | WHERE ' . implode(' AND ', $where), |
| 661 | 687 | $insertion_variables |
| 662 | 688 | ); |
| 689 | + } |
|
| 663 | 690 | } |
| 664 | 691 | $smcFunc['db_free_result']($request); |
| 665 | 692 | $context['start'] += 500; |
@@ -704,10 +731,11 @@ discard block |
||
| 704 | 731 | |
| 705 | 732 | checkSession('request'); |
| 706 | 733 | |
| 707 | - if (!isset($_SESSION['optimized_tables'])) |
|
| 708 | - validateToken('admin-maint'); |
|
| 709 | - else |
|
| 710 | - validateToken('admin-optimize', 'post', false); |
|
| 734 | + if (!isset($_SESSION['optimized_tables'])) { |
|
| 735 | + validateToken('admin-maint'); |
|
| 736 | + } else { |
|
| 737 | + validateToken('admin-optimize', 'post', false); |
|
| 738 | + } |
|
| 711 | 739 | |
| 712 | 740 | ignore_user_abort(true); |
| 713 | 741 | db_extend(); |
@@ -723,13 +751,15 @@ discard block |
||
| 723 | 751 | // Get a list of tables, as well as how many there are. |
| 724 | 752 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
| 725 | 753 | $tables = array(); |
| 726 | - foreach ($temp_tables as $table) |
|
| 727 | - $tables[] = array('table_name' => $table); |
|
| 754 | + foreach ($temp_tables as $table) { |
|
| 755 | + $tables[] = array('table_name' => $table); |
|
| 756 | + } |
|
| 728 | 757 | |
| 729 | 758 | // If there aren't any tables then I believe that would mean the world has exploded... |
| 730 | 759 | $context['num_tables'] = count($tables); |
| 731 | - if ($context['num_tables'] == 0) |
|
| 732 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 760 | + if ($context['num_tables'] == 0) { |
|
| 761 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 762 | + } |
|
| 733 | 763 | |
| 734 | 764 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 735 | 765 | |
@@ -740,8 +770,9 @@ discard block |
||
| 740 | 770 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
| 741 | 771 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
| 742 | 772 | { |
| 743 | - if (empty($tables[$key])) |
|
| 744 | - break; |
|
| 773 | + if (empty($tables[$key])) { |
|
| 774 | + break; |
|
| 775 | + } |
|
| 745 | 776 | |
| 746 | 777 | // Continue? |
| 747 | 778 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10) |
@@ -755,8 +786,9 @@ discard block |
||
| 755 | 786 | createToken('admin-optimize'); |
| 756 | 787 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
| 757 | 788 | |
| 758 | - if (function_exists('apache_reset_timeout')) |
|
| 759 | - apache_reset_timeout(); |
|
| 789 | + if (function_exists('apache_reset_timeout')) { |
|
| 790 | + apache_reset_timeout(); |
|
| 791 | + } |
|
| 760 | 792 | |
| 761 | 793 | return; |
| 762 | 794 | } |
@@ -764,11 +796,12 @@ discard block |
||
| 764 | 796 | // Optimize the table! We use backticks here because it might be a custom table. |
| 765 | 797 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
| 766 | 798 | |
| 767 | - if ($data_freed > 0) |
|
| 768 | - $_SESSION['optimized_tables'][] = array( |
|
| 799 | + if ($data_freed > 0) { |
|
| 800 | + $_SESSION['optimized_tables'][] = array( |
|
| 769 | 801 | 'name' => $tables[$key]['table_name'], |
| 770 | 802 | 'data_freed' => $data_freed, |
| 771 | 803 | ); |
| 804 | + } |
|
| 772 | 805 | } |
| 773 | 806 | |
| 774 | 807 | // Number of tables, etc... |
@@ -803,10 +836,11 @@ discard block |
||
| 803 | 836 | checkSession('request'); |
| 804 | 837 | |
| 805 | 838 | // validate the request or the loop |
| 806 | - if (!isset($_REQUEST['step'])) |
|
| 807 | - validateToken('admin-maint'); |
|
| 808 | - else |
|
| 809 | - validateToken('admin-boardrecount'); |
|
| 839 | + if (!isset($_REQUEST['step'])) { |
|
| 840 | + validateToken('admin-maint'); |
|
| 841 | + } else { |
|
| 842 | + validateToken('admin-boardrecount'); |
|
| 843 | + } |
|
| 810 | 844 | |
| 811 | 845 | $context['page_title'] = $txt['not_done_title']; |
| 812 | 846 | $context['continue_post_data'] = ''; |
@@ -827,8 +861,9 @@ discard block |
||
| 827 | 861 | $smcFunc['db_free_result']($request); |
| 828 | 862 | |
| 829 | 863 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
| 830 | - if (empty($_REQUEST['start'])) |
|
| 831 | - $_REQUEST['start'] = 0; |
|
| 864 | + if (empty($_REQUEST['start'])) { |
|
| 865 | + $_REQUEST['start'] = 0; |
|
| 866 | + } |
|
| 832 | 867 | |
| 833 | 868 | $total_steps = 8; |
| 834 | 869 | |
@@ -855,8 +890,8 @@ discard block |
||
| 855 | 890 | 'max_id' => $_REQUEST['start'] + $increment, |
| 856 | 891 | ) |
| 857 | 892 | ); |
| 858 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 859 | - $smcFunc['db_query']('', ' |
|
| 893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 894 | + $smcFunc['db_query']('', ' |
|
| 860 | 895 | UPDATE {db_prefix}topics |
| 861 | 896 | SET num_replies = {int:num_replies} |
| 862 | 897 | WHERE id_topic = {int:id_topic}', |
@@ -865,6 +900,7 @@ discard block |
||
| 865 | 900 | 'id_topic' => $row['id_topic'], |
| 866 | 901 | ) |
| 867 | 902 | ); |
| 903 | + } |
|
| 868 | 904 | $smcFunc['db_free_result']($request); |
| 869 | 905 | |
| 870 | 906 | // Recount unapproved messages |
@@ -883,8 +919,8 @@ discard block |
||
| 883 | 919 | 'max_id' => $_REQUEST['start'] + $increment, |
| 884 | 920 | ) |
| 885 | 921 | ); |
| 886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 887 | - $smcFunc['db_query']('', ' |
|
| 922 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 923 | + $smcFunc['db_query']('', ' |
|
| 888 | 924 | UPDATE {db_prefix}topics |
| 889 | 925 | SET unapproved_posts = {int:unapproved_posts} |
| 890 | 926 | WHERE id_topic = {int:id_topic}', |
@@ -893,6 +929,7 @@ discard block |
||
| 893 | 929 | 'id_topic' => $row['id_topic'], |
| 894 | 930 | ) |
| 895 | 931 | ); |
| 932 | + } |
|
| 896 | 933 | $smcFunc['db_free_result']($request); |
| 897 | 934 | |
| 898 | 935 | $_REQUEST['start'] += $increment; |
@@ -915,8 +952,8 @@ discard block |
||
| 915 | 952 | // Update the post count of each board. |
| 916 | 953 | if ($_REQUEST['step'] <= 1) |
| 917 | 954 | { |
| 918 | - if (empty($_REQUEST['start'])) |
|
| 919 | - $smcFunc['db_query']('', ' |
|
| 955 | + if (empty($_REQUEST['start'])) { |
|
| 956 | + $smcFunc['db_query']('', ' |
|
| 920 | 957 | UPDATE {db_prefix}boards |
| 921 | 958 | SET num_posts = {int:num_posts} |
| 922 | 959 | WHERE redirect = {string:redirect}', |
@@ -925,6 +962,7 @@ discard block |
||
| 925 | 962 | 'redirect' => '', |
| 926 | 963 | ) |
| 927 | 964 | ); |
| 965 | + } |
|
| 928 | 966 | |
| 929 | 967 | while ($_REQUEST['start'] < $max_topics) |
| 930 | 968 | { |
@@ -941,8 +979,8 @@ discard block |
||
| 941 | 979 | 'is_approved' => 1, |
| 942 | 980 | ) |
| 943 | 981 | ); |
| 944 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 945 | - $smcFunc['db_query']('', ' |
|
| 982 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 983 | + $smcFunc['db_query']('', ' |
|
| 946 | 984 | UPDATE {db_prefix}boards |
| 947 | 985 | SET num_posts = num_posts + {int:real_num_posts} |
| 948 | 986 | WHERE id_board = {int:id_board}', |
@@ -951,6 +989,7 @@ discard block |
||
| 951 | 989 | 'real_num_posts' => $row['real_num_posts'], |
| 952 | 990 | ) |
| 953 | 991 | ); |
| 992 | + } |
|
| 954 | 993 | $smcFunc['db_free_result']($request); |
| 955 | 994 | |
| 956 | 995 | $_REQUEST['start'] += $increment; |
@@ -973,14 +1012,15 @@ discard block |
||
| 973 | 1012 | // Update the topic count of each board. |
| 974 | 1013 | if ($_REQUEST['step'] <= 2) |
| 975 | 1014 | { |
| 976 | - if (empty($_REQUEST['start'])) |
|
| 977 | - $smcFunc['db_query']('', ' |
|
| 1015 | + if (empty($_REQUEST['start'])) { |
|
| 1016 | + $smcFunc['db_query']('', ' |
|
| 978 | 1017 | UPDATE {db_prefix}boards |
| 979 | 1018 | SET num_topics = {int:num_topics}', |
| 980 | 1019 | array( |
| 981 | 1020 | 'num_topics' => 0, |
| 982 | 1021 | ) |
| 983 | 1022 | ); |
| 1023 | + } |
|
| 984 | 1024 | |
| 985 | 1025 | while ($_REQUEST['start'] < $max_topics) |
| 986 | 1026 | { |
@@ -997,8 +1037,8 @@ discard block |
||
| 997 | 1037 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 998 | 1038 | ) |
| 999 | 1039 | ); |
| 1000 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1001 | - $smcFunc['db_query']('', ' |
|
| 1040 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1041 | + $smcFunc['db_query']('', ' |
|
| 1002 | 1042 | UPDATE {db_prefix}boards |
| 1003 | 1043 | SET num_topics = num_topics + {int:real_num_topics} |
| 1004 | 1044 | WHERE id_board = {int:id_board}', |
@@ -1007,6 +1047,7 @@ discard block |
||
| 1007 | 1047 | 'real_num_topics' => $row['real_num_topics'], |
| 1008 | 1048 | ) |
| 1009 | 1049 | ); |
| 1050 | + } |
|
| 1010 | 1051 | $smcFunc['db_free_result']($request); |
| 1011 | 1052 | |
| 1012 | 1053 | $_REQUEST['start'] += $increment; |
@@ -1029,14 +1070,15 @@ discard block |
||
| 1029 | 1070 | // Update the unapproved post count of each board. |
| 1030 | 1071 | if ($_REQUEST['step'] <= 3) |
| 1031 | 1072 | { |
| 1032 | - if (empty($_REQUEST['start'])) |
|
| 1033 | - $smcFunc['db_query']('', ' |
|
| 1073 | + if (empty($_REQUEST['start'])) { |
|
| 1074 | + $smcFunc['db_query']('', ' |
|
| 1034 | 1075 | UPDATE {db_prefix}boards |
| 1035 | 1076 | SET unapproved_posts = {int:unapproved_posts}', |
| 1036 | 1077 | array( |
| 1037 | 1078 | 'unapproved_posts' => 0, |
| 1038 | 1079 | ) |
| 1039 | 1080 | ); |
| 1081 | + } |
|
| 1040 | 1082 | |
| 1041 | 1083 | while ($_REQUEST['start'] < $max_topics) |
| 1042 | 1084 | { |
@@ -1053,8 +1095,8 @@ discard block |
||
| 1053 | 1095 | 'is_approved' => 0, |
| 1054 | 1096 | ) |
| 1055 | 1097 | ); |
| 1056 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1057 | - $smcFunc['db_query']('', ' |
|
| 1098 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1099 | + $smcFunc['db_query']('', ' |
|
| 1058 | 1100 | UPDATE {db_prefix}boards |
| 1059 | 1101 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
| 1060 | 1102 | WHERE id_board = {int:id_board}', |
@@ -1063,6 +1105,7 @@ discard block |
||
| 1063 | 1105 | 'unapproved_posts' => $row['real_unapproved_posts'], |
| 1064 | 1106 | ) |
| 1065 | 1107 | ); |
| 1108 | + } |
|
| 1066 | 1109 | $smcFunc['db_free_result']($request); |
| 1067 | 1110 | |
| 1068 | 1111 | $_REQUEST['start'] += $increment; |
@@ -1085,14 +1128,15 @@ discard block |
||
| 1085 | 1128 | // Update the unapproved topic count of each board. |
| 1086 | 1129 | if ($_REQUEST['step'] <= 4) |
| 1087 | 1130 | { |
| 1088 | - if (empty($_REQUEST['start'])) |
|
| 1089 | - $smcFunc['db_query']('', ' |
|
| 1131 | + if (empty($_REQUEST['start'])) { |
|
| 1132 | + $smcFunc['db_query']('', ' |
|
| 1090 | 1133 | UPDATE {db_prefix}boards |
| 1091 | 1134 | SET unapproved_topics = {int:unapproved_topics}', |
| 1092 | 1135 | array( |
| 1093 | 1136 | 'unapproved_topics' => 0, |
| 1094 | 1137 | ) |
| 1095 | 1138 | ); |
| 1139 | + } |
|
| 1096 | 1140 | |
| 1097 | 1141 | while ($_REQUEST['start'] < $max_topics) |
| 1098 | 1142 | { |
@@ -1109,8 +1153,8 @@ discard block |
||
| 1109 | 1153 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1110 | 1154 | ) |
| 1111 | 1155 | ); |
| 1112 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1113 | - $smcFunc['db_query']('', ' |
|
| 1156 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1157 | + $smcFunc['db_query']('', ' |
|
| 1114 | 1158 | UPDATE {db_prefix}boards |
| 1115 | 1159 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
| 1116 | 1160 | WHERE id_board = {int:id_board}', |
@@ -1119,6 +1163,7 @@ discard block |
||
| 1119 | 1163 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
| 1120 | 1164 | ) |
| 1121 | 1165 | ); |
| 1166 | + } |
|
| 1122 | 1167 | $smcFunc['db_free_result']($request); |
| 1123 | 1168 | |
| 1124 | 1169 | $_REQUEST['start'] += $increment; |
@@ -1152,8 +1197,9 @@ discard block |
||
| 1152 | 1197 | 'is_not_deleted' => 0, |
| 1153 | 1198 | ) |
| 1154 | 1199 | ); |
| 1155 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1156 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1201 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1202 | + } |
|
| 1157 | 1203 | $smcFunc['db_free_result']($request); |
| 1158 | 1204 | |
| 1159 | 1205 | $request = $smcFunc['db_query']('', ' |
@@ -1168,8 +1214,9 @@ discard block |
||
| 1168 | 1214 | 'is_not_read' => 0, |
| 1169 | 1215 | ) |
| 1170 | 1216 | ); |
| 1171 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1172 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1217 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1218 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1219 | + } |
|
| 1173 | 1220 | $smcFunc['db_free_result']($request); |
| 1174 | 1221 | |
| 1175 | 1222 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) |
@@ -1201,12 +1248,13 @@ discard block |
||
| 1201 | 1248 | ) |
| 1202 | 1249 | ); |
| 1203 | 1250 | $boards = array(); |
| 1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1205 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1251 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1252 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1253 | + } |
|
| 1206 | 1254 | $smcFunc['db_free_result']($request); |
| 1207 | 1255 | |
| 1208 | - foreach ($boards as $board_id => $messages) |
|
| 1209 | - $smcFunc['db_query']('', ' |
|
| 1256 | + foreach ($boards as $board_id => $messages) { |
|
| 1257 | + $smcFunc['db_query']('', ' |
|
| 1210 | 1258 | UPDATE {db_prefix}messages |
| 1211 | 1259 | SET id_board = {int:id_board} |
| 1212 | 1260 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1215,6 +1263,7 @@ discard block |
||
| 1215 | 1263 | 'id_board' => $board_id, |
| 1216 | 1264 | ) |
| 1217 | 1265 | ); |
| 1266 | + } |
|
| 1218 | 1267 | |
| 1219 | 1268 | $_REQUEST['start'] += $increment; |
| 1220 | 1269 | |
@@ -1244,8 +1293,9 @@ discard block |
||
| 1244 | 1293 | ) |
| 1245 | 1294 | ); |
| 1246 | 1295 | $realBoardCounts = array(); |
| 1247 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1248 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1296 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1297 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1298 | + } |
|
| 1249 | 1299 | $smcFunc['db_free_result']($request); |
| 1250 | 1300 | |
| 1251 | 1301 | $request = $smcFunc['db_query']('', ' |
@@ -1265,18 +1315,20 @@ discard block |
||
| 1265 | 1315 | krsort($resort_me); |
| 1266 | 1316 | |
| 1267 | 1317 | $lastModifiedMsg = array(); |
| 1268 | - foreach ($resort_me as $rows) |
|
| 1269 | - foreach ($rows as $row) |
|
| 1318 | + foreach ($resort_me as $rows) { |
|
| 1319 | + foreach ($rows as $row) |
|
| 1270 | 1320 | { |
| 1271 | 1321 | // The latest message is the latest of the current board and its children. |
| 1272 | 1322 | if (isset($lastModifiedMsg[$row['id_board']])) |
| 1273 | 1323 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
| 1274 | - else |
|
| 1275 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1324 | + } |
|
| 1325 | + else { |
|
| 1326 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1327 | + } |
|
| 1276 | 1328 | |
| 1277 | 1329 | // If what is and what should be the latest message differ, an update is necessary. |
| 1278 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
| 1279 | - $smcFunc['db_query']('', ' |
|
| 1330 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
| 1331 | + $smcFunc['db_query']('', ' |
|
| 1280 | 1332 | UPDATE {db_prefix}boards |
| 1281 | 1333 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
| 1282 | 1334 | WHERE id_board = {int:id_board}', |
@@ -1286,12 +1338,14 @@ discard block |
||
| 1286 | 1338 | 'id_board' => $row['id_board'], |
| 1287 | 1339 | ) |
| 1288 | 1340 | ); |
| 1341 | + } |
|
| 1289 | 1342 | |
| 1290 | 1343 | // Parent boards inherit the latest modified message of their children. |
| 1291 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
| 1292 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1293 | - else |
|
| 1294 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1344 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
| 1345 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1346 | + } else { |
|
| 1347 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1348 | + } |
|
| 1295 | 1349 | } |
| 1296 | 1350 | |
| 1297 | 1351 | // Update all the basic statistics. |
@@ -1363,8 +1417,9 @@ discard block |
||
| 1363 | 1417 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1364 | 1418 | $members = findMembers($_POST['to']); |
| 1365 | 1419 | |
| 1366 | - if (empty($members)) |
|
| 1367 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1420 | + if (empty($members)) { |
|
| 1421 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1422 | + } |
|
| 1368 | 1423 | |
| 1369 | 1424 | $memID = array_shift($members); |
| 1370 | 1425 | $memID = $memID['id']; |
@@ -1394,8 +1449,9 @@ discard block |
||
| 1394 | 1449 | validateToken('admin-maint'); |
| 1395 | 1450 | |
| 1396 | 1451 | $groups = array(); |
| 1397 | - foreach ($_POST['groups'] as $id => $dummy) |
|
| 1398 | - $groups[] = (int) $id; |
|
| 1452 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
| 1453 | + $groups[] = (int) $id; |
|
| 1454 | + } |
|
| 1399 | 1455 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
| 1400 | 1456 | $where_vars = array( |
| 1401 | 1457 | 'time_limit' => $time_limit, |
@@ -1404,9 +1460,9 @@ discard block |
||
| 1404 | 1460 | { |
| 1405 | 1461 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
| 1406 | 1462 | $where_vars['is_activated'] = 0; |
| 1463 | + } else { |
|
| 1464 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1407 | 1465 | } |
| 1408 | - else |
|
| 1409 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1410 | 1466 | |
| 1411 | 1467 | // Need to get *all* groups then work out which (if any) we avoid. |
| 1412 | 1468 | $request = $smcFunc['db_query']('', ' |
@@ -1425,8 +1481,7 @@ discard block |
||
| 1425 | 1481 | { |
| 1426 | 1482 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
| 1427 | 1483 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
| 1428 | - } |
|
| 1429 | - else |
|
| 1484 | + } else |
|
| 1430 | 1485 | { |
| 1431 | 1486 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
| 1432 | 1487 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1453,8 +1508,9 @@ discard block |
||
| 1453 | 1508 | $members = array(); |
| 1454 | 1509 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1455 | 1510 | { |
| 1456 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
| 1457 | - $members[] = $row['id_member']; |
|
| 1511 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
| 1512 | + $members[] = $row['id_member']; |
|
| 1513 | + } |
|
| 1458 | 1514 | } |
| 1459 | 1515 | $smcFunc['db_free_result']($request); |
| 1460 | 1516 | |
@@ -1501,8 +1557,9 @@ discard block |
||
| 1501 | 1557 | ) |
| 1502 | 1558 | ); |
| 1503 | 1559 | |
| 1504 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1505 | - $drafts[] = (int) $row[0]; |
|
| 1560 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1561 | + $drafts[] = (int) $row[0]; |
|
| 1562 | + } |
|
| 1506 | 1563 | $smcFunc['db_free_result']($request); |
| 1507 | 1564 | |
| 1508 | 1565 | // If we have old drafts, remove them |
@@ -1545,8 +1602,9 @@ discard block |
||
| 1545 | 1602 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
| 1546 | 1603 | |
| 1547 | 1604 | // No boards then this is your stop. |
| 1548 | - if (empty($id_board_from) || empty($id_board_to)) |
|
| 1549 | - return; |
|
| 1605 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
| 1606 | + return; |
|
| 1607 | + } |
|
| 1550 | 1608 | |
| 1551 | 1609 | // The big WHERE clause |
| 1552 | 1610 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1594,18 +1652,20 @@ discard block |
||
| 1594 | 1652 | ); |
| 1595 | 1653 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
| 1596 | 1654 | $smcFunc['db_free_result']($request); |
| 1655 | + } else { |
|
| 1656 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1597 | 1657 | } |
| 1598 | - else |
|
| 1599 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1600 | 1658 | |
| 1601 | 1659 | // Seems like we need this here. |
| 1602 | 1660 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
| 1603 | 1661 | |
| 1604 | - if ($locked) |
|
| 1605 | - $context['continue_get_data'] .= ';locked'; |
|
| 1662 | + if ($locked) { |
|
| 1663 | + $context['continue_get_data'] .= ';locked'; |
|
| 1664 | + } |
|
| 1606 | 1665 | |
| 1607 | - if ($sticky) |
|
| 1608 | - $context['continue_get_data'] .= ';sticky'; |
|
| 1666 | + if ($sticky) { |
|
| 1667 | + $context['continue_get_data'] .= ';sticky'; |
|
| 1668 | + } |
|
| 1609 | 1669 | |
| 1610 | 1670 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1611 | 1671 | |
@@ -1626,8 +1686,9 @@ discard block |
||
| 1626 | 1686 | |
| 1627 | 1687 | // Get the ids. |
| 1628 | 1688 | $topics = array(); |
| 1629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1630 | - $topics[] = $row['id_topic']; |
|
| 1689 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1690 | + $topics[] = $row['id_topic']; |
|
| 1691 | + } |
|
| 1631 | 1692 | |
| 1632 | 1693 | // Just return if we don't have any topics left to move. |
| 1633 | 1694 | if (empty($topics)) |
@@ -1718,9 +1779,9 @@ discard block |
||
| 1718 | 1779 | // save it so we don't do this again for this task |
| 1719 | 1780 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
| 1720 | 1781 | $smcFunc['db_free_result']($request); |
| 1782 | + } else { |
|
| 1783 | + validateToken('admin-recountposts'); |
|
| 1721 | 1784 | } |
| 1722 | - else |
|
| 1723 | - validateToken('admin-recountposts'); |
|
| 1724 | 1785 | |
| 1725 | 1786 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
| 1726 | 1787 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1827,9 @@ discard block |
||
| 1766 | 1827 | createToken('admin-recountposts'); |
| 1767 | 1828 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
| 1768 | 1829 | |
| 1769 | - if (function_exists('apache_reset_timeout')) |
|
| 1770 | - apache_reset_timeout(); |
|
| 1830 | + if (function_exists('apache_reset_timeout')) { |
|
| 1831 | + apache_reset_timeout(); |
|
| 1832 | + } |
|
| 1771 | 1833 | return; |
| 1772 | 1834 | } |
| 1773 | 1835 | |
@@ -1853,10 +1915,9 @@ discard block |
||
| 1853 | 1915 | checkSession('request'); |
| 1854 | 1916 | validateToken('admin-hook', 'request'); |
| 1855 | 1917 | |
| 1856 | - if ($_REQUEST['do'] == 'remove') |
|
| 1857 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1858 | - |
|
| 1859 | - else |
|
| 1918 | + if ($_REQUEST['do'] == 'remove') { |
|
| 1919 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1920 | + } else |
|
| 1860 | 1921 | { |
| 1861 | 1922 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
| 1862 | 1923 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1906,11 +1967,11 @@ discard block |
||
| 1906 | 1967 | // Show a nice icon to indicate this is an instance. |
| 1907 | 1968 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
| 1908 | 1969 | |
| 1909 | - if (!empty($data['included_file'])) |
|
| 1910 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1911 | - |
|
| 1912 | - else |
|
| 1913 | - return $instance . $data['real_function']; |
|
| 1970 | + if (!empty($data['included_file'])) { |
|
| 1971 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1972 | + } else { |
|
| 1973 | + return $instance . $data['real_function']; |
|
| 1974 | + } |
|
| 1914 | 1975 | }, |
| 1915 | 1976 | ), |
| 1916 | 1977 | 'sort' => array( |
@@ -1975,11 +2036,12 @@ discard block |
||
| 1975 | 2036 | 'data' => array( |
| 1976 | 2037 | 'function' => function($data) use ($txt, $scripturl, $context) |
| 1977 | 2038 | { |
| 1978 | - if (!$data['hook_exists']) |
|
| 1979 | - return ' |
|
| 2039 | + if (!$data['hook_exists']) { |
|
| 2040 | + return ' |
|
| 1980 | 2041 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
| 1981 | 2042 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
| 1982 | 2043 | </a>'; |
| 2044 | + } |
|
| 1983 | 2045 | }, |
| 1984 | 2046 | 'class' => 'centertext', |
| 1985 | 2047 | ), |
@@ -2014,10 +2076,11 @@ discard block |
||
| 2014 | 2076 | { |
| 2015 | 2077 | if ($file != '.' && $file != '..') |
| 2016 | 2078 | { |
| 2017 | - if (is_dir($dir_path . '/' . $file)) |
|
| 2018 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2019 | - else |
|
| 2020 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2079 | + if (is_dir($dir_path . '/' . $file)) { |
|
| 2080 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2081 | + } else { |
|
| 2082 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2083 | + } |
|
| 2021 | 2084 | } |
| 2022 | 2085 | } |
| 2023 | 2086 | } |
@@ -2066,16 +2129,16 @@ discard block |
||
| 2066 | 2129 | // I need to know if there is at least one function called in this file. |
| 2067 | 2130 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
| 2068 | 2131 | unset($temp_hooks[$hook][$rawFunc]); |
| 2069 | - } |
|
| 2070 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2132 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2071 | 2133 | { |
| 2072 | 2134 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
| 2073 | 2135 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
| 2074 | 2136 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
| 2075 | 2137 | |
| 2076 | 2138 | // Does the hook has its own file? |
| 2077 | - if (!empty($hookParsedData['hookFile'])) |
|
| 2078 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2139 | + if (!empty($hookParsedData['hookFile'])) { |
|
| 2140 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2141 | + } |
|
| 2079 | 2142 | |
| 2080 | 2143 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
| 2081 | 2144 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2102,15 +2165,17 @@ discard block |
||
| 2102 | 2165 | $sort = array(); |
| 2103 | 2166 | $hooks_filters = array(); |
| 2104 | 2167 | |
| 2105 | - foreach ($hooks as $hook => $functions) |
|
| 2106 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2168 | + foreach ($hooks as $hook => $functions) { |
|
| 2169 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2170 | + } |
|
| 2107 | 2171 | |
| 2108 | - if (!empty($hooks_filters)) |
|
| 2109 | - $context['insert_after_template'] .= ' |
|
| 2172 | + if (!empty($hooks_filters)) { |
|
| 2173 | + $context['insert_after_template'] .= ' |
|
| 2110 | 2174 | <script> |
| 2111 | 2175 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
| 2112 | 2176 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
| 2113 | 2177 | </script>'; |
| 2178 | + } |
|
| 2114 | 2179 | |
| 2115 | 2180 | $temp_data = array(); |
| 2116 | 2181 | $id = 0; |
@@ -2152,10 +2217,11 @@ discard block |
||
| 2152 | 2217 | |
| 2153 | 2218 | foreach ($temp_data as $data) |
| 2154 | 2219 | { |
| 2155 | - if (++$counter < $start) |
|
| 2156 | - continue; |
|
| 2157 | - elseif ($counter == $start + $per_page) |
|
| 2158 | - break; |
|
| 2220 | + if (++$counter < $start) { |
|
| 2221 | + continue; |
|
| 2222 | + } elseif ($counter == $start + $per_page) { |
|
| 2223 | + break; |
|
| 2224 | + } |
|
| 2159 | 2225 | |
| 2160 | 2226 | $hooks_data[] = $data; |
| 2161 | 2227 | } |
@@ -2177,13 +2243,15 @@ discard block |
||
| 2177 | 2243 | $hooks_count = 0; |
| 2178 | 2244 | |
| 2179 | 2245 | $context['filter'] = false; |
| 2180 | - if (isset($_GET['filter'])) |
|
| 2181 | - $context['filter'] = $_GET['filter']; |
|
| 2246 | + if (isset($_GET['filter'])) { |
|
| 2247 | + $context['filter'] = $_GET['filter']; |
|
| 2248 | + } |
|
| 2182 | 2249 | |
| 2183 | 2250 | foreach ($hooks as $hook => $functions) |
| 2184 | 2251 | { |
| 2185 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
| 2186 | - $hooks_count += count($functions); |
|
| 2252 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
| 2253 | + $hooks_count += count($functions); |
|
| 2254 | + } |
|
| 2187 | 2255 | } |
| 2188 | 2256 | |
| 2189 | 2257 | return $hooks_count; |
@@ -2204,8 +2272,9 @@ discard block |
||
| 2204 | 2272 | $integration_hooks = array(); |
| 2205 | 2273 | foreach ($modSettings as $key => $value) |
| 2206 | 2274 | { |
| 2207 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
| 2208 | - $integration_hooks[$key] = explode(',', $value); |
|
| 2275 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
| 2276 | + $integration_hooks[$key] = explode(',', $value); |
|
| 2277 | + } |
|
| 2209 | 2278 | } |
| 2210 | 2279 | } |
| 2211 | 2280 | |
@@ -2236,8 +2305,9 @@ discard block |
||
| 2236 | 2305 | ); |
| 2237 | 2306 | |
| 2238 | 2307 | // Meh... |
| 2239 | - if (empty($rawData)) |
|
| 2240 | - return $hookData; |
|
| 2308 | + if (empty($rawData)) { |
|
| 2309 | + return $hookData; |
|
| 2310 | + } |
|
| 2241 | 2311 | |
| 2242 | 2312 | // For convenience purposes only! |
| 2243 | 2313 | $modFunc = $rawData; |
@@ -2248,11 +2318,11 @@ discard block |
||
| 2248 | 2318 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
| 2249 | 2319 | |
| 2250 | 2320 | // Does the file exists? who knows! |
| 2251 | - if (empty($settings['theme_dir'])) |
|
| 2252 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2253 | - |
|
| 2254 | - else |
|
| 2255 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2321 | + if (empty($settings['theme_dir'])) { |
|
| 2322 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2323 | + } else { |
|
| 2324 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2325 | + } |
|
| 2256 | 2326 | |
| 2257 | 2327 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
| 2258 | 2328 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2277,11 +2347,10 @@ discard block |
||
| 2277 | 2347 | { |
| 2278 | 2348 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
| 2279 | 2349 | $hookData['pureFunc'] = $hookData['method']; |
| 2350 | + } else { |
|
| 2351 | + $hookData['pureFunc'] = $modFunc; |
|
| 2280 | 2352 | } |
| 2281 | 2353 | |
| 2282 | - else |
|
| 2283 | - $hookData['pureFunc'] = $modFunc; |
|
| 2284 | - |
|
| 2285 | 2354 | return $hookData; |
| 2286 | 2355 | } |
| 2287 | 2356 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * This file contains helper functions for upgrade.php |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF_VERSION')) |
|
| 16 | +if (!defined('SMF_VERSION')) { |
|
| 17 | 17 | die('No direct access!'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | global $smcFunc; |
| 46 | 47 | static $member_groups = array(); |
| 47 | 48 | |
| 48 | - if (!empty($member_groups)) |
|
| 49 | - return $member_groups; |
|
| 49 | + if (!empty($member_groups)) { |
|
| 50 | + return $member_groups; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $request = $smcFunc['db_query']('', ' |
| 52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
| 71 | 73 | ) |
| 72 | 74 | ); |
| 73 | 75 | } |
| 74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 75 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 77 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 78 | + } |
|
| 76 | 79 | $smcFunc['db_free_result']($request); |
| 77 | 80 | |
| 78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | { |
| 89 | 92 | global $upcontext, $boarddir, $sourcedir; |
| 90 | 93 | |
| 91 | - if (empty($files)) |
|
| 92 | - return true; |
|
| 94 | + if (empty($files)) { |
|
| 95 | + return true; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | $failure = false; |
| 95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -104,14 +108,16 @@ discard block |
||
| 104 | 108 | @chmod($file, 0755); |
| 105 | 109 | |
| 106 | 110 | // Well, 755 hopefully worked... if not, try 777. |
| 107 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 108 | - $failure = true; |
|
| 111 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 112 | + $failure = true; |
|
| 113 | + } |
|
| 109 | 114 | // Otherwise remove it as it's good! |
| 110 | - else |
|
| 111 | - unset($files[$k]); |
|
| 115 | + else { |
|
| 116 | + unset($files[$k]); |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + unset($files[$k]); |
|
| 112 | 120 | } |
| 113 | - else |
|
| 114 | - unset($files[$k]); |
|
| 115 | 121 | } |
| 116 | 122 | } |
| 117 | 123 | // Windows is trickier. Let's try opening for r+... |
@@ -122,30 +128,35 @@ discard block |
||
| 122 | 128 | foreach ($files as $k => $file) |
| 123 | 129 | { |
| 124 | 130 | // Folders can't be opened for write... but the index.php in them can ;). |
| 125 | - if (is_dir($file)) |
|
| 126 | - $file .= '/index.php'; |
|
| 131 | + if (is_dir($file)) { |
|
| 132 | + $file .= '/index.php'; |
|
| 133 | + } |
|
| 127 | 134 | |
| 128 | 135 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 129 | 136 | @chmod($file, 0777); |
| 130 | 137 | $fp = @fopen($file, 'r+'); |
| 131 | 138 | |
| 132 | 139 | // Hmm, okay, try just for write in that case... |
| 133 | - if (!$fp) |
|
| 134 | - $fp = @fopen($file, 'w'); |
|
| 140 | + if (!$fp) { |
|
| 141 | + $fp = @fopen($file, 'w'); |
|
| 142 | + } |
|
| 135 | 143 | |
| 136 | - if (!$fp) |
|
| 137 | - $failure = true; |
|
| 138 | - else |
|
| 139 | - unset($files[$k]); |
|
| 144 | + if (!$fp) { |
|
| 145 | + $failure = true; |
|
| 146 | + } else { |
|
| 147 | + unset($files[$k]); |
|
| 148 | + } |
|
| 140 | 149 | @fclose($fp); |
| 141 | 150 | } |
| 142 | 151 | } |
| 143 | 152 | |
| 144 | - if (empty($files)) |
|
| 145 | - return true; |
|
| 153 | + if (empty($files)) { |
|
| 154 | + return true; |
|
| 155 | + } |
|
| 146 | 156 | |
| 147 | - if (!isset($_SERVER)) |
|
| 148 | - return !$failure; |
|
| 157 | + if (!isset($_SERVER)) { |
|
| 158 | + return !$failure; |
|
| 159 | + } |
|
| 149 | 160 | |
| 150 | 161 | // What still needs to be done? |
| 151 | 162 | $upcontext['chmod']['files'] = $files; |
@@ -197,36 +208,40 @@ discard block |
||
| 197 | 208 | |
| 198 | 209 | if (!isset($ftp) || $ftp->error !== false) |
| 199 | 210 | { |
| 200 | - if (!isset($ftp)) |
|
| 201 | - $ftp = new ftp_connection(null); |
|
| 211 | + if (!isset($ftp)) { |
|
| 212 | + $ftp = new ftp_connection(null); |
|
| 213 | + } |
|
| 202 | 214 | // Save the error so we can mess with listing... |
| 203 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 204 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 215 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 216 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 217 | + } |
|
| 205 | 218 | |
| 206 | 219 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 207 | 220 | |
| 208 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 209 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 221 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 222 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 223 | + } |
|
| 210 | 224 | |
| 211 | - if (!isset($upcontext['chmod']['username'])) |
|
| 212 | - $upcontext['chmod']['username'] = $username; |
|
| 225 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 226 | + $upcontext['chmod']['username'] = $username; |
|
| 227 | + } |
|
| 213 | 228 | |
| 214 | 229 | // Don't forget the login token. |
| 215 | 230 | $upcontext += createToken('login'); |
| 216 | 231 | |
| 217 | 232 | return false; |
| 218 | - } |
|
| 219 | - else |
|
| 233 | + } else |
|
| 220 | 234 | { |
| 221 | 235 | // We want to do a relative path for FTP. |
| 222 | 236 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 223 | 237 | { |
| 224 | 238 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 225 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 226 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 239 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 240 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 241 | + } |
|
| 242 | + } else { |
|
| 243 | + $ftp_root = $boarddir; |
|
| 227 | 244 | } |
| 228 | - else |
|
| 229 | - $ftp_root = $boarddir; |
|
| 230 | 245 | |
| 231 | 246 | // Save the info for next time! |
| 232 | 247 | $_SESSION['installer_temp_ftp'] = array( |
@@ -240,10 +255,12 @@ discard block |
||
| 240 | 255 | |
| 241 | 256 | foreach ($files as $k => $file) |
| 242 | 257 | { |
| 243 | - if (!is_writable($file)) |
|
| 244 | - $ftp->chmod($file, 0755); |
|
| 245 | - if (!is_writable($file)) |
|
| 246 | - $ftp->chmod($file, 0777); |
|
| 258 | + if (!is_writable($file)) { |
|
| 259 | + $ftp->chmod($file, 0755); |
|
| 260 | + } |
|
| 261 | + if (!is_writable($file)) { |
|
| 262 | + $ftp->chmod($file, 0777); |
|
| 263 | + } |
|
| 247 | 264 | |
| 248 | 265 | // Assuming that didn't work calculate the path without the boarddir. |
| 249 | 266 | if (!is_writable($file)) |
@@ -252,19 +269,23 @@ discard block |
||
| 252 | 269 | { |
| 253 | 270 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 254 | 271 | $ftp->chmod($ftp_file, 0755); |
| 255 | - if (!is_writable($file)) |
|
| 256 | - $ftp->chmod($ftp_file, 0777); |
|
| 272 | + if (!is_writable($file)) { |
|
| 273 | + $ftp->chmod($ftp_file, 0777); |
|
| 274 | + } |
|
| 257 | 275 | // Sometimes an extra slash can help... |
| 258 | 276 | $ftp_file = '/' . $ftp_file; |
| 259 | - if (!is_writable($file)) |
|
| 260 | - $ftp->chmod($ftp_file, 0755); |
|
| 261 | - if (!is_writable($file)) |
|
| 262 | - $ftp->chmod($ftp_file, 0777); |
|
| 277 | + if (!is_writable($file)) { |
|
| 278 | + $ftp->chmod($ftp_file, 0755); |
|
| 279 | + } |
|
| 280 | + if (!is_writable($file)) { |
|
| 281 | + $ftp->chmod($ftp_file, 0777); |
|
| 282 | + } |
|
| 263 | 283 | } |
| 264 | 284 | } |
| 265 | 285 | |
| 266 | - if (is_writable($file)) |
|
| 267 | - unset($files[$k]); |
|
| 286 | + if (is_writable($file)) { |
|
| 287 | + unset($files[$k]); |
|
| 288 | + } |
|
| 268 | 289 | } |
| 269 | 290 | |
| 270 | 291 | $ftp->close(); |
@@ -274,8 +295,9 @@ discard block |
||
| 274 | 295 | // What remains? |
| 275 | 296 | $upcontext['chmod']['files'] = $files; |
| 276 | 297 | |
| 277 | - if (empty($files)) |
|
| 278 | - return true; |
|
| 298 | + if (empty($files)) { |
|
| 299 | + return true; |
|
| 300 | + } |
|
| 279 | 301 | |
| 280 | 302 | return false; |
| 281 | 303 | } |
@@ -288,8 +310,9 @@ discard block |
||
| 288 | 310 | */ |
| 289 | 311 | function quickFileWritable($file) |
| 290 | 312 | { |
| 291 | - if (is_writable($file)) |
|
| 292 | - return true; |
|
| 313 | + if (is_writable($file)) { |
|
| 314 | + return true; |
|
| 315 | + } |
|
| 293 | 316 | |
| 294 | 317 | @chmod($file, 0755); |
| 295 | 318 | |
@@ -299,10 +322,11 @@ discard block |
||
| 299 | 322 | foreach ($chmod_values as $val) |
| 300 | 323 | { |
| 301 | 324 | // If it's writable, break out of the loop |
| 302 | - if (is_writable($file)) |
|
| 303 | - break; |
|
| 304 | - else |
|
| 305 | - @chmod($file, $val); |
|
| 325 | + if (is_writable($file)) { |
|
| 326 | + break; |
|
| 327 | + } else { |
|
| 328 | + @chmod($file, $val); |
|
| 329 | + } |
|
| 306 | 330 | } |
| 307 | 331 | |
| 308 | 332 | return is_writable($file); |
@@ -329,14 +353,16 @@ discard block |
||
| 329 | 353 | { |
| 330 | 354 | static $fp = null; |
| 331 | 355 | |
| 332 | - if ($fp === null) |
|
| 333 | - $fp = fopen('php://stderr', 'wb'); |
|
| 356 | + if ($fp === null) { |
|
| 357 | + $fp = fopen('php://stderr', 'wb'); |
|
| 358 | + } |
|
| 334 | 359 | |
| 335 | 360 | fwrite($fp, $message . "\n"); |
| 336 | 361 | |
| 337 | - if ($fatal) |
|
| 338 | - exit; |
|
| 339 | -} |
|
| 362 | + if ($fatal) { |
|
| 363 | + exit; |
|
| 364 | + } |
|
| 365 | + } |
|
| 340 | 366 | |
| 341 | 367 | /** |
| 342 | 368 | * Throws a graphical error message. |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | loadLanguage('Drafts'); |
| 21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
| 34 | 35 | |
| 35 | 36 | // can you be, should you be ... here? |
| 36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
| 37 | - return false; |
|
| 37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | // read in what they sent us, if anything |
| 40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
| 46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 47 | 49 | |
| 48 | 50 | // since we were called from the autosave function, send something back |
| 49 | - if (!empty($id_draft)) |
|
| 50 | - XmlDraft($id_draft); |
|
| 51 | + if (!empty($id_draft)) { |
|
| 52 | + XmlDraft($id_draft); |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | return true; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - if (!isset($_POST['message'])) |
|
| 56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 58 | + if (!isset($_POST['message'])) { |
|
| 59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // prepare any data from the form |
| 59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
| 66 | 70 | |
| 67 | 71 | // message and subject still need a bit more work |
| 68 | 72 | preparsecode($draft['body']); |
| 69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 75 | + } |
|
| 71 | 76 | |
| 72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
| 73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
| 148 | 153 | { |
| 149 | 154 | $context['draft_saved'] = true; |
| 150 | 155 | $context['id_draft'] = $id_draft; |
| 156 | + } else { |
|
| 157 | + $post_errors[] = 'draft_not_saved'; |
|
| 151 | 158 | } |
| 152 | - else |
|
| 153 | - $post_errors[] = 'draft_not_saved'; |
|
| 154 | 159 | |
| 155 | 160 | // cleanup |
| 156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
| 180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
| 181 | 186 | |
| 182 | 187 | // PM survey says ... can you stay or must you go |
| 183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
| 184 | - return false; |
|
| 188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | // read in what you sent us |
| 187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
| 193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 194 | 200 | |
| 195 | 201 | // Send something back to the javascript caller |
| 196 | - if (!empty($id_draft)) |
|
| 197 | - XmlDraft($id_draft); |
|
| 202 | + if (!empty($id_draft)) { |
|
| 203 | + XmlDraft($id_draft); |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | return true; |
| 200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
| 204 | 211 | { |
| 205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
| 206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
| 214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
| 215 | + $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
| 207 | 216 | } |
| 208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
| 209 | - $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
| 210 | 217 | |
| 211 | 218 | // prepare the data we got from the form |
| 212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | |
| 216 | 223 | // message and subject always need a bit more work |
| 217 | 224 | preparsecode($draft['body']); |
| 218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | // Modifying an existing PM draft? |
| 222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
| 280 | 288 | { |
| 281 | 289 | $context['draft_saved'] = true; |
| 282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
| 291 | + } else { |
|
| 292 | + $post_errors[] = 'draft_not_saved'; |
|
| 283 | 293 | } |
| 284 | - else |
|
| 285 | - $post_errors[] = 'draft_not_saved'; |
|
| 286 | 294 | } |
| 287 | 295 | |
| 288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
| 315 | 323 | $type = (int) $type; |
| 316 | 324 | |
| 317 | 325 | // nothing to read, nothing to do |
| 318 | - if (empty($id_draft)) |
|
| 319 | - return false; |
|
| 326 | + if (empty($id_draft)) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 320 | 329 | |
| 321 | 330 | // load in this draft from the DB |
| 322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
| 337 | 346 | ); |
| 338 | 347 | |
| 339 | 348 | // no results? |
| 340 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 341 | - return false; |
|
| 349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 350 | + return false; |
|
| 351 | + } |
|
| 342 | 352 | |
| 343 | 353 | // load up the data |
| 344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
| 358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
| 359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
| 360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
| 361 | - } |
|
| 362 | - elseif ($type === 1) |
|
| 371 | + } elseif ($type === 1) |
|
| 363 | 372 | { |
| 364 | 373 | // one of those pm drafts? then set it up like we have an error |
| 365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
| 395 | 404 | global $user_info, $smcFunc; |
| 396 | 405 | |
| 397 | 406 | // Only a single draft. |
| 398 | - if (is_numeric($id_draft)) |
|
| 399 | - $id_draft = array($id_draft); |
|
| 407 | + if (is_numeric($id_draft)) { |
|
| 408 | + $id_draft = array($id_draft); |
|
| 409 | + } |
|
| 400 | 410 | |
| 401 | 411 | // can't delete nothing |
| 402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
| 403 | - return false; |
|
| 412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
| 413 | + return false; |
|
| 414 | + } |
|
| 404 | 415 | |
| 405 | 416 | $smcFunc['db_query']('', ' |
| 406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
| 429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
| 430 | 441 | |
| 431 | 442 | // Permissions |
| 432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
| 433 | - return false; |
|
| 443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 434 | 446 | |
| 435 | 447 | $context['drafts'] = array(); |
| 436 | 448 | |
| 437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
| 438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
| 439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
| 451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 452 | + } |
|
| 440 | 453 | |
| 441 | 454 | // load the drafts this user has available |
| 442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
| 459 | 472 | // add them to the draft array for display |
| 460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 461 | 474 | { |
| 462 | - if (empty($row['subject'])) |
|
| 463 | - $row['subject'] = $txt['no_subject']; |
|
| 475 | + if (empty($row['subject'])) { |
|
| 476 | + $row['subject'] = $txt['no_subject']; |
|
| 477 | + } |
|
| 464 | 478 | |
| 465 | 479 | // Post drafts |
| 466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | } |
| 546 | 560 | |
| 547 | 561 | // Default to 10. |
| 548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 549 | - $_REQUEST['viewscount'] = 10; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = 10; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
| 552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
| 611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 612 | 627 | { |
| 613 | 628 | // Censor.... |
| 614 | - if (empty($row['body'])) |
|
| 615 | - $row['body'] = ''; |
|
| 629 | + if (empty($row['body'])) { |
|
| 630 | + $row['body'] = ''; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 618 | - if (empty($row['subject'])) |
|
| 619 | - $row['subject'] = $txt['no_subject']; |
|
| 634 | + if (empty($row['subject'])) { |
|
| 635 | + $row['subject'] = $txt['no_subject']; |
|
| 636 | + } |
|
| 620 | 637 | |
| 621 | 638 | censorText($row['body']); |
| 622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
| 648 | 665 | $smcFunc['db_free_result']($request); |
| 649 | 666 | |
| 650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
| 651 | - if ($reverse) |
|
| 652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 668 | + if ($reverse) { |
|
| 669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 670 | + } |
|
| 653 | 671 | |
| 654 | 672 | // Menu tab |
| 655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
| 707 | 725 | } |
| 708 | 726 | |
| 709 | 727 | // Default to 10. |
| 710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 711 | - $_REQUEST['viewscount'] = 10; |
|
| 728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 729 | + $_REQUEST['viewscount'] = 10; |
|
| 730 | + } |
|
| 712 | 731 | |
| 713 | 732 | // Get the count of applicable drafts |
| 714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
| 767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 768 | 787 | { |
| 769 | 788 | // Censor.... |
| 770 | - if (empty($row['body'])) |
|
| 771 | - $row['body'] = ''; |
|
| 789 | + if (empty($row['body'])) { |
|
| 790 | + $row['body'] = ''; |
|
| 791 | + } |
|
| 772 | 792 | |
| 773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 774 | - if (empty($row['subject'])) |
|
| 775 | - $row['subject'] = $txt['no_subject']; |
|
| 794 | + if (empty($row['subject'])) { |
|
| 795 | + $row['subject'] = $txt['no_subject']; |
|
| 796 | + } |
|
| 776 | 797 | |
| 777 | 798 | censorText($row['body']); |
| 778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
| 827 | 848 | $smcFunc['db_free_result']($request); |
| 828 | 849 | |
| 829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
| 830 | - if ($reverse) |
|
| 831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 851 | + if ($reverse) { |
|
| 852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 853 | + } |
|
| 832 | 854 | |
| 833 | 855 | // off to the template we go |
| 834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | class Attachments |
| 20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
| 72 | 73 | |
| 73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
| 74 | - $this->{$this->_sa}(); |
|
| 74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
| 75 | + $this->{$this->_sa}(); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | // Just send a generic message. |
| 77 | - else |
|
| 78 | - $this->setResponse(array( |
|
| 79 | + else { |
|
| 80 | + $this->setResponse(array( |
|
| 79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
| 80 | 82 | 'type' => 'error', |
| 81 | 83 | 'data' => false, |
| 82 | 84 | )); |
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | // Back to the future, oh, to the browser! |
| 85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
| 95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
| 96 | 99 | |
| 97 | 100 | // Need something to work with. |
| 98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
| 99 | - return $this->setResponse(array( |
|
| 101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
| 102 | + return $this->setResponse(array( |
|
| 100 | 103 | 'text' => 'attached_file_deleted_error', |
| 101 | 104 | 'type' => 'error', |
| 102 | 105 | 'data' => false, |
| 103 | 106 | )); |
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // Lets pass some params and see what happens :P |
| 106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
| 119 | 123 | public function add() |
| 120 | 124 | { |
| 121 | 125 | // You gotta be able to post attachments. |
| 122 | - if (!$this->_canPostAttachment) |
|
| 123 | - return $this->setResponse(array( |
|
| 126 | + if (!$this->_canPostAttachment) { |
|
| 127 | + return $this->setResponse(array( |
|
| 124 | 128 | 'text' => 'attached_file_cannot', |
| 125 | 129 | 'type' => 'error', |
| 126 | 130 | 'data' => false, |
| 127 | 131 | )); |
| 132 | + } |
|
| 128 | 133 | |
| 129 | 134 | // Process them at once! |
| 130 | 135 | $this->processAttachments(); |
| 131 | 136 | |
| 132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
| 133 | - if (!empty($_SESSION['temp_attachments'])) |
|
| 134 | - $this->createAtttach(); |
|
| 138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
| 139 | + $this->createAtttach(); |
|
| 140 | + } |
|
| 135 | 141 | |
| 136 | 142 | // Set the response. |
| 137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
| 144 | 150 | { |
| 145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
| 146 | 152 | |
| 147 | - if (!isset($_FILES['attachment']['name'])) |
|
| 148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
| 153 | + if (!isset($_FILES['attachment']['name'])) { |
|
| 154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // If there are attachments, calculate the total size and how many. |
| 151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
| 155 | 162 | if (isset($_REQUEST['msg'])) |
| 156 | 163 | { |
| 157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 158 | - foreach ($context['current_attachments'] as $attachment) |
|
| 159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 165 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 167 | + } |
|
| 160 | 168 | } |
| 161 | 169 | |
| 162 | 170 | // A bit of house keeping first. |
| 163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 164 | - unset($_SESSION['temp_attachments']); |
|
| 171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 172 | + unset($_SESSION['temp_attachments']); |
|
| 173 | + } |
|
| 165 | 174 | |
| 166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
| 167 | - if (!isset($_SESSION['temp_attachments'])) |
|
| 168 | - $_SESSION['temp_attachments'] = array(); |
|
| 176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
| 177 | + $_SESSION['temp_attachments'] = array(); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // Make sure we're uploading to the right place. |
| 171 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 172 | - automanage_attachments_check_directory(); |
|
| 181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 182 | + automanage_attachments_check_directory(); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | // Is the attachments folder actually there? |
| 175 | - if (!empty($context['dir_creation_error'])) |
|
| 176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 186 | + if (!empty($context['dir_creation_error'])) { |
|
| 187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 188 | + } |
|
| 177 | 189 | |
| 178 | 190 | // The current attach folder ha some issues... |
| 179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
| 198 | 210 | ); |
| 199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
| 200 | 212 | $smcFunc['db_free_result']($request); |
| 201 | - } |
|
| 202 | - |
|
| 203 | - else |
|
| 204 | - $context['attachments'] = array( |
|
| 213 | + } else { |
|
| 214 | + $context['attachments'] = array( |
|
| 205 | 215 | 'quantity' => 0, |
| 206 | 216 | 'total_size' => 0, |
| 207 | 217 | ); |
| 218 | + } |
|
| 208 | 219 | |
| 209 | 220 | // Check for other general errors here. |
| 210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
| 212 | 223 | if (!empty($this->_generalErrors)) |
| 213 | 224 | { |
| 214 | 225 | // And delete the files 'cos they ain't going nowhere. |
| 215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
| 216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
| 227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
| 229 | + } |
|
| 218 | 230 | |
| 219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
| 220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
| 225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
| 226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 227 | 239 | { |
| 228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
| 229 | - continue; |
|
| 240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 230 | 243 | |
| 231 | 244 | // First, let's first check for PHP upload errors. |
| 232 | 245 | $errors = array(); |
| 233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
| 234 | 247 | { |
| 235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
| 236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 237 | - |
|
| 238 | - else |
|
| 239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
| 249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 250 | + } else { |
|
| 251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 252 | + } |
|
| 240 | 253 | |
| 241 | 254 | // Log this one, because... |
| 242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
| 243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
| 256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 257 | + } |
|
| 244 | 258 | |
| 245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
| 246 | - if (empty($errors)) |
|
| 247 | - $errors[] = 'attach_php_error'; |
|
| 260 | + if (empty($errors)) { |
|
| 261 | + $errors[] = 'attach_php_error'; |
|
| 262 | + } |
|
| 248 | 263 | } |
| 249 | 264 | |
| 250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
| 256 | 271 | { |
| 257 | 272 | // The reported MIME type of the attachment might not be reliable. |
| 258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
| 259 | - if (function_exists('mime_content_type')) |
|
| 260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
| 274 | + if (function_exists('mime_content_type')) { |
|
| 275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
| 276 | + } |
|
| 261 | 277 | |
| 262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
| 263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
| 269 | 285 | ); |
| 270 | 286 | |
| 271 | 287 | // Move the file to the attachments folder with a temp name for now. |
| 272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
| 273 | - smf_chmod($destName, 0644); |
|
| 288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
| 289 | + smf_chmod($destName, 0644); |
|
| 290 | + } |
|
| 274 | 291 | |
| 275 | 292 | // This is madness!! |
| 276 | 293 | else |
| 277 | 294 | { |
| 278 | 295 | // File couldn't be moved. |
| 279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
| 280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 299 | + } |
|
| 282 | 300 | } |
| 283 | 301 | } |
| 284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
| 291 | 309 | 'errors' => $errors, |
| 292 | 310 | ); |
| 293 | 311 | |
| 294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 314 | + } |
|
| 296 | 315 | } |
| 297 | 316 | |
| 298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
| 299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
| 300 | - attachmentChecks($attachID); |
|
| 318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
| 319 | + attachmentChecks($attachID); |
|
| 320 | + } |
|
| 301 | 321 | } |
| 302 | 322 | |
| 303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
| 344 | 364 | |
| 345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
| 346 | 366 | |
| 347 | - if (!empty($attachmentOptions['thumb'])) |
|
| 348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 367 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 369 | + } |
|
| 349 | 370 | |
| 350 | - if ($this->_msg) |
|
| 351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 371 | + if ($this->_msg) { |
|
| 372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 373 | + } |
|
| 352 | 374 | } |
| 353 | - } |
|
| 354 | - else |
|
| 375 | + } else |
|
| 355 | 376 | { |
| 356 | 377 | // Sort out the errors for display and delete any associated files. |
| 357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
| 363 | 384 | if (!is_array($error)) |
| 364 | 385 | { |
| 365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
| 366 | - if (in_array($error, $log_these)) |
|
| 367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 387 | + if (in_array($error, $log_these)) { |
|
| 388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 389 | + } |
|
| 390 | + } else { |
|
| 391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 368 | 392 | } |
| 369 | - else |
|
| 370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 371 | 393 | } |
| 372 | - if (file_exists($attachment['tmp_name'])) |
|
| 373 | - unlink($attachment['tmp_name']); |
|
| 394 | + if (file_exists($attachment['tmp_name'])) { |
|
| 395 | + unlink($attachment['tmp_name']); |
|
| 396 | + } |
|
| 374 | 397 | } |
| 375 | 398 | |
| 376 | 399 | // Regardless of errors, pass the results. |
@@ -378,8 +401,9 @@ discard block |
||
| 378 | 401 | } |
| 379 | 402 | |
| 380 | 403 | // Temp save this on the db. |
| 381 | - if (!empty($_SESSION['already_attached'])) |
|
| 382 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 404 | + if (!empty($_SESSION['already_attached'])) { |
|
| 405 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 406 | + } |
|
| 383 | 407 | |
| 384 | 408 | unset($_SESSION['temp_attachments']); |
| 385 | 409 | } |
@@ -399,14 +423,16 @@ discard block |
||
| 399 | 423 | if ($this->_sa == 'add') |
| 400 | 424 | { |
| 401 | 425 | // Is there any generic errors? made some sense out of them! |
| 402 | - if ($this->_generalErrors) |
|
| 403 | - foreach ($this->_generalErrors as $k => $v) |
|
| 426 | + if ($this->_generalErrors) { |
|
| 427 | + foreach ($this->_generalErrors as $k => $v) |
|
| 404 | 428 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
| 429 | + } |
|
| 405 | 430 | |
| 406 | 431 | // Gotta urlencode the filename. |
| 407 | - if ($this->_attachResults) |
|
| 408 | - foreach ($this->_attachResults as $k => $v) |
|
| 432 | + if ($this->_attachResults) { |
|
| 433 | + foreach ($this->_attachResults as $k => $v) |
|
| 409 | 434 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
| 435 | + } |
|
| 410 | 436 | |
| 411 | 437 | $this->_response = array( |
| 412 | 438 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -415,9 +441,10 @@ discard block |
||
| 415 | 441 | } |
| 416 | 442 | |
| 417 | 443 | // Rest of us mere mortals gets no special treatment... |
| 418 | - elseif (!empty($data)) |
|
| 419 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 444 | + elseif (!empty($data)) { |
|
| 445 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 420 | 446 | $this->_response['text'] = $txt[$data['text']]; |
| 447 | + } |
|
| 421 | 448 | } |
| 422 | 449 | |
| 423 | 450 | protected function sendResponse() |
@@ -426,11 +453,11 @@ discard block |
||
| 426 | 453 | |
| 427 | 454 | ob_end_clean(); |
| 428 | 455 | |
| 429 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 430 | - @ob_start('ob_gzhandler'); |
|
| 431 | - |
|
| 432 | - else |
|
| 433 | - ob_start(); |
|
| 456 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 457 | + @ob_start('ob_gzhandler'); |
|
| 458 | + } else { |
|
| 459 | + ob_start(); |
|
| 460 | + } |
|
| 434 | 461 | |
| 435 | 462 | // Set the header. |
| 436 | 463 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -53,14 +53,15 @@ discard block |
||
| 53 | 53 | foreach ($context['smileys'] as $location => $smileyRows) |
| 54 | 54 | { |
| 55 | 55 | $countLocations--; |
| 56 | - if ($location == 'postform') |
|
| 57 | - echo ' |
|
| 56 | + if ($location == 'postform') { |
|
| 57 | + echo ' |
|
| 58 | 58 | dropdown: |
| 59 | 59 | {'; |
| 60 | - elseif ($location == 'popup') |
|
| 61 | - echo ' |
|
| 60 | + } elseif ($location == 'popup') { |
|
| 61 | + echo ' |
|
| 62 | 62 | popup: |
| 63 | 63 | {'; |
| 64 | + } |
|
| 64 | 65 | |
| 65 | 66 | $numRows = count($smileyRows); |
| 66 | 67 | // This is needed because otherwise the editor will remove all the duplicate (empty) keys and leave only 1 additional line |
@@ -72,21 +73,22 @@ discard block |
||
| 72 | 73 | echo ' |
| 73 | 74 | ', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : ''; |
| 74 | 75 | } |
| 75 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
| 76 | - echo ', |
|
| 76 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
| 77 | + echo ', |
|
| 77 | 78 | \'-', $emptyPlaceholder++, '\': \'\','; |
| 79 | + } |
|
| 78 | 80 | } |
| 79 | 81 | echo ' |
| 80 | 82 | }', $countLocations != 0 ? ',' : ''; |
| 81 | 83 | } |
| 82 | 84 | echo ' |
| 83 | 85 | }'; |
| 84 | - } |
|
| 85 | - else |
|
| 86 | - echo ', |
|
| 86 | + } else { |
|
| 87 | + echo ', |
|
| 87 | 88 | emoticons: |
| 88 | 89 | {}, |
| 89 | 90 | emoticonsEnabled:false'; |
| 91 | + } |
|
| 90 | 92 | |
| 91 | 93 | if ($context['show_bbc'] && $bbcContainer !== null) |
| 92 | 94 | { |
@@ -97,15 +99,16 @@ discard block |
||
| 97 | 99 | { |
| 98 | 100 | echo implode('|', $buttonRow); |
| 99 | 101 | $count_tags--; |
| 100 | - if (!empty($count_tags)) |
|
| 101 | - echo '||'; |
|
| 102 | + if (!empty($count_tags)) { |
|
| 103 | + echo '||'; |
|
| 104 | + } |
|
| 102 | 105 | } |
| 103 | 106 | |
| 104 | 107 | echo '",'; |
| 105 | - } |
|
| 106 | - else |
|
| 107 | - echo ', |
|
| 108 | + } else { |
|
| 109 | + echo ', |
|
| 108 | 110 | toolbar: "",'; |
| 111 | + } |
|
| 109 | 112 | |
| 110 | 113 | echo ' |
| 111 | 114 | }); |
@@ -146,43 +149,48 @@ discard block |
||
| 146 | 149 | </span>'; |
| 147 | 150 | |
| 148 | 151 | $tempTab = $context['tabindex']; |
| 149 | - if (!empty($context['drafts_pm_save'])) |
|
| 150 | - $tempTab++; |
|
| 151 | - elseif (!empty($context['drafts_save'])) |
|
| 152 | - $tempTab++; |
|
| 153 | - elseif ($editor_context['preview_type']) |
|
| 154 | - $tempTab++; |
|
| 155 | - elseif ($context['show_spellchecking']) |
|
| 156 | - $tempTab++; |
|
| 152 | + if (!empty($context['drafts_pm_save'])) { |
|
| 153 | + $tempTab++; |
|
| 154 | + } elseif (!empty($context['drafts_save'])) { |
|
| 155 | + $tempTab++; |
|
| 156 | + } elseif ($editor_context['preview_type']) { |
|
| 157 | + $tempTab++; |
|
| 158 | + } elseif ($context['show_spellchecking']) { |
|
| 159 | + $tempTab++; |
|
| 160 | + } |
|
| 157 | 161 | |
| 158 | 162 | $tempTab++; |
| 159 | 163 | $context['tabindex'] = $tempTab; |
| 160 | 164 | |
| 161 | - if (!empty($context['drafts_pm_save'])) |
|
| 162 | - echo ' |
|
| 165 | + if (!empty($context['drafts_pm_save'])) { |
|
| 166 | + echo ' |
|
| 163 | 167 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button_submit"> |
| 164 | 168 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
| 169 | + } |
|
| 165 | 170 | |
| 166 | - if (!empty($context['drafts_save'])) |
|
| 167 | - echo ' |
|
| 171 | + if (!empty($context['drafts_save'])) { |
|
| 172 | + echo ' |
|
| 168 | 173 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button_submit"> |
| 169 | 174 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
| 175 | + } |
|
| 170 | 176 | |
| 171 | - if ($context['show_spellchecking']) |
|
| 172 | - echo ' |
|
| 177 | + if ($context['show_spellchecking']) { |
|
| 178 | + echo ' |
|
| 173 | 179 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button_submit">'; |
| 180 | + } |
|
| 174 | 181 | |
| 175 | - if ($editor_context['preview_type']) |
|
| 176 | - echo ' |
|
| 182 | + if ($editor_context['preview_type']) { |
|
| 183 | + echo ' |
|
| 177 | 184 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button_submit">'; |
| 185 | + } |
|
| 178 | 186 | |
| 179 | 187 | |
| 180 | 188 | echo ' |
| 181 | 189 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit">'; |
| 182 | 190 | |
| 183 | 191 | // Load in the PM autosaver if it's enabled |
| 184 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
| 185 | - echo ' |
|
| 192 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
| 193 | + echo ' |
|
| 186 | 194 | <span class="righttext padding" style="display: block"> |
| 187 | 195 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"> </span> |
| 188 | 196 | <span id="draft_lastautosave" ></span> |
@@ -200,10 +208,11 @@ discard block |
||
| 200 | 208 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
| 201 | 209 | }); |
| 202 | 210 | </script>'; |
| 211 | + } |
|
| 203 | 212 | |
| 204 | 213 | // Start an instance of the auto saver if its enabled |
| 205 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
| 206 | - echo ' |
|
| 214 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
| 215 | + echo ' |
|
| 207 | 216 | <span class="righttext padding" style="display: block"> |
| 208 | 217 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"> </span> |
| 209 | 218 | <span id="draft_lastautosave" ></span> |
@@ -220,7 +229,8 @@ discard block |
||
| 220 | 229 | iFreq: ', $context['drafts_autosave_frequency'], ' |
| 221 | 230 | }); |
| 222 | 231 | </script>'; |
| 223 | -} |
|
| 232 | + } |
|
| 233 | + } |
|
| 224 | 234 | |
| 225 | 235 | /** |
| 226 | 236 | * This template displays a verification form |
@@ -237,51 +247,57 @@ discard block |
||
| 237 | 247 | $verify_context = &$context['controls']['verification'][$verify_id]; |
| 238 | 248 | |
| 239 | 249 | // Keep track of where we are. |
| 240 | - if (empty($verify_context['tracking']) || $reset) |
|
| 241 | - $verify_context['tracking'] = 0; |
|
| 250 | + if (empty($verify_context['tracking']) || $reset) { |
|
| 251 | + $verify_context['tracking'] = 0; |
|
| 252 | + } |
|
| 242 | 253 | |
| 243 | 254 | // How many items are there to display in total. |
| 244 | 255 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
| 245 | 256 | |
| 246 | 257 | // If we've gone too far, stop. |
| 247 | - if ($verify_context['tracking'] > $total_items) |
|
| 248 | - return false; |
|
| 258 | + if ($verify_context['tracking'] > $total_items) { |
|
| 259 | + return false; |
|
| 260 | + } |
|
| 249 | 261 | |
| 250 | 262 | // Loop through each item to show them. |
| 251 | 263 | for ($i = 0; $i < $total_items; $i++) |
| 252 | 264 | { |
| 253 | 265 | // If we're after a single item only show it if we're in the right place. |
| 254 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
| 255 | - continue; |
|
| 266 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
| 267 | + continue; |
|
| 268 | + } |
|
| 256 | 269 | |
| 257 | - if ($display_type != 'single') |
|
| 258 | - echo ' |
|
| 270 | + if ($display_type != 'single') { |
|
| 271 | + echo ' |
|
| 259 | 272 | <div id="verification_control_', $i, '" class="verification_control">'; |
| 273 | + } |
|
| 260 | 274 | |
| 261 | 275 | // Display empty field, but only if we have one, and it's the first time. |
| 262 | - if ($verify_context['empty_field'] && empty($i)) |
|
| 263 | - echo ' |
|
| 276 | + if ($verify_context['empty_field'] && empty($i)) { |
|
| 277 | + echo ' |
|
| 264 | 278 | <div class="smalltext vv_special"> |
| 265 | 279 | ', $txt['visual_verification_hidden'], ': |
| 266 | 280 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
| 267 | 281 | </div>'; |
| 282 | + } |
|
| 268 | 283 | |
| 269 | 284 | // Do the actual stuff |
| 270 | 285 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
| 271 | 286 | { |
| 272 | 287 | if ($verify_context['show_visual']) |
| 273 | 288 | { |
| 274 | - if ($context['use_graphic_library']) |
|
| 275 | - echo ' |
|
| 289 | + if ($context['use_graphic_library']) { |
|
| 290 | + echo ' |
|
| 276 | 291 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
| 277 | - else |
|
| 278 | - echo ' |
|
| 292 | + } else { |
|
| 293 | + echo ' |
|
| 279 | 294 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
| 280 | 295 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
| 281 | 296 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
| 282 | 297 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
| 283 | 298 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
| 284 | 299 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
| 300 | + } |
|
| 285 | 301 | |
| 286 | 302 | echo ' |
| 287 | 303 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -297,8 +313,7 @@ discard block |
||
| 297 | 313 | <div class="g-recaptcha centertext" data-sitekey="' . $verify_context['recaptcha_site_key'] . '" data-theme="' . $verify_context['recaptcha_theme'] . '"></div><br> |
| 298 | 314 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>'; |
| 299 | 315 | } |
| 300 | - } |
|
| 301 | - else |
|
| 316 | + } else |
|
| 302 | 317 | { |
| 303 | 318 | // Where in the question array is this question? |
| 304 | 319 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -310,21 +325,24 @@ discard block |
||
| 310 | 325 | </div>'; |
| 311 | 326 | } |
| 312 | 327 | |
| 313 | - if ($display_type != 'single') |
|
| 314 | - echo ' |
|
| 328 | + if ($display_type != 'single') { |
|
| 329 | + echo ' |
|
| 315 | 330 | </div>'; |
| 331 | + } |
|
| 316 | 332 | |
| 317 | 333 | // If we were displaying just one and we did it, break. |
| 318 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
| 319 | - break; |
|
| 334 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
| 335 | + break; |
|
| 336 | + } |
|
| 320 | 337 | } |
| 321 | 338 | |
| 322 | 339 | // Assume we found something, always, |
| 323 | 340 | $verify_context['tracking']++; |
| 324 | 341 | |
| 325 | 342 | // Tell something displaying piecemeal to keep going. |
| 326 | - if ($display_type == 'single') |
|
| 327 | - return true; |
|
| 328 | -} |
|
| 343 | + if ($display_type == 'single') { |
|
| 344 | + return true; |
|
| 345 | + } |
|
| 346 | + } |
|
| 329 | 347 | |
| 330 | 348 | ?> |
| 331 | 349 | \ No newline at end of file |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
| 245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 246 | 247 | { |
| 247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
| 248 | - if (!empty($row['private'])) |
|
| 249 | - $row['subject'] = $txt['personal_message']; |
|
| 249 | + if (!empty($row['private'])) { |
|
| 250 | + $row['subject'] = $txt['personal_message']; |
|
| 251 | + } |
|
| 250 | 252 | |
| 251 | 253 | $mails[] = $row; |
| 252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
| 300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
| 301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
| 302 | 304 | } |
| 303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
| 304 | - $emails[$index] = $index; |
|
| 305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
| 306 | + $emails[$index] = $index; |
|
| 307 | + } |
|
| 305 | 308 | |
| 306 | 309 | $config_vars = array( |
| 307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
| 322 | 325 | |
| 323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
| 324 | 327 | |
| 325 | - if ($return_config) |
|
| 326 | - return $config_vars; |
|
| 328 | + if ($return_config) { |
|
| 329 | + return $config_vars; |
|
| 330 | + } |
|
| 327 | 331 | |
| 328 | 332 | // Saving? |
| 329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
| 398 | 402 | ); |
| 399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
| 400 | 404 | $smcFunc['db_free_result']($request); |
| 405 | + } else { |
|
| 406 | + $_GET['te'] = (int) $_GET['te']; |
|
| 401 | 407 | } |
| 402 | - else |
|
| 403 | - $_GET['te'] = (int) $_GET['te']; |
|
| 404 | 408 | |
| 405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
| 406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
| 424 | 428 | |
| 425 | 429 | // Try get more time... |
| 426 | 430 | @set_time_limit(600); |
| 427 | - if (function_exists('apache_reset_timeout')) |
|
| 428 | - @apache_reset_timeout(); |
|
| 431 | + if (function_exists('apache_reset_timeout')) { |
|
| 432 | + @apache_reset_timeout(); |
|
| 433 | + } |
|
| 429 | 434 | |
| 430 | 435 | // Have we already used our maximum time? |
| 431 | - if (time() - array_sum(explode(' ', $time_start)) < 5) |
|
| 432 | - return; |
|
| 436 | + if (time() - array_sum(explode(' ', $time_start)) < 5) { |
|
| 437 | + return; |
|
| 438 | + } |
|
| 433 | 439 | |
| 434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
| 459 | 465 | { |
| 460 | 466 | global $txt; |
| 461 | 467 | |
| 462 | - if ($time_diff < 0) |
|
| 463 | - $time_diff = 0; |
|
| 468 | + if ($time_diff < 0) { |
|
| 469 | + $time_diff = 0; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | // Just do a bit of an if fest... |
| 466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
| 481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
| 482 | 489 | } |
| 483 | 490 | // Otherwise must be second |
| 484 | - else |
|
| 485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 486 | -} |
|
| 491 | + else { |
|
| 492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 493 | + } |
|
| 494 | + } |
|
| 487 | 495 | |
| 488 | 496 | ?> |
| 489 | 497 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('Location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |