@@ -18,7 +18,7 @@ |
||
| 18 | 18 | class ApproveReply_Notify_Background extends SMF_BackgroundTask |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
| 21 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
| 22 | 22 | * @return bool Always returns true. |
| 23 | 23 | */ |
| 24 | 24 | public function execute() |
@@ -96,14 +96,15 @@ |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Insert the alerts if any |
| 99 | - if (!empty($alert_rows)) |
|
| 100 | - $smcFunc['db_insert']('', |
|
| 99 | + if (!empty($alert_rows)) { |
|
| 100 | + $smcFunc['db_insert']('', |
|
| 101 | 101 | '{db_prefix}user_alerts', |
| 102 | 102 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 103 | 103 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 104 | 104 | $alert_rows, |
| 105 | 105 | array() |
| 106 | 106 | ); |
| 107 | + } |
|
| 107 | 108 | |
| 108 | 109 | return true; |
| 109 | 110 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | class GroupReq_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
| 24 | 24 | * @return bool Always returns true. |
| 25 | 25 | */ |
| 26 | 26 | public function execute() |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | 39 | $moderators = array(); |
| 40 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 41 | - $moderators[] = $row['id_member']; |
|
| 40 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 41 | + $moderators[] = $row['id_member']; |
|
| 42 | + } |
|
| 42 | 43 | $smcFunc['db_free_result']($request); |
| 43 | 44 | |
| 44 | 45 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -59,11 +60,13 @@ discard block |
||
| 59 | 60 | { |
| 60 | 61 | if (!empty($prefs[$mod]['request_group'])) |
| 61 | 62 | { |
| 62 | - if ($prefs[$mod]['request_group'] & 0x01) |
|
| 63 | - $data['alert'][] = $mod; |
|
| 63 | + if ($prefs[$mod]['request_group'] & 0x01) { |
|
| 64 | + $data['alert'][] = $mod; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | - if ($prefs[$mod]['request_group'] & 0x02) |
|
| 66 | - $data['email'][] = $mod; |
|
| 67 | + if ($prefs[$mod]['request_group'] & 0x02) { |
|
| 68 | + $data['email'][] = $mod; |
|
| 69 | + } |
|
| 67 | 70 | } |
| 68 | 71 | } |
| 69 | 72 | |
@@ -240,8 +240,8 @@ |
||
| 240 | 240 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
| 241 | 241 | |
| 242 | 242 | $js_time_string = str_replace( |
| 243 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 244 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 243 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 244 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 245 | 245 | $time_string |
| 246 | 246 | ); |
| 247 | 247 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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'); |
@@ -88,22 +91,25 @@ discard block |
||
| 88 | 91 | $context['page_title'] = $txt['calendar']; |
| 89 | 92 | |
| 90 | 93 | // Ensure a default view is defined |
| 91 | - if (empty($modSettings['calendar_default_view'])) |
|
| 92 | - $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 94 | + if (empty($modSettings['calendar_default_view'])) { |
|
| 95 | + $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | // What view do we want? |
| 95 | - if (isset($_GET['viewweek'])) |
|
| 96 | - $context['calendar_view'] = 'viewweek'; |
|
| 97 | - elseif (isset($_GET['viewmonth'])) |
|
| 98 | - $context['calendar_view'] = 'viewmonth'; |
|
| 99 | - elseif (isset($_GET['viewlist'])) |
|
| 100 | - $context['calendar_view'] = 'viewlist'; |
|
| 101 | - else |
|
| 102 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 99 | + if (isset($_GET['viewweek'])) { |
|
| 100 | + $context['calendar_view'] = 'viewweek'; |
|
| 101 | + } elseif (isset($_GET['viewmonth'])) { |
|
| 102 | + $context['calendar_view'] = 'viewmonth'; |
|
| 103 | + } elseif (isset($_GET['viewlist'])) { |
|
| 104 | + $context['calendar_view'] = 'viewlist'; |
|
| 105 | + } else { |
|
| 106 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // Don't let search engines index the non-default calendar pages |
| 105 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
| 106 | - $context['robot_no_index'] = true; |
|
| 110 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
| 111 | + $context['robot_no_index'] = true; |
|
| 112 | + } |
|
| 107 | 113 | |
| 108 | 114 | // Get the current day of month... |
| 109 | 115 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -164,16 +170,19 @@ discard block |
||
| 164 | 170 | ); |
| 165 | 171 | |
| 166 | 172 | // Make sure the year and month are in valid ranges. |
| 167 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
| 168 | - fatal_lang_error('invalid_month', false); |
|
| 169 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
| 170 | - fatal_lang_error('invalid_year', false); |
|
| 173 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
| 174 | + fatal_lang_error('invalid_month', false); |
|
| 175 | + } |
|
| 176 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
| 177 | + fatal_lang_error('invalid_year', false); |
|
| 178 | + } |
|
| 171 | 179 | // If we have a day clean that too. |
| 172 | 180 | if ($context['calendar_view'] != 'viewmonth') |
| 173 | 181 | { |
| 174 | 182 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
| 175 | - if (!$isValid) |
|
| 176 | - fatal_lang_error('invalid_day', false); |
|
| 183 | + if (!$isValid) { |
|
| 184 | + fatal_lang_error('invalid_day', false); |
|
| 185 | + } |
|
| 177 | 186 | } |
| 178 | 187 | |
| 179 | 188 | // Load all the context information needed to show the calendar grid. |
@@ -195,23 +204,26 @@ discard block |
||
| 195 | 204 | ); |
| 196 | 205 | |
| 197 | 206 | // Load up the main view. |
| 198 | - if ($context['calendar_view'] == 'viewlist') |
|
| 199 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 200 | - elseif ($context['calendar_view'] == 'viewweek') |
|
| 201 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 202 | - else |
|
| 203 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 207 | + if ($context['calendar_view'] == 'viewlist') { |
|
| 208 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 209 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
| 210 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 211 | + } else { |
|
| 212 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 213 | + } |
|
| 204 | 214 | |
| 205 | 215 | // Load up the previous and next months. |
| 206 | 216 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
| 207 | 217 | |
| 208 | 218 | // Only show previous month if it isn't pre-January of the min-year |
| 209 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
| 210 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 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); |
|
| 221 | + } |
|
| 211 | 222 | |
| 212 | 223 | // Only show next month if it isn't post-December of the max-year |
| 213 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
| 214 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 224 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
| 225 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 226 | + } |
|
| 215 | 227 | |
| 216 | 228 | // Basic template stuff. |
| 217 | 229 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -231,8 +243,9 @@ discard block |
||
| 231 | 243 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
| 232 | 244 | |
| 233 | 245 | // Set the page title to mention the month or week, too |
| 234 | - if ($context['calendar_view'] != 'viewlist') |
|
| 235 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 246 | + if ($context['calendar_view'] != 'viewlist') { |
|
| 247 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 248 | + } |
|
| 236 | 249 | |
| 237 | 250 | // Load up the linktree! |
| 238 | 251 | $context['linktree'][] = array( |
@@ -245,17 +258,19 @@ discard block |
||
| 245 | 258 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
| 246 | 259 | ); |
| 247 | 260 | // If applicable, add the current week to the linktree. |
| 248 | - if ($context['calendar_view'] == 'viewweek') |
|
| 249 | - $context['linktree'][] = array( |
|
| 261 | + if ($context['calendar_view'] == 'viewweek') { |
|
| 262 | + $context['linktree'][] = array( |
|
| 250 | 263 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 251 | 264 | 'name' => $context['calendar_grid_main']['week_title'], |
| 252 | 265 | ); |
| 266 | + } |
|
| 253 | 267 | |
| 254 | 268 | // Build the calendar button array. |
| 255 | 269 | $context['calendar_buttons'] = array(); |
| 256 | 270 | |
| 257 | - if ($context['can_post']) |
|
| 258 | - $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']); |
|
| 271 | + if ($context['can_post']) { |
|
| 272 | + $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']); |
|
| 273 | + } |
|
| 259 | 274 | |
| 260 | 275 | // Allow mods to add additional buttons here |
| 261 | 276 | call_integration_hook('integrate_calendar_buttons'); |
@@ -284,14 +299,16 @@ discard block |
||
| 284 | 299 | require_once($sourcedir . '/Subs.php'); |
| 285 | 300 | |
| 286 | 301 | // Cast this for safety... |
| 287 | - if (isset($_REQUEST['eventid'])) |
|
| 288 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 302 | + if (isset($_REQUEST['eventid'])) { |
|
| 303 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 304 | + } |
|
| 289 | 305 | |
| 290 | 306 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 291 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 292 | - $time_string = '%k:%M'; |
|
| 293 | - else |
|
| 294 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 307 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 308 | + $time_string = '%k:%M'; |
|
| 309 | + } else { |
|
| 310 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 311 | + } |
|
| 295 | 312 | |
| 296 | 313 | $js_time_string = str_replace( |
| 297 | 314 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -305,12 +322,14 @@ discard block |
||
| 305 | 322 | checkSession(); |
| 306 | 323 | |
| 307 | 324 | // Validate the post... |
| 308 | - if (!isset($_POST['link_to_board'])) |
|
| 309 | - validateEventPost(); |
|
| 325 | + if (!isset($_POST['link_to_board'])) { |
|
| 326 | + validateEventPost(); |
|
| 327 | + } |
|
| 310 | 328 | |
| 311 | 329 | // If you're not allowed to edit any events, you have to be the poster. |
| 312 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
| 313 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 330 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
| 331 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 332 | + } |
|
| 314 | 333 | |
| 315 | 334 | // New - and directing? |
| 316 | 335 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -333,8 +352,9 @@ discard block |
||
| 333 | 352 | } |
| 334 | 353 | |
| 335 | 354 | // Deleting... |
| 336 | - elseif (isset($_REQUEST['deleteevent'])) |
|
| 337 | - removeEvent($_REQUEST['eventid']); |
|
| 355 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
| 356 | + removeEvent($_REQUEST['eventid']); |
|
| 357 | + } |
|
| 338 | 358 | |
| 339 | 359 | // ... or just update it? |
| 340 | 360 | else |
@@ -357,15 +377,13 @@ discard block |
||
| 357 | 377 | $year = $d['year']; |
| 358 | 378 | $month = $d['month']; |
| 359 | 379 | $day = $d['day']; |
| 360 | - } |
|
| 361 | - elseif (isset($_POST['start_datetime'])) |
|
| 380 | + } elseif (isset($_POST['start_datetime'])) |
|
| 362 | 381 | { |
| 363 | 382 | $d = date_parse($_POST['start_datetime']); |
| 364 | 383 | $year = $d['year']; |
| 365 | 384 | $month = $d['month']; |
| 366 | 385 | $day = $d['day']; |
| 367 | - } |
|
| 368 | - else |
|
| 386 | + } else |
|
| 369 | 387 | { |
| 370 | 388 | $today = getdate(); |
| 371 | 389 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -399,13 +417,13 @@ discard block |
||
| 399 | 417 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
| 400 | 418 | |
| 401 | 419 | $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'])); |
| 402 | - } |
|
| 403 | - else |
|
| 420 | + } else |
|
| 404 | 421 | { |
| 405 | 422 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
| 406 | 423 | |
| 407 | - if ($context['event'] === false) |
|
| 408 | - fatal_lang_error('no_access', false); |
|
| 424 | + if ($context['event'] === false) { |
|
| 425 | + fatal_lang_error('no_access', false); |
|
| 426 | + } |
|
| 409 | 427 | |
| 410 | 428 | // If it has a board, then they should be editing it within the topic. |
| 411 | 429 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -416,10 +434,11 @@ discard block |
||
| 416 | 434 | } |
| 417 | 435 | |
| 418 | 436 | // Make sure the user is allowed to edit this event. |
| 419 | - if ($context['event']['member'] != $user_info['id']) |
|
| 420 | - isAllowedTo('calendar_edit_any'); |
|
| 421 | - elseif (!allowedTo('calendar_edit_any')) |
|
| 422 | - isAllowedTo('calendar_edit_own'); |
|
| 437 | + if ($context['event']['member'] != $user_info['id']) { |
|
| 438 | + isAllowedTo('calendar_edit_any'); |
|
| 439 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
| 440 | + isAllowedTo('calendar_edit_own'); |
|
| 441 | + } |
|
| 423 | 442 | } |
| 424 | 443 | |
| 425 | 444 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -453,8 +472,7 @@ discard block |
||
| 453 | 472 | { |
| 454 | 473 | // You can post new events but can't link them to anything... |
| 455 | 474 | $context['event']['categories'] = array(); |
| 456 | - } |
|
| 457 | - else |
|
| 475 | + } else |
|
| 458 | 476 | { |
| 459 | 477 | // Load the list of boards and categories in the context. |
| 460 | 478 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -541,12 +559,14 @@ discard block |
||
| 541 | 559 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
| 542 | 560 | |
| 543 | 561 | // You can't export if the calendar export feature is off. |
| 544 | - if (empty($modSettings['cal_export'])) |
|
| 545 | - fatal_lang_error('calendar_export_off', false); |
|
| 562 | + if (empty($modSettings['cal_export'])) { |
|
| 563 | + fatal_lang_error('calendar_export_off', false); |
|
| 564 | + } |
|
| 546 | 565 | |
| 547 | 566 | // Goes without saying that this is required. |
| 548 | - if (!isset($_REQUEST['eventid'])) |
|
| 549 | - fatal_lang_error('no_access', false); |
|
| 567 | + if (!isset($_REQUEST['eventid'])) { |
|
| 568 | + fatal_lang_error('no_access', false); |
|
| 569 | + } |
|
| 550 | 570 | |
| 551 | 571 | // This is kinda wanted. |
| 552 | 572 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -554,15 +574,17 @@ discard block |
||
| 554 | 574 | // Load up the event in question and check it exists. |
| 555 | 575 | $event = getEventProperties($_REQUEST['eventid']); |
| 556 | 576 | |
| 557 | - if ($event === false) |
|
| 558 | - fatal_lang_error('no_access', false); |
|
| 577 | + if ($event === false) { |
|
| 578 | + fatal_lang_error('no_access', false); |
|
| 579 | + } |
|
| 559 | 580 | |
| 560 | 581 | // Check the title isn't too long - iCal requires some formatting if so. |
| 561 | 582 | $title = str_split($event['title'], 30); |
| 562 | 583 | foreach ($title as $id => $line) |
| 563 | 584 | { |
| 564 | - if ($id != 0) |
|
| 565 | - $title[$id] = ' ' . $title[$id]; |
|
| 585 | + if ($id != 0) { |
|
| 586 | + $title[$id] = ' ' . $title[$id]; |
|
| 587 | + } |
|
| 566 | 588 | $title[$id] .= "\n"; |
| 567 | 589 | } |
| 568 | 590 | |
@@ -575,8 +597,7 @@ discard block |
||
| 575 | 597 | { |
| 576 | 598 | $datestart = date_format($start_date, 'Ymd\THis'); |
| 577 | 599 | $dateend = date_format($end_date, 'Ymd\THis'); |
| 578 | - } |
|
| 579 | - else |
|
| 600 | + } else |
|
| 580 | 601 | { |
| 581 | 602 | $datestart = date_format($start_date, 'Ymd'); |
| 582 | 603 | |
@@ -597,15 +618,18 @@ discard block |
||
| 597 | 618 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
| 598 | 619 | |
| 599 | 620 | // event has a duration |
| 600 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
| 601 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 621 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
| 622 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 623 | + } |
|
| 602 | 624 | |
| 603 | 625 | // event has changed? advance the sequence for this UID |
| 604 | - if ($event['sequence'] > 0) |
|
| 605 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 626 | + if ($event['sequence'] > 0) { |
|
| 627 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 628 | + } |
|
| 606 | 629 | |
| 607 | - if (!empty($event['location'])) |
|
| 608 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 630 | + if (!empty($event['location'])) { |
|
| 631 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 632 | + } |
|
| 609 | 633 | |
| 610 | 634 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 611 | 635 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -614,23 +638,26 @@ discard block |
||
| 614 | 638 | |
| 615 | 639 | // Send some standard headers. |
| 616 | 640 | ob_end_clean(); |
| 617 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 618 | - @ob_start('ob_gzhandler'); |
|
| 619 | - else |
|
| 620 | - ob_start(); |
|
| 641 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 642 | + @ob_start('ob_gzhandler'); |
|
| 643 | + } else { |
|
| 644 | + ob_start(); |
|
| 645 | + } |
|
| 621 | 646 | |
| 622 | 647 | // Send the file headers |
| 623 | 648 | header('Pragma: '); |
| 624 | 649 | header('Cache-Control: no-cache'); |
| 625 | - if (!isBrowser('gecko')) |
|
| 626 | - header('Content-Transfer-Encoding: binary'); |
|
| 650 | + if (!isBrowser('gecko')) { |
|
| 651 | + header('Content-Transfer-Encoding: binary'); |
|
| 652 | + } |
|
| 627 | 653 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 628 | 654 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
| 629 | 655 | header('Accept-Ranges: bytes'); |
| 630 | 656 | header('Connection: close'); |
| 631 | 657 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 632 | - if (empty($modSettings['enableCompressedOutput'])) |
|
| 633 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 658 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
| 659 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 660 | + } |
|
| 634 | 661 | |
| 635 | 662 | // This is a calendar item! |
| 636 | 663 | header('Content-Type: text/calendar'); |
@@ -669,20 +696,17 @@ discard block |
||
| 669 | 696 | $context['sub_template'] = 'bcd'; |
| 670 | 697 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
| 671 | 698 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true); |
| 672 | - } |
|
| 673 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 699 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 674 | 700 | { |
| 675 | 701 | $context['sub_template'] = 'hms'; |
| 676 | 702 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
| 677 | 703 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true); |
| 678 | - } |
|
| 679 | - elseif ($omfg) |
|
| 704 | + } elseif ($omfg) |
|
| 680 | 705 | { |
| 681 | 706 | $context['sub_template'] = 'omfg'; |
| 682 | 707 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
| 683 | 708 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true); |
| 684 | - } |
|
| 685 | - elseif (isset($_REQUEST['time'])) |
|
| 709 | + } elseif (isset($_REQUEST['time'])) |
|
| 686 | 710 | { |
| 687 | 711 | $context['sub_template'] = 'thetime'; |
| 688 | 712 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -736,12 +760,13 @@ discard block |
||
| 736 | 760 | ), |
| 737 | 761 | ); |
| 738 | 762 | |
| 739 | - foreach ($context['clockicons'] as $t => $vs) |
|
| 740 | - foreach ($vs as $v => $dumb) |
|
| 763 | + foreach ($context['clockicons'] as $t => $vs) { |
|
| 764 | + foreach ($vs as $v => $dumb) |
|
| 741 | 765 | { |
| 742 | 766 | if ($$t >= $v) |
| 743 | 767 | { |
| 744 | 768 | $$t -= $v; |
| 769 | + } |
|
| 745 | 770 | $context['clockicons'][$t][$v] = true; |
| 746 | 771 | } |
| 747 | 772 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | <div id="recent" class="main_section"> |
| 22 | 22 | <div class="cat_bar"> |
| 23 | 23 | <h3 class="catbg"> |
| 24 | - <span class="xx"></span>',$txt['recent_posts'],' |
|
| 24 | + <span class="xx"></span>',$txt['recent_posts'], ' |
|
| 25 | 25 | </h3> |
| 26 | 26 | </div> |
| 27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
@@ -26,9 +26,10 @@ discard block |
||
| 26 | 26 | </div> |
| 27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
| 28 | 28 | |
| 29 | - if (empty($context['posts'])) |
|
| 30 | - echo ' |
|
| 29 | + if (empty($context['posts'])) { |
|
| 30 | + echo ' |
|
| 31 | 31 | <div class="windowbg">', $txt['no_messages'], '</div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | foreach ($context['posts'] as $post) |
| 34 | 35 | { |
@@ -41,28 +42,33 @@ discard block |
||
| 41 | 42 | </div> |
| 42 | 43 | <div class="list_posts">', $post['message'], '</div>'; |
| 43 | 44 | |
| 44 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 45 | - echo ' |
|
| 45 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 46 | + echo ' |
|
| 46 | 47 | <ul class="quickbuttons">'; |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // If they *can* reply? |
| 49 | - if ($post['can_reply']) |
|
| 50 | - echo ' |
|
| 51 | + if ($post['can_reply']) { |
|
| 52 | + echo ' |
|
| 51 | 53 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // If they *can* quote? |
| 54 | - if ($post['can_quote']) |
|
| 55 | - echo ' |
|
| 57 | + if ($post['can_quote']) { |
|
| 58 | + echo ' |
|
| 56 | 59 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // How about... even... remove it entirely?! |
| 59 | - if ($post['can_delete']) |
|
| 60 | - echo ' |
|
| 63 | + if ($post['can_delete']) { |
|
| 64 | + echo ' |
|
| 61 | 65 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 66 | + } |
|
| 62 | 67 | |
| 63 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 64 | - echo ' |
|
| 68 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 69 | + echo ' |
|
| 65 | 70 | </ul>'; |
| 71 | + } |
|
| 66 | 72 | |
| 67 | 73 | echo ' |
| 68 | 74 | </div><!-- $post[css_class] -->'; |
@@ -84,12 +90,13 @@ discard block |
||
| 84 | 90 | echo ' |
| 85 | 91 | <div id="recent" class="main_content">'; |
| 86 | 92 | |
| 87 | - if ($context['showCheckboxes']) |
|
| 88 | - echo ' |
|
| 93 | + if ($context['showCheckboxes']) { |
|
| 94 | + echo ' |
|
| 89 | 95 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
| 90 | 96 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 91 | 97 | <input type="hidden" name="qaction" value="markread"> |
| 92 | 98 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
| 99 | + } |
|
| 93 | 100 | |
| 94 | 101 | if (!empty($context['topics'])) |
| 95 | 102 | { |
@@ -118,11 +125,12 @@ discard block |
||
| 118 | 125 | </div>'; |
| 119 | 126 | |
| 120 | 127 | // Show a "select all" box for quick moderation? |
| 121 | - if ($context['showCheckboxes']) |
|
| 122 | - echo ' |
|
| 128 | + if ($context['showCheckboxes']) { |
|
| 129 | + echo ' |
|
| 123 | 130 | <div class="moderation"> |
| 124 | 131 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 125 | 132 | </div>'; |
| 133 | + } |
|
| 126 | 134 | |
| 127 | 135 | echo ' |
| 128 | 136 | </div><!-- #topic_header --> |
@@ -142,17 +150,20 @@ discard block |
||
| 142 | 150 | echo ' |
| 143 | 151 | <div class="icons floatright">'; |
| 144 | 152 | |
| 145 | - if ($topic['is_locked']) |
|
| 146 | - echo ' |
|
| 153 | + if ($topic['is_locked']) { |
|
| 154 | + echo ' |
|
| 147 | 155 | <span class="generic_icons lock"></span>'; |
| 156 | + } |
|
| 148 | 157 | |
| 149 | - if ($topic['is_sticky']) |
|
| 150 | - echo ' |
|
| 158 | + if ($topic['is_sticky']) { |
|
| 159 | + echo ' |
|
| 151 | 160 | <span class="generic_icons sticky"></span>'; |
| 161 | + } |
|
| 152 | 162 | |
| 153 | - if ($topic['is_poll']) |
|
| 154 | - echo ' |
|
| 163 | + if ($topic['is_poll']) { |
|
| 164 | + echo ' |
|
| 155 | 165 | <span class="generic_icons poll"></span>'; |
| 166 | + } |
|
| 156 | 167 | |
| 157 | 168 | echo ' |
| 158 | 169 | </div>'; |
@@ -178,19 +189,21 @@ discard block |
||
| 178 | 189 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
| 179 | 190 | </div>'; |
| 180 | 191 | |
| 181 | - if ($context['showCheckboxes']) |
|
| 182 | - echo ' |
|
| 192 | + if ($context['showCheckboxes']) { |
|
| 193 | + echo ' |
|
| 183 | 194 | <div class="moderation"> |
| 184 | 195 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
| 185 | 196 | </div>'; |
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | echo ' |
| 188 | 200 | </div><!-- $topic[css_class] -->'; |
| 189 | 201 | } |
| 190 | 202 | |
| 191 | - if (empty($context['topics'])) |
|
| 192 | - echo ' |
|
| 203 | + if (empty($context['topics'])) { |
|
| 204 | + echo ' |
|
| 193 | 205 | <div style="display: none;"></div>'; |
| 206 | + } |
|
| 194 | 207 | |
| 195 | 208 | echo ' |
| 196 | 209 | </div><!-- #topic_container --> |
@@ -205,25 +218,27 @@ discard block |
||
| 205 | 218 | ', $context['page_index'], ' |
| 206 | 219 | </div> |
| 207 | 220 | </div>'; |
| 208 | - } |
|
| 209 | - else |
|
| 210 | - echo ' |
|
| 221 | + } else { |
|
| 222 | + echo ' |
|
| 211 | 223 | <div class="cat_bar"> |
| 212 | 224 | <h3 class="catbg centertext"> |
| 213 | 225 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
| 214 | 226 | </h3> |
| 215 | 227 | </div>'; |
| 228 | + } |
|
| 216 | 229 | |
| 217 | - if ($context['showCheckboxes']) |
|
| 218 | - echo ' |
|
| 230 | + if ($context['showCheckboxes']) { |
|
| 231 | + echo ' |
|
| 219 | 232 | </form>'; |
| 233 | + } |
|
| 220 | 234 | |
| 221 | 235 | echo ' |
| 222 | 236 | </div><!-- #recent -->'; |
| 223 | 237 | |
| 224 | - if (empty($context['no_topic_listing'])) |
|
| 225 | - template_topic_legend(); |
|
| 226 | -} |
|
| 238 | + if (empty($context['no_topic_listing'])) { |
|
| 239 | + template_topic_legend(); |
|
| 240 | + } |
|
| 241 | + } |
|
| 227 | 242 | |
| 228 | 243 | /** |
| 229 | 244 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -235,12 +250,13 @@ discard block |
||
| 235 | 250 | echo ' |
| 236 | 251 | <div id="recent">'; |
| 237 | 252 | |
| 238 | - if ($context['showCheckboxes']) |
|
| 239 | - echo ' |
|
| 253 | + if ($context['showCheckboxes']) { |
|
| 254 | + echo ' |
|
| 240 | 255 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
| 241 | 256 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 242 | 257 | <input type="hidden" name="qaction" value="markread"> |
| 243 | 258 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
| 259 | + } |
|
| 244 | 260 | |
| 245 | 261 | if (!empty($context['topics'])) |
| 246 | 262 | { |
@@ -269,11 +285,12 @@ discard block |
||
| 269 | 285 | </div>'; |
| 270 | 286 | |
| 271 | 287 | // Show a "select all" box for quick moderation? |
| 272 | - if ($context['showCheckboxes']) |
|
| 273 | - echo ' |
|
| 288 | + if ($context['showCheckboxes']) { |
|
| 289 | + echo ' |
|
| 274 | 290 | <div class="moderation"> |
| 275 | 291 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 276 | 292 | </div>'; |
| 293 | + } |
|
| 277 | 294 | |
| 278 | 295 | echo ' |
| 279 | 296 | </div><!-- #topic_header --> |
@@ -293,17 +310,20 @@ discard block |
||
| 293 | 310 | echo ' |
| 294 | 311 | <div class="icons floatright">'; |
| 295 | 312 | |
| 296 | - if ($topic['is_locked']) |
|
| 297 | - echo ' |
|
| 313 | + if ($topic['is_locked']) { |
|
| 314 | + echo ' |
|
| 298 | 315 | <span class="generic_icons lock"></span>'; |
| 316 | + } |
|
| 299 | 317 | |
| 300 | - if ($topic['is_sticky']) |
|
| 301 | - echo ' |
|
| 318 | + if ($topic['is_sticky']) { |
|
| 319 | + echo ' |
|
| 302 | 320 | <span class="generic_icons sticky"></span>'; |
| 321 | + } |
|
| 303 | 322 | |
| 304 | - if ($topic['is_poll']) |
|
| 305 | - echo ' |
|
| 323 | + if ($topic['is_poll']) { |
|
| 324 | + echo ' |
|
| 306 | 325 | <span class="generic_icons poll"></span>'; |
| 326 | + } |
|
| 307 | 327 | |
| 308 | 328 | echo ' |
| 309 | 329 | </div>'; |
@@ -329,11 +349,12 @@ discard block |
||
| 329 | 349 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
| 330 | 350 | </div>'; |
| 331 | 351 | |
| 332 | - if ($context['showCheckboxes']) |
|
| 333 | - echo ' |
|
| 352 | + if ($context['showCheckboxes']) { |
|
| 353 | + echo ' |
|
| 334 | 354 | <div class="moderation"> |
| 335 | 355 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
| 336 | 356 | </div>'; |
| 357 | + } |
|
| 337 | 358 | |
| 338 | 359 | echo ' |
| 339 | 360 | </div><!-- $topic[css_class] -->'; |
@@ -350,24 +371,26 @@ discard block |
||
| 350 | 371 | ', $context['page_index'], ' |
| 351 | 372 | </div> |
| 352 | 373 | </div>'; |
| 353 | - } |
|
| 354 | - else |
|
| 355 | - echo ' |
|
| 374 | + } else { |
|
| 375 | + echo ' |
|
| 356 | 376 | <div class="cat_bar"> |
| 357 | 377 | <h3 class="catbg centertext"> |
| 358 | 378 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
| 359 | 379 | </h3> |
| 360 | 380 | </div>'; |
| 381 | + } |
|
| 361 | 382 | |
| 362 | - if ($context['showCheckboxes']) |
|
| 363 | - echo ' |
|
| 383 | + if ($context['showCheckboxes']) { |
|
| 384 | + echo ' |
|
| 364 | 385 | </form>'; |
| 386 | + } |
|
| 365 | 387 | |
| 366 | 388 | echo ' |
| 367 | 389 | </div><!-- #recent -->'; |
| 368 | 390 | |
| 369 | - if (empty($context['no_topic_listing'])) |
|
| 370 | - template_topic_legend(); |
|
| 371 | -} |
|
| 391 | + if (empty($context['no_topic_listing'])) { |
|
| 392 | + template_topic_legend(); |
|
| 393 | + } |
|
| 394 | + } |
|
| 372 | 395 | |
| 373 | 396 | ?> |
| 374 | 397 | \ No newline at end of file |
@@ -673,7 +673,7 @@ |
||
| 673 | 673 | 'Nikola "Dzonny" Novaković', |
| 674 | 674 | // Localizers |
| 675 | 675 | 'Dr. Deejay', |
| 676 | - 'd3vcho', |
|
| 676 | + 'd3vcho', |
|
| 677 | 677 | // Former Localizers |
| 678 | 678 | 'Relyana', |
| 679 | 679 | ), |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | 'Shitiz "Dragooon" Garg', |
| 591 | 591 | 'Karl "RegularExpression" Benson', |
| 592 | 592 | 'Matthew "Labradoodle-360" Kerle', |
| 593 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
| 593 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
| 594 | 594 | 'Michael "Thantos" Miller', |
| 595 | 595 | 'Norv', |
| 596 | 596 | 'Peter "Arantor" Spicer', |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | $credit_info = $smcFunc['json_decode']($row['credits'], true); |
| 815 | 815 | |
| 816 | 816 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
| 817 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 817 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 818 | 818 | $version = $txt['credits_version'] . ' ' . $row['version']; |
| 819 | 819 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
| 820 | 820 | |
| 821 | 821 | // build this one out and stash it away |
| 822 | 822 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
| 823 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 823 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 824 | 824 | } |
| 825 | 825 | cache_put_data('mods_credits', $mods, 86400); |
| 826 | 826 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = $smcFunc['json_decode']($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = $smcFunc['json_decode']($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -710,8 +740,8 @@ discard block |
||
| 710 | 740 | ); |
| 711 | 741 | |
| 712 | 742 | // Give the translators some credit for their hard work. |
| 713 | - if (!empty($txt['translation_credits'])) |
|
| 714 | - $context['credits'][] = array( |
|
| 743 | + if (!empty($txt['translation_credits'])) { |
|
| 744 | + $context['credits'][] = array( |
|
| 715 | 745 | 'title' => $txt['credits_groups_translation'], |
| 716 | 746 | 'groups' => array( |
| 717 | 747 | array( |
@@ -720,6 +750,7 @@ discard block |
||
| 720 | 750 | ), |
| 721 | 751 | ), |
| 722 | 752 | ); |
| 753 | + } |
|
| 723 | 754 | |
| 724 | 755 | $context['credits'][] = array( |
| 725 | 756 | 'title' => $txt['credits_special'], |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | * |
| 105 | 105 | * @param string $class The fully-qualified class name. |
| 106 | 106 | */ |
| 107 | -spl_autoload_register(function ($class) use ($sourcedir) |
|
| 107 | +spl_autoload_register(function($class) use ($sourcedir) |
|
| 108 | 108 | { |
| 109 | 109 | $classMap = array( |
| 110 | 110 | 'ReCaptcha\\' => 'ReCaptcha/', |
@@ -32,16 +32,18 @@ discard block |
||
| 32 | 32 | ob_start(); |
| 33 | 33 | |
| 34 | 34 | // Do some cleaning, just in case. |
| 35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 36 | 36 | if (isset($GLOBALS[$variable])) |
| 37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 38 | +} |
|
| 38 | 39 | |
| 39 | 40 | // Load the settings... |
| 40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 41 | 42 | |
| 42 | 43 | // Make absolutely sure the cache directory is defined. |
| 43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 44 | 45 | $cachedir = $boarddir . '/cache'; |
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | // Without those we can't go anywhere |
| 47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | require_once($sourcedir . '/Load.php'); |
| 52 | 54 | |
| 53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 54 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 55 | 57 | display_maintenance_message(); |
| 58 | +} |
|
| 56 | 59 | |
| 57 | 60 | // Create a variable to store some SMF specific functions in. |
| 58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | cleanRequest(); |
| 68 | 71 | |
| 69 | 72 | // Seed the random generator. |
| 70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 71 | 74 | smf_seed_generator(); |
| 75 | +} |
|
| 72 | 76 | |
| 73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
| 88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 89 | 93 | { |
| 90 | 94 | // If zlib is being used, turn off output compression. |
| 91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 93 | - else |
|
| 95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 97 | + } else |
|
| 94 | 98 | { |
| 95 | 99 | ob_end_clean(); |
| 96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
| 182 | 186 | loadPermissions(); |
| 183 | 187 | |
| 184 | 188 | // Attachments don't require the entire theme to be loaded. |
| 185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 186 | - detectBrowser(); |
|
| 189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 190 | + detectBrowser(); |
|
| 191 | + } |
|
| 187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 188 | - else |
|
| 189 | - loadTheme(); |
|
| 193 | + else { |
|
| 194 | + loadTheme(); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | // Check if the user should be disallowed access. |
| 192 | 198 | is_not_banned(); |
| 193 | 199 | |
| 194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 196 | - fatal_lang_error('not_a_topic', false); |
|
| 201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 202 | + fatal_lang_error('not_a_topic', false); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | writeLog(); |
| 205 | 212 | |
| 206 | 213 | // Track forum statistics and hits...? |
| 207 | - if (!empty($modSettings['hitStats'])) |
|
| 208 | - trackStats(array('hits' => '+')); |
|
| 214 | + if (!empty($modSettings['hitStats'])) { |
|
| 215 | + trackStats(array('hits' => '+')); |
|
| 216 | + } |
|
| 209 | 217 | } |
| 210 | 218 | unset($no_stat_actions); |
| 211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
| 219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 220 | 228 | } |
| 221 | 229 | // Don't even try it, sonny. |
| 222 | - else |
|
| 223 | - return 'InMaintenance'; |
|
| 230 | + else { |
|
| 231 | + return 'InMaintenance'; |
|
| 232 | + } |
|
| 224 | 233 | } |
| 225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
| 226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 227 | - return 'KickGuest'; |
|
| 228 | - elseif (empty($_REQUEST['action'])) |
|
| 235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 236 | + return 'KickGuest'; |
|
| 237 | + } elseif (empty($_REQUEST['action'])) |
|
| 229 | 238 | { |
| 230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
| 239 | 248 | |
| 240 | 249 | $call = call_helper($defaultAction, true); |
| 241 | 250 | |
| 242 | - if (!empty($call)) |
|
| 243 | - return $call; |
|
| 251 | + if (!empty($call)) { |
|
| 252 | + return $call; |
|
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | |
| 371 | 381 | $call = call_helper($fallbackAction, true); |
| 372 | 382 | |
| 373 | - if (!empty($call)) |
|
| 374 | - return $call; |
|
| 383 | + if (!empty($call)) { |
|
| 384 | + return $call; |
|
| 385 | + } |
|
| 375 | 386 | } |
| 376 | 387 | |
| 377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // Otherwise, it was set - so let's go to that action. |
| 385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
| 386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
| 397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 398 | + } |
|
| 387 | 399 | |
| 388 | 400 | // Do the right thing. |
| 389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * Display a list of upcoming events, birthdays, and holidays. |
| 69 | 69 | * |
| 70 | 70 | * @param string $grid_name The grid name |
| 71 | - * @return void|bool Returns false if the grid doesn't exist. |
|
| 71 | + * @return false|null Returns false if the grid doesn't exist. |
|
| 72 | 72 | */ |
| 73 | 73 | function template_show_upcoming_list($grid_name) |
| 74 | 74 | { |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param string $grid_name The grid name |
| 240 | 240 | * @param bool $is_mini Is this a mini grid? |
| 241 | - * @return void|bool Returns false if the grid doesn't exist. |
|
| 241 | + * @return false|null Returns false if the grid doesn't exist. |
|
| 242 | 242 | */ |
| 243 | 243 | function template_show_month_grid($grid_name, $is_mini = false) |
| 244 | 244 | { |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | * Shows a weekly grid |
| 524 | 524 | * |
| 525 | 525 | * @param string $grid_name The name of the grid |
| 526 | - * @return void|bool Returns false if the grid doesn't exist |
|
| 526 | + * @return false|null Returns false if the grid doesn't exist |
|
| 527 | 527 | */ |
| 528 | 528 | function template_show_week_grid($grid_name) |
| 529 | 529 | { |
@@ -22,30 +22,32 @@ discard block |
||
| 22 | 22 | <div id="calendar">'; |
| 23 | 23 | |
| 24 | 24 | // Show the mini-blocks if they're enabled. |
| 25 | - if (empty($context['blocks_disabled'])) |
|
| 26 | - echo ' |
|
| 25 | + if (empty($context['blocks_disabled'])) { |
|
| 26 | + echo ' |
|
| 27 | 27 | <div id="month_grid"> |
| 28 | 28 | ', template_show_month_grid('prev', true), ' |
| 29 | 29 | ', template_show_month_grid('current', true), ' |
| 30 | 30 | ', template_show_month_grid('next', true), ' |
| 31 | 31 | </div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | // What view are we showing? |
| 34 | - if ($context['calendar_view'] == 'viewlist') |
|
| 35 | - echo ' |
|
| 35 | + if ($context['calendar_view'] == 'viewlist') { |
|
| 36 | + echo ' |
|
| 36 | 37 | <div id="main_grid"> |
| 37 | 38 | ', template_show_upcoming_list('main'), ' |
| 38 | 39 | </div>'; |
| 39 | - elseif ($context['calendar_view'] == 'viewweek') |
|
| 40 | - echo ' |
|
| 40 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
| 41 | + echo ' |
|
| 41 | 42 | <div id="main_grid"> |
| 42 | 43 | ', template_show_week_grid('main'), ' |
| 43 | 44 | </div>'; |
| 44 | - else |
|
| 45 | - echo ' |
|
| 45 | + } else { |
|
| 46 | + echo ' |
|
| 46 | 47 | <div id="main_grid"> |
| 47 | 48 | ', template_show_month_grid('main'), ' |
| 48 | 49 | </div>'; |
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Close our wrapper. |
| 51 | 53 | echo ' |
@@ -64,20 +66,22 @@ discard block |
||
| 64 | 66 | global $context, $scripturl, $txt; |
| 65 | 67 | |
| 66 | 68 | // Bail out if we have nothing to work with |
| 67 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 68 | - return false; |
|
| 69 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | // Protect programmer sanity |
| 71 | 74 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 72 | 75 | |
| 73 | 76 | // Do we want a title? |
| 74 | - if (empty($calendar_data['disable_title'])) |
|
| 75 | - echo ' |
|
| 77 | + if (empty($calendar_data['disable_title'])) { |
|
| 78 | + echo ' |
|
| 76 | 79 | <div class="cat_bar"> |
| 77 | 80 | <h3 class="catbg centertext largetext"> |
| 78 | 81 | <a href="', $scripturl, '?action=calendar;viewlist;year=', $calendar_data['start_year'], ';month=', $calendar_data['start_month'], ';day=', $calendar_data['start_day'], '">', $txt['calendar_upcoming'], '</a> |
| 79 | 82 | </h3> |
| 80 | 83 | </div>'; |
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | // Give the user some controls to work with |
| 83 | 87 | template_calendar_top($calendar_data); |
@@ -100,11 +104,13 @@ discard block |
||
| 100 | 104 | <li class="windowbg"> |
| 101 | 105 | <strong class="event_title">', $event['link'], '</strong>'; |
| 102 | 106 | |
| 103 | - if ($event['can_edit']) |
|
| 104 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 107 | + if ($event['can_edit']) { |
|
| 108 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 109 | + } |
|
| 105 | 110 | |
| 106 | - if ($event['can_export']) |
|
| 107 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 111 | + if ($event['can_export']) { |
|
| 112 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 113 | + } |
|
| 108 | 114 | |
| 109 | 115 | echo ' |
| 110 | 116 | <br>'; |
@@ -112,14 +118,14 @@ discard block |
||
| 112 | 118 | if (!empty($event['allday'])) |
| 113 | 119 | { |
| 114 | 120 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 115 | - } |
|
| 116 | - else |
|
| 121 | + } else |
|
| 117 | 122 | { |
| 118 | 123 | // Display event info relative to user's local timezone |
| 119 | 124 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 120 | 125 | |
| 121 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 122 | - echo trim($event['end_date_local']) . ', '; |
|
| 126 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 127 | + echo trim($event['end_date_local']) . ', '; |
|
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | echo trim($event['end_time_local']); |
| 125 | 131 | |
@@ -128,23 +134,27 @@ discard block |
||
| 128 | 134 | { |
| 129 | 135 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 130 | 136 | |
| 131 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 132 | - echo trim($event['start_date_orig']), ', '; |
|
| 137 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 138 | + echo trim($event['start_date_orig']), ', '; |
|
| 139 | + } |
|
| 133 | 140 | |
| 134 | 141 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 135 | 142 | |
| 136 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 137 | - echo trim($event['end_date_orig']) . ', '; |
|
| 143 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 144 | + echo trim($event['end_date_orig']) . ', '; |
|
| 145 | + } |
|
| 138 | 146 | |
| 139 | 147 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 140 | 148 | } |
| 141 | 149 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 142 | - else |
|
| 143 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 150 | + else { |
|
| 151 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 152 | + } |
|
| 144 | 153 | } |
| 145 | 154 | |
| 146 | - if (!empty($event['location'])) |
|
| 147 | - echo '<br>', $event['location']; |
|
| 155 | + if (!empty($event['location'])) { |
|
| 156 | + echo '<br>', $event['location']; |
|
| 157 | + } |
|
| 148 | 158 | |
| 149 | 159 | echo ' |
| 150 | 160 | </li>'; |
@@ -176,8 +186,9 @@ discard block |
||
| 176 | 186 | |
| 177 | 187 | $birthdays = array(); |
| 178 | 188 | |
| 179 | - foreach ($date as $member) |
|
| 180 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 189 | + foreach ($date as $member) { |
|
| 190 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 191 | + } |
|
| 181 | 192 | |
| 182 | 193 | echo implode(', ', $birthdays); |
| 183 | 194 | |
@@ -208,8 +219,9 @@ discard block |
||
| 208 | 219 | $date_local = $date['date_local']; |
| 209 | 220 | unset($date['date_local']); |
| 210 | 221 | |
| 211 | - foreach ($date as $holiday) |
|
| 212 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 222 | + foreach ($date as $holiday) { |
|
| 223 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 224 | + } |
|
| 213 | 225 | } |
| 214 | 226 | |
| 215 | 227 | echo implode(', ', $holidays); |
@@ -233,17 +245,19 @@ discard block |
||
| 233 | 245 | global $context, $txt, $scripturl, $modSettings; |
| 234 | 246 | |
| 235 | 247 | // If the grid doesn't exist, no point in proceeding. |
| 236 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 237 | - return false; |
|
| 248 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 238 | 251 | |
| 239 | 252 | // A handy little pointer variable. |
| 240 | 253 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 241 | 254 | |
| 242 | 255 | // Some conditions for whether or not we should show the week links *here*. |
| 243 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
| 244 | - $show_week_links = true; |
|
| 245 | - else |
|
| 246 | - $show_week_links = false; |
|
| 256 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
| 257 | + $show_week_links = true; |
|
| 258 | + } else { |
|
| 259 | + $show_week_links = false; |
|
| 260 | + } |
|
| 247 | 261 | |
| 248 | 262 | // Assuming that we've not disabled it, show the title block! |
| 249 | 263 | if (empty($calendar_data['disable_title'])) |
@@ -253,18 +267,20 @@ discard block |
||
| 253 | 267 | <h3 class="catbg centertext largetext">'; |
| 254 | 268 | |
| 255 | 269 | // Previous Link: If we're showing prev / next and it's not a mini-calendar. |
| 256 | - if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
| 257 | - echo ' |
|
| 270 | + if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) { |
|
| 271 | + echo ' |
|
| 258 | 272 | <span class="floatleft"> |
| 259 | 273 | <a href="', $calendar_data['previous_calendar']['href'], '">«</a> |
| 260 | 274 | </span>'; |
| 275 | + } |
|
| 261 | 276 | |
| 262 | 277 | // Next Link: if we're showing prev / next and it's not a mini-calendar. |
| 263 | - if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
| 264 | - echo ' |
|
| 278 | + if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) { |
|
| 279 | + echo ' |
|
| 265 | 280 | <span class="floatright"> |
| 266 | 281 | <a href="', $calendar_data['next_calendar']['href'], '">»</a> |
| 267 | 282 | </span>'; |
| 283 | + } |
|
| 268 | 284 | |
| 269 | 285 | // Arguably the most exciting part, the title! |
| 270 | 286 | echo ' |
@@ -274,8 +290,9 @@ discard block |
||
| 274 | 290 | } |
| 275 | 291 | |
| 276 | 292 | // Show the controls on main grids |
| 277 | - if ($is_mini === false) |
|
| 278 | - template_calendar_top($calendar_data); |
|
| 293 | + if ($is_mini === false) { |
|
| 294 | + template_calendar_top($calendar_data); |
|
| 295 | + } |
|
| 279 | 296 | |
| 280 | 297 | // Finally, the main calendar table. |
| 281 | 298 | echo ' |
@@ -288,14 +305,16 @@ discard block |
||
| 288 | 305 | <tr>'; |
| 289 | 306 | |
| 290 | 307 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
| 291 | - if ($show_week_links === true) |
|
| 292 | - echo ' |
|
| 308 | + if ($show_week_links === true) { |
|
| 309 | + echo ' |
|
| 293 | 310 | <th></th>'; |
| 311 | + } |
|
| 294 | 312 | |
| 295 | 313 | // Now, loop through each actual day of the week. |
| 296 | - foreach ($calendar_data['week_days'] as $day) |
|
| 297 | - echo ' |
|
| 314 | + foreach ($calendar_data['week_days'] as $day) { |
|
| 315 | + echo ' |
|
| 298 | 316 | <th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>'; |
| 317 | + } |
|
| 299 | 318 | |
| 300 | 319 | echo ' |
| 301 | 320 | </tr>'; |
@@ -314,11 +333,12 @@ discard block |
||
| 314 | 333 | <tr class="days_wrapper">'; |
| 315 | 334 | |
| 316 | 335 | // This is where we add the actual week link, if enabled on this location. |
| 317 | - if ($show_week_links === true) |
|
| 318 | - echo ' |
|
| 336 | + if ($show_week_links === true) { |
|
| 337 | + echo ' |
|
| 319 | 338 | <td class="windowbg2 weeks"> |
| 320 | 339 | <a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">»</a> |
| 321 | 340 | </td>'; |
| 341 | + } |
|
| 322 | 342 | |
| 323 | 343 | // Now loop through each day in the week we're on. |
| 324 | 344 | foreach ($week['days'] as $day) |
@@ -335,27 +355,29 @@ discard block |
||
| 335 | 355 | // Additional classes are given for events, holidays, and birthdays. |
| 336 | 356 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
| 337 | 357 | { |
| 338 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
| 339 | - $classes[] = 'events'; |
|
| 340 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
| 341 | - $classes[] = 'events'; |
|
| 358 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
| 359 | + $classes[] = 'events'; |
|
| 360 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
| 361 | + $classes[] = 'events'; |
|
| 362 | + } |
|
| 342 | 363 | } |
| 343 | 364 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
| 344 | 365 | { |
| 345 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
| 346 | - $classes[] = 'holidays'; |
|
| 347 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
| 348 | - $classes[] = 'holidays'; |
|
| 366 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
| 367 | + $classes[] = 'holidays'; |
|
| 368 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
| 369 | + $classes[] = 'holidays'; |
|
| 370 | + } |
|
| 349 | 371 | } |
| 350 | 372 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
| 351 | 373 | { |
| 352 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
| 353 | - $classes[] = 'birthdays'; |
|
| 354 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
| 355 | - $classes[] = 'birthdays'; |
|
| 374 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
| 375 | + $classes[] = 'birthdays'; |
|
| 376 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
| 377 | + $classes[] = 'birthdays'; |
|
| 378 | + } |
|
| 356 | 379 | } |
| 357 | - } |
|
| 358 | - else |
|
| 380 | + } else |
|
| 359 | 381 | { |
| 360 | 382 | // Default Classes (either compact or comfortable and disabled). |
| 361 | 383 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -374,25 +396,27 @@ discard block |
||
| 374 | 396 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
| 375 | 397 | |
| 376 | 398 | // The actual day number - be it a link, or just plain old text! |
| 377 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 378 | - echo ' |
|
| 399 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 400 | + echo ' |
|
| 379 | 401 | <a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
| 380 | - elseif ($is_mini) |
|
| 381 | - echo ' |
|
| 402 | + } elseif ($is_mini) { |
|
| 403 | + echo ' |
|
| 382 | 404 | <a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
| 383 | - else |
|
| 384 | - echo ' |
|
| 405 | + } else { |
|
| 406 | + echo ' |
|
| 385 | 407 | <span class="day_text">', $title_prefix, $day['day'], '</span>'; |
| 408 | + } |
|
| 386 | 409 | |
| 387 | 410 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
| 388 | 411 | if ($is_mini === false) |
| 389 | 412 | { |
| 390 | 413 | // Holidays are always fun, let's show them! |
| 391 | - if (!empty($day['holidays'])) |
|
| 392 | - echo ' |
|
| 414 | + if (!empty($day['holidays'])) { |
|
| 415 | + echo ' |
|
| 393 | 416 | <div class="smalltext holiday"> |
| 394 | 417 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), ' |
| 395 | 418 | </div>'; |
| 419 | + } |
|
| 396 | 420 | |
| 397 | 421 | // Happy Birthday Dear Member! |
| 398 | 422 | if (!empty($day['birthdays'])) |
@@ -410,15 +434,17 @@ discard block |
||
| 410 | 434 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
| 411 | 435 | |
| 412 | 436 | // 9...10! Let's stop there. |
| 413 | - if ($birthday_count == 10 && $use_js_hide) |
|
| 414 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 437 | + if ($birthday_count == 10 && $use_js_hide) { |
|
| 438 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 415 | 439 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
| 440 | + } |
|
| 416 | 441 | |
| 417 | 442 | ++$birthday_count; |
| 418 | 443 | } |
| 419 | - if ($use_js_hide) |
|
| 420 | - echo ' |
|
| 444 | + if ($use_js_hide) { |
|
| 445 | + echo ' |
|
| 421 | 446 | </span>'; |
| 447 | + } |
|
| 422 | 448 | |
| 423 | 449 | echo ' |
| 424 | 450 | </div><!-- .smalltext -->'; |
@@ -429,8 +455,9 @@ discard block |
||
| 429 | 455 | { |
| 430 | 456 | // Sort events by start time (all day events will be listed first) |
| 431 | 457 | uasort($day['events'], function($a, $b) { |
| 432 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 433 | - return 0; |
|
| 458 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 459 | + return 0; |
|
| 460 | + } |
|
| 434 | 461 | |
| 435 | 462 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 436 | 463 | }); |
@@ -450,20 +477,22 @@ discard block |
||
| 450 | 477 | ', $event['link'], '<br> |
| 451 | 478 | <span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 452 | 479 | |
| 453 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
| 454 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 455 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
| 456 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 457 | - elseif (!empty($event['allday'])) |
|
| 458 | - echo $txt['calendar_allday']; |
|
| 480 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
| 481 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 482 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
| 483 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 484 | + } elseif (!empty($event['allday'])) { |
|
| 485 | + echo $txt['calendar_allday']; |
|
| 486 | + } |
|
| 459 | 487 | |
| 460 | 488 | echo ' |
| 461 | 489 | </span>'; |
| 462 | 490 | |
| 463 | - if (!empty($event['location'])) |
|
| 464 | - echo ' |
|
| 491 | + if (!empty($event['location'])) { |
|
| 492 | + echo ' |
|
| 465 | 493 | <br> |
| 466 | 494 | <span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
| 495 | + } |
|
| 467 | 496 | |
| 468 | 497 | if ($event['can_edit'] || $event['can_export']) |
| 469 | 498 | { |
@@ -471,18 +500,20 @@ discard block |
||
| 471 | 500 | <span class="modify_event_links">'; |
| 472 | 501 | |
| 473 | 502 | // If they can edit the event, show an icon they can click on.... |
| 474 | - if ($event['can_edit']) |
|
| 475 | - echo ' |
|
| 503 | + if ($event['can_edit']) { |
|
| 504 | + echo ' |
|
| 476 | 505 | <a class="modify_event" href="', $event['modify_href'], '"> |
| 477 | 506 | <span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
| 478 | 507 | </a>'; |
| 508 | + } |
|
| 479 | 509 | |
| 480 | 510 | // Exporting! |
| 481 | - if ($event['can_export']) |
|
| 482 | - echo ' |
|
| 511 | + if ($event['can_export']) { |
|
| 512 | + echo ' |
|
| 483 | 513 | <a class="modify_event" href="', $event['export_href'], '"> |
| 484 | 514 | <span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
| 485 | 515 | </a>'; |
| 516 | + } |
|
| 486 | 517 | |
| 487 | 518 | echo ' |
| 488 | 519 | </span><br class="clear">'; |
@@ -501,10 +532,11 @@ discard block |
||
| 501 | 532 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
| 502 | 533 | elseif ($is_mini === false) |
| 503 | 534 | { |
| 504 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
| 505 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 506 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
| 507 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 535 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
| 536 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 537 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
| 538 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 539 | + } |
|
| 508 | 540 | } |
| 509 | 541 | |
| 510 | 542 | // Close this day and increase var count. |
@@ -534,8 +566,9 @@ discard block |
||
| 534 | 566 | global $context, $txt, $scripturl, $modSettings; |
| 535 | 567 | |
| 536 | 568 | // We might have no reason to proceed, if the variable isn't there. |
| 537 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 538 | - return false; |
|
| 569 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 570 | + return false; |
|
| 571 | + } |
|
| 539 | 572 | |
| 540 | 573 | // Handy pointer. |
| 541 | 574 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -552,22 +585,25 @@ discard block |
||
| 552 | 585 | <h3 class="catbg centertext largetext">'; |
| 553 | 586 | |
| 554 | 587 | // Previous Week Link... |
| 555 | - if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
| 556 | - echo ' |
|
| 588 | + if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) { |
|
| 589 | + echo ' |
|
| 557 | 590 | <span class="floatleft"> |
| 558 | 591 | <a href="', $calendar_data['previous_week']['href'], '">«</a> |
| 559 | 592 | </span>'; |
| 593 | + } |
|
| 560 | 594 | |
| 561 | 595 | // Next Week Link... |
| 562 | - if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
| 563 | - echo ' |
|
| 596 | + if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) { |
|
| 597 | + echo ' |
|
| 564 | 598 | <span class="floatright"> |
| 565 | 599 | <a href="', $calendar_data['next_week']['href'], '">»</a> |
| 566 | 600 | </span>'; |
| 601 | + } |
|
| 567 | 602 | |
| 568 | 603 | // The Month Title + Week Number... |
| 569 | - if (!empty($calendar_data['week_title'])) |
|
| 570 | - echo $calendar_data['week_title']; |
|
| 604 | + if (!empty($calendar_data['week_title'])) { |
|
| 605 | + echo $calendar_data['week_title']; |
|
| 606 | + } |
|
| 571 | 607 | |
| 572 | 608 | echo ' |
| 573 | 609 | </h3> |
@@ -608,11 +644,12 @@ discard block |
||
| 608 | 644 | <td class="', implode(' ', $classes), ' act_day">'; |
| 609 | 645 | |
| 610 | 646 | // Should the day number be a link? |
| 611 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 612 | - echo ' |
|
| 647 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 648 | + echo ' |
|
| 613 | 649 | <a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
| 614 | - else |
|
| 615 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 650 | + } else { |
|
| 651 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 652 | + } |
|
| 616 | 653 | |
| 617 | 654 | echo ' |
| 618 | 655 | </td> |
@@ -623,8 +660,9 @@ discard block |
||
| 623 | 660 | { |
| 624 | 661 | // Sort events by start time (all day events will be listed first) |
| 625 | 662 | uasort($day['events'], function($a, $b) { |
| 626 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 627 | - return 0; |
|
| 663 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 664 | + return 0; |
|
| 665 | + } |
|
| 628 | 666 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 629 | 667 | }); |
| 630 | 668 | |
@@ -638,35 +676,39 @@ discard block |
||
| 638 | 676 | echo $event['link'], '<br> |
| 639 | 677 | <span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 640 | 678 | |
| 641 | - if (!empty($event['start_time_local'])) |
|
| 642 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 643 | - else |
|
| 644 | - echo $txt['calendar_allday']; |
|
| 679 | + if (!empty($event['start_time_local'])) { |
|
| 680 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 681 | + } else { |
|
| 682 | + echo $txt['calendar_allday']; |
|
| 683 | + } |
|
| 645 | 684 | |
| 646 | 685 | echo ' |
| 647 | 686 | </span>'; |
| 648 | 687 | |
| 649 | - if (!empty($event['location'])) |
|
| 650 | - echo '<br> |
|
| 688 | + if (!empty($event['location'])) { |
|
| 689 | + echo '<br> |
|
| 651 | 690 | <span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
| 691 | + } |
|
| 652 | 692 | |
| 653 | 693 | if (!empty($event_icons_needed)) |
| 654 | 694 | { |
| 655 | 695 | echo ' <span class="modify_event_links">'; |
| 656 | 696 | |
| 657 | 697 | // If they can edit the event, show a star they can click on.... |
| 658 | - if (!empty($event['can_edit'])) |
|
| 659 | - echo ' |
|
| 698 | + if (!empty($event['can_edit'])) { |
|
| 699 | + echo ' |
|
| 660 | 700 | <a class="modify_event" href="', $event['modify_href'], '"> |
| 661 | 701 | <span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
| 662 | 702 | </a>'; |
| 703 | + } |
|
| 663 | 704 | |
| 664 | 705 | // Can we export? Sweet. |
| 665 | - if (!empty($event['can_export'])) |
|
| 666 | - echo ' |
|
| 706 | + if (!empty($event['can_export'])) { |
|
| 707 | + echo ' |
|
| 667 | 708 | <a class="modify_event" href="', $event['export_href'], '"> |
| 668 | 709 | <span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
| 669 | 710 | </a>'; |
| 711 | + } |
|
| 670 | 712 | |
| 671 | 713 | echo ' |
| 672 | 714 | </span><br class="clear">'; |
@@ -684,22 +726,23 @@ discard block |
||
| 684 | 726 | </div> |
| 685 | 727 | <br class="clear">'; |
| 686 | 728 | } |
| 687 | - } |
|
| 688 | - else |
|
| 729 | + } else |
|
| 689 | 730 | { |
| 690 | - if (!empty($context['can_post'])) |
|
| 691 | - echo ' |
|
| 731 | + if (!empty($context['can_post'])) { |
|
| 732 | + echo ' |
|
| 692 | 733 | <div class="week_add_event"> |
| 693 | 734 | <a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a> |
| 694 | 735 | </div>'; |
| 736 | + } |
|
| 695 | 737 | } |
| 696 | 738 | echo ' |
| 697 | 739 | </td> |
| 698 | 740 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
| 699 | 741 | |
| 700 | 742 | // Show any holidays! |
| 701 | - if (!empty($day['holidays'])) |
|
| 702 | - echo implode('<br>', $day['holidays']); |
|
| 743 | + if (!empty($day['holidays'])) { |
|
| 744 | + echo implode('<br>', $day['holidays']); |
|
| 745 | + } |
|
| 703 | 746 | |
| 704 | 747 | echo ' |
| 705 | 748 | </td> |
@@ -708,11 +751,12 @@ discard block |
||
| 708 | 751 | // Show any birthdays... |
| 709 | 752 | if (!empty($day['birthdays'])) |
| 710 | 753 | { |
| 711 | - foreach ($day['birthdays'] as $member) |
|
| 712 | - echo ' |
|
| 754 | + foreach ($day['birthdays'] as $member) { |
|
| 755 | + echo ' |
|
| 713 | 756 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a> |
| 714 | 757 | ', isset($member['age']) ? ' (' . $member['age'] . ')' : '', ' |
| 715 | 758 | ', $member['is_last'] ? '' : '<br>'; |
| 759 | + } |
|
| 716 | 760 | } |
| 717 | 761 | echo ' |
| 718 | 762 | </td> |
@@ -758,26 +802,27 @@ discard block |
||
| 758 | 802 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="date_input end" data-type="date"> |
| 759 | 803 | <input type="submit" class="button" style="float:none" id="view_button" value="', $txt['view'], '"> |
| 760 | 804 | </form>'; |
| 761 | - } |
|
| 762 | - else |
|
| 805 | + } else |
|
| 763 | 806 | { |
| 764 | 807 | echo' |
| 765 | 808 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
| 766 | 809 | <select name="month" id="input_month">'; |
| 767 | 810 | |
| 768 | 811 | // Show a select box with all the months. |
| 769 | - foreach ($txt['months_short'] as $number => $month) |
|
| 770 | - echo ' |
|
| 812 | + foreach ($txt['months_short'] as $number => $month) { |
|
| 813 | + echo ' |
|
| 771 | 814 | <option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>'; |
| 815 | + } |
|
| 772 | 816 | |
| 773 | 817 | echo ' |
| 774 | 818 | </select> |
| 775 | 819 | <select name="year">'; |
| 776 | 820 | |
| 777 | 821 | // Show a link for every year... |
| 778 | - for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) |
|
| 779 | - echo ' |
|
| 822 | + for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) { |
|
| 823 | + echo ' |
|
| 780 | 824 | <option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>'; |
| 825 | + } |
|
| 781 | 826 | |
| 782 | 827 | echo ' |
| 783 | 828 | </select> |
@@ -799,9 +844,10 @@ discard block |
||
| 799 | 844 | echo ' |
| 800 | 845 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">'; |
| 801 | 846 | |
| 802 | - if (!empty($context['event']['new'])) |
|
| 803 | - echo ' |
|
| 847 | + if (!empty($context['event']['new'])) { |
|
| 848 | + echo ' |
|
| 804 | 849 | <input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
| 850 | + } |
|
| 805 | 851 | |
| 806 | 852 | // Start the main table. |
| 807 | 853 | echo ' |
@@ -812,8 +858,8 @@ discard block |
||
| 812 | 858 | </h3> |
| 813 | 859 | </div>'; |
| 814 | 860 | |
| 815 | - if (!empty($context['post_error']['messages'])) |
|
| 816 | - echo ' |
|
| 861 | + if (!empty($context['post_error']['messages'])) { |
|
| 862 | + echo ' |
|
| 817 | 863 | <div class="errorbox"> |
| 818 | 864 | <dl class="event_error"> |
| 819 | 865 | <dt> |
@@ -824,6 +870,7 @@ discard block |
||
| 824 | 870 | </dt> |
| 825 | 871 | </dl> |
| 826 | 872 | </div>'; |
| 873 | + } |
|
| 827 | 874 | |
| 828 | 875 | echo ' |
| 829 | 876 | <div class="roundframe noup"> |
@@ -851,9 +898,10 @@ discard block |
||
| 851 | 898 | echo ' |
| 852 | 899 | <optgroup label="', $category['name'], '">'; |
| 853 | 900 | |
| 854 | - foreach ($category['boards'] as $board) |
|
| 855 | - echo ' |
|
| 901 | + foreach ($category['boards'] as $board) { |
|
| 902 | + echo ' |
|
| 856 | 903 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 904 | + } |
|
| 857 | 905 | echo ' |
| 858 | 906 | </optgroup>'; |
| 859 | 907 | } |
@@ -889,9 +937,10 @@ discard block |
||
| 889 | 937 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 890 | 938 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 891 | 939 | |
| 892 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 893 | - echo ' |
|
| 940 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 941 | + echo ' |
|
| 894 | 942 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 943 | + } |
|
| 895 | 944 | |
| 896 | 945 | echo ' |
| 897 | 946 | </select> |
@@ -907,9 +956,10 @@ discard block |
||
| 907 | 956 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button">'; |
| 908 | 957 | |
| 909 | 958 | // Delete button? |
| 910 | - if (empty($context['event']['new'])) |
|
| 911 | - echo ' |
|
| 959 | + if (empty($context['event']['new'])) { |
|
| 960 | + echo ' |
|
| 912 | 961 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button you_sure">'; |
| 962 | + } |
|
| 913 | 963 | |
| 914 | 964 | echo ' |
| 915 | 965 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -937,9 +987,10 @@ discard block |
||
| 937 | 987 | echo ' |
| 938 | 988 | <td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">'; |
| 939 | 989 | |
| 940 | - foreach ($v as $i) |
|
| 941 | - echo ' |
|
| 990 | + foreach ($v as $i) { |
|
| 991 | + echo ' |
|
| 942 | 992 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>'; |
| 993 | + } |
|
| 943 | 994 | |
| 944 | 995 | echo ' |
| 945 | 996 | </td>'; |
@@ -960,9 +1011,10 @@ discard block |
||
| 960 | 1011 | |
| 961 | 1012 | foreach ($context['clockicons'] as $t => $v) |
| 962 | 1013 | { |
| 963 | - foreach ($v as $i) |
|
| 964 | - echo ' |
|
| 1014 | + foreach ($v as $i) { |
|
| 1015 | + echo ' |
|
| 965 | 1016 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1017 | + } |
|
| 966 | 1018 | } |
| 967 | 1019 | |
| 968 | 1020 | echo ' |
@@ -987,13 +1039,14 @@ discard block |
||
| 987 | 1039 | |
| 988 | 1040 | foreach ($context['clockicons'] as $t => $v) |
| 989 | 1041 | { |
| 990 | - foreach ($v as $i) |
|
| 991 | - echo ' |
|
| 1042 | + foreach ($v as $i) { |
|
| 1043 | + echo ' |
|
| 992 | 1044 | if (', $t, ' >= ', $i, ') |
| 993 | 1045 | { |
| 994 | 1046 | turnon.push("', $t, '_', $i, '"); |
| 995 | 1047 | ', $t, ' -= ', $i, '; |
| 996 | 1048 | }'; |
| 1049 | + } |
|
| 997 | 1050 | } |
| 998 | 1051 | |
| 999 | 1052 | echo ' |
@@ -1037,9 +1090,10 @@ discard block |
||
| 1037 | 1090 | <tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
| 1038 | 1091 | <td>'; |
| 1039 | 1092 | |
| 1040 | - foreach ($v as $i) |
|
| 1041 | - echo ' |
|
| 1093 | + foreach ($v as $i) { |
|
| 1094 | + echo ' |
|
| 1042 | 1095 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
| 1096 | + } |
|
| 1043 | 1097 | |
| 1044 | 1098 | echo ' |
| 1045 | 1099 | </td> |
@@ -1061,9 +1115,10 @@ discard block |
||
| 1061 | 1115 | |
| 1062 | 1116 | foreach ($context['clockicons'] as $t => $v) |
| 1063 | 1117 | { |
| 1064 | - foreach ($v as $i) |
|
| 1065 | - echo ' |
|
| 1118 | + foreach ($v as $i) { |
|
| 1119 | + echo ' |
|
| 1066 | 1120 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1121 | + } |
|
| 1067 | 1122 | } |
| 1068 | 1123 | |
| 1069 | 1124 | echo ' |
@@ -1080,13 +1135,14 @@ discard block |
||
| 1080 | 1135 | |
| 1081 | 1136 | foreach ($context['clockicons'] as $t => $v) |
| 1082 | 1137 | { |
| 1083 | - foreach ($v as $i) |
|
| 1084 | - echo ' |
|
| 1138 | + foreach ($v as $i) { |
|
| 1139 | + echo ' |
|
| 1085 | 1140 | if (', $t, ' >= ', $i, ') |
| 1086 | 1141 | { |
| 1087 | 1142 | turnon.push("', $t, '_', $i, '"); |
| 1088 | 1143 | ', $t, ' -= ', $i, '; |
| 1089 | 1144 | }'; |
| 1145 | + } |
|
| 1090 | 1146 | } |
| 1091 | 1147 | |
| 1092 | 1148 | echo ' |
@@ -1130,9 +1186,10 @@ discard block |
||
| 1130 | 1186 | <tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
| 1131 | 1187 | <td>'; |
| 1132 | 1188 | |
| 1133 | - foreach ($v as $i) |
|
| 1134 | - echo ' |
|
| 1189 | + foreach ($v as $i) { |
|
| 1190 | + echo ' |
|
| 1135 | 1191 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
| 1192 | + } |
|
| 1136 | 1193 | |
| 1137 | 1194 | echo ' |
| 1138 | 1195 | </td> |
@@ -1148,9 +1205,10 @@ discard block |
||
| 1148 | 1205 | |
| 1149 | 1206 | foreach ($context['clockicons'] as $t => $v) |
| 1150 | 1207 | { |
| 1151 | - foreach ($v as $i) |
|
| 1152 | - echo ' |
|
| 1208 | + foreach ($v as $i) { |
|
| 1209 | + echo ' |
|
| 1153 | 1210 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1211 | + } |
|
| 1154 | 1212 | } |
| 1155 | 1213 | |
| 1156 | 1214 | echo ' |
@@ -1171,13 +1229,14 @@ discard block |
||
| 1171 | 1229 | |
| 1172 | 1230 | foreach ($context['clockicons'] as $t => $v) |
| 1173 | 1231 | { |
| 1174 | - foreach ($v as $i) |
|
| 1175 | - echo ' |
|
| 1232 | + foreach ($v as $i) { |
|
| 1233 | + echo ' |
|
| 1176 | 1234 | if (', $t, ' >= ', $i, ') |
| 1177 | 1235 | { |
| 1178 | 1236 | turnon.push("', $t, '_', $i, '"); |
| 1179 | 1237 | ', $t, ' -= ', $i, '; |
| 1180 | 1238 | }'; |
| 1239 | + } |
|
| 1181 | 1240 | } |
| 1182 | 1241 | |
| 1183 | 1242 | echo ' |
@@ -1221,9 +1280,10 @@ discard block |
||
| 1221 | 1280 | <tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
| 1222 | 1281 | <td>'; |
| 1223 | 1282 | |
| 1224 | - foreach ($v as $i) |
|
| 1225 | - echo ' |
|
| 1283 | + foreach ($v as $i) { |
|
| 1284 | + echo ' |
|
| 1226 | 1285 | <img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">'; |
| 1286 | + } |
|
| 1227 | 1287 | |
| 1228 | 1288 | echo ' |
| 1229 | 1289 | </td> |
@@ -388,6 +388,9 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Used to direct the user to another location. |
| 391 | +/** |
|
| 392 | + * @param string $location |
|
| 393 | + */ |
|
| 391 | 394 | function redirectLocation($location, $addForm = true) |
| 392 | 395 | { |
| 393 | 396 | global $upgradeurl, $upcontext, $command_line; |
@@ -1560,6 +1563,9 @@ discard block |
||
| 1560 | 1563 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
| 1561 | 1564 | } |
| 1562 | 1565 | |
| 1566 | +/** |
|
| 1567 | + * @param string $filename |
|
| 1568 | + */ |
|
| 1563 | 1569 | function parse_sql($filename) |
| 1564 | 1570 | { |
| 1565 | 1571 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -1594,6 +1600,10 @@ discard block |
||
| 1594 | 1600 | |
| 1595 | 1601 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1596 | 1602 | set_error_handler( |
| 1603 | + |
|
| 1604 | + /** |
|
| 1605 | + * @param string $errno |
|
| 1606 | + */ |
|
| 1597 | 1607 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1598 | 1608 | { |
| 1599 | 1609 | if ($support_js) |
@@ -1840,6 +1850,9 @@ discard block |
||
| 1840 | 1850 | return true; |
| 1841 | 1851 | } |
| 1842 | 1852 | |
| 1853 | +/** |
|
| 1854 | + * @param string $string |
|
| 1855 | + */ |
|
| 1843 | 1856 | function upgrade_query($string, $unbuffered = false) |
| 1844 | 1857 | { |
| 1845 | 1858 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4495,7 +4508,7 @@ discard block |
||
| 4495 | 4508 | * @param int $setSize The amount of entries after which to update the database. |
| 4496 | 4509 | * |
| 4497 | 4510 | * newCol needs to be a varbinary(16) null able field |
| 4498 | - * @return bool |
|
| 4511 | + * @return boolean|null |
|
| 4499 | 4512 | */ |
| 4500 | 4513 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
| 4501 | 4514 | { |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | |
| 83 | 83 | // The helper is crucial. Include it first thing. |
| 84 | 84 | if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
| 85 | - die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
|
| 85 | + die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
|
| 86 | 86 | |
| 87 | 87 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 88 | 88 | |
@@ -1610,7 +1610,7 @@ discard block |
||
| 1610 | 1610 | |
| 1611 | 1611 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1612 | 1612 | set_error_handler( |
| 1613 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1613 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1614 | 1614 | { |
| 1615 | 1615 | if ($support_js) |
| 1616 | 1616 | return true; |
@@ -2595,94 +2595,94 @@ discard block |
||
| 2595 | 2595 | // Translation table for the character sets not native for MySQL. |
| 2596 | 2596 | $translation_tables = array( |
| 2597 | 2597 | 'windows-1255' => array( |
| 2598 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2599 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2600 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2601 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2602 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2603 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2604 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2605 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2606 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2607 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2608 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2609 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2610 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2611 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2612 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2613 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2614 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2615 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2616 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2617 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2618 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2619 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2620 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2621 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2622 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2623 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2624 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2625 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2626 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2627 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2628 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2629 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2630 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2631 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2632 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2633 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2634 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2635 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2636 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2637 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2638 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2639 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2598 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2599 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2600 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2601 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2602 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2603 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2604 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2605 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2606 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2607 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2608 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2609 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2610 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2611 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2612 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2613 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2614 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2615 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2616 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2617 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2618 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2619 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2620 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2621 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2622 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2623 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2624 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2625 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2626 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2627 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2628 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2629 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2630 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2631 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2632 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2633 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2634 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2635 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2636 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2637 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2638 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2639 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2640 | 2640 | '0xFA' => '0xD7AA', |
| 2641 | 2641 | ), |
| 2642 | 2642 | 'windows-1253' => array( |
| 2643 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2644 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2645 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2646 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2647 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2648 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2649 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2650 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2651 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2652 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2653 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2654 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2655 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2656 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2657 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2658 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2659 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2660 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2661 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2662 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2663 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2664 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2665 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2666 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2667 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2668 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2669 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2670 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2671 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2672 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2673 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2674 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2675 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2676 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2677 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2678 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2679 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2680 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2681 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2682 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2683 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2684 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2685 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2643 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2644 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2645 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2646 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2647 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2648 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2649 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2650 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2651 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2652 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2653 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2654 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2655 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2656 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2657 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2658 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2659 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2660 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2661 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2662 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2663 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2664 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2665 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2666 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2667 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2668 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2669 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2670 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2671 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2672 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2673 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2674 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2675 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2676 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2677 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2678 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2679 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2680 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2681 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2682 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2683 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2684 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2685 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2686 | 2686 | ), |
| 2687 | 2687 | ); |
| 2688 | 2688 | |
@@ -3781,7 +3781,7 @@ discard block |
||
| 3781 | 3781 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 3782 | 3782 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
| 3783 | 3783 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
| 3784 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
| 3784 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
| 3785 | 3785 | <span id="debuginfo"></span> |
| 3786 | 3786 | </div>'; |
| 3787 | 3787 | |
@@ -4282,7 +4282,7 @@ discard block |
||
| 4282 | 4282 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 4283 | 4283 | <input type="hidden" name="utf8_done" id="utf8_done" value="0"> |
| 4284 | 4284 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
| 4285 | - <div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;"> |
|
| 4285 | + <div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;"> |
|
| 4286 | 4286 | <span id="debuginfo"></span> |
| 4287 | 4287 | </div>'; |
| 4288 | 4288 | |
@@ -4383,7 +4383,7 @@ discard block |
||
| 4383 | 4383 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 4384 | 4384 | <input type="hidden" name="json_done" id="json_done" value="0"> |
| 4385 | 4385 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
| 4386 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
| 4386 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
| 4387 | 4387 | <span id="debuginfo"></span> |
| 4388 | 4388 | </div>'; |
| 4389 | 4389 | |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -197,8 +204,9 @@ discard block |
||
| 197 | 204 | 'db_error_skip' => true, |
| 198 | 205 | ) |
| 199 | 206 | ); |
| 200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 201 | - $modSettings[$row['variable']] = $row['value']; |
|
| 207 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 208 | + $modSettings[$row['variable']] = $row['value']; |
|
| 209 | + } |
|
| 202 | 210 | $smcFunc['db_free_result']($request); |
| 203 | 211 | } |
| 204 | 212 | |
@@ -208,10 +216,12 @@ discard block |
||
| 208 | 216 | $modSettings['theme_url'] = 'Themes/default'; |
| 209 | 217 | $modSettings['images_url'] = 'Themes/default/images'; |
| 210 | 218 | } |
| 211 | -if (!isset($settings['default_theme_url'])) |
|
| 219 | +if (!isset($settings['default_theme_url'])) { |
|
| 212 | 220 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 213 | -if (!isset($settings['default_theme_dir'])) |
|
| 221 | +} |
|
| 222 | +if (!isset($settings['default_theme_dir'])) { |
|
| 214 | 223 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 224 | +} |
|
| 215 | 225 | |
| 216 | 226 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 217 | 227 | // Default title... |
@@ -229,13 +239,15 @@ discard block |
||
| 229 | 239 | $support_js = $upcontext['upgrade_status']['js']; |
| 230 | 240 | |
| 231 | 241 | // Only set this if the upgrader status says so. |
| 232 | - if (empty($is_debug)) |
|
| 233 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 242 | + if (empty($is_debug)) { |
|
| 243 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // Load the language. |
| 236 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 237 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 238 | -} |
|
| 247 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 248 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | + } |
|
| 250 | + } |
|
| 239 | 251 | // Set the defaults. |
| 240 | 252 | else |
| 241 | 253 | { |
@@ -253,15 +265,18 @@ discard block |
||
| 253 | 265 | } |
| 254 | 266 | |
| 255 | 267 | // If this isn't the first stage see whether they are logging in and resuming. |
| 256 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 268 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 257 | 269 | checkLogin(); |
| 270 | +} |
|
| 258 | 271 | |
| 259 | -if ($command_line) |
|
| 272 | +if ($command_line) { |
|
| 260 | 273 | cmdStep0(); |
| 274 | +} |
|
| 261 | 275 | |
| 262 | 276 | // Don't error if we're using xml. |
| 263 | -if (isset($_GET['xml'])) |
|
| 277 | +if (isset($_GET['xml'])) { |
|
| 264 | 278 | $upcontext['return_error'] = true; |
| 279 | +} |
|
| 265 | 280 | |
| 266 | 281 | // Loop through all the steps doing each one as required. |
| 267 | 282 | $upcontext['overall_percent'] = 0; |
@@ -282,9 +297,9 @@ discard block |
||
| 282 | 297 | } |
| 283 | 298 | |
| 284 | 299 | // Call the step and if it returns false that means pause! |
| 285 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 286 | - break; |
|
| 287 | - elseif (function_exists($step[2])) { |
|
| 300 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 301 | + break; |
|
| 302 | + } elseif (function_exists($step[2])) { |
|
| 288 | 303 | //Start each new step with this unset, so the 'normal' template is called first |
| 289 | 304 | unset($_GET['xml']); |
| 290 | 305 | //Clear out warnings at the start of each step |
@@ -330,17 +345,18 @@ discard block |
||
| 330 | 345 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 331 | 346 | if (!empty($command_line)) |
| 332 | 347 | { |
| 333 | - if (function_exists('debug_print_backtrace')) |
|
| 334 | - debug_print_backtrace(); |
|
| 348 | + if (function_exists('debug_print_backtrace')) { |
|
| 349 | + debug_print_backtrace(); |
|
| 350 | + } |
|
| 335 | 351 | |
| 336 | 352 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 337 | 353 | flush(); |
| 338 | 354 | die(); |
| 339 | 355 | } |
| 340 | 356 | |
| 341 | - if (!isset($_GET['xml'])) |
|
| 342 | - template_upgrade_above(); |
|
| 343 | - else |
|
| 357 | + if (!isset($_GET['xml'])) { |
|
| 358 | + template_upgrade_above(); |
|
| 359 | + } else |
|
| 344 | 360 | { |
| 345 | 361 | header('Content-Type: text/xml; charset=UTF-8'); |
| 346 | 362 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -362,25 +378,29 @@ discard block |
||
| 362 | 378 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 363 | 379 | |
| 364 | 380 | // Custom stuff to pass back? |
| 365 | - if (!empty($upcontext['query_string'])) |
|
| 366 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 381 | + if (!empty($upcontext['query_string'])) { |
|
| 382 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | // Call the appropriate subtemplate |
| 369 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 370 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 371 | - else |
|
| 372 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 386 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 387 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 388 | + } else { |
|
| 389 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 390 | + } |
|
| 373 | 391 | } |
| 374 | 392 | |
| 375 | 393 | // Was there an error? |
| 376 | - if (!empty($upcontext['forced_error_message'])) |
|
| 377 | - echo $upcontext['forced_error_message']; |
|
| 394 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 395 | + echo $upcontext['forced_error_message']; |
|
| 396 | + } |
|
| 378 | 397 | |
| 379 | 398 | // Show the footer. |
| 380 | - if (!isset($_GET['xml'])) |
|
| 381 | - template_upgrade_below(); |
|
| 382 | - else |
|
| 383 | - template_xml_below(); |
|
| 399 | + if (!isset($_GET['xml'])) { |
|
| 400 | + template_upgrade_below(); |
|
| 401 | + } else { |
|
| 402 | + template_xml_below(); |
|
| 403 | + } |
|
| 384 | 404 | } |
| 385 | 405 | |
| 386 | 406 | |
@@ -392,15 +412,19 @@ discard block |
||
| 392 | 412 | $seconds = intval($active % 60); |
| 393 | 413 | |
| 394 | 414 | $totalTime = ''; |
| 395 | - if ($hours > 0) |
|
| 396 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 397 | - if ($minutes > 0) |
|
| 398 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 399 | - if ($seconds > 0) |
|
| 400 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 415 | + if ($hours > 0) { |
|
| 416 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 417 | + } |
|
| 418 | + if ($minutes > 0) { |
|
| 419 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 420 | + } |
|
| 421 | + if ($seconds > 0) { |
|
| 422 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 423 | + } |
|
| 401 | 424 | |
| 402 | - if (!empty($totalTime)) |
|
| 403 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 425 | + if (!empty($totalTime)) { |
|
| 426 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 427 | + } |
|
| 404 | 428 | } |
| 405 | 429 | |
| 406 | 430 | // Bang - gone! |
@@ -413,8 +437,9 @@ discard block |
||
| 413 | 437 | global $upgradeurl, $upcontext, $command_line; |
| 414 | 438 | |
| 415 | 439 | // Command line users can't be redirected. |
| 416 | - if ($command_line) |
|
| 417 | - upgradeExit(true); |
|
| 440 | + if ($command_line) { |
|
| 441 | + upgradeExit(true); |
|
| 442 | + } |
|
| 418 | 443 | |
| 419 | 444 | // Are we providing the core info? |
| 420 | 445 | if ($addForm) |
@@ -440,12 +465,14 @@ discard block |
||
| 440 | 465 | define('SMF', 1); |
| 441 | 466 | |
| 442 | 467 | // Start the session. |
| 443 | - if (@ini_get('session.save_handler') == 'user') |
|
| 444 | - @ini_set('session.save_handler', 'files'); |
|
| 468 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 469 | + @ini_set('session.save_handler', 'files'); |
|
| 470 | + } |
|
| 445 | 471 | @session_start(); |
| 446 | 472 | |
| 447 | - if (empty($smcFunc)) |
|
| 448 | - $smcFunc = array(); |
|
| 473 | + if (empty($smcFunc)) { |
|
| 474 | + $smcFunc = array(); |
|
| 475 | + } |
|
| 449 | 476 | |
| 450 | 477 | // We need this for authentication and some upgrade code |
| 451 | 478 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -472,24 +499,27 @@ discard block |
||
| 472 | 499 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 473 | 500 | |
| 474 | 501 | // Make the connection... |
| 475 | - if (empty($db_connection)) |
|
| 476 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 477 | - else |
|
| 478 | - // If we've returned here, ping/reconnect to be safe |
|
| 502 | + if (empty($db_connection)) { |
|
| 503 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 504 | + } else { |
|
| 505 | + // If we've returned here, ping/reconnect to be safe |
|
| 479 | 506 | $smcFunc['db_ping']($db_connection); |
| 507 | + } |
|
| 480 | 508 | |
| 481 | 509 | // Oh dear god!! |
| 482 | - if ($db_connection === null) |
|
| 483 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 510 | + if ($db_connection === null) { |
|
| 511 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 512 | + } |
|
| 484 | 513 | |
| 485 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 486 | - $smcFunc['db_query']('', ' |
|
| 514 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 515 | + $smcFunc['db_query']('', ' |
|
| 487 | 516 | SET NAMES {string:db_character_set}', |
| 488 | 517 | array( |
| 489 | 518 | 'db_error_skip' => true, |
| 490 | 519 | 'db_character_set' => $db_character_set, |
| 491 | 520 | ) |
| 492 | 521 | ); |
| 522 | + } |
|
| 493 | 523 | |
| 494 | 524 | // Load the modSettings data... |
| 495 | 525 | $request = $smcFunc['db_query']('', ' |
@@ -500,11 +530,11 @@ discard block |
||
| 500 | 530 | ) |
| 501 | 531 | ); |
| 502 | 532 | $modSettings = array(); |
| 503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 504 | - $modSettings[$row['variable']] = $row['value']; |
|
| 533 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 534 | + $modSettings[$row['variable']] = $row['value']; |
|
| 535 | + } |
|
| 505 | 536 | $smcFunc['db_free_result']($request); |
| 506 | - } |
|
| 507 | - else |
|
| 537 | + } else |
|
| 508 | 538 | { |
| 509 | 539 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 510 | 540 | } |
@@ -518,9 +548,10 @@ discard block |
||
| 518 | 548 | cleanRequest(); |
| 519 | 549 | } |
| 520 | 550 | |
| 521 | - if (!isset($_GET['substep'])) |
|
| 522 | - $_GET['substep'] = 0; |
|
| 523 | -} |
|
| 551 | + if (!isset($_GET['substep'])) { |
|
| 552 | + $_GET['substep'] = 0; |
|
| 553 | + } |
|
| 554 | + } |
|
| 524 | 555 | |
| 525 | 556 | function initialize_inputs() |
| 526 | 557 | { |
@@ -550,8 +581,9 @@ discard block |
||
| 550 | 581 | $dh = opendir(dirname(__FILE__)); |
| 551 | 582 | while ($file = readdir($dh)) |
| 552 | 583 | { |
| 553 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 554 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 584 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 585 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 586 | + } |
|
| 555 | 587 | } |
| 556 | 588 | closedir($dh); |
| 557 | 589 | |
@@ -580,8 +612,9 @@ discard block |
||
| 580 | 612 | $temp = 'upgrade_php?step'; |
| 581 | 613 | while (strlen($temp) > 4) |
| 582 | 614 | { |
| 583 | - if (isset($_GET[$temp])) |
|
| 584 | - unset($_GET[$temp]); |
|
| 615 | + if (isset($_GET[$temp])) { |
|
| 616 | + unset($_GET[$temp]); |
|
| 617 | + } |
|
| 585 | 618 | $temp = substr($temp, 1); |
| 586 | 619 | } |
| 587 | 620 | |
@@ -608,32 +641,39 @@ discard block |
||
| 608 | 641 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 609 | 642 | |
| 610 | 643 | // Need legacy scripts? |
| 611 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 612 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 644 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 645 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 646 | + } |
|
| 647 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 648 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 649 | + } |
|
| 650 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 651 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 652 | + } |
|
| 617 | 653 | |
| 618 | 654 | // We don't need "-utf8" files anymore... |
| 619 | 655 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 620 | 656 | |
| 621 | 657 | // This needs to exist! |
| 622 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 623 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 624 | - else |
|
| 625 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 658 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 659 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 660 | + } else { |
|
| 661 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 662 | + } |
|
| 626 | 663 | |
| 627 | - if (!$check) |
|
| 628 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 664 | + if (!$check) { |
|
| 665 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 629 | 666 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 667 | + } |
|
| 630 | 668 | |
| 631 | 669 | // Do they meet the install requirements? |
| 632 | - if (!php_version_check()) |
|
| 633 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 670 | + if (!php_version_check()) { |
|
| 671 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 672 | + } |
|
| 634 | 673 | |
| 635 | - if (!db_version_check()) |
|
| 636 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 674 | + if (!db_version_check()) { |
|
| 675 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 676 | + } |
|
| 637 | 677 | |
| 638 | 678 | // Do some checks to make sure they have proper privileges |
| 639 | 679 | db_extend('packages'); |
@@ -648,14 +688,16 @@ discard block |
||
| 648 | 688 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 649 | 689 | |
| 650 | 690 | // Sorry... we need CREATE, ALTER and DROP |
| 651 | - if (!$create || !$alter || !$drop) |
|
| 652 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 691 | + if (!$create || !$alter || !$drop) { |
|
| 692 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Do a quick version spot check. |
| 655 | 696 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 656 | 697 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 657 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 658 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 698 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 699 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 700 | + } |
|
| 659 | 701 | |
| 660 | 702 | // What absolutely needs to be writable? |
| 661 | 703 | $writable_files = array( |
@@ -664,12 +706,13 @@ discard block |
||
| 664 | 706 | ); |
| 665 | 707 | |
| 666 | 708 | // Only check for minified writable files if we have it enabled or not set. |
| 667 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 668 | - $writable_files += array( |
|
| 709 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 710 | + $writable_files += array( |
|
| 669 | 711 | $modSettings['theme_dir'] . '/css/minified.css', |
| 670 | 712 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 671 | 713 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 672 | 714 | ); |
| 715 | + } |
|
| 673 | 716 | |
| 674 | 717 | // Do we need to add this setting? |
| 675 | 718 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -681,12 +724,13 @@ discard block |
||
| 681 | 724 | quickFileWritable($custom_av_dir); |
| 682 | 725 | |
| 683 | 726 | // Are we good now? |
| 684 | - if (!is_writable($custom_av_dir)) |
|
| 685 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 686 | - elseif ($need_settings_update) |
|
| 727 | + if (!is_writable($custom_av_dir)) { |
|
| 728 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 729 | + } elseif ($need_settings_update) |
|
| 687 | 730 | { |
| 688 | - if (!function_exists('cache_put_data')) |
|
| 689 | - require_once($sourcedir . '/Load.php'); |
|
| 731 | + if (!function_exists('cache_put_data')) { |
|
| 732 | + require_once($sourcedir . '/Load.php'); |
|
| 733 | + } |
|
| 690 | 734 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 691 | 735 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 692 | 736 | } |
@@ -695,28 +739,33 @@ discard block |
||
| 695 | 739 | |
| 696 | 740 | // Check the cache directory. |
| 697 | 741 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 698 | - if (!file_exists($cachedir_temp)) |
|
| 699 | - @mkdir($cachedir_temp); |
|
| 700 | - if (!file_exists($cachedir_temp)) |
|
| 701 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 702 | - |
|
| 703 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 704 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 705 | - elseif (!isset($_GET['skiplang'])) |
|
| 742 | + if (!file_exists($cachedir_temp)) { |
|
| 743 | + @mkdir($cachedir_temp); |
|
| 744 | + } |
|
| 745 | + if (!file_exists($cachedir_temp)) { |
|
| 746 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 750 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 751 | + } elseif (!isset($_GET['skiplang'])) |
|
| 706 | 752 | { |
| 707 | 753 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 708 | 754 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 709 | 755 | |
| 710 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 711 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 756 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 757 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 758 | + } |
|
| 712 | 759 | } |
| 713 | 760 | |
| 714 | - if (!makeFilesWritable($writable_files)) |
|
| 715 | - return false; |
|
| 761 | + if (!makeFilesWritable($writable_files)) { |
|
| 762 | + return false; |
|
| 763 | + } |
|
| 716 | 764 | |
| 717 | 765 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 718 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 719 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 766 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 767 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 768 | + } |
|
| 720 | 769 | |
| 721 | 770 | // Upgrade the agreement. |
| 722 | 771 | elseif (isset($modSettings['agreement'])) |
@@ -727,8 +776,8 @@ discard block |
||
| 727 | 776 | } |
| 728 | 777 | |
| 729 | 778 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 730 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 731 | - $upcontext['warning'] = ' |
|
| 779 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 780 | + $upcontext['warning'] = ' |
|
| 732 | 781 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 733 | 782 | <ul> |
| 734 | 783 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -736,19 +785,23 @@ discard block |
||
| 736 | 785 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 737 | 786 | </ul> |
| 738 | 787 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 788 | + } |
|
| 739 | 789 | |
| 740 | 790 | // Confirm mbstring is loaded... |
| 741 | - if (!extension_loaded('mbstring')) |
|
| 742 | - return throw_error($txt['install_no_mbstring']); |
|
| 791 | + if (!extension_loaded('mbstring')) { |
|
| 792 | + return throw_error($txt['install_no_mbstring']); |
|
| 793 | + } |
|
| 743 | 794 | |
| 744 | 795 | // Check for https stream support. |
| 745 | 796 | $supported_streams = stream_get_wrappers(); |
| 746 | - if (!in_array('https', $supported_streams)) |
|
| 747 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 797 | + if (!in_array('https', $supported_streams)) { |
|
| 798 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 799 | + } |
|
| 748 | 800 | |
| 749 | 801 | // Either we're logged in or we're going to present the login. |
| 750 | - if (checkLogin()) |
|
| 751 | - return true; |
|
| 802 | + if (checkLogin()) { |
|
| 803 | + return true; |
|
| 804 | + } |
|
| 752 | 805 | |
| 753 | 806 | $upcontext += createToken('login'); |
| 754 | 807 | |
@@ -762,15 +815,17 @@ discard block |
||
| 762 | 815 | global $smcFunc, $db_type, $support_js; |
| 763 | 816 | |
| 764 | 817 | // Don't bother if the security is disabled. |
| 765 | - if ($disable_security) |
|
| 766 | - return true; |
|
| 818 | + if ($disable_security) { |
|
| 819 | + return true; |
|
| 820 | + } |
|
| 767 | 821 | |
| 768 | 822 | // Are we trying to login? |
| 769 | 823 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 770 | 824 | { |
| 771 | 825 | // If we've disabled security pick a suitable name! |
| 772 | - if (empty($_POST['user'])) |
|
| 773 | - $_POST['user'] = 'Administrator'; |
|
| 826 | + if (empty($_POST['user'])) { |
|
| 827 | + $_POST['user'] = 'Administrator'; |
|
| 828 | + } |
|
| 774 | 829 | |
| 775 | 830 | // Before 2.0 these column names were different! |
| 776 | 831 | $oldDB = false; |
@@ -785,16 +840,17 @@ discard block |
||
| 785 | 840 | 'db_error_skip' => true, |
| 786 | 841 | ) |
| 787 | 842 | ); |
| 788 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 789 | - $oldDB = true; |
|
| 843 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 844 | + $oldDB = true; |
|
| 845 | + } |
|
| 790 | 846 | $smcFunc['db_free_result']($request); |
| 791 | 847 | } |
| 792 | 848 | |
| 793 | 849 | // Get what we believe to be their details. |
| 794 | 850 | if (!$disable_security) |
| 795 | 851 | { |
| 796 | - if ($oldDB) |
|
| 797 | - $request = $smcFunc['db_query']('', ' |
|
| 852 | + if ($oldDB) { |
|
| 853 | + $request = $smcFunc['db_query']('', ' |
|
| 798 | 854 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 799 | 855 | additionalGroups AS additional_groups, lngfile |
| 800 | 856 | FROM {db_prefix}members |
@@ -804,8 +860,8 @@ discard block |
||
| 804 | 860 | 'db_error_skip' => true, |
| 805 | 861 | ) |
| 806 | 862 | ); |
| 807 | - else |
|
| 808 | - $request = $smcFunc['db_query']('', ' |
|
| 863 | + } else { |
|
| 864 | + $request = $smcFunc['db_query']('', ' |
|
| 809 | 865 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 810 | 866 | FROM {db_prefix}members |
| 811 | 867 | WHERE member_name = {string:member_name}', |
@@ -814,6 +870,7 @@ discard block |
||
| 814 | 870 | 'db_error_skip' => true, |
| 815 | 871 | ) |
| 816 | 872 | ); |
| 873 | + } |
|
| 817 | 874 | if ($smcFunc['db_num_rows']($request) != 0) |
| 818 | 875 | { |
| 819 | 876 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -821,16 +878,17 @@ discard block |
||
| 821 | 878 | $groups = explode(',', $addGroups); |
| 822 | 879 | $groups[] = $id_group; |
| 823 | 880 | |
| 824 | - foreach ($groups as $k => $v) |
|
| 825 | - $groups[$k] = (int) $v; |
|
| 881 | + foreach ($groups as $k => $v) { |
|
| 882 | + $groups[$k] = (int) $v; |
|
| 883 | + } |
|
| 826 | 884 | |
| 827 | 885 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 828 | 886 | |
| 829 | 887 | // We don't use "-utf8" anymore... |
| 830 | 888 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 889 | + } else { |
|
| 890 | + $upcontext['username_incorrect'] = true; |
|
| 831 | 891 | } |
| 832 | - else |
|
| 833 | - $upcontext['username_incorrect'] = true; |
|
| 834 | 892 | $smcFunc['db_free_result']($request); |
| 835 | 893 | } |
| 836 | 894 | $upcontext['username'] = $_POST['user']; |
@@ -840,13 +898,14 @@ discard block |
||
| 840 | 898 | { |
| 841 | 899 | $upcontext['upgrade_status']['js'] = 1; |
| 842 | 900 | $support_js = 1; |
| 901 | + } else { |
|
| 902 | + $support_js = 0; |
|
| 843 | 903 | } |
| 844 | - else |
|
| 845 | - $support_js = 0; |
|
| 846 | 904 | |
| 847 | 905 | // Note down the version we are coming from. |
| 848 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 849 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 906 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 907 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 908 | + } |
|
| 850 | 909 | |
| 851 | 910 | // Didn't get anywhere? |
| 852 | 911 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -880,15 +939,15 @@ discard block |
||
| 880 | 939 | 'db_error_skip' => true, |
| 881 | 940 | ) |
| 882 | 941 | ); |
| 883 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 884 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 942 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 943 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 944 | + } |
|
| 885 | 945 | $smcFunc['db_free_result']($request); |
| 886 | 946 | } |
| 887 | 947 | |
| 888 | 948 | $upcontext['user']['id'] = $id_member; |
| 889 | 949 | $upcontext['user']['name'] = $name; |
| 890 | - } |
|
| 891 | - else |
|
| 950 | + } else |
|
| 892 | 951 | { |
| 893 | 952 | $upcontext['user']['id'] = 1; |
| 894 | 953 | $upcontext['user']['name'] = 'Administrator'; |
@@ -904,11 +963,11 @@ discard block |
||
| 904 | 963 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 905 | 964 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 906 | 965 | |
| 907 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 908 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 909 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 910 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 911 | - else |
|
| 966 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 967 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 968 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 969 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 970 | + } else |
|
| 912 | 971 | { |
| 913 | 972 | // Set this as the new language. |
| 914 | 973 | $upcontext['language'] = $user_language; |
@@ -952,8 +1011,9 @@ discard block |
||
| 952 | 1011 | unset($member_columns); |
| 953 | 1012 | |
| 954 | 1013 | // If we've not submitted then we're done. |
| 955 | - if (empty($_POST['upcont'])) |
|
| 956 | - return false; |
|
| 1014 | + if (empty($_POST['upcont'])) { |
|
| 1015 | + return false; |
|
| 1016 | + } |
|
| 957 | 1017 | |
| 958 | 1018 | // Firstly, if they're enabling SM stat collection just do it. |
| 959 | 1019 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -973,16 +1033,17 @@ discard block |
||
| 973 | 1033 | fwrite($fp, $out); |
| 974 | 1034 | |
| 975 | 1035 | $return_data = ''; |
| 976 | - while (!feof($fp)) |
|
| 977 | - $return_data .= fgets($fp, 128); |
|
| 1036 | + while (!feof($fp)) { |
|
| 1037 | + $return_data .= fgets($fp, 128); |
|
| 1038 | + } |
|
| 978 | 1039 | |
| 979 | 1040 | fclose($fp); |
| 980 | 1041 | |
| 981 | 1042 | // Get the unique site ID. |
| 982 | 1043 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 983 | 1044 | |
| 984 | - if (!empty($ID[1])) |
|
| 985 | - $smcFunc['db_insert']('replace', |
|
| 1045 | + if (!empty($ID[1])) { |
|
| 1046 | + $smcFunc['db_insert']('replace', |
|
| 986 | 1047 | $db_prefix . 'settings', |
| 987 | 1048 | array('variable' => 'string', 'value' => 'string'), |
| 988 | 1049 | array( |
@@ -991,9 +1052,9 @@ discard block |
||
| 991 | 1052 | ), |
| 992 | 1053 | array('variable') |
| 993 | 1054 | ); |
| 1055 | + } |
|
| 994 | 1056 | } |
| 995 | - } |
|
| 996 | - else |
|
| 1057 | + } else |
|
| 997 | 1058 | { |
| 998 | 1059 | $smcFunc['db_insert']('replace', |
| 999 | 1060 | $db_prefix . 'settings', |
@@ -1004,8 +1065,8 @@ discard block |
||
| 1004 | 1065 | } |
| 1005 | 1066 | } |
| 1006 | 1067 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1007 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1008 | - $smcFunc['db_query']('', ' |
|
| 1068 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1069 | + $smcFunc['db_query']('', ' |
|
| 1009 | 1070 | DELETE FROM {db_prefix}settings |
| 1010 | 1071 | WHERE variable = {string:enable_sm_stats}', |
| 1011 | 1072 | array( |
@@ -1013,6 +1074,7 @@ discard block |
||
| 1013 | 1074 | 'db_error_skip' => true, |
| 1014 | 1075 | ) |
| 1015 | 1076 | ); |
| 1077 | + } |
|
| 1016 | 1078 | |
| 1017 | 1079 | // Deleting old karma stuff? |
| 1018 | 1080 | if (!empty($_POST['delete_karma'])) |
@@ -1027,20 +1089,22 @@ discard block |
||
| 1027 | 1089 | ); |
| 1028 | 1090 | |
| 1029 | 1091 | // Cleaning up old karma member settings. |
| 1030 | - if ($upcontext['karma_installed']['good']) |
|
| 1031 | - $smcFunc['db_query']('', ' |
|
| 1092 | + if ($upcontext['karma_installed']['good']) { |
|
| 1093 | + $smcFunc['db_query']('', ' |
|
| 1032 | 1094 | ALTER TABLE {db_prefix}members |
| 1033 | 1095 | DROP karma_good', |
| 1034 | 1096 | array() |
| 1035 | 1097 | ); |
| 1098 | + } |
|
| 1036 | 1099 | |
| 1037 | 1100 | // Does karma bad was enable? |
| 1038 | - if ($upcontext['karma_installed']['bad']) |
|
| 1039 | - $smcFunc['db_query']('', ' |
|
| 1101 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1102 | + $smcFunc['db_query']('', ' |
|
| 1040 | 1103 | ALTER TABLE {db_prefix}members |
| 1041 | 1104 | DROP karma_bad', |
| 1042 | 1105 | array() |
| 1043 | 1106 | ); |
| 1107 | + } |
|
| 1044 | 1108 | |
| 1045 | 1109 | // Cleaning up old karma permissions. |
| 1046 | 1110 | $smcFunc['db_query']('', ' |
@@ -1058,32 +1122,37 @@ discard block |
||
| 1058 | 1122 | } |
| 1059 | 1123 | |
| 1060 | 1124 | // Emptying the error log? |
| 1061 | - if (!empty($_POST['empty_error'])) |
|
| 1062 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1125 | + if (!empty($_POST['empty_error'])) { |
|
| 1126 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1063 | 1127 | TRUNCATE {db_prefix}log_errors', |
| 1064 | 1128 | array( |
| 1065 | 1129 | ) |
| 1066 | 1130 | ); |
| 1131 | + } |
|
| 1067 | 1132 | |
| 1068 | 1133 | $changes = array(); |
| 1069 | 1134 | |
| 1070 | 1135 | // Add proxy settings. |
| 1071 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1072 | - $changes += array( |
|
| 1136 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1137 | + $changes += array( |
|
| 1073 | 1138 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1074 | 1139 | 'image_proxy_maxsize' => 5190, |
| 1075 | 1140 | 'image_proxy_enabled' => 0, |
| 1076 | 1141 | ); |
| 1142 | + } |
|
| 1077 | 1143 | |
| 1078 | 1144 | // If $boardurl reflects https, set force_ssl |
| 1079 | - if (!function_exists('cache_put_data')) |
|
| 1080 | - require_once($sourcedir . '/Load.php'); |
|
| 1081 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1082 | - updateSettings(array('force_ssl' => '1')); |
|
| 1145 | + if (!function_exists('cache_put_data')) { |
|
| 1146 | + require_once($sourcedir . '/Load.php'); |
|
| 1147 | + } |
|
| 1148 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1149 | + updateSettings(array('force_ssl' => '1')); |
|
| 1150 | + } |
|
| 1083 | 1151 | |
| 1084 | 1152 | // If we're overriding the language follow it through. |
| 1085 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1086 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1153 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1154 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1155 | + } |
|
| 1087 | 1156 | |
| 1088 | 1157 | if (!empty($_POST['maint'])) |
| 1089 | 1158 | { |
@@ -1095,26 +1164,29 @@ discard block |
||
| 1095 | 1164 | { |
| 1096 | 1165 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1097 | 1166 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1098 | - } |
|
| 1099 | - else |
|
| 1167 | + } else |
|
| 1100 | 1168 | { |
| 1101 | 1169 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1102 | 1170 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1103 | 1171 | } |
| 1104 | 1172 | } |
| 1105 | 1173 | |
| 1106 | - if ($command_line) |
|
| 1107 | - echo ' * Updating Settings.php...'; |
|
| 1174 | + if ($command_line) { |
|
| 1175 | + echo ' * Updating Settings.php...'; |
|
| 1176 | + } |
|
| 1108 | 1177 | |
| 1109 | 1178 | // Fix some old paths. |
| 1110 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1111 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1179 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1180 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1181 | + } |
|
| 1112 | 1182 | |
| 1113 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1114 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1183 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1184 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1185 | + } |
|
| 1115 | 1186 | |
| 1116 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1117 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1187 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1188 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1189 | + } |
|
| 1118 | 1190 | |
| 1119 | 1191 | // If they have a "host:port" setup for the host, split that into separate values |
| 1120 | 1192 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1125,32 +1197,36 @@ discard block |
||
| 1125 | 1197 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1126 | 1198 | |
| 1127 | 1199 | // Only set this if we're not using the default port |
| 1128 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1129 | - $changes['db_port'] = (int) $db_port; |
|
| 1130 | - } |
|
| 1131 | - elseif (!empty($db_port)) |
|
| 1200 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1201 | + $changes['db_port'] = (int) $db_port; |
|
| 1202 | + } |
|
| 1203 | + } elseif (!empty($db_port)) |
|
| 1132 | 1204 | { |
| 1133 | 1205 | // If db_port is set and is the same as the default, set it to '' |
| 1134 | 1206 | if ($db_type == 'mysql') |
| 1135 | 1207 | { |
| 1136 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1137 | - $changes['db_port'] = '\'\''; |
|
| 1138 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1139 | - $changes['db_port'] = '\'\''; |
|
| 1208 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1209 | + $changes['db_port'] = '\'\''; |
|
| 1210 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1211 | + $changes['db_port'] = '\'\''; |
|
| 1212 | + } |
|
| 1140 | 1213 | } |
| 1141 | 1214 | } |
| 1142 | 1215 | |
| 1143 | 1216 | // Maybe we haven't had this option yet? |
| 1144 | - if (empty($packagesdir)) |
|
| 1145 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1217 | + if (empty($packagesdir)) { |
|
| 1218 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1219 | + } |
|
| 1146 | 1220 | |
| 1147 | 1221 | // Add support for $tasksdir var. |
| 1148 | - if (empty($tasksdir)) |
|
| 1149 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1222 | + if (empty($tasksdir)) { |
|
| 1223 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1224 | + } |
|
| 1150 | 1225 | |
| 1151 | 1226 | // Make sure we fix the language as well. |
| 1152 | - if (stristr($language, '-utf8')) |
|
| 1153 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1227 | + if (stristr($language, '-utf8')) { |
|
| 1228 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1229 | + } |
|
| 1154 | 1230 | |
| 1155 | 1231 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1156 | 1232 | |
@@ -1158,8 +1234,9 @@ discard block |
||
| 1158 | 1234 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1159 | 1235 | updateSettingsFile($changes); |
| 1160 | 1236 | |
| 1161 | - if ($command_line) |
|
| 1162 | - echo ' Successful.' . "\n"; |
|
| 1237 | + if ($command_line) { |
|
| 1238 | + echo ' Successful.' . "\n"; |
|
| 1239 | + } |
|
| 1163 | 1240 | |
| 1164 | 1241 | // Are we doing debug? |
| 1165 | 1242 | if (isset($_POST['debug'])) |
@@ -1169,8 +1246,9 @@ discard block |
||
| 1169 | 1246 | } |
| 1170 | 1247 | |
| 1171 | 1248 | // If we're not backing up then jump one. |
| 1172 | - if (empty($_POST['backup'])) |
|
| 1173 | - $upcontext['current_step']++; |
|
| 1249 | + if (empty($_POST['backup'])) { |
|
| 1250 | + $upcontext['current_step']++; |
|
| 1251 | + } |
|
| 1174 | 1252 | |
| 1175 | 1253 | // If we've got here then let's proceed to the next step! |
| 1176 | 1254 | return true; |
@@ -1185,8 +1263,9 @@ discard block |
||
| 1185 | 1263 | $upcontext['page_title'] = 'Backup Database'; |
| 1186 | 1264 | |
| 1187 | 1265 | // Done it already - js wise? |
| 1188 | - if (!empty($_POST['backup_done'])) |
|
| 1189 | - return true; |
|
| 1266 | + if (!empty($_POST['backup_done'])) { |
|
| 1267 | + return true; |
|
| 1268 | + } |
|
| 1190 | 1269 | |
| 1191 | 1270 | // Some useful stuff here. |
| 1192 | 1271 | db_extend(); |
@@ -1200,9 +1279,10 @@ discard block |
||
| 1200 | 1279 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1201 | 1280 | |
| 1202 | 1281 | $table_names = array(); |
| 1203 | - foreach ($tables as $table) |
|
| 1204 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1282 | + foreach ($tables as $table) { |
|
| 1283 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1205 | 1284 | $table_names[] = $table; |
| 1285 | + } |
|
| 1206 | 1286 | |
| 1207 | 1287 | $upcontext['table_count'] = count($table_names); |
| 1208 | 1288 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1212,12 +1292,14 @@ discard block |
||
| 1212 | 1292 | $file_steps = $upcontext['table_count']; |
| 1213 | 1293 | |
| 1214 | 1294 | // What ones have we already done? |
| 1215 | - foreach ($table_names as $id => $table) |
|
| 1216 | - if ($id < $_GET['substep']) |
|
| 1295 | + foreach ($table_names as $id => $table) { |
|
| 1296 | + if ($id < $_GET['substep']) |
|
| 1217 | 1297 | $upcontext['previous_tables'][] = $table; |
| 1298 | + } |
|
| 1218 | 1299 | |
| 1219 | - if ($command_line) |
|
| 1220 | - echo 'Backing Up Tables.'; |
|
| 1300 | + if ($command_line) { |
|
| 1301 | + echo 'Backing Up Tables.'; |
|
| 1302 | + } |
|
| 1221 | 1303 | |
| 1222 | 1304 | // If we don't support javascript we backup here. |
| 1223 | 1305 | if (!$support_js || isset($_GET['xml'])) |
@@ -1236,8 +1318,9 @@ discard block |
||
| 1236 | 1318 | backupTable($table_names[$substep]); |
| 1237 | 1319 | |
| 1238 | 1320 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1239 | - if (isset($_GET['xml'])) |
|
| 1240 | - return upgradeExit(); |
|
| 1321 | + if (isset($_GET['xml'])) { |
|
| 1322 | + return upgradeExit(); |
|
| 1323 | + } |
|
| 1241 | 1324 | } |
| 1242 | 1325 | |
| 1243 | 1326 | if ($command_line) |
@@ -1270,9 +1353,10 @@ discard block |
||
| 1270 | 1353 | |
| 1271 | 1354 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1272 | 1355 | |
| 1273 | - if ($command_line) |
|
| 1274 | - echo ' done.'; |
|
| 1275 | -} |
|
| 1356 | + if ($command_line) { |
|
| 1357 | + echo ' done.'; |
|
| 1358 | + } |
|
| 1359 | + } |
|
| 1276 | 1360 | |
| 1277 | 1361 | // Step 2: Everything. |
| 1278 | 1362 | function DatabaseChanges() |
@@ -1281,8 +1365,9 @@ discard block |
||
| 1281 | 1365 | global $upcontext, $support_js, $db_type; |
| 1282 | 1366 | |
| 1283 | 1367 | // Have we just completed this? |
| 1284 | - if (!empty($_POST['database_done'])) |
|
| 1285 | - return true; |
|
| 1368 | + if (!empty($_POST['database_done'])) { |
|
| 1369 | + return true; |
|
| 1370 | + } |
|
| 1286 | 1371 | |
| 1287 | 1372 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1288 | 1373 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1297,15 +1382,16 @@ discard block |
||
| 1297 | 1382 | ); |
| 1298 | 1383 | |
| 1299 | 1384 | // How many files are there in total? |
| 1300 | - if (isset($_GET['filecount'])) |
|
| 1301 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1302 | - else |
|
| 1385 | + if (isset($_GET['filecount'])) { |
|
| 1386 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1387 | + } else |
|
| 1303 | 1388 | { |
| 1304 | 1389 | $upcontext['file_count'] = 0; |
| 1305 | 1390 | foreach ($files as $file) |
| 1306 | 1391 | { |
| 1307 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1308 | - $upcontext['file_count']++; |
|
| 1392 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1393 | + $upcontext['file_count']++; |
|
| 1394 | + } |
|
| 1309 | 1395 | } |
| 1310 | 1396 | } |
| 1311 | 1397 | |
@@ -1315,9 +1401,9 @@ discard block |
||
| 1315 | 1401 | $upcontext['cur_file_num'] = 0; |
| 1316 | 1402 | foreach ($files as $file) |
| 1317 | 1403 | { |
| 1318 | - if ($did_not_do) |
|
| 1319 | - $did_not_do--; |
|
| 1320 | - else |
|
| 1404 | + if ($did_not_do) { |
|
| 1405 | + $did_not_do--; |
|
| 1406 | + } else |
|
| 1321 | 1407 | { |
| 1322 | 1408 | $upcontext['cur_file_num']++; |
| 1323 | 1409 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1344,12 +1430,13 @@ discard block |
||
| 1344 | 1430 | // Flag to move on to the next. |
| 1345 | 1431 | $upcontext['completed_step'] = true; |
| 1346 | 1432 | // Did we complete the whole file? |
| 1347 | - if ($nextFile) |
|
| 1348 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1433 | + if ($nextFile) { |
|
| 1434 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1435 | + } |
|
| 1349 | 1436 | return upgradeExit(); |
| 1437 | + } elseif ($support_js) { |
|
| 1438 | + break; |
|
| 1350 | 1439 | } |
| 1351 | - elseif ($support_js) |
|
| 1352 | - break; |
|
| 1353 | 1440 | } |
| 1354 | 1441 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1355 | 1442 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1374,8 +1461,9 @@ discard block |
||
| 1374 | 1461 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1375 | 1462 | |
| 1376 | 1463 | // Now it's nice to have some of the basic SMF source files. |
| 1377 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1378 | - redirectLocation('&ssi=1'); |
|
| 1464 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1465 | + redirectLocation('&ssi=1'); |
|
| 1466 | + } |
|
| 1379 | 1467 | |
| 1380 | 1468 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1381 | 1469 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1391,14 +1479,16 @@ discard block |
||
| 1391 | 1479 | // Are we in maintenance mode? |
| 1392 | 1480 | if (isset($upcontext['user']['main'])) |
| 1393 | 1481 | { |
| 1394 | - if ($command_line) |
|
| 1395 | - echo ' * '; |
|
| 1482 | + if ($command_line) { |
|
| 1483 | + echo ' * '; |
|
| 1484 | + } |
|
| 1396 | 1485 | $upcontext['removed_maintenance'] = true; |
| 1397 | 1486 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1398 | 1487 | } |
| 1399 | 1488 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1400 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1401 | - $changes['maintenance'] = 1; |
|
| 1489 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1490 | + $changes['maintenance'] = 1; |
|
| 1491 | + } |
|
| 1402 | 1492 | |
| 1403 | 1493 | // Wipe this out... |
| 1404 | 1494 | $upcontext['user'] = array(); |
@@ -1413,9 +1503,9 @@ discard block |
||
| 1413 | 1503 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1414 | 1504 | |
| 1415 | 1505 | // Now is the perfect time to fetch the SM files. |
| 1416 | - if ($command_line) |
|
| 1417 | - cli_scheduled_fetchSMfiles(); |
|
| 1418 | - else |
|
| 1506 | + if ($command_line) { |
|
| 1507 | + cli_scheduled_fetchSMfiles(); |
|
| 1508 | + } else |
|
| 1419 | 1509 | { |
| 1420 | 1510 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1421 | 1511 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1423,8 +1513,9 @@ discard block |
||
| 1423 | 1513 | } |
| 1424 | 1514 | |
| 1425 | 1515 | // Log what we've done. |
| 1426 | - if (empty($user_info['id'])) |
|
| 1427 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1516 | + if (empty($user_info['id'])) { |
|
| 1517 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1518 | + } |
|
| 1428 | 1519 | |
| 1429 | 1520 | // Log the action manually, so CLI still works. |
| 1430 | 1521 | $smcFunc['db_insert']('', |
@@ -1443,8 +1534,9 @@ discard block |
||
| 1443 | 1534 | |
| 1444 | 1535 | // Save the current database version. |
| 1445 | 1536 | $server_version = $smcFunc['db_server_info'](); |
| 1446 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1447 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1537 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1538 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1539 | + } |
|
| 1448 | 1540 | |
| 1449 | 1541 | if ($command_line) |
| 1450 | 1542 | { |
@@ -1456,8 +1548,9 @@ discard block |
||
| 1456 | 1548 | |
| 1457 | 1549 | // Make sure it says we're done. |
| 1458 | 1550 | $upcontext['overall_percent'] = 100; |
| 1459 | - if (isset($upcontext['step_progress'])) |
|
| 1460 | - unset($upcontext['step_progress']); |
|
| 1551 | + if (isset($upcontext['step_progress'])) { |
|
| 1552 | + unset($upcontext['step_progress']); |
|
| 1553 | + } |
|
| 1461 | 1554 | |
| 1462 | 1555 | $_GET['substep'] = 0; |
| 1463 | 1556 | return false; |
@@ -1468,8 +1561,9 @@ discard block |
||
| 1468 | 1561 | { |
| 1469 | 1562 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1470 | 1563 | |
| 1471 | - if (empty($modSettings['time_format'])) |
|
| 1472 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1564 | + if (empty($modSettings['time_format'])) { |
|
| 1565 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1566 | + } |
|
| 1473 | 1567 | |
| 1474 | 1568 | // What files do we want to get |
| 1475 | 1569 | $request = $smcFunc['db_query']('', ' |
@@ -1503,8 +1597,9 @@ discard block |
||
| 1503 | 1597 | $file_data = fetch_web_data($url); |
| 1504 | 1598 | |
| 1505 | 1599 | // If we got an error - give up - the site might be down. |
| 1506 | - if ($file_data === false) |
|
| 1507 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1600 | + if ($file_data === false) { |
|
| 1601 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1602 | + } |
|
| 1508 | 1603 | |
| 1509 | 1604 | // Save the file to the database. |
| 1510 | 1605 | $smcFunc['db_query']('substring', ' |
@@ -1546,8 +1641,9 @@ discard block |
||
| 1546 | 1641 | $themeData = array(); |
| 1547 | 1642 | foreach ($values as $variable => $value) |
| 1548 | 1643 | { |
| 1549 | - if (!isset($value) || $value === null) |
|
| 1550 | - $value = 0; |
|
| 1644 | + if (!isset($value) || $value === null) { |
|
| 1645 | + $value = 0; |
|
| 1646 | + } |
|
| 1551 | 1647 | |
| 1552 | 1648 | $themeData[] = array(0, 1, $variable, $value); |
| 1553 | 1649 | } |
@@ -1576,8 +1672,9 @@ discard block |
||
| 1576 | 1672 | |
| 1577 | 1673 | foreach ($values as $variable => $value) |
| 1578 | 1674 | { |
| 1579 | - if (empty($modSettings[$value[0]])) |
|
| 1580 | - continue; |
|
| 1675 | + if (empty($modSettings[$value[0]])) { |
|
| 1676 | + continue; |
|
| 1677 | + } |
|
| 1581 | 1678 | |
| 1582 | 1679 | $smcFunc['db_query']('', ' |
| 1583 | 1680 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1663,19 +1760,21 @@ discard block |
||
| 1663 | 1760 | set_error_handler( |
| 1664 | 1761 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1665 | 1762 | { |
| 1666 | - if ($support_js) |
|
| 1667 | - return true; |
|
| 1668 | - else |
|
| 1669 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1763 | + if ($support_js) { |
|
| 1764 | + return true; |
|
| 1765 | + } else { |
|
| 1766 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1767 | + } |
|
| 1670 | 1768 | } |
| 1671 | 1769 | ); |
| 1672 | 1770 | |
| 1673 | 1771 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1674 | 1772 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1675 | - if ($db_type == 'mysql') |
|
| 1676 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1677 | - else |
|
| 1678 | - $db_collation = ''; |
|
| 1773 | + if ($db_type == 'mysql') { |
|
| 1774 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1775 | + } else { |
|
| 1776 | + $db_collation = ''; |
|
| 1777 | + } |
|
| 1679 | 1778 | |
| 1680 | 1779 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1681 | 1780 | |
@@ -1687,8 +1786,9 @@ discard block |
||
| 1687 | 1786 | $last_step = ''; |
| 1688 | 1787 | |
| 1689 | 1788 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1690 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1691 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1789 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1790 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1791 | + } |
|
| 1692 | 1792 | |
| 1693 | 1793 | // Count the total number of steps within this file - for progress. |
| 1694 | 1794 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1708,15 +1808,18 @@ discard block |
||
| 1708 | 1808 | $do_current = $substep >= $_GET['substep']; |
| 1709 | 1809 | |
| 1710 | 1810 | // Get rid of any comments in the beginning of the line... |
| 1711 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1712 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1811 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1812 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1813 | + } |
|
| 1713 | 1814 | |
| 1714 | 1815 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1715 | - if ($is_debug && !$support_js && $command_line) |
|
| 1716 | - flush(); |
|
| 1816 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1817 | + flush(); |
|
| 1818 | + } |
|
| 1717 | 1819 | |
| 1718 | - if (trim($line) === '') |
|
| 1719 | - continue; |
|
| 1820 | + if (trim($line) === '') { |
|
| 1821 | + continue; |
|
| 1822 | + } |
|
| 1720 | 1823 | |
| 1721 | 1824 | if (trim(substr($line, 0, 3)) === '---') |
| 1722 | 1825 | { |
@@ -1726,8 +1829,9 @@ discard block |
||
| 1726 | 1829 | if (trim($current_data) != '' && $type !== '}') |
| 1727 | 1830 | { |
| 1728 | 1831 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1729 | - if ($command_line) |
|
| 1730 | - echo $upcontext['error_message']; |
|
| 1832 | + if ($command_line) { |
|
| 1833 | + echo $upcontext['error_message']; |
|
| 1834 | + } |
|
| 1731 | 1835 | } |
| 1732 | 1836 | |
| 1733 | 1837 | if ($type == ' ') |
@@ -1745,17 +1849,18 @@ discard block |
||
| 1745 | 1849 | if ($do_current) |
| 1746 | 1850 | { |
| 1747 | 1851 | $upcontext['actioned_items'][] = $last_step; |
| 1748 | - if ($command_line) |
|
| 1749 | - echo ' * '; |
|
| 1852 | + if ($command_line) { |
|
| 1853 | + echo ' * '; |
|
| 1854 | + } |
|
| 1750 | 1855 | } |
| 1751 | - } |
|
| 1752 | - elseif ($type == '#') |
|
| 1856 | + } elseif ($type == '#') |
|
| 1753 | 1857 | { |
| 1754 | 1858 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1755 | 1859 | |
| 1756 | 1860 | $upcontext['current_debug_item_num']++; |
| 1757 | - if (trim($line) != '---#') |
|
| 1758 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1861 | + if (trim($line) != '---#') { |
|
| 1862 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1863 | + } |
|
| 1759 | 1864 | |
| 1760 | 1865 | // Have we already done something? |
| 1761 | 1866 | if (isset($_GET['xml']) && $done_something) |
@@ -1766,34 +1871,36 @@ discard block |
||
| 1766 | 1871 | |
| 1767 | 1872 | if ($do_current) |
| 1768 | 1873 | { |
| 1769 | - if (trim($line) == '---#' && $command_line) |
|
| 1770 | - echo ' done.', $endl; |
|
| 1771 | - elseif ($command_line) |
|
| 1772 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1773 | - elseif (trim($line) != '---#') |
|
| 1874 | + if (trim($line) == '---#' && $command_line) { |
|
| 1875 | + echo ' done.', $endl; |
|
| 1876 | + } elseif ($command_line) { |
|
| 1877 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1878 | + } elseif (trim($line) != '---#') |
|
| 1774 | 1879 | { |
| 1775 | - if ($is_debug) |
|
| 1776 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1880 | + if ($is_debug) { |
|
| 1881 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1882 | + } |
|
| 1777 | 1883 | } |
| 1778 | 1884 | } |
| 1779 | 1885 | |
| 1780 | 1886 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1781 | 1887 | { |
| 1782 | - if ($command_line) |
|
| 1783 | - echo ' * '; |
|
| 1784 | - else |
|
| 1785 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1888 | + if ($command_line) { |
|
| 1889 | + echo ' * '; |
|
| 1890 | + } else { |
|
| 1891 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1892 | + } |
|
| 1786 | 1893 | } |
| 1787 | 1894 | |
| 1788 | 1895 | // Small step - only if we're actually doing stuff. |
| 1789 | - if ($do_current) |
|
| 1790 | - nextSubstep(++$substep); |
|
| 1791 | - else |
|
| 1792 | - $substep++; |
|
| 1793 | - } |
|
| 1794 | - elseif ($type == '{') |
|
| 1795 | - $current_type = 'code'; |
|
| 1796 | - elseif ($type == '}') |
|
| 1896 | + if ($do_current) { |
|
| 1897 | + nextSubstep(++$substep); |
|
| 1898 | + } else { |
|
| 1899 | + $substep++; |
|
| 1900 | + } |
|
| 1901 | + } elseif ($type == '{') { |
|
| 1902 | + $current_type = 'code'; |
|
| 1903 | + } elseif ($type == '}') |
|
| 1797 | 1904 | { |
| 1798 | 1905 | $current_type = 'sql'; |
| 1799 | 1906 | |
@@ -1806,8 +1913,9 @@ discard block |
||
| 1806 | 1913 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1807 | 1914 | { |
| 1808 | 1915 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1809 | - if ($command_line) |
|
| 1810 | - echo $upcontext['error_message']; |
|
| 1916 | + if ($command_line) { |
|
| 1917 | + echo $upcontext['error_message']; |
|
| 1918 | + } |
|
| 1811 | 1919 | } |
| 1812 | 1920 | |
| 1813 | 1921 | // Done with code! |
@@ -1887,8 +1995,9 @@ discard block |
||
| 1887 | 1995 | $db_unbuffered = false; |
| 1888 | 1996 | |
| 1889 | 1997 | // Failure?! |
| 1890 | - if ($result !== false) |
|
| 1891 | - return $result; |
|
| 1998 | + if ($result !== false) { |
|
| 1999 | + return $result; |
|
| 2000 | + } |
|
| 1892 | 2001 | |
| 1893 | 2002 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1894 | 2003 | // If MySQL we do something more clever. |
@@ -1916,54 +2025,61 @@ discard block |
||
| 1916 | 2025 | { |
| 1917 | 2026 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1918 | 2027 | $result = mysqli_query($db_connection, $string); |
| 1919 | - if ($result !== false) |
|
| 1920 | - return $result; |
|
| 2028 | + if ($result !== false) { |
|
| 2029 | + return $result; |
|
| 2030 | + } |
|
| 1921 | 2031 | } |
| 1922 | - } |
|
| 1923 | - elseif ($mysqli_errno == 2013) |
|
| 2032 | + } elseif ($mysqli_errno == 2013) |
|
| 1924 | 2033 | { |
| 1925 | 2034 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1926 | 2035 | mysqli_select_db($db_connection, $db_name); |
| 1927 | 2036 | if ($db_connection) |
| 1928 | 2037 | { |
| 1929 | 2038 | $result = mysqli_query($db_connection, $string); |
| 1930 | - if ($result !== false) |
|
| 1931 | - return $result; |
|
| 2039 | + if ($result !== false) { |
|
| 2040 | + return $result; |
|
| 2041 | + } |
|
| 1932 | 2042 | } |
| 1933 | 2043 | } |
| 1934 | 2044 | // Duplicate column name... should be okay ;). |
| 1935 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1936 | - return false; |
|
| 2045 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2046 | + return false; |
|
| 2047 | + } |
|
| 1937 | 2048 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1938 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1939 | - return false; |
|
| 2049 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2050 | + return false; |
|
| 2051 | + } |
|
| 1940 | 2052 | // Creating an index on a non-existent column. |
| 1941 | - elseif ($mysqli_errno == 1072) |
|
| 1942 | - return false; |
|
| 1943 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1944 | - return false; |
|
| 2053 | + elseif ($mysqli_errno == 1072) { |
|
| 2054 | + return false; |
|
| 2055 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2056 | + return false; |
|
| 2057 | + } |
|
| 1945 | 2058 | } |
| 1946 | 2059 | // If a table already exists don't go potty. |
| 1947 | 2060 | else |
| 1948 | 2061 | { |
| 1949 | 2062 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1950 | 2063 | { |
| 1951 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1952 | - return true; |
|
| 1953 | - } |
|
| 1954 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2064 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2065 | + return true; |
|
| 2066 | + } |
|
| 2067 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1955 | 2068 | { |
| 1956 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1957 | - return true; |
|
| 2069 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2070 | + return true; |
|
| 2071 | + } |
|
| 1958 | 2072 | } |
| 1959 | 2073 | } |
| 1960 | 2074 | |
| 1961 | 2075 | // Get the query string so we pass everything. |
| 1962 | 2076 | $query_string = ''; |
| 1963 | - foreach ($_GET as $k => $v) |
|
| 1964 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1965 | - if (strlen($query_string) != 0) |
|
| 1966 | - $query_string = '?' . substr($query_string, 1); |
|
| 2077 | + foreach ($_GET as $k => $v) { |
|
| 2078 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2079 | + } |
|
| 2080 | + if (strlen($query_string) != 0) { |
|
| 2081 | + $query_string = '?' . substr($query_string, 1); |
|
| 2082 | + } |
|
| 1967 | 2083 | |
| 1968 | 2084 | if ($command_line) |
| 1969 | 2085 | { |
@@ -2018,16 +2134,18 @@ discard block |
||
| 2018 | 2134 | { |
| 2019 | 2135 | $found |= 1; |
| 2020 | 2136 | // Do some checks on the data if we have it set. |
| 2021 | - if (isset($change['col_type'])) |
|
| 2022 | - $found &= $change['col_type'] === $column['type']; |
|
| 2023 | - if (isset($change['null_allowed'])) |
|
| 2024 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2025 | - if (isset($change['default'])) |
|
| 2026 | - $found &= $change['default'] === $column['default']; |
|
| 2137 | + if (isset($change['col_type'])) { |
|
| 2138 | + $found &= $change['col_type'] === $column['type']; |
|
| 2139 | + } |
|
| 2140 | + if (isset($change['null_allowed'])) { |
|
| 2141 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2142 | + } |
|
| 2143 | + if (isset($change['default'])) { |
|
| 2144 | + $found &= $change['default'] === $column['default']; |
|
| 2145 | + } |
|
| 2027 | 2146 | } |
| 2028 | 2147 | } |
| 2029 | - } |
|
| 2030 | - elseif ($change['type'] === 'index') |
|
| 2148 | + } elseif ($change['type'] === 'index') |
|
| 2031 | 2149 | { |
| 2032 | 2150 | $request = upgrade_query(' |
| 2033 | 2151 | SHOW INDEX |
@@ -2036,9 +2154,10 @@ discard block |
||
| 2036 | 2154 | { |
| 2037 | 2155 | $cur_index = array(); |
| 2038 | 2156 | |
| 2039 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2040 | - if ($row['Key_name'] === $change['name']) |
|
| 2157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2158 | + if ($row['Key_name'] === $change['name']) |
|
| 2041 | 2159 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2160 | + } |
|
| 2042 | 2161 | |
| 2043 | 2162 | ksort($cur_index, SORT_NUMERIC); |
| 2044 | 2163 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2048,14 +2167,17 @@ discard block |
||
| 2048 | 2167 | } |
| 2049 | 2168 | |
| 2050 | 2169 | // If we're trying to add and it's added, we're done. |
| 2051 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2052 | - return true; |
|
| 2170 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2171 | + return true; |
|
| 2172 | + } |
|
| 2053 | 2173 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2054 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2055 | - return true; |
|
| 2174 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2175 | + return true; |
|
| 2176 | + } |
|
| 2056 | 2177 | // Otherwise is it just a test? |
| 2057 | - elseif ($is_test) |
|
| 2058 | - return false; |
|
| 2178 | + elseif ($is_test) { |
|
| 2179 | + return false; |
|
| 2180 | + } |
|
| 2059 | 2181 | |
| 2060 | 2182 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2061 | 2183 | $running = false; |
@@ -2066,8 +2188,9 @@ discard block |
||
| 2066 | 2188 | SHOW FULL PROCESSLIST'); |
| 2067 | 2189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2068 | 2190 | { |
| 2069 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2070 | - $found = true; |
|
| 2191 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2192 | + $found = true; |
|
| 2193 | + } |
|
| 2071 | 2194 | } |
| 2072 | 2195 | |
| 2073 | 2196 | // Can't find it? Then we need to run it fools! |
@@ -2079,8 +2202,9 @@ discard block |
||
| 2079 | 2202 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2080 | 2203 | ' . $change['text'], true) !== false; |
| 2081 | 2204 | |
| 2082 | - if (!$success) |
|
| 2083 | - return false; |
|
| 2205 | + if (!$success) { |
|
| 2206 | + return false; |
|
| 2207 | + } |
|
| 2084 | 2208 | |
| 2085 | 2209 | // Return |
| 2086 | 2210 | $running = true; |
@@ -2122,8 +2246,9 @@ discard block |
||
| 2122 | 2246 | 'db_error_skip' => true, |
| 2123 | 2247 | ) |
| 2124 | 2248 | ); |
| 2125 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2126 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2249 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2250 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2251 | + } |
|
| 2127 | 2252 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2128 | 2253 | $smcFunc['db_free_result']($request); |
| 2129 | 2254 | |
@@ -2145,18 +2270,19 @@ discard block |
||
| 2145 | 2270 | ) |
| 2146 | 2271 | ); |
| 2147 | 2272 | // No results? Just forget it all together. |
| 2148 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2149 | - unset($table_row['Collation']); |
|
| 2150 | - else |
|
| 2151 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2273 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2274 | + unset($table_row['Collation']); |
|
| 2275 | + } else { |
|
| 2276 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2277 | + } |
|
| 2152 | 2278 | $smcFunc['db_free_result']($request); |
| 2153 | 2279 | } |
| 2154 | 2280 | |
| 2155 | 2281 | if ($column_fix) |
| 2156 | 2282 | { |
| 2157 | 2283 | // Make sure there are no NULL's left. |
| 2158 | - if ($null_fix) |
|
| 2159 | - $smcFunc['db_query']('', ' |
|
| 2284 | + if ($null_fix) { |
|
| 2285 | + $smcFunc['db_query']('', ' |
|
| 2160 | 2286 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2161 | 2287 | SET ' . $change['column'] . ' = {string:default} |
| 2162 | 2288 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2165,6 +2291,7 @@ discard block |
||
| 2165 | 2291 | 'db_error_skip' => true, |
| 2166 | 2292 | ) |
| 2167 | 2293 | ); |
| 2294 | + } |
|
| 2168 | 2295 | |
| 2169 | 2296 | // Do the actual alteration. |
| 2170 | 2297 | $smcFunc['db_query']('', ' |
@@ -2193,8 +2320,9 @@ discard block |
||
| 2193 | 2320 | } |
| 2194 | 2321 | |
| 2195 | 2322 | // Not a column we need to check on? |
| 2196 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2197 | - return; |
|
| 2323 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2324 | + return; |
|
| 2325 | + } |
|
| 2198 | 2326 | |
| 2199 | 2327 | // Break it up you (six|seven). |
| 2200 | 2328 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2213,13 +2341,13 @@ discard block |
||
| 2213 | 2341 | 'new_name' => $temp[2], |
| 2214 | 2342 | )); |
| 2215 | 2343 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2216 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2217 | - return; |
|
| 2344 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2345 | + return; |
|
| 2346 | + } |
|
| 2218 | 2347 | |
| 2219 | 2348 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2220 | 2349 | $smcFunc['db_free_result']($request); |
| 2221 | - } |
|
| 2222 | - else |
|
| 2350 | + } else |
|
| 2223 | 2351 | { |
| 2224 | 2352 | // Do this the old fashion, sure method way. |
| 2225 | 2353 | $request = $smcFunc['db_query']('', ' |
@@ -2230,21 +2358,24 @@ discard block |
||
| 2230 | 2358 | )); |
| 2231 | 2359 | // Mayday! |
| 2232 | 2360 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2233 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2234 | - return; |
|
| 2361 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2362 | + return; |
|
| 2363 | + } |
|
| 2235 | 2364 | |
| 2236 | 2365 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2237 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2238 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2366 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2367 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2239 | 2368 | { |
| 2240 | 2369 | $current_type = $row['Type']; |
| 2370 | + } |
|
| 2241 | 2371 | break; |
| 2242 | 2372 | } |
| 2243 | 2373 | } |
| 2244 | 2374 | |
| 2245 | 2375 | // If this doesn't match, the column may of been altered for a reason. |
| 2246 | - if (trim($current_type) != trim($temp[3])) |
|
| 2247 | - $temp[3] = $current_type; |
|
| 2376 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2377 | + $temp[3] = $current_type; |
|
| 2378 | + } |
|
| 2248 | 2379 | |
| 2249 | 2380 | // Piece this back together. |
| 2250 | 2381 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2256,8 +2387,9 @@ discard block |
||
| 2256 | 2387 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2257 | 2388 | global $step_progress, $is_debug, $upcontext; |
| 2258 | 2389 | |
| 2259 | - if ($_GET['substep'] < $substep) |
|
| 2260 | - $_GET['substep'] = $substep; |
|
| 2390 | + if ($_GET['substep'] < $substep) { |
|
| 2391 | + $_GET['substep'] = $substep; |
|
| 2392 | + } |
|
| 2261 | 2393 | |
| 2262 | 2394 | if ($command_line) |
| 2263 | 2395 | { |
@@ -2270,29 +2402,33 @@ discard block |
||
| 2270 | 2402 | } |
| 2271 | 2403 | |
| 2272 | 2404 | @set_time_limit(300); |
| 2273 | - if (function_exists('apache_reset_timeout')) |
|
| 2274 | - @apache_reset_timeout(); |
|
| 2405 | + if (function_exists('apache_reset_timeout')) { |
|
| 2406 | + @apache_reset_timeout(); |
|
| 2407 | + } |
|
| 2275 | 2408 | |
| 2276 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2277 | - return; |
|
| 2409 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2410 | + return; |
|
| 2411 | + } |
|
| 2278 | 2412 | |
| 2279 | 2413 | // Do we have some custom step progress stuff? |
| 2280 | 2414 | if (!empty($step_progress)) |
| 2281 | 2415 | { |
| 2282 | 2416 | $upcontext['substep_progress'] = 0; |
| 2283 | 2417 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2284 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2285 | - $upcontext['substep_progress'] = 99.9; |
|
| 2286 | - else |
|
| 2287 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2418 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2419 | + $upcontext['substep_progress'] = 99.9; |
|
| 2420 | + } else { |
|
| 2421 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2422 | + } |
|
| 2288 | 2423 | |
| 2289 | 2424 | // Make it nicely rounded. |
| 2290 | 2425 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2291 | 2426 | } |
| 2292 | 2427 | |
| 2293 | 2428 | // If this is XML we just exit right away! |
| 2294 | - if (isset($_GET['xml'])) |
|
| 2295 | - return upgradeExit(); |
|
| 2429 | + if (isset($_GET['xml'])) { |
|
| 2430 | + return upgradeExit(); |
|
| 2431 | + } |
|
| 2296 | 2432 | |
| 2297 | 2433 | // We're going to pause after this! |
| 2298 | 2434 | $upcontext['pause'] = true; |
@@ -2300,13 +2436,15 @@ discard block |
||
| 2300 | 2436 | $upcontext['query_string'] = ''; |
| 2301 | 2437 | foreach ($_GET as $k => $v) |
| 2302 | 2438 | { |
| 2303 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2304 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2439 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2440 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2441 | + } |
|
| 2305 | 2442 | } |
| 2306 | 2443 | |
| 2307 | 2444 | // Custom warning? |
| 2308 | - if (!empty($custom_warning)) |
|
| 2309 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2445 | + if (!empty($custom_warning)) { |
|
| 2446 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2447 | + } |
|
| 2310 | 2448 | |
| 2311 | 2449 | upgradeExit(); |
| 2312 | 2450 | } |
@@ -2321,25 +2459,26 @@ discard block |
||
| 2321 | 2459 | ob_implicit_flush(true); |
| 2322 | 2460 | @set_time_limit(600); |
| 2323 | 2461 | |
| 2324 | - if (!isset($_SERVER['argv'])) |
|
| 2325 | - $_SERVER['argv'] = array(); |
|
| 2462 | + if (!isset($_SERVER['argv'])) { |
|
| 2463 | + $_SERVER['argv'] = array(); |
|
| 2464 | + } |
|
| 2326 | 2465 | $_GET['maint'] = 1; |
| 2327 | 2466 | |
| 2328 | 2467 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2329 | 2468 | { |
| 2330 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2331 | - $_GET['lang'] = $match[1]; |
|
| 2332 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2333 | - continue; |
|
| 2334 | - elseif ($arg == '--no-maintenance') |
|
| 2335 | - $_GET['maint'] = 0; |
|
| 2336 | - elseif ($arg == '--debug') |
|
| 2337 | - $is_debug = true; |
|
| 2338 | - elseif ($arg == '--backup') |
|
| 2339 | - $_POST['backup'] = 1; |
|
| 2340 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2341 | - $_GET['conv'] = 1; |
|
| 2342 | - elseif ($i != 0) |
|
| 2469 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2470 | + $_GET['lang'] = $match[1]; |
|
| 2471 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2472 | + continue; |
|
| 2473 | + } elseif ($arg == '--no-maintenance') { |
|
| 2474 | + $_GET['maint'] = 0; |
|
| 2475 | + } elseif ($arg == '--debug') { |
|
| 2476 | + $is_debug = true; |
|
| 2477 | + } elseif ($arg == '--backup') { |
|
| 2478 | + $_POST['backup'] = 1; |
|
| 2479 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2480 | + $_GET['conv'] = 1; |
|
| 2481 | + } elseif ($i != 0) |
|
| 2343 | 2482 | { |
| 2344 | 2483 | echo 'SMF Command-line Upgrader |
| 2345 | 2484 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2353,10 +2492,12 @@ discard block |
||
| 2353 | 2492 | } |
| 2354 | 2493 | } |
| 2355 | 2494 | |
| 2356 | - if (!php_version_check()) |
|
| 2357 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2358 | - if (!db_version_check()) |
|
| 2359 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2495 | + if (!php_version_check()) { |
|
| 2496 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2497 | + } |
|
| 2498 | + if (!db_version_check()) { |
|
| 2499 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2500 | + } |
|
| 2360 | 2501 | |
| 2361 | 2502 | // Do some checks to make sure they have proper privileges |
| 2362 | 2503 | db_extend('packages'); |
@@ -2371,34 +2512,39 @@ discard block |
||
| 2371 | 2512 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2372 | 2513 | |
| 2373 | 2514 | // Sorry... we need CREATE, ALTER and DROP |
| 2374 | - if (!$create || !$alter || !$drop) |
|
| 2375 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2515 | + if (!$create || !$alter || !$drop) { |
|
| 2516 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2517 | + } |
|
| 2376 | 2518 | |
| 2377 | 2519 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2378 | 2520 | && @file_exists($sourcedir . '/QueryString.php') |
| 2379 | 2521 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2380 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2381 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2522 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2523 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2524 | + } |
|
| 2382 | 2525 | |
| 2383 | 2526 | // Do a quick version spot check. |
| 2384 | 2527 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2385 | 2528 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2386 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2387 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2529 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2530 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2531 | + } |
|
| 2388 | 2532 | |
| 2389 | 2533 | // Make sure Settings.php is writable. |
| 2390 | 2534 | quickFileWritable($boarddir . '/Settings.php'); |
| 2391 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2392 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2535 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2536 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2537 | + } |
|
| 2393 | 2538 | |
| 2394 | 2539 | // Make sure Settings_bak.php is writable. |
| 2395 | 2540 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2396 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2397 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2541 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2542 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2543 | + } |
|
| 2398 | 2544 | |
| 2399 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2400 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2401 | - elseif (isset($modSettings['agreement'])) |
|
| 2545 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2546 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2547 | + } elseif (isset($modSettings['agreement'])) |
|
| 2402 | 2548 | { |
| 2403 | 2549 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2404 | 2550 | fwrite($fp, $modSettings['agreement']); |
@@ -2408,36 +2554,42 @@ discard block |
||
| 2408 | 2554 | // Make sure Themes is writable. |
| 2409 | 2555 | quickFileWritable($modSettings['theme_dir']); |
| 2410 | 2556 | |
| 2411 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2412 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2557 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2558 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2559 | + } |
|
| 2413 | 2560 | |
| 2414 | 2561 | // Make sure cache directory exists and is writable! |
| 2415 | 2562 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2416 | - if (!file_exists($cachedir_temp)) |
|
| 2417 | - @mkdir($cachedir_temp); |
|
| 2563 | + if (!file_exists($cachedir_temp)) { |
|
| 2564 | + @mkdir($cachedir_temp); |
|
| 2565 | + } |
|
| 2418 | 2566 | |
| 2419 | 2567 | // Make sure the cache temp dir is writable. |
| 2420 | 2568 | quickFileWritable($cachedir_temp); |
| 2421 | 2569 | |
| 2422 | - if (!is_writable($cachedir_temp)) |
|
| 2423 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2570 | + if (!is_writable($cachedir_temp)) { |
|
| 2571 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2572 | + } |
|
| 2424 | 2573 | |
| 2425 | 2574 | // Make sure db_last_error.php is writable. |
| 2426 | 2575 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2427 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2428 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2576 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2577 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2578 | + } |
|
| 2429 | 2579 | |
| 2430 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2431 | - print_error('Error: Unable to find language files!', true); |
|
| 2432 | - else |
|
| 2580 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2581 | + print_error('Error: Unable to find language files!', true); |
|
| 2582 | + } else |
|
| 2433 | 2583 | { |
| 2434 | 2584 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2435 | 2585 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2436 | 2586 | |
| 2437 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2438 | - print_error('Error: Language files out of date.', true); |
|
| 2439 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2440 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2587 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2588 | + print_error('Error: Language files out of date.', true); |
|
| 2589 | + } |
|
| 2590 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2591 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2592 | + } |
|
| 2441 | 2593 | |
| 2442 | 2594 | // Otherwise include it! |
| 2443 | 2595 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2456,8 +2608,9 @@ discard block |
||
| 2456 | 2608 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2457 | 2609 | |
| 2458 | 2610 | // Done it already? |
| 2459 | - if (!empty($_POST['utf8_done'])) |
|
| 2460 | - return true; |
|
| 2611 | + if (!empty($_POST['utf8_done'])) { |
|
| 2612 | + return true; |
|
| 2613 | + } |
|
| 2461 | 2614 | |
| 2462 | 2615 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2463 | 2616 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2470,8 +2623,7 @@ discard block |
||
| 2470 | 2623 | ); |
| 2471 | 2624 | |
| 2472 | 2625 | return true; |
| 2473 | - } |
|
| 2474 | - else |
|
| 2626 | + } else |
|
| 2475 | 2627 | { |
| 2476 | 2628 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2477 | 2629 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2515,8 +2667,9 @@ discard block |
||
| 2515 | 2667 | ) |
| 2516 | 2668 | ); |
| 2517 | 2669 | $db_charsets = array(); |
| 2518 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2519 | - $db_charsets[] = $row['Charset']; |
|
| 2670 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2671 | + $db_charsets[] = $row['Charset']; |
|
| 2672 | + } |
|
| 2520 | 2673 | |
| 2521 | 2674 | $smcFunc['db_free_result']($request); |
| 2522 | 2675 | |
@@ -2552,13 +2705,15 @@ discard block |
||
| 2552 | 2705 | // If there's a fulltext index, we need to drop it first... |
| 2553 | 2706 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2554 | 2707 | { |
| 2555 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2556 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2708 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2709 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2557 | 2710 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2711 | + } |
|
| 2558 | 2712 | $smcFunc['db_free_result']($request); |
| 2559 | 2713 | |
| 2560 | - if (isset($upcontext['fulltext_index'])) |
|
| 2561 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2714 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2715 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2716 | + } |
|
| 2562 | 2717 | } |
| 2563 | 2718 | |
| 2564 | 2719 | // Drop it and make a note... |
@@ -2748,8 +2903,9 @@ discard block |
||
| 2748 | 2903 | $replace = '%field%'; |
| 2749 | 2904 | |
| 2750 | 2905 | // Build a huge REPLACE statement... |
| 2751 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2752 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2906 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2907 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2908 | + } |
|
| 2753 | 2909 | } |
| 2754 | 2910 | |
| 2755 | 2911 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2759,9 +2915,10 @@ discard block |
||
| 2759 | 2915 | $upcontext['table_count'] = count($queryTables); |
| 2760 | 2916 | |
| 2761 | 2917 | // What ones have we already done? |
| 2762 | - foreach ($queryTables as $id => $table) |
|
| 2763 | - if ($id < $_GET['substep']) |
|
| 2918 | + foreach ($queryTables as $id => $table) { |
|
| 2919 | + if ($id < $_GET['substep']) |
|
| 2764 | 2920 | $upcontext['previous_tables'][] = $table; |
| 2921 | + } |
|
| 2765 | 2922 | |
| 2766 | 2923 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2767 | 2924 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2798,8 +2955,9 @@ discard block |
||
| 2798 | 2955 | nextSubstep($substep); |
| 2799 | 2956 | |
| 2800 | 2957 | // Just to make sure it doesn't time out. |
| 2801 | - if (function_exists('apache_reset_timeout')) |
|
| 2802 | - @apache_reset_timeout(); |
|
| 2958 | + if (function_exists('apache_reset_timeout')) { |
|
| 2959 | + @apache_reset_timeout(); |
|
| 2960 | + } |
|
| 2803 | 2961 | |
| 2804 | 2962 | $table_charsets = array(); |
| 2805 | 2963 | |
@@ -2822,8 +2980,9 @@ discard block |
||
| 2822 | 2980 | |
| 2823 | 2981 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2824 | 2982 | if ($charset != 'utf8') { |
| 2825 | - if (!isset($table_charsets[$charset])) |
|
| 2826 | - $table_charsets[$charset] = array(); |
|
| 2983 | + if (!isset($table_charsets[$charset])) { |
|
| 2984 | + $table_charsets[$charset] = array(); |
|
| 2985 | + } |
|
| 2827 | 2986 | |
| 2828 | 2987 | $table_charsets[$charset][] = $column_info; |
| 2829 | 2988 | } |
@@ -2864,10 +3023,11 @@ discard block |
||
| 2864 | 3023 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2865 | 3024 | { |
| 2866 | 3025 | $update = ''; |
| 2867 | - foreach ($table_charsets as $charset => $columns) |
|
| 2868 | - foreach ($columns as $column) |
|
| 3026 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3027 | + foreach ($columns as $column) |
|
| 2869 | 3028 | $update .= ' |
| 2870 | 3029 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3030 | + } |
|
| 2871 | 3031 | |
| 2872 | 3032 | $smcFunc['db_query']('', ' |
| 2873 | 3033 | UPDATE {raw:table_name} |
@@ -2892,8 +3052,9 @@ discard block |
||
| 2892 | 3052 | // Now do the actual conversion (if still needed). |
| 2893 | 3053 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2894 | 3054 | { |
| 2895 | - if ($command_line) |
|
| 2896 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3055 | + if ($command_line) { |
|
| 3056 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3057 | + } |
|
| 2897 | 3058 | |
| 2898 | 3059 | $smcFunc['db_query']('', ' |
| 2899 | 3060 | ALTER TABLE {raw:table_name} |
@@ -2903,12 +3064,14 @@ discard block |
||
| 2903 | 3064 | ) |
| 2904 | 3065 | ); |
| 2905 | 3066 | |
| 2906 | - if ($command_line) |
|
| 2907 | - echo " done.\n"; |
|
| 3067 | + if ($command_line) { |
|
| 3068 | + echo " done.\n"; |
|
| 3069 | + } |
|
| 2908 | 3070 | } |
| 2909 | 3071 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2910 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 2911 | - return upgradeExit(); |
|
| 3072 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3073 | + return upgradeExit(); |
|
| 3074 | + } |
|
| 2912 | 3075 | } |
| 2913 | 3076 | |
| 2914 | 3077 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2937,8 +3100,8 @@ discard block |
||
| 2937 | 3100 | ); |
| 2938 | 3101 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2939 | 3102 | { |
| 2940 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 2941 | - $smcFunc['db_query']('', ' |
|
| 3103 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3104 | + $smcFunc['db_query']('', ' |
|
| 2942 | 3105 | UPDATE {db_prefix}log_actions |
| 2943 | 3106 | SET extra = {string:extra} |
| 2944 | 3107 | WHERE id_action = {int:current_action}', |
@@ -2947,6 +3110,7 @@ discard block |
||
| 2947 | 3110 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2948 | 3111 | ) |
| 2949 | 3112 | ); |
| 3113 | + } |
|
| 2950 | 3114 | } |
| 2951 | 3115 | $smcFunc['db_free_result']($request); |
| 2952 | 3116 | |
@@ -2968,15 +3132,17 @@ discard block |
||
| 2968 | 3132 | // First thing's first - did we already do this? |
| 2969 | 3133 | if (!empty($modSettings['json_done'])) |
| 2970 | 3134 | { |
| 2971 | - if ($command_line) |
|
| 2972 | - return DeleteUpgrade(); |
|
| 2973 | - else |
|
| 2974 | - return true; |
|
| 3135 | + if ($command_line) { |
|
| 3136 | + return DeleteUpgrade(); |
|
| 3137 | + } else { |
|
| 3138 | + return true; |
|
| 3139 | + } |
|
| 2975 | 3140 | } |
| 2976 | 3141 | |
| 2977 | 3142 | // Done it already - js wise? |
| 2978 | - if (!empty($_POST['json_done'])) |
|
| 2979 | - return true; |
|
| 3143 | + if (!empty($_POST['json_done'])) { |
|
| 3144 | + return true; |
|
| 3145 | + } |
|
| 2980 | 3146 | |
| 2981 | 3147 | // List of tables affected by this function |
| 2982 | 3148 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3008,12 +3174,14 @@ discard block |
||
| 3008 | 3174 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3009 | 3175 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3010 | 3176 | |
| 3011 | - foreach ($keys as $id => $table) |
|
| 3012 | - if ($id < $_GET['substep']) |
|
| 3177 | + foreach ($keys as $id => $table) { |
|
| 3178 | + if ($id < $_GET['substep']) |
|
| 3013 | 3179 | $upcontext['previous_tables'][] = $table; |
| 3180 | + } |
|
| 3014 | 3181 | |
| 3015 | - if ($command_line) |
|
| 3016 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3182 | + if ($command_line) { |
|
| 3183 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3184 | + } |
|
| 3017 | 3185 | |
| 3018 | 3186 | if (!$support_js || isset($_GET['xml'])) |
| 3019 | 3187 | { |
@@ -3053,8 +3221,9 @@ discard block |
||
| 3053 | 3221 | |
| 3054 | 3222 | // Loop through and fix these... |
| 3055 | 3223 | $new_settings = array(); |
| 3056 | - if ($command_line) |
|
| 3057 | - echo "\n" . 'Fixing some settings...'; |
|
| 3224 | + if ($command_line) { |
|
| 3225 | + echo "\n" . 'Fixing some settings...'; |
|
| 3226 | + } |
|
| 3058 | 3227 | |
| 3059 | 3228 | foreach ($serialized_settings as $var) |
| 3060 | 3229 | { |
@@ -3062,22 +3231,24 @@ discard block |
||
| 3062 | 3231 | { |
| 3063 | 3232 | // Attempt to unserialize the setting |
| 3064 | 3233 | $temp = @safe_unserialize($modSettings[$var]); |
| 3065 | - if (!$temp && $command_line) |
|
| 3066 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3067 | - elseif ($temp !== false) |
|
| 3068 | - $new_settings[$var] = json_encode($temp); |
|
| 3234 | + if (!$temp && $command_line) { |
|
| 3235 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3236 | + } elseif ($temp !== false) { |
|
| 3237 | + $new_settings[$var] = json_encode($temp); |
|
| 3238 | + } |
|
| 3069 | 3239 | } |
| 3070 | 3240 | } |
| 3071 | 3241 | |
| 3072 | 3242 | // Update everything at once |
| 3073 | - if (!function_exists('cache_put_data')) |
|
| 3074 | - require_once($sourcedir . '/Load.php'); |
|
| 3243 | + if (!function_exists('cache_put_data')) { |
|
| 3244 | + require_once($sourcedir . '/Load.php'); |
|
| 3245 | + } |
|
| 3075 | 3246 | updateSettings($new_settings, true); |
| 3076 | 3247 | |
| 3077 | - if ($command_line) |
|
| 3078 | - echo ' done.'; |
|
| 3079 | - } |
|
| 3080 | - elseif ($table == 'themes') |
|
| 3248 | + if ($command_line) { |
|
| 3249 | + echo ' done.'; |
|
| 3250 | + } |
|
| 3251 | + } elseif ($table == 'themes') |
|
| 3081 | 3252 | { |
| 3082 | 3253 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3083 | 3254 | $query = $smcFunc['db_query']('', ' |
@@ -3096,10 +3267,11 @@ discard block |
||
| 3096 | 3267 | |
| 3097 | 3268 | if ($command_line) |
| 3098 | 3269 | { |
| 3099 | - if ($temp === false) |
|
| 3100 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3101 | - else |
|
| 3102 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3270 | + if ($temp === false) { |
|
| 3271 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3272 | + } else { |
|
| 3273 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3274 | + } |
|
| 3103 | 3275 | } |
| 3104 | 3276 | |
| 3105 | 3277 | if ($temp !== false) |
@@ -3121,15 +3293,15 @@ discard block |
||
| 3121 | 3293 | ) |
| 3122 | 3294 | ); |
| 3123 | 3295 | |
| 3124 | - if ($command_line) |
|
| 3125 | - echo ' done.'; |
|
| 3296 | + if ($command_line) { |
|
| 3297 | + echo ' done.'; |
|
| 3298 | + } |
|
| 3126 | 3299 | } |
| 3127 | 3300 | } |
| 3128 | 3301 | |
| 3129 | 3302 | $smcFunc['db_free_result']($query); |
| 3130 | 3303 | } |
| 3131 | - } |
|
| 3132 | - else |
|
| 3304 | + } else |
|
| 3133 | 3305 | { |
| 3134 | 3306 | // First item is always the key... |
| 3135 | 3307 | $key = $info[0]; |
@@ -3140,8 +3312,7 @@ discard block |
||
| 3140 | 3312 | { |
| 3141 | 3313 | $col_select = $info[1]; |
| 3142 | 3314 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3143 | - } |
|
| 3144 | - else |
|
| 3315 | + } else |
|
| 3145 | 3316 | { |
| 3146 | 3317 | $col_select = implode(', ', $info); |
| 3147 | 3318 | } |
@@ -3174,8 +3345,7 @@ discard block |
||
| 3174 | 3345 | if ($temp === false && $command_line) |
| 3175 | 3346 | { |
| 3176 | 3347 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3177 | - } |
|
| 3178 | - else |
|
| 3348 | + } else |
|
| 3179 | 3349 | { |
| 3180 | 3350 | $row[$col] = json_encode($temp); |
| 3181 | 3351 | |
@@ -3200,16 +3370,18 @@ discard block |
||
| 3200 | 3370 | } |
| 3201 | 3371 | } |
| 3202 | 3372 | |
| 3203 | - if ($command_line) |
|
| 3204 | - echo ' done.'; |
|
| 3373 | + if ($command_line) { |
|
| 3374 | + echo ' done.'; |
|
| 3375 | + } |
|
| 3205 | 3376 | |
| 3206 | 3377 | // Free up some memory... |
| 3207 | 3378 | $smcFunc['db_free_result']($query); |
| 3208 | 3379 | } |
| 3209 | 3380 | } |
| 3210 | 3381 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3211 | - if (isset($_GET['xml'])) |
|
| 3212 | - return upgradeExit(); |
|
| 3382 | + if (isset($_GET['xml'])) { |
|
| 3383 | + return upgradeExit(); |
|
| 3384 | + } |
|
| 3213 | 3385 | } |
| 3214 | 3386 | |
| 3215 | 3387 | if ($command_line) |
@@ -3224,8 +3396,9 @@ discard block |
||
| 3224 | 3396 | |
| 3225 | 3397 | $_GET['substep'] = 0; |
| 3226 | 3398 | // Make sure we move on! |
| 3227 | - if ($command_line) |
|
| 3228 | - return DeleteUpgrade(); |
|
| 3399 | + if ($command_line) { |
|
| 3400 | + return DeleteUpgrade(); |
|
| 3401 | + } |
|
| 3229 | 3402 | |
| 3230 | 3403 | return true; |
| 3231 | 3404 | } |
@@ -3245,14 +3418,16 @@ discard block |
||
| 3245 | 3418 | global $upcontext, $txt, $settings; |
| 3246 | 3419 | |
| 3247 | 3420 | // Don't call me twice! |
| 3248 | - if (!empty($upcontext['chmod_called'])) |
|
| 3249 | - return; |
|
| 3421 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3422 | + return; |
|
| 3423 | + } |
|
| 3250 | 3424 | |
| 3251 | 3425 | $upcontext['chmod_called'] = true; |
| 3252 | 3426 | |
| 3253 | 3427 | // Nothing? |
| 3254 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3255 | - return; |
|
| 3428 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3429 | + return; |
|
| 3430 | + } |
|
| 3256 | 3431 | |
| 3257 | 3432 | // Was it a problem with Windows? |
| 3258 | 3433 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3284,11 +3459,12 @@ discard block |
||
| 3284 | 3459 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3285 | 3460 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3286 | 3461 | |
| 3287 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3288 | - echo ' |
|
| 3462 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3463 | + echo ' |
|
| 3289 | 3464 | content.write(\'<hr>\n\t\t\t\'); |
| 3290 | 3465 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3291 | 3466 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3467 | + } |
|
| 3292 | 3468 | |
| 3293 | 3469 | echo ' |
| 3294 | 3470 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3296,17 +3472,19 @@ discard block |
||
| 3296 | 3472 | } |
| 3297 | 3473 | </script>'; |
| 3298 | 3474 | |
| 3299 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3300 | - echo ' |
|
| 3475 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3476 | + echo ' |
|
| 3301 | 3477 | <div class="error_message red"> |
| 3302 | 3478 | The following error was encountered when trying to connect:<br><br> |
| 3303 | 3479 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3304 | 3480 | </div> |
| 3305 | 3481 | <br>'; |
| 3482 | + } |
|
| 3306 | 3483 | |
| 3307 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3308 | - echo ' |
|
| 3484 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3485 | + echo ' |
|
| 3309 | 3486 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3487 | + } |
|
| 3310 | 3488 | |
| 3311 | 3489 | echo ' |
| 3312 | 3490 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3341,10 +3519,11 @@ discard block |
||
| 3341 | 3519 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3342 | 3520 | </div>'; |
| 3343 | 3521 | |
| 3344 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3345 | - echo ' |
|
| 3522 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3523 | + echo ' |
|
| 3346 | 3524 | </form>'; |
| 3347 | -} |
|
| 3525 | + } |
|
| 3526 | + } |
|
| 3348 | 3527 | |
| 3349 | 3528 | function template_upgrade_above() |
| 3350 | 3529 | { |
@@ -3404,9 +3583,10 @@ discard block |
||
| 3404 | 3583 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3405 | 3584 | <ul>'; |
| 3406 | 3585 | |
| 3407 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3408 | - echo ' |
|
| 3586 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3587 | + echo ' |
|
| 3409 | 3588 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3589 | + } |
|
| 3410 | 3590 | |
| 3411 | 3591 | echo ' |
| 3412 | 3592 | </ul> |
@@ -3419,8 +3599,8 @@ discard block |
||
| 3419 | 3599 | </div> |
| 3420 | 3600 | </div>'; |
| 3421 | 3601 | |
| 3422 | - if (isset($upcontext['step_progress'])) |
|
| 3423 | - echo ' |
|
| 3602 | + if (isset($upcontext['step_progress'])) { |
|
| 3603 | + echo ' |
|
| 3424 | 3604 | <br> |
| 3425 | 3605 | <br> |
| 3426 | 3606 | <div id="progress_bar_step"> |
@@ -3429,6 +3609,7 @@ discard block |
||
| 3429 | 3609 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3430 | 3610 | </div> |
| 3431 | 3611 | </div>'; |
| 3612 | + } |
|
| 3432 | 3613 | |
| 3433 | 3614 | echo ' |
| 3434 | 3615 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3459,32 +3640,36 @@ discard block |
||
| 3459 | 3640 | { |
| 3460 | 3641 | global $upcontext, $txt; |
| 3461 | 3642 | |
| 3462 | - if (!empty($upcontext['pause'])) |
|
| 3463 | - echo ' |
|
| 3643 | + if (!empty($upcontext['pause'])) { |
|
| 3644 | + echo ' |
|
| 3464 | 3645 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3465 | 3646 | |
| 3466 | 3647 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3467 | 3648 | <h3> |
| 3468 | 3649 | ', $txt['upgrade_paused_overload'], ' |
| 3469 | 3650 | </h3>'; |
| 3651 | + } |
|
| 3470 | 3652 | |
| 3471 | - if (!empty($upcontext['custom_warning'])) |
|
| 3472 | - echo ' |
|
| 3653 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3654 | + echo ' |
|
| 3473 | 3655 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3474 | 3656 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3475 | 3657 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3476 | 3658 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3477 | 3659 | </div>'; |
| 3660 | + } |
|
| 3478 | 3661 | |
| 3479 | 3662 | echo ' |
| 3480 | 3663 | <div class="righttext" style="margin: 1ex;">'; |
| 3481 | 3664 | |
| 3482 | - if (!empty($upcontext['continue'])) |
|
| 3483 | - echo ' |
|
| 3665 | + if (!empty($upcontext['continue'])) { |
|
| 3666 | + echo ' |
|
| 3484 | 3667 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3485 | - if (!empty($upcontext['skip'])) |
|
| 3486 | - echo ' |
|
| 3668 | + } |
|
| 3669 | + if (!empty($upcontext['skip'])) { |
|
| 3670 | + echo ' |
|
| 3487 | 3671 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3672 | + } |
|
| 3488 | 3673 | |
| 3489 | 3674 | echo ' |
| 3490 | 3675 | </div> |
@@ -3534,11 +3719,12 @@ discard block |
||
| 3534 | 3719 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3535 | 3720 | <smf>'; |
| 3536 | 3721 | |
| 3537 | - if (!empty($upcontext['get_data'])) |
|
| 3538 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3722 | + if (!empty($upcontext['get_data'])) { |
|
| 3723 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3539 | 3724 | echo ' |
| 3540 | 3725 | <get key="', $k, '">', $v, '</get>'; |
| 3541 | -} |
|
| 3726 | + } |
|
| 3727 | + } |
|
| 3542 | 3728 | |
| 3543 | 3729 | function template_xml_below() |
| 3544 | 3730 | { |
@@ -3579,8 +3765,8 @@ discard block |
||
| 3579 | 3765 | template_chmod(); |
| 3580 | 3766 | |
| 3581 | 3767 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3582 | - if ($upcontext['is_large_forum']) |
|
| 3583 | - echo ' |
|
| 3768 | + if ($upcontext['is_large_forum']) { |
|
| 3769 | + echo ' |
|
| 3584 | 3770 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3585 | 3771 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3586 | 3772 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3588,10 +3774,11 @@ discard block |
||
| 3588 | 3774 | ', $txt['upgrade_warning_lots_data'], ' |
| 3589 | 3775 | </div> |
| 3590 | 3776 | </div>'; |
| 3777 | + } |
|
| 3591 | 3778 | |
| 3592 | 3779 | // A warning message? |
| 3593 | - if (!empty($upcontext['warning'])) |
|
| 3594 | - echo ' |
|
| 3780 | + if (!empty($upcontext['warning'])) { |
|
| 3781 | + echo ' |
|
| 3595 | 3782 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3596 | 3783 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3597 | 3784 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3599,6 +3786,7 @@ discard block |
||
| 3599 | 3786 | ', $upcontext['warning'], ' |
| 3600 | 3787 | </div> |
| 3601 | 3788 | </div>'; |
| 3789 | + } |
|
| 3602 | 3790 | |
| 3603 | 3791 | // Paths are incorrect? |
| 3604 | 3792 | echo ' |
@@ -3614,20 +3802,22 @@ discard block |
||
| 3614 | 3802 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3615 | 3803 | { |
| 3616 | 3804 | $ago = time() - $upcontext['started']; |
| 3617 | - if ($ago < 60) |
|
| 3618 | - $ago = $ago . ' seconds'; |
|
| 3619 | - elseif ($ago < 3600) |
|
| 3620 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3621 | - else |
|
| 3622 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3805 | + if ($ago < 60) { |
|
| 3806 | + $ago = $ago . ' seconds'; |
|
| 3807 | + } elseif ($ago < 3600) { |
|
| 3808 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3809 | + } else { |
|
| 3810 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3811 | + } |
|
| 3623 | 3812 | |
| 3624 | 3813 | $active = time() - $upcontext['updated']; |
| 3625 | - if ($active < 60) |
|
| 3626 | - $updated = $active . ' seconds'; |
|
| 3627 | - elseif ($active < 3600) |
|
| 3628 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3629 | - else |
|
| 3630 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3814 | + if ($active < 60) { |
|
| 3815 | + $updated = $active . ' seconds'; |
|
| 3816 | + } elseif ($active < 3600) { |
|
| 3817 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3818 | + } else { |
|
| 3819 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3820 | + } |
|
| 3631 | 3821 | |
| 3632 | 3822 | echo ' |
| 3633 | 3823 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3636,16 +3826,18 @@ discard block |
||
| 3636 | 3826 | <div style="padding-left: 6ex;"> |
| 3637 | 3827 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3638 | 3828 | |
| 3639 | - if ($active < 600) |
|
| 3640 | - echo ' |
|
| 3829 | + if ($active < 600) { |
|
| 3830 | + echo ' |
|
| 3641 | 3831 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3832 | + } |
|
| 3642 | 3833 | |
| 3643 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3644 | - echo ' |
|
| 3834 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3835 | + echo ' |
|
| 3645 | 3836 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3646 | - else |
|
| 3647 | - echo ' |
|
| 3837 | + } else { |
|
| 3838 | + echo ' |
|
| 3648 | 3839 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3840 | + } |
|
| 3649 | 3841 | |
| 3650 | 3842 | echo ' |
| 3651 | 3843 | </div> |
@@ -3661,9 +3853,10 @@ discard block |
||
| 3661 | 3853 | <td> |
| 3662 | 3854 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3663 | 3855 | |
| 3664 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3665 | - echo ' |
|
| 3856 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3857 | + echo ' |
|
| 3666 | 3858 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3859 | + } |
|
| 3667 | 3860 | |
| 3668 | 3861 | echo ' |
| 3669 | 3862 | </td> |
@@ -3674,9 +3867,10 @@ discard block |
||
| 3674 | 3867 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3675 | 3868 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3676 | 3869 | |
| 3677 | - if (!empty($upcontext['password_failed'])) |
|
| 3678 | - echo ' |
|
| 3870 | + if (!empty($upcontext['password_failed'])) { |
|
| 3871 | + echo ' |
|
| 3679 | 3872 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3873 | + } |
|
| 3680 | 3874 | |
| 3681 | 3875 | echo ' |
| 3682 | 3876 | </td> |
@@ -3747,8 +3941,8 @@ discard block |
||
| 3747 | 3941 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3748 | 3942 | |
| 3749 | 3943 | // Warning message? |
| 3750 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3751 | - echo ' |
|
| 3944 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3945 | + echo ' |
|
| 3752 | 3946 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3753 | 3947 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3754 | 3948 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3756,6 +3950,7 @@ discard block |
||
| 3756 | 3950 | ', $upcontext['upgrade_options_warning'], ' |
| 3757 | 3951 | </div> |
| 3758 | 3952 | </div>'; |
| 3953 | + } |
|
| 3759 | 3954 | |
| 3760 | 3955 | echo ' |
| 3761 | 3956 | <table> |
@@ -3798,8 +3993,8 @@ discard block |
||
| 3798 | 3993 | </td> |
| 3799 | 3994 | </tr>'; |
| 3800 | 3995 | |
| 3801 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3802 | - echo ' |
|
| 3996 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3997 | + echo ' |
|
| 3803 | 3998 | <tr valign="top"> |
| 3804 | 3999 | <td width="2%"> |
| 3805 | 4000 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3808,6 +4003,7 @@ discard block |
||
| 3808 | 4003 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3809 | 4004 | </td> |
| 3810 | 4005 | </tr>'; |
| 4006 | + } |
|
| 3811 | 4007 | |
| 3812 | 4008 | echo ' |
| 3813 | 4009 | <tr valign="top"> |
@@ -3845,10 +4041,11 @@ discard block |
||
| 3845 | 4041 | </div>'; |
| 3846 | 4042 | |
| 3847 | 4043 | // Dont any tables so far? |
| 3848 | - if (!empty($upcontext['previous_tables'])) |
|
| 3849 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4044 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4045 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3850 | 4046 | echo ' |
| 3851 | 4047 | <br>Completed Table: "', $table, '".'; |
| 4048 | + } |
|
| 3852 | 4049 | |
| 3853 | 4050 | echo ' |
| 3854 | 4051 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3885,12 +4082,13 @@ discard block |
||
| 3885 | 4082 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3886 | 4083 | |
| 3887 | 4084 | // If debug flood the screen. |
| 3888 | - if ($is_debug) |
|
| 3889 | - echo ' |
|
| 4085 | + if ($is_debug) { |
|
| 4086 | + echo ' |
|
| 3890 | 4087 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3891 | 4088 | |
| 3892 | 4089 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3893 | 4090 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4091 | + } |
|
| 3894 | 4092 | |
| 3895 | 4093 | echo ' |
| 3896 | 4094 | // Get the next update... |
@@ -3923,8 +4121,9 @@ discard block |
||
| 3923 | 4121 | { |
| 3924 | 4122 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3925 | 4123 | |
| 3926 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3927 | - $is_debug = true; |
|
| 4124 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4125 | + $is_debug = true; |
|
| 4126 | + } |
|
| 3928 | 4127 | |
| 3929 | 4128 | echo ' |
| 3930 | 4129 | <h3>Executing database changes</h3> |
@@ -3939,8 +4138,9 @@ discard block |
||
| 3939 | 4138 | { |
| 3940 | 4139 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3941 | 4140 | { |
| 3942 | - if ($num != 0) |
|
| 3943 | - echo ' Successful!'; |
|
| 4141 | + if ($num != 0) { |
|
| 4142 | + echo ' Successful!'; |
|
| 4143 | + } |
|
| 3944 | 4144 | echo '<br>' . $item; |
| 3945 | 4145 | } |
| 3946 | 4146 | if (!empty($upcontext['changes_complete'])) |
@@ -3953,28 +4153,32 @@ discard block |
||
| 3953 | 4153 | $seconds = intval($active % 60); |
| 3954 | 4154 | |
| 3955 | 4155 | $totalTime = ''; |
| 3956 | - if ($hours > 0) |
|
| 3957 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3958 | - if ($minutes > 0) |
|
| 3959 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3960 | - if ($seconds > 0) |
|
| 3961 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4156 | + if ($hours > 0) { |
|
| 4157 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4158 | + } |
|
| 4159 | + if ($minutes > 0) { |
|
| 4160 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4161 | + } |
|
| 4162 | + if ($seconds > 0) { |
|
| 4163 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4164 | + } |
|
| 3962 | 4165 | } |
| 3963 | 4166 | |
| 3964 | - if ($is_debug && !empty($totalTime)) |
|
| 3965 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3966 | - else |
|
| 3967 | - echo ' Successful!<br><br>'; |
|
| 4167 | + if ($is_debug && !empty($totalTime)) { |
|
| 4168 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4169 | + } else { |
|
| 4170 | + echo ' Successful!<br><br>'; |
|
| 4171 | + } |
|
| 3968 | 4172 | |
| 3969 | 4173 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3970 | 4174 | } |
| 3971 | - } |
|
| 3972 | - else |
|
| 4175 | + } else |
|
| 3973 | 4176 | { |
| 3974 | 4177 | // Tell them how many files we have in total. |
| 3975 | - if ($upcontext['file_count'] > 1) |
|
| 3976 | - echo ' |
|
| 4178 | + if ($upcontext['file_count'] > 1) { |
|
| 4179 | + echo ' |
|
| 3977 | 4180 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4181 | + } |
|
| 3978 | 4182 | |
| 3979 | 4183 | echo ' |
| 3980 | 4184 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3990,19 +4194,23 @@ discard block |
||
| 3990 | 4194 | $seconds = intval($active % 60); |
| 3991 | 4195 | |
| 3992 | 4196 | $totalTime = ''; |
| 3993 | - if ($hours > 0) |
|
| 3994 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3995 | - if ($minutes > 0) |
|
| 3996 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3997 | - if ($seconds > 0) |
|
| 3998 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4197 | + if ($hours > 0) { |
|
| 4198 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4199 | + } |
|
| 4200 | + if ($minutes > 0) { |
|
| 4201 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4202 | + } |
|
| 4203 | + if ($seconds > 0) { |
|
| 4204 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4205 | + } |
|
| 3999 | 4206 | } |
| 4000 | 4207 | |
| 4001 | 4208 | echo ' |
| 4002 | 4209 | <br><span id="upgradeCompleted">'; |
| 4003 | 4210 | |
| 4004 | - if (!empty($totalTime)) |
|
| 4005 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4211 | + if (!empty($totalTime)) { |
|
| 4212 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4213 | + } |
|
| 4006 | 4214 | |
| 4007 | 4215 | echo '</span> |
| 4008 | 4216 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4039,9 +4247,10 @@ discard block |
||
| 4039 | 4247 | var getData = ""; |
| 4040 | 4248 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4041 | 4249 | |
| 4042 | - if ($is_debug) |
|
| 4043 | - echo ' |
|
| 4250 | + if ($is_debug) { |
|
| 4251 | + echo ' |
|
| 4044 | 4252 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4253 | + } |
|
| 4045 | 4254 | |
| 4046 | 4255 | echo ' |
| 4047 | 4256 | function getNextItem() |
@@ -4081,9 +4290,10 @@ discard block |
||
| 4081 | 4290 | document.getElementById("error_block").style.display = ""; |
| 4082 | 4291 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4083 | 4292 | |
| 4084 | - if ($is_debug) |
|
| 4085 | - echo ' |
|
| 4293 | + if ($is_debug) { |
|
| 4294 | + echo ' |
|
| 4086 | 4295 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4296 | + } |
|
| 4087 | 4297 | |
| 4088 | 4298 | echo ' |
| 4089 | 4299 | } |
@@ -4104,9 +4314,10 @@ discard block |
||
| 4104 | 4314 | document.getElementById("error_block").style.display = ""; |
| 4105 | 4315 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4106 | 4316 | |
| 4107 | - if ($is_debug) |
|
| 4108 | - echo ' |
|
| 4317 | + if ($is_debug) { |
|
| 4318 | + echo ' |
|
| 4109 | 4319 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4320 | + } |
|
| 4110 | 4321 | |
| 4111 | 4322 | echo ' |
| 4112 | 4323 | } |
@@ -4165,8 +4376,8 @@ discard block |
||
| 4165 | 4376 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4166 | 4377 | {'; |
| 4167 | 4378 | |
| 4168 | - if ($is_debug) |
|
| 4169 | - echo ' |
|
| 4379 | + if ($is_debug) { |
|
| 4380 | + echo ' |
|
| 4170 | 4381 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4171 | 4382 | |
| 4172 | 4383 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4184,6 +4395,7 @@ discard block |
||
| 4184 | 4395 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4185 | 4396 | |
| 4186 | 4397 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4398 | + } |
|
| 4187 | 4399 | |
| 4188 | 4400 | echo ' |
| 4189 | 4401 | |
@@ -4191,9 +4403,10 @@ discard block |
||
| 4191 | 4403 | document.getElementById(\'contbutt\').disabled = 0; |
| 4192 | 4404 | document.getElementById(\'database_done\').value = 1;'; |
| 4193 | 4405 | |
| 4194 | - if ($upcontext['file_count'] > 1) |
|
| 4195 | - echo ' |
|
| 4406 | + if ($upcontext['file_count'] > 1) { |
|
| 4407 | + echo ' |
|
| 4196 | 4408 | document.getElementById(\'info1\').style.display = "none";'; |
| 4409 | + } |
|
| 4197 | 4410 | |
| 4198 | 4411 | echo ' |
| 4199 | 4412 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4206,9 +4419,10 @@ discard block |
||
| 4206 | 4419 | lastItem = 0; |
| 4207 | 4420 | prevFile = curFile;'; |
| 4208 | 4421 | |
| 4209 | - if ($is_debug) |
|
| 4210 | - echo ' |
|
| 4422 | + if ($is_debug) { |
|
| 4423 | + echo ' |
|
| 4211 | 4424 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4425 | + } |
|
| 4212 | 4426 | |
| 4213 | 4427 | echo ' |
| 4214 | 4428 | getNextItem(); |
@@ -4216,8 +4430,8 @@ discard block |
||
| 4216 | 4430 | }'; |
| 4217 | 4431 | |
| 4218 | 4432 | // If debug scroll the screen. |
| 4219 | - if ($is_debug) |
|
| 4220 | - echo ' |
|
| 4433 | + if ($is_debug) { |
|
| 4434 | + echo ' |
|
| 4221 | 4435 | if (iLastSubStepProgress == -1) |
| 4222 | 4436 | { |
| 4223 | 4437 | // Give it consistent dots. |
@@ -4236,6 +4450,7 @@ discard block |
||
| 4236 | 4450 | |
| 4237 | 4451 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4238 | 4452 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4453 | + } |
|
| 4239 | 4454 | |
| 4240 | 4455 | echo ' |
| 4241 | 4456 | // Update the page. |
@@ -4296,9 +4511,10 @@ discard block |
||
| 4296 | 4511 | }'; |
| 4297 | 4512 | |
| 4298 | 4513 | // Start things off assuming we've not errored. |
| 4299 | - if (empty($upcontext['error_message'])) |
|
| 4300 | - echo ' |
|
| 4514 | + if (empty($upcontext['error_message'])) { |
|
| 4515 | + echo ' |
|
| 4301 | 4516 | getNextItem();'; |
| 4517 | + } |
|
| 4302 | 4518 | |
| 4303 | 4519 | echo ' |
| 4304 | 4520 | //# sourceURL=dynamicScript-dbch.js |
@@ -4316,18 +4532,21 @@ discard block |
||
| 4316 | 4532 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4317 | 4533 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4318 | 4534 | |
| 4319 | - if (!empty($upcontext['error_message'])) |
|
| 4320 | - echo ' |
|
| 4535 | + if (!empty($upcontext['error_message'])) { |
|
| 4536 | + echo ' |
|
| 4321 | 4537 | <error>', $upcontext['error_message'], '</error>'; |
| 4538 | + } |
|
| 4322 | 4539 | |
| 4323 | - if (!empty($upcontext['error_string'])) |
|
| 4324 | - echo ' |
|
| 4540 | + if (!empty($upcontext['error_string'])) { |
|
| 4541 | + echo ' |
|
| 4325 | 4542 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4543 | + } |
|
| 4326 | 4544 | |
| 4327 | - if ($is_debug) |
|
| 4328 | - echo ' |
|
| 4545 | + if ($is_debug) { |
|
| 4546 | + echo ' |
|
| 4329 | 4547 | <curtime>', time(), '</curtime>'; |
| 4330 | -} |
|
| 4548 | + } |
|
| 4549 | + } |
|
| 4331 | 4550 | |
| 4332 | 4551 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4333 | 4552 | function template_convert_utf8() |
@@ -4346,18 +4565,20 @@ discard block |
||
| 4346 | 4565 | </div>'; |
| 4347 | 4566 | |
| 4348 | 4567 | // Done any tables so far? |
| 4349 | - if (!empty($upcontext['previous_tables'])) |
|
| 4350 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4568 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4569 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4351 | 4570 | echo ' |
| 4352 | 4571 | <br>Completed Table: "', $table, '".'; |
| 4572 | + } |
|
| 4353 | 4573 | |
| 4354 | 4574 | echo ' |
| 4355 | 4575 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4356 | 4576 | |
| 4357 | 4577 | // If we dropped their index, let's let them know |
| 4358 | - if ($upcontext['dropping_index']) |
|
| 4359 | - echo ' |
|
| 4578 | + if ($upcontext['dropping_index']) { |
|
| 4579 | + echo ' |
|
| 4360 | 4580 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4581 | + } |
|
| 4361 | 4582 | |
| 4362 | 4583 | // Completion notification |
| 4363 | 4584 | echo ' |
@@ -4394,12 +4615,13 @@ discard block |
||
| 4394 | 4615 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4395 | 4616 | |
| 4396 | 4617 | // If debug flood the screen. |
| 4397 | - if ($is_debug) |
|
| 4398 | - echo ' |
|
| 4618 | + if ($is_debug) { |
|
| 4619 | + echo ' |
|
| 4399 | 4620 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4400 | 4621 | |
| 4401 | 4622 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4402 | 4623 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4624 | + } |
|
| 4403 | 4625 | |
| 4404 | 4626 | echo ' |
| 4405 | 4627 | // Get the next update... |
@@ -4447,19 +4669,21 @@ discard block |
||
| 4447 | 4669 | </div>'; |
| 4448 | 4670 | |
| 4449 | 4671 | // Dont any tables so far? |
| 4450 | - if (!empty($upcontext['previous_tables'])) |
|
| 4451 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4672 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4673 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4452 | 4674 | echo ' |
| 4453 | 4675 | <br>Completed Table: "', $table, '".'; |
| 4676 | + } |
|
| 4454 | 4677 | |
| 4455 | 4678 | echo ' |
| 4456 | 4679 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4457 | 4680 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4458 | 4681 | |
| 4459 | 4682 | // Try to make sure substep was reset. |
| 4460 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4461 | - echo ' |
|
| 4683 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4684 | + echo ' |
|
| 4462 | 4685 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4686 | + } |
|
| 4463 | 4687 | |
| 4464 | 4688 | // Continue please! |
| 4465 | 4689 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4492,12 +4716,13 @@ discard block |
||
| 4492 | 4716 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4493 | 4717 | |
| 4494 | 4718 | // If debug flood the screen. |
| 4495 | - if ($is_debug) |
|
| 4496 | - echo ' |
|
| 4719 | + if ($is_debug) { |
|
| 4720 | + echo ' |
|
| 4497 | 4721 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4498 | 4722 | |
| 4499 | 4723 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4500 | 4724 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4725 | + } |
|
| 4501 | 4726 | |
| 4502 | 4727 | echo ' |
| 4503 | 4728 | // Get the next update... |
@@ -4533,8 +4758,8 @@ discard block |
||
| 4533 | 4758 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4534 | 4759 | <form action="', $boardurl, '/index.php">'; |
| 4535 | 4760 | |
| 4536 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4537 | - echo ' |
|
| 4761 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4762 | + echo ' |
|
| 4538 | 4763 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4539 | 4764 | <script> |
| 4540 | 4765 | function doTheDelete(theCheck) |
@@ -4546,6 +4771,7 @@ discard block |
||
| 4546 | 4771 | } |
| 4547 | 4772 | </script> |
| 4548 | 4773 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4774 | + } |
|
| 4549 | 4775 | |
| 4550 | 4776 | $active = time() - $upcontext['started']; |
| 4551 | 4777 | $hours = floor($active / 3600); |
@@ -4555,16 +4781,20 @@ discard block |
||
| 4555 | 4781 | if ($is_debug) |
| 4556 | 4782 | { |
| 4557 | 4783 | $totalTime = ''; |
| 4558 | - if ($hours > 0) |
|
| 4559 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4560 | - if ($minutes > 0) |
|
| 4561 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4562 | - if ($seconds > 0) |
|
| 4563 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4784 | + if ($hours > 0) { |
|
| 4785 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4786 | + } |
|
| 4787 | + if ($minutes > 0) { |
|
| 4788 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4789 | + } |
|
| 4790 | + if ($seconds > 0) { |
|
| 4791 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4792 | + } |
|
| 4564 | 4793 | } |
| 4565 | 4794 | |
| 4566 | - if ($is_debug && !empty($totalTime)) |
|
| 4567 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4795 | + if ($is_debug && !empty($totalTime)) { |
|
| 4796 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4797 | + } |
|
| 4568 | 4798 | |
| 4569 | 4799 | echo '<br> |
| 4570 | 4800 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4591,8 +4821,9 @@ discard block |
||
| 4591 | 4821 | |
| 4592 | 4822 | $current_substep = $_GET['substep']; |
| 4593 | 4823 | |
| 4594 | - if (empty($_GET['a'])) |
|
| 4595 | - $_GET['a'] = 0; |
|
| 4824 | + if (empty($_GET['a'])) { |
|
| 4825 | + $_GET['a'] = 0; |
|
| 4826 | + } |
|
| 4596 | 4827 | $step_progress['name'] = 'Converting ips'; |
| 4597 | 4828 | $step_progress['current'] = $_GET['a']; |
| 4598 | 4829 | |
@@ -4635,16 +4866,19 @@ discard block |
||
| 4635 | 4866 | 'empty' => '', |
| 4636 | 4867 | 'limit' => $limit, |
| 4637 | 4868 | )); |
| 4638 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4639 | - $arIp[] = $row[$oldCol]; |
|
| 4869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4870 | + $arIp[] = $row[$oldCol]; |
|
| 4871 | + } |
|
| 4640 | 4872 | $smcFunc['db_free_result']($request); |
| 4641 | 4873 | |
| 4642 | 4874 | // Special case, null ip could keep us in a loop. |
| 4643 | - if (is_null($arIp[0])) |
|
| 4644 | - unset($arIp[0]); |
|
| 4875 | + if (is_null($arIp[0])) { |
|
| 4876 | + unset($arIp[0]); |
|
| 4877 | + } |
|
| 4645 | 4878 | |
| 4646 | - if (empty($arIp)) |
|
| 4647 | - $is_done = true; |
|
| 4879 | + if (empty($arIp)) { |
|
| 4880 | + $is_done = true; |
|
| 4881 | + } |
|
| 4648 | 4882 | |
| 4649 | 4883 | $updates = array(); |
| 4650 | 4884 | $cases = array(); |
@@ -4653,16 +4887,18 @@ discard block |
||
| 4653 | 4887 | { |
| 4654 | 4888 | $arIp[$i] = trim($arIp[$i]); |
| 4655 | 4889 | |
| 4656 | - if (empty($arIp[$i])) |
|
| 4657 | - continue; |
|
| 4890 | + if (empty($arIp[$i])) { |
|
| 4891 | + continue; |
|
| 4892 | + } |
|
| 4658 | 4893 | |
| 4659 | 4894 | $updates['ip' . $i] = $arIp[$i]; |
| 4660 | 4895 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4661 | 4896 | |
| 4662 | 4897 | if ($setSize > 0 && $i % $setSize === 0) |
| 4663 | 4898 | { |
| 4664 | - if (count($updates) == 1) |
|
| 4665 | - continue; |
|
| 4899 | + if (count($updates) == 1) { |
|
| 4900 | + continue; |
|
| 4901 | + } |
|
| 4666 | 4902 | |
| 4667 | 4903 | $updates['whereSet'] = array_values($updates); |
| 4668 | 4904 | $smcFunc['db_query']('', ' |
@@ -4696,8 +4932,7 @@ discard block |
||
| 4696 | 4932 | 'ip' => $ip |
| 4697 | 4933 | )); |
| 4698 | 4934 | } |
| 4699 | - } |
|
| 4700 | - else |
|
| 4935 | + } else |
|
| 4701 | 4936 | { |
| 4702 | 4937 | $updates['whereSet'] = array_values($updates); |
| 4703 | 4938 | $smcFunc['db_query']('', ' |
@@ -4711,9 +4946,9 @@ discard block |
||
| 4711 | 4946 | $updates |
| 4712 | 4947 | ); |
| 4713 | 4948 | } |
| 4949 | + } else { |
|
| 4950 | + $is_done = true; |
|
| 4714 | 4951 | } |
| 4715 | - else |
|
| 4716 | - $is_done = true; |
|
| 4717 | 4952 | |
| 4718 | 4953 | $_GET['a'] += $limit; |
| 4719 | 4954 | $step_progress['current'] = $_GET['a']; |
@@ -4739,10 +4974,11 @@ discard block |
||
| 4739 | 4974 | |
| 4740 | 4975 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4741 | 4976 | |
| 4742 | - if (isset($columns[$column])) |
|
| 4743 | - return $columns[$column]; |
|
| 4744 | - else |
|
| 4745 | - return null; |
|
| 4746 | -} |
|
| 4977 | + if (isset($columns[$column])) { |
|
| 4978 | + return $columns[$column]; |
|
| 4979 | + } else { |
|
| 4980 | + return null; |
|
| 4981 | + } |
|
| 4982 | + } |
|
| 4747 | 4983 | |
| 4748 | 4984 | ?> |
| 4749 | 4985 | \ No newline at end of file |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | public $headers; |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * Start the curl object |
|
| 98 | - * - allow for user override values |
|
| 99 | - * |
|
| 100 | - * @param array $options An array of cURL options |
|
| 101 | - * @param int $max_redirect Maximum number of redirects |
|
| 102 | - */ |
|
| 97 | + * Start the curl object |
|
| 98 | + * - allow for user override values |
|
| 99 | + * |
|
| 100 | + * @param array $options An array of cURL options |
|
| 101 | + * @param int $max_redirect Maximum number of redirects |
|
| 102 | + */ |
|
| 103 | 103 | public function __construct($options = array(), $max_redirect = 3) |
| 104 | 104 | { |
| 105 | 105 | // Initialize class variables |
@@ -108,16 +108,16 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * Main calling function, |
|
| 112 | - * - will request the page data from a given $url |
|
| 113 | - * - optionally will post data to the page form if post data is supplied |
|
| 114 | - * - passed arrays will be converted to a post string joined with &'s |
|
| 115 | - * - calls set_options to set the curl opts array values based on the defaults and user input |
|
| 116 | - * |
|
| 117 | - * @param string $url the site we are going to fetch |
|
| 118 | - * @param array $post_data any post data as form name => value |
|
| 119 | - * @return object An instance of the curl_fetch_web_data class |
|
| 120 | - */ |
|
| 111 | + * Main calling function, |
|
| 112 | + * - will request the page data from a given $url |
|
| 113 | + * - optionally will post data to the page form if post data is supplied |
|
| 114 | + * - passed arrays will be converted to a post string joined with &'s |
|
| 115 | + * - calls set_options to set the curl opts array values based on the defaults and user input |
|
| 116 | + * |
|
| 117 | + * @param string $url the site we are going to fetch |
|
| 118 | + * @param array $post_data any post data as form name => value |
|
| 119 | + * @return object An instance of the curl_fetch_web_data class |
|
| 120 | + */ |
|
| 121 | 121 | public function get_url_data($url, $post_data = array()) |
| 122 | 122 | { |
| 123 | 123 | // POSTing some data perhaps? |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | - * Makes the actual cURL call |
|
| 138 | - * - stores responses (url, code, error, headers, body) in the response array |
|
| 139 | - * - detects 301, 302, 307 codes and will redirect to the given response header location |
|
| 140 | - * |
|
| 141 | - * @param string $url The site to fetch |
|
| 142 | - * @param bool $redirect Whether or not this was a redirect request |
|
| 143 | - * @return void|bool Sets various properties of the class or returns false if the URL isn't specified |
|
| 144 | - */ |
|
| 137 | + * Makes the actual cURL call |
|
| 138 | + * - stores responses (url, code, error, headers, body) in the response array |
|
| 139 | + * - detects 301, 302, 307 codes and will redirect to the given response header location |
|
| 140 | + * |
|
| 141 | + * @param string $url The site to fetch |
|
| 142 | + * @param bool $redirect Whether or not this was a redirect request |
|
| 143 | + * @return void|bool Sets various properties of the class or returns false if the URL isn't specified |
|
| 144 | + */ |
|
| 145 | 145 | private function curl_request($url, $redirect = false) |
| 146 | 146 | { |
| 147 | 147 | // we do have a url I hope |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | - * Used if being redirected to ensure we have a fully qualified address |
|
| 197 | - * |
|
| 198 | - * @param string $last_url The URL we went to |
|
| 199 | - * @param string $new_url The URL we were redirected to |
|
| 200 | - * @return string The new URL that was in the HTTP header |
|
| 201 | - */ |
|
| 196 | + * Used if being redirected to ensure we have a fully qualified address |
|
| 197 | + * |
|
| 198 | + * @param string $last_url The URL we went to |
|
| 199 | + * @param string $new_url The URL we were redirected to |
|
| 200 | + * @return string The new URL that was in the HTTP header |
|
| 201 | + */ |
|
| 202 | 202 | private function get_redirect_url($last_url = '', $new_url = '') |
| 203 | 203 | { |
| 204 | 204 | // Get the elements for these urls |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Used to return the results to the calling program |
|
| 220 | - * - called as ->result() will return the full final array |
|
| 221 | - * - called as ->result('body') to just return the page source of the result |
|
| 222 | - * |
|
| 223 | - * @param string $area Used to return an area such as body, header, error |
|
| 224 | - * @return string The response |
|
| 225 | - */ |
|
| 219 | + * Used to return the results to the calling program |
|
| 220 | + * - called as ->result() will return the full final array |
|
| 221 | + * - called as ->result('body') to just return the page source of the result |
|
| 222 | + * |
|
| 223 | + * @param string $area Used to return an area such as body, header, error |
|
| 224 | + * @return string The response |
|
| 225 | + */ |
|
| 226 | 226 | public function result($area = '') |
| 227 | 227 | { |
| 228 | 228 | $max_result = count($this->response) - 1; |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | - * Will return all results from all loops (redirects) |
|
| 239 | - * - Can be called as ->result_raw(x) where x is a specific loop results. |
|
| 240 | - * - Call as ->result_raw() for everything. |
|
| 241 | - * |
|
| 242 | - * @param string $response_number Which response we want to get |
|
| 243 | - * @return array|string The entire response array or just the specified response |
|
| 244 | - */ |
|
| 238 | + * Will return all results from all loops (redirects) |
|
| 239 | + * - Can be called as ->result_raw(x) where x is a specific loop results. |
|
| 240 | + * - Call as ->result_raw() for everything. |
|
| 241 | + * |
|
| 242 | + * @param string $response_number Which response we want to get |
|
| 243 | + * @return array|string The entire response array or just the specified response |
|
| 244 | + */ |
|
| 245 | 245 | public function result_raw($response_number = '') |
| 246 | 246 | { |
| 247 | 247 | if (!is_numeric($response_number)) |
@@ -254,13 +254,13 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | - * Takes supplied POST data and url encodes it |
|
| 258 | - * - forms the date (for post) in to a string var=xyz&var2=abc&var3=123 |
|
| 259 | - * - drops vars with @ since we don't support sending files (uploading) |
|
| 260 | - * |
|
| 261 | - * @param array|string $post_data The raw POST data |
|
| 262 | - * @return string A string of post data |
|
| 263 | - */ |
|
| 257 | + * Takes supplied POST data and url encodes it |
|
| 258 | + * - forms the date (for post) in to a string var=xyz&var2=abc&var3=123 |
|
| 259 | + * - drops vars with @ since we don't support sending files (uploading) |
|
| 260 | + * |
|
| 261 | + * @param array|string $post_data The raw POST data |
|
| 262 | + * @return string A string of post data |
|
| 263 | + */ |
|
| 264 | 264 | private function build_post_data($post_data) |
| 265 | 265 | { |
| 266 | 266 | if (is_array($post_data)) |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | - * Sets the final cURL options for the current call |
|
| 283 | - * - overwrites our default values with user supplied ones or appends new user ones to what we have |
|
| 284 | - * - sets the callback function now that $this is existing |
|
| 285 | - * @return void |
|
| 286 | - */ |
|
| 282 | + * Sets the final cURL options for the current call |
|
| 283 | + * - overwrites our default values with user supplied ones or appends new user ones to what we have |
|
| 284 | + * - sets the callback function now that $this is existing |
|
| 285 | + * @return void |
|
| 286 | + */ |
|
| 287 | 287 | private function set_options() |
| 288 | 288 | { |
| 289 | 289 | // Callback to parse the returned headers, if any |
@@ -308,12 +308,12 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | - * Called to initiate a redirect from a 301, 302 or 307 header |
|
| 312 | - * - resets the cURL options for the loop, sets the referrer flag |
|
| 313 | - * |
|
| 314 | - * @param string $target_url The URL we want to redirect to |
|
| 315 | - * @param string $referer_url The URL that we're redirecting from |
|
| 316 | - */ |
|
| 311 | + * Called to initiate a redirect from a 301, 302 or 307 header |
|
| 312 | + * - resets the cURL options for the loop, sets the referrer flag |
|
| 313 | + * |
|
| 314 | + * @param string $target_url The URL we want to redirect to |
|
| 315 | + * @param string $referer_url The URL that we're redirecting from |
|
| 316 | + */ |
|
| 317 | 317 | private function redirect($target_url, $referer_url) |
| 318 | 318 | { |
| 319 | 319 | // no no I last saw that over there ... really, 301, 302, 307 |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
| 326 | - * Callback function to parse returned headers |
|
| 327 | - * - lowercases everything to make it consistent |
|
| 328 | - * |
|
| 329 | - * @param type $cr Not sure what this is used for? |
|
| 330 | - * @param string $header The header |
|
| 331 | - * @return int The length of the header |
|
| 332 | - */ |
|
| 326 | + * Callback function to parse returned headers |
|
| 327 | + * - lowercases everything to make it consistent |
|
| 328 | + * |
|
| 329 | + * @param type $cr Not sure what this is used for? |
|
| 330 | + * @param string $header The header |
|
| 331 | + * @return int The length of the header |
|
| 332 | + */ |
|
| 333 | 333 | private function header_callback($cr, $header) |
| 334 | 334 | { |
| 335 | 335 | $_header = trim($header); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * Start the curl object |
| 98 | 98 | * - allow for user override values |
| 99 | 99 | * |
| 100 | - * @param array $options An array of cURL options |
|
| 100 | + * @param integer[] $options An array of cURL options |
|
| 101 | 101 | * @param int $max_redirect Maximum number of redirects |
| 102 | 102 | */ |
| 103 | 103 | public function __construct($options = array(), $max_redirect = 3) |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | * - calls set_options to set the curl opts array values based on the defaults and user input |
| 116 | 116 | * |
| 117 | 117 | * @param string $url the site we are going to fetch |
| 118 | - * @param array $post_data any post data as form name => value |
|
| 119 | - * @return object An instance of the curl_fetch_web_data class |
|
| 118 | + * @param string $post_data any post data as form name => value |
|
| 119 | + * @return curl_fetch_web_data An instance of the curl_fetch_web_data class |
|
| 120 | 120 | */ |
| 121 | 121 | public function get_url_data($url, $post_data = array()) |
| 122 | 122 | { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @param string $url The site to fetch |
| 142 | 142 | * @param bool $redirect Whether or not this was a redirect request |
| 143 | - * @return void|bool Sets various properties of the class or returns false if the URL isn't specified |
|
| 143 | + * @return false|null Sets various properties of the class or returns false if the URL isn't specified |
|
| 144 | 144 | */ |
| 145 | 145 | private function curl_request($url, $redirect = false) |
| 146 | 146 | { |
@@ -10,8 +10,9 @@ discard block |
||
| 10 | 10 | * @version 2.1 Beta 4 |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if (!defined('SMF')) |
|
| 13 | +if (!defined('SMF')) { |
|
| 14 | 14 | die('No direct access...'); |
| 15 | +} |
|
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Class curl_fetch_web_data |
@@ -121,10 +122,11 @@ discard block |
||
| 121 | 122 | public function get_url_data($url, $post_data = array()) |
| 122 | 123 | { |
| 123 | 124 | // POSTing some data perhaps? |
| 124 | - if (!empty($post_data) && is_array($post_data)) |
|
| 125 | - $this->post_data = $this->build_post_data($post_data); |
|
| 126 | - elseif (!empty($post_data)) |
|
| 127 | - $this->post_data = trim($post_data); |
|
| 125 | + if (!empty($post_data) && is_array($post_data)) { |
|
| 126 | + $this->post_data = $this->build_post_data($post_data); |
|
| 127 | + } elseif (!empty($post_data)) { |
|
| 128 | + $this->post_data = trim($post_data); |
|
| 129 | + } |
|
| 128 | 130 | |
| 129 | 131 | // set the options and get it |
| 130 | 132 | $this->set_options(); |
@@ -145,10 +147,11 @@ discard block |
||
| 145 | 147 | private function curl_request($url, $redirect = false) |
| 146 | 148 | { |
| 147 | 149 | // we do have a url I hope |
| 148 | - if ($url == '') |
|
| 149 | - return false; |
|
| 150 | - else |
|
| 151 | - $this->options[CURLOPT_URL] = $url; |
|
| 150 | + if ($url == '') { |
|
| 151 | + return false; |
|
| 152 | + } else { |
|
| 153 | + $this->options[CURLOPT_URL] = $url; |
|
| 154 | + } |
|
| 152 | 155 | |
| 153 | 156 | // if we have not already been redirected, set it up so we can if needed |
| 154 | 157 | if (!$redirect) |
@@ -228,10 +231,11 @@ discard block |
||
| 228 | 231 | $max_result = count($this->response) - 1; |
| 229 | 232 | |
| 230 | 233 | // just return a specifed area or the entire result? |
| 231 | - if ($area == '') |
|
| 232 | - return $this->response[$max_result]; |
|
| 233 | - else |
|
| 234 | - return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result]; |
|
| 234 | + if ($area == '') { |
|
| 235 | + return $this->response[$max_result]; |
|
| 236 | + } else { |
|
| 237 | + return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result]; |
|
| 238 | + } |
|
| 235 | 239 | } |
| 236 | 240 | |
| 237 | 241 | /** |
@@ -244,9 +248,9 @@ discard block |
||
| 244 | 248 | */ |
| 245 | 249 | public function result_raw($response_number = '') |
| 246 | 250 | { |
| 247 | - if (!is_numeric($response_number)) |
|
| 248 | - return $this->response; |
|
| 249 | - else |
|
| 251 | + if (!is_numeric($response_number)) { |
|
| 252 | + return $this->response; |
|
| 253 | + } else |
|
| 250 | 254 | { |
| 251 | 255 | $response_number = min($response_number, count($this->response) - 1); |
| 252 | 256 | return $this->response[$response_number]; |
@@ -268,13 +272,14 @@ discard block |
||
| 268 | 272 | $postvars = array(); |
| 269 | 273 | |
| 270 | 274 | // build the post data, drop ones with leading @'s since those can be used to send files, we don't support that. |
| 271 | - foreach ($post_data as $name => $value) |
|
| 272 | - $postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value); |
|
| 275 | + foreach ($post_data as $name => $value) { |
|
| 276 | + $postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value); |
|
| 277 | + } |
|
| 273 | 278 | |
| 274 | 279 | return implode('&', $postvars); |
| 280 | + } else { |
|
| 281 | + return $post_data; |
|
| 275 | 282 | } |
| 276 | - else |
|
| 277 | - return $post_data; |
|
| 278 | 283 | |
| 279 | 284 | } |
| 280 | 285 | |
@@ -295,9 +300,9 @@ discard block |
||
| 295 | 300 | $keys = array_merge(array_keys($this->default_options), array_keys($this->user_options)); |
| 296 | 301 | $vals = array_merge($this->default_options, $this->user_options); |
| 297 | 302 | $this->options = array_combine($keys, $vals); |
| 303 | + } else { |
|
| 304 | + $this->options = $this->default_options; |
|
| 298 | 305 | } |
| 299 | - else |
|
| 300 | - $this->options = $this->default_options; |
|
| 301 | 306 | |
| 302 | 307 | // POST data options, here we don't allow any overide |
| 303 | 308 | if (isset($this->post_data)) |
@@ -336,8 +341,9 @@ discard block |
||
| 336 | 341 | $temp = explode(': ', $_header, 2); |
| 337 | 342 | |
| 338 | 343 | // set proper headers only |
| 339 | - if (isset($temp[0]) && isset($temp[1])) |
|
| 340 | - $this->headers[strtolower($temp[0])] = strtolower(trim($temp[1])); |
|
| 344 | + if (isset($temp[0]) && isset($temp[1])) { |
|
| 345 | + $this->headers[strtolower($temp[0])] = strtolower(trim($temp[1])); |
|
| 346 | + } |
|
| 341 | 347 | |
| 342 | 348 | // return the length of what was passed unless you want a Failed writing header error ;) |
| 343 | 349 | return strlen($header); |