@@ -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 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
24 | 25 | global $time_start, $smcFunc; |
25 | 26 | |
26 | 27 | // Special case for doing the mail queue. |
27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
28 | - ReduceMailQueue(); |
|
29 | - else |
|
28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
29 | + ReduceMailQueue(); |
|
30 | + } else |
|
30 | 31 | { |
31 | 32 | $task_string = ''; |
32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
53 | 54 | |
54 | 55 | // How long in seconds it the gap? |
55 | 56 | $duration = $row['time_regularity']; |
56 | - if ($row['time_unit'] == 'm') |
|
57 | - $duration *= 60; |
|
58 | - elseif ($row['time_unit'] == 'h') |
|
59 | - $duration *= 3600; |
|
60 | - elseif ($row['time_unit'] == 'd') |
|
61 | - $duration *= 86400; |
|
62 | - elseif ($row['time_unit'] == 'w') |
|
63 | - $duration *= 604800; |
|
57 | + if ($row['time_unit'] == 'm') { |
|
58 | + $duration *= 60; |
|
59 | + } elseif ($row['time_unit'] == 'h') { |
|
60 | + $duration *= 3600; |
|
61 | + } elseif ($row['time_unit'] == 'd') { |
|
62 | + $duration *= 86400; |
|
63 | + } elseif ($row['time_unit'] == 'w') { |
|
64 | + $duration *= 604800; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // If we were really late running this task actually skip the next one. |
66 | - if (time() + ($duration / 2) > $next_time) |
|
67 | - $next_time += $duration; |
|
68 | + if (time() + ($duration / 2) > $next_time) { |
|
69 | + $next_time += $duration; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Update it now, so no others run this! |
70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
82 | 85 | |
83 | 86 | // What kind of task are we handling? |
84 | - if (!empty($row['callable'])) |
|
85 | - $task_string = $row['callable']; |
|
87 | + if (!empty($row['callable'])) { |
|
88 | + $task_string = $row['callable']; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | // Default SMF task or old mods? |
88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
89 | - $task_string = 'scheduled_' . $row['task']; |
|
92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
93 | + $task_string = 'scheduled_' . $row['task']; |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // One last resource, the task name. |
92 | - elseif (!empty($row['task'])) |
|
93 | - $task_string = $row['task']; |
|
97 | + elseif (!empty($row['task'])) { |
|
98 | + $task_string = $row['task']; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
101 | 107 | $callable_task = call_helper($task_string, true); |
102 | 108 | |
103 | 109 | // Perform the task. |
104 | - if (!empty($callable_task)) |
|
105 | - $completed = call_user_func($callable_task); |
|
106 | - |
|
107 | - else |
|
108 | - $completed = false; |
|
110 | + if (!empty($callable_task)) { |
|
111 | + $completed = call_user_func($callable_task); |
|
112 | + } else { |
|
113 | + $completed = false; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Log that we did it ;) |
111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
138 | 144 | ) |
139 | 145 | ); |
140 | 146 | // No new task scheduled yet? |
141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
142 | - $nextEvent = time() + 86400; |
|
143 | - else |
|
144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
148 | + $nextEvent = time() + 86400; |
|
149 | + } else { |
|
150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
151 | + } |
|
145 | 152 | $smcFunc['db_free_result']($request); |
146 | 153 | |
147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
148 | 155 | } |
149 | 156 | |
150 | 157 | // Shall we return? |
151 | - if (!isset($_GET['scheduled'])) |
|
152 | - return true; |
|
158 | + if (!isset($_GET['scheduled'])) { |
|
159 | + return true; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | // Finally, send some stuff... |
155 | 163 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
182 | 190 | { |
183 | 191 | // If this is no longer around we'll ignore it. |
184 | - if (empty($row['id_topic'])) |
|
185 | - continue; |
|
192 | + if (empty($row['id_topic'])) { |
|
193 | + continue; |
|
194 | + } |
|
186 | 195 | |
187 | 196 | // What type is it? |
188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
189 | - $type = 'topic'; |
|
190 | - elseif ($row['id_attach']) |
|
191 | - $type = 'attach'; |
|
192 | - else |
|
193 | - $type = 'msg'; |
|
197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
198 | + $type = 'topic'; |
|
199 | + } elseif ($row['id_attach']) { |
|
200 | + $type = 'attach'; |
|
201 | + } else { |
|
202 | + $type = 'msg'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // Add it to the array otherwise. |
196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
211 | 221 | ); |
212 | 222 | |
213 | 223 | // If nothing quit now. |
214 | - if (empty($notices)) |
|
215 | - return true; |
|
224 | + if (empty($notices)) { |
|
225 | + return true; |
|
226 | + } |
|
216 | 227 | |
217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
232 | 243 | { |
233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
234 | - if ($row['id_group'] < 2) |
|
235 | - continue; |
|
245 | + if ($row['id_group'] < 2) { |
|
246 | + continue; |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
238 | 250 | |
239 | 251 | // Anyone who can access has to be considered. |
240 | - if ($row['add_deny']) |
|
241 | - $addGroups[] = $row['id_group']; |
|
252 | + if ($row['add_deny']) { |
|
253 | + $addGroups[] = $row['id_group']; |
|
254 | + } |
|
242 | 255 | } |
243 | 256 | $smcFunc['db_free_result']($request); |
244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | if (!empty($row['mod_prefs'])) |
284 | 297 | { |
285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
286 | - if (!($pref_binary & 4)) |
|
287 | - continue; |
|
299 | + if (!($pref_binary & 4)) { |
|
300 | + continue; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | |
290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
309 | 323 | $emailbody = ''; |
310 | 324 | |
311 | 325 | // Load the language file as required. |
312 | - if (empty($current_language) || $current_language != $member['language']) |
|
313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // Loop through each notice... |
316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
318 | 333 | $access = false; |
319 | 334 | |
320 | 335 | // Can they mod in this board? |
321 | - if (isset($mods[$id][$board])) |
|
322 | - $access = true; |
|
336 | + if (isset($mods[$id][$board])) { |
|
337 | + $access = true; |
|
338 | + } |
|
323 | 339 | |
324 | 340 | // Do the group check... |
325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
326 | 342 | { |
327 | 343 | // They can access?! |
328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
329 | - $access = true; |
|
344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
345 | + $access = true; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | // If they have deny rights don't consider them! |
332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
334 | 351 | $access = false; |
352 | + } |
|
335 | 353 | } |
336 | 354 | |
337 | 355 | // Finally, fix it for admins! |
338 | - if (in_array(1, $member['groups'])) |
|
339 | - $access = true; |
|
356 | + if (in_array(1, $member['groups'])) { |
|
357 | + $access = true; |
|
358 | + } |
|
340 | 359 | |
341 | 360 | // If they can't access it then give it a break! |
342 | - if (!$access) |
|
343 | - continue; |
|
361 | + if (!$access) { |
|
362 | + continue; |
|
363 | + } |
|
344 | 364 | |
345 | 365 | foreach ($notice as $type => $items) |
346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
349 | 369 | '------------------------------------------------------' . "\n"; |
350 | 370 | |
351 | - foreach ($items as $item) |
|
352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
371 | + foreach ($items as $item) { |
|
372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
373 | + } |
|
353 | 374 | |
354 | 375 | $emailbody .= "\n"; |
355 | 376 | } |
356 | 377 | } |
357 | 378 | |
358 | - if ($emailbody == '') |
|
359 | - continue; |
|
379 | + if ($emailbody == '') { |
|
380 | + continue; |
|
381 | + } |
|
360 | 382 | |
361 | 383 | $replacements = array( |
362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
397 | 419 | ) |
398 | 420 | ); |
399 | 421 | $members = array(); |
400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
401 | - $members[$row['id_member']] = $row['warning']; |
|
422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
423 | + $members[$row['id_member']] = $row['warning']; |
|
424 | + } |
|
402 | 425 | $smcFunc['db_free_result']($request); |
403 | 426 | |
404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
421 | 444 | { |
422 | 445 | // More than 24 hours ago? |
423 | - if ($row['last_warning'] <= time() - 86400) |
|
424 | - $member_changes[] = array( |
|
446 | + if ($row['last_warning'] <= time() - 86400) { |
|
447 | + $member_changes[] = array( |
|
425 | 448 | 'id' => $row['id_recipient'], |
426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
427 | 450 | ); |
451 | + } |
|
428 | 452 | } |
429 | 453 | $smcFunc['db_free_result']($request); |
430 | 454 | |
431 | 455 | // Have some members to change? |
432 | - if (!empty($member_changes)) |
|
433 | - foreach ($member_changes as $change) |
|
456 | + if (!empty($member_changes)) { |
|
457 | + foreach ($member_changes as $change) |
|
434 | 458 | $smcFunc['db_query']('', ' |
435 | 459 | UPDATE {db_prefix}members |
436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
440 | 464 | 'id_member' => $change['id'], |
441 | 465 | ) |
442 | 466 | ); |
467 | + } |
|
443 | 468 | } |
444 | 469 | } |
445 | 470 | |
@@ -506,15 +531,17 @@ discard block |
||
506 | 531 | |
507 | 532 | // Store this useful data! |
508 | 533 | $boards[$row['id_board']] = $row['id_board']; |
509 | - if ($row['id_topic']) |
|
510 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
511 | - else |
|
512 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
534 | + if ($row['id_topic']) { |
|
535 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
536 | + } else { |
|
537 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
538 | + } |
|
513 | 539 | } |
514 | 540 | $smcFunc['db_free_result']($request); |
515 | 541 | |
516 | - if (empty($boards)) |
|
517 | - return true; |
|
542 | + if (empty($boards)) { |
|
543 | + return true; |
|
544 | + } |
|
518 | 545 | |
519 | 546 | // Just get the board names. |
520 | 547 | $request = $smcFunc['db_query']('', ' |
@@ -526,12 +553,14 @@ discard block |
||
526 | 553 | ) |
527 | 554 | ); |
528 | 555 | $boards = array(); |
529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
530 | - $boards[$row['id_board']] = $row['name']; |
|
556 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
557 | + $boards[$row['id_board']] = $row['name']; |
|
558 | + } |
|
531 | 559 | $smcFunc['db_free_result']($request); |
532 | 560 | |
533 | - if (empty($boards)) |
|
534 | - return true; |
|
561 | + if (empty($boards)) { |
|
562 | + return true; |
|
563 | + } |
|
535 | 564 | |
536 | 565 | // Get the actual topics... |
537 | 566 | $request = $smcFunc['db_query']('', ' |
@@ -551,52 +580,57 @@ discard block |
||
551 | 580 | $types = array(); |
552 | 581 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
553 | 582 | { |
554 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
555 | - $types[$row['note_type']][$row['id_board']] = array( |
|
583 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
584 | + $types[$row['note_type']][$row['id_board']] = array( |
|
556 | 585 | 'lines' => array(), |
557 | 586 | 'name' => $row['board_name'], |
558 | 587 | 'id' => $row['id_board'], |
559 | 588 | ); |
589 | + } |
|
560 | 590 | |
561 | 591 | if ($row['note_type'] == 'reply') |
562 | 592 | { |
563 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
564 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
565 | - else |
|
566 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
593 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
594 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
595 | + } else { |
|
596 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
567 | 597 | 'id' => $row['id_topic'], |
568 | 598 | 'subject' => un_htmlspecialchars($row['subject']), |
569 | 599 | 'count' => 1, |
570 | 600 | ); |
571 | - } |
|
572 | - elseif ($row['note_type'] == 'topic') |
|
601 | + } |
|
602 | + } elseif ($row['note_type'] == 'topic') |
|
573 | 603 | { |
574 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
575 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
604 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
605 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
576 | 606 | 'id' => $row['id_topic'], |
577 | 607 | 'subject' => un_htmlspecialchars($row['subject']), |
578 | 608 | ); |
579 | - } |
|
580 | - else |
|
609 | + } |
|
610 | + } else |
|
581 | 611 | { |
582 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
583 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
612 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
613 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
584 | 614 | 'id' => $row['id_topic'], |
585 | 615 | 'subject' => un_htmlspecialchars($row['subject']), |
586 | 616 | 'starter' => $row['id_member_started'], |
587 | 617 | ); |
618 | + } |
|
588 | 619 | } |
589 | 620 | |
590 | 621 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
591 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
592 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
593 | - if (!empty($notify['boards'][$row['id_board']])) |
|
594 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
622 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
623 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
624 | + } |
|
625 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
626 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
627 | + } |
|
595 | 628 | } |
596 | 629 | $smcFunc['db_free_result']($request); |
597 | 630 | |
598 | - if (empty($types)) |
|
599 | - return true; |
|
631 | + if (empty($types)) { |
|
632 | + return true; |
|
633 | + } |
|
600 | 634 | |
601 | 635 | // Let's load all the languages into a cache thingy. |
602 | 636 | $langtxt = array(); |
@@ -637,8 +671,9 @@ discard block |
||
637 | 671 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
638 | 672 | |
639 | 673 | // Did they not elect to choose this? |
640 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
641 | - continue; |
|
674 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
675 | + continue; |
|
676 | + } |
|
642 | 677 | |
643 | 678 | // Right character set! |
644 | 679 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -654,39 +689,43 @@ discard block |
||
654 | 689 | if (isset($types['topic'])) |
655 | 690 | { |
656 | 691 | $titled = false; |
657 | - foreach ($types['topic'] as $id => $board) |
|
658 | - foreach ($board['lines'] as $topic) |
|
692 | + foreach ($types['topic'] as $id => $board) { |
|
693 | + foreach ($board['lines'] as $topic) |
|
659 | 694 | if (in_array($mid, $topic['members'])) |
660 | 695 | { |
661 | 696 | if (!$titled) |
662 | 697 | { |
663 | 698 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
699 | + } |
|
664 | 700 | $titled = true; |
665 | 701 | } |
666 | 702 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
667 | 703 | } |
668 | - if ($titled) |
|
669 | - $email['body'] .= "\n"; |
|
704 | + if ($titled) { |
|
705 | + $email['body'] .= "\n"; |
|
706 | + } |
|
670 | 707 | } |
671 | 708 | |
672 | 709 | // What about replies? |
673 | 710 | if (isset($types['reply'])) |
674 | 711 | { |
675 | 712 | $titled = false; |
676 | - foreach ($types['reply'] as $id => $board) |
|
677 | - foreach ($board['lines'] as $topic) |
|
713 | + foreach ($types['reply'] as $id => $board) { |
|
714 | + foreach ($board['lines'] as $topic) |
|
678 | 715 | if (in_array($mid, $topic['members'])) |
679 | 716 | { |
680 | 717 | if (!$titled) |
681 | 718 | { |
682 | 719 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
720 | + } |
|
683 | 721 | $titled = true; |
684 | 722 | } |
685 | 723 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
686 | 724 | } |
687 | 725 | |
688 | - if ($titled) |
|
689 | - $email['body'] .= "\n"; |
|
726 | + if ($titled) { |
|
727 | + $email['body'] .= "\n"; |
|
728 | + } |
|
690 | 729 | } |
691 | 730 | |
692 | 731 | // Finally, moderation actions! |
@@ -695,24 +734,27 @@ discard block |
||
695 | 734 | $titled = false; |
696 | 735 | foreach ($types as $note_type => $type) |
697 | 736 | { |
698 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
699 | - continue; |
|
737 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
738 | + continue; |
|
739 | + } |
|
700 | 740 | |
701 | - foreach ($type as $id => $board) |
|
702 | - foreach ($board['lines'] as $topic) |
|
741 | + foreach ($type as $id => $board) { |
|
742 | + foreach ($board['lines'] as $topic) |
|
703 | 743 | if (in_array($mid, $topic['members'])) |
704 | 744 | { |
705 | 745 | if (!$titled) |
706 | 746 | { |
707 | 747 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
748 | + } |
|
708 | 749 | $titled = true; |
709 | 750 | } |
710 | 751 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
711 | 752 | } |
712 | 753 | } |
713 | 754 | } |
714 | - if ($titled) |
|
715 | - $email['body'] .= "\n"; |
|
755 | + if ($titled) { |
|
756 | + $email['body'] .= "\n"; |
|
757 | + } |
|
716 | 758 | |
717 | 759 | // Then just say our goodbyes! |
718 | 760 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -740,8 +782,7 @@ discard block |
||
740 | 782 | 'not_daily' => 0, |
741 | 783 | ) |
742 | 784 | ); |
743 | - } |
|
744 | - else |
|
785 | + } else |
|
745 | 786 | { |
746 | 787 | // Clear any only weekly ones, and stop us from sending daily again. |
747 | 788 | $smcFunc['db_query']('', ' |
@@ -803,16 +844,19 @@ discard block |
||
803 | 844 | global $modSettings, $smcFunc, $sourcedir; |
804 | 845 | |
805 | 846 | // Are we intending another script to be sending out the queue? |
806 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
807 | - return false; |
|
847 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
848 | + return false; |
|
849 | + } |
|
808 | 850 | |
809 | 851 | // By default send 5 at once. |
810 | - if (!$number) |
|
811 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
852 | + if (!$number) { |
|
853 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
854 | + } |
|
812 | 855 | |
813 | 856 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
814 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
815 | - return false; |
|
857 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
858 | + return false; |
|
859 | + } |
|
816 | 860 | |
817 | 861 | // By default move the next sending on by 10 seconds, and require an affected row. |
818 | 862 | if (!$override_limit) |
@@ -829,8 +873,9 @@ discard block |
||
829 | 873 | 'last_send' => $modSettings['mail_next_send'], |
830 | 874 | ) |
831 | 875 | ); |
832 | - if ($smcFunc['db_affected_rows']() == 0) |
|
833 | - return false; |
|
876 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
877 | + return false; |
|
878 | + } |
|
834 | 879 | $modSettings['mail_next_send'] = time() + $delay; |
835 | 880 | } |
836 | 881 | |
@@ -851,8 +896,9 @@ discard block |
||
851 | 896 | $mn += $number; |
852 | 897 | } |
853 | 898 | // No more I'm afraid, return! |
854 | - else |
|
855 | - return false; |
|
899 | + else { |
|
900 | + return false; |
|
901 | + } |
|
856 | 902 | |
857 | 903 | // Reflect that we're about to send some, do it now to be safe. |
858 | 904 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -887,14 +933,15 @@ discard block |
||
887 | 933 | $smcFunc['db_free_result']($request); |
888 | 934 | |
889 | 935 | // Delete, delete, delete!!! |
890 | - if (!empty($ids)) |
|
891 | - $smcFunc['db_query']('', ' |
|
936 | + if (!empty($ids)) { |
|
937 | + $smcFunc['db_query']('', ' |
|
892 | 938 | DELETE FROM {db_prefix}mail_queue |
893 | 939 | WHERE id_mail IN ({array_int:mail_list})', |
894 | 940 | array( |
895 | 941 | 'mail_list' => $ids, |
896 | 942 | ) |
897 | 943 | ); |
944 | + } |
|
898 | 945 | |
899 | 946 | // Don't believe we have any left? |
900 | 947 | if (count($ids) < $number) |
@@ -912,11 +959,13 @@ discard block |
||
912 | 959 | ); |
913 | 960 | } |
914 | 961 | |
915 | - if (empty($ids)) |
|
916 | - return false; |
|
962 | + if (empty($ids)) { |
|
963 | + return false; |
|
964 | + } |
|
917 | 965 | |
918 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
919 | - require_once($sourcedir . '/Subs-Post.php'); |
|
966 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
967 | + require_once($sourcedir . '/Subs-Post.php'); |
|
968 | + } |
|
920 | 969 | |
921 | 970 | // Send each email, yea! |
922 | 971 | $failed_emails = array(); |
@@ -936,15 +985,17 @@ discard block |
||
936 | 985 | |
937 | 986 | // Try to stop a timeout, this would be bad... |
938 | 987 | @set_time_limit(300); |
939 | - if (function_exists('apache_reset_timeout')) |
|
940 | - @apache_reset_timeout(); |
|
988 | + if (function_exists('apache_reset_timeout')) { |
|
989 | + @apache_reset_timeout(); |
|
990 | + } |
|
991 | + } else { |
|
992 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
941 | 993 | } |
942 | - else |
|
943 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
944 | 994 | |
945 | 995 | // Hopefully it sent? |
946 | - if (!$result) |
|
947 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
996 | + if (!$result) { |
|
997 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
998 | + } |
|
948 | 999 | } |
949 | 1000 | |
950 | 1001 | // Any emails that didn't send? |
@@ -959,8 +1010,8 @@ discard block |
||
959 | 1010 | ); |
960 | 1011 | |
961 | 1012 | // If we have failed to many times, tell mail to wait a bit and try again. |
962 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
963 | - $smcFunc['db_query']('', ' |
|
1013 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
1014 | + $smcFunc['db_query']('', ' |
|
964 | 1015 | UPDATE {db_prefix}settings |
965 | 1016 | SET value = {string:next_mail_send} |
966 | 1017 | WHERE variable = {literal:mail_next_send} |
@@ -969,6 +1020,7 @@ discard block |
||
969 | 1020 | 'next_mail_send' => time() + 60, |
970 | 1021 | 'last_send' => $modSettings['mail_next_send'], |
971 | 1022 | )); |
1023 | + } |
|
972 | 1024 | |
973 | 1025 | // Add our email back to the queue, manually. |
974 | 1026 | $smcFunc['db_insert']('insert', |
@@ -981,8 +1033,8 @@ discard block |
||
981 | 1033 | return false; |
982 | 1034 | } |
983 | 1035 | // We where unable to send the email, clear our failed attempts. |
984 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
985 | - $smcFunc['db_query']('', ' |
|
1036 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
1037 | + $smcFunc['db_query']('', ' |
|
986 | 1038 | UPDATE {db_prefix}settings |
987 | 1039 | SET value = {string:zero} |
988 | 1040 | WHERE variable = {string:mail_failed_attempts}', |
@@ -990,6 +1042,7 @@ discard block |
||
990 | 1042 | 'zero' => '0', |
991 | 1043 | 'mail_failed_attempts' => 'mail_failed_attempts', |
992 | 1044 | )); |
1045 | + } |
|
993 | 1046 | |
994 | 1047 | // Had something to send... |
995 | 1048 | return true; |
@@ -1006,16 +1059,18 @@ discard block |
||
1006 | 1059 | global $modSettings, $smcFunc; |
1007 | 1060 | |
1008 | 1061 | $task_query = ''; |
1009 | - if (!is_array($tasks)) |
|
1010 | - $tasks = array($tasks); |
|
1062 | + if (!is_array($tasks)) { |
|
1063 | + $tasks = array($tasks); |
|
1064 | + } |
|
1011 | 1065 | |
1012 | 1066 | // Actually have something passed? |
1013 | 1067 | if (!empty($tasks)) |
1014 | 1068 | { |
1015 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
1016 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1017 | - else |
|
1018 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
1069 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
1070 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1071 | + } else { |
|
1072 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
1073 | + } |
|
1019 | 1074 | } |
1020 | 1075 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
1021 | 1076 | |
@@ -1036,20 +1091,22 @@ discard block |
||
1036 | 1091 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
1037 | 1092 | |
1038 | 1093 | // Only bother moving the task if it's out of place or we're forcing it! |
1039 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
1040 | - $tasks[$row['id_task']] = $next_time; |
|
1041 | - else |
|
1042 | - $next_time = $row['next_time']; |
|
1094 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
1095 | + $tasks[$row['id_task']] = $next_time; |
|
1096 | + } else { |
|
1097 | + $next_time = $row['next_time']; |
|
1098 | + } |
|
1043 | 1099 | |
1044 | 1100 | // If this is sooner than the current next task, make this the next task. |
1045 | - if ($next_time < $nextTaskTime) |
|
1046 | - $nextTaskTime = $next_time; |
|
1101 | + if ($next_time < $nextTaskTime) { |
|
1102 | + $nextTaskTime = $next_time; |
|
1103 | + } |
|
1047 | 1104 | } |
1048 | 1105 | $smcFunc['db_free_result']($request); |
1049 | 1106 | |
1050 | 1107 | // Now make the changes! |
1051 | - foreach ($tasks as $id => $time) |
|
1052 | - $smcFunc['db_query']('', ' |
|
1108 | + foreach ($tasks as $id => $time) { |
|
1109 | + $smcFunc['db_query']('', ' |
|
1053 | 1110 | UPDATE {db_prefix}scheduled_tasks |
1054 | 1111 | SET next_time = {int:next_time} |
1055 | 1112 | WHERE id_task = {int:id_task}', |
@@ -1058,11 +1115,13 @@ discard block |
||
1058 | 1115 | 'id_task' => $id, |
1059 | 1116 | ) |
1060 | 1117 | ); |
1118 | + } |
|
1061 | 1119 | |
1062 | 1120 | // If the next task is now different update. |
1063 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
1064 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1065 | -} |
|
1121 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
1122 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1123 | + } |
|
1124 | + } |
|
1066 | 1125 | |
1067 | 1126 | /** |
1068 | 1127 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1075,8 +1134,9 @@ discard block |
||
1075 | 1134 | function next_time($regularity, $unit, $offset) |
1076 | 1135 | { |
1077 | 1136 | // Just in case! |
1078 | - if ($regularity == 0) |
|
1079 | - $regularity = 2; |
|
1137 | + if ($regularity == 0) { |
|
1138 | + $regularity = 2; |
|
1139 | + } |
|
1080 | 1140 | |
1081 | 1141 | $curMin = date('i', time()); |
1082 | 1142 | |
@@ -1086,15 +1146,16 @@ discard block |
||
1086 | 1146 | $off = date('i', $offset); |
1087 | 1147 | |
1088 | 1148 | // If it's now just pretend it ain't, |
1089 | - if ($off == $curMin) |
|
1090 | - $next_time = time() + $regularity; |
|
1091 | - else |
|
1149 | + if ($off == $curMin) { |
|
1150 | + $next_time = time() + $regularity; |
|
1151 | + } else |
|
1092 | 1152 | { |
1093 | 1153 | // Make sure that the offset is always in the past. |
1094 | 1154 | $off = $off > $curMin ? $off - 60 : $off; |
1095 | 1155 | |
1096 | - while ($off <= $curMin) |
|
1097 | - $off += $regularity; |
|
1156 | + while ($off <= $curMin) { |
|
1157 | + $off += $regularity; |
|
1158 | + } |
|
1098 | 1159 | |
1099 | 1160 | // Now we know when the time should be! |
1100 | 1161 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1114,11 +1175,13 @@ discard block |
||
1114 | 1175 | // Default we'll jump in hours. |
1115 | 1176 | $applyOffset = 3600; |
1116 | 1177 | // 24 hours = 1 day. |
1117 | - if ($unit == 'd') |
|
1118 | - $applyOffset = 86400; |
|
1178 | + if ($unit == 'd') { |
|
1179 | + $applyOffset = 86400; |
|
1180 | + } |
|
1119 | 1181 | // Otherwise a week. |
1120 | - if ($unit == 'w') |
|
1121 | - $applyOffset = 604800; |
|
1182 | + if ($unit == 'w') { |
|
1183 | + $applyOffset = 604800; |
|
1184 | + } |
|
1122 | 1185 | |
1123 | 1186 | $applyOffset *= $regularity; |
1124 | 1187 | |
@@ -1155,8 +1218,9 @@ discard block |
||
1155 | 1218 | $settings[$row['variable']] = $row['value']; |
1156 | 1219 | |
1157 | 1220 | // Is this the default theme? |
1158 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
1159 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1221 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
1222 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1223 | + } |
|
1160 | 1224 | } |
1161 | 1225 | $smcFunc['db_free_result']($result); |
1162 | 1226 | |
@@ -1166,12 +1230,14 @@ discard block |
||
1166 | 1230 | $settings['template_dirs'] = array($settings['theme_dir']); |
1167 | 1231 | |
1168 | 1232 | // Based on theme (if there is one). |
1169 | - if (!empty($settings['base_theme_dir'])) |
|
1170 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1233 | + if (!empty($settings['base_theme_dir'])) { |
|
1234 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1235 | + } |
|
1171 | 1236 | |
1172 | 1237 | // Lastly the default theme. |
1173 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1174 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1238 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1239 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1240 | + } |
|
1175 | 1241 | } |
1176 | 1242 | |
1177 | 1243 | // Assume we want this. |
@@ -1318,8 +1384,9 @@ discard block |
||
1318 | 1384 | // Ok should we prune the logs? |
1319 | 1385 | if (!empty($modSettings['pruningOptions'])) |
1320 | 1386 | { |
1321 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
1322 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1387 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
1388 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1389 | + } |
|
1323 | 1390 | |
1324 | 1391 | if (!empty($modSettings['pruneErrorLog'])) |
1325 | 1392 | { |
@@ -1385,8 +1452,9 @@ discard block |
||
1385 | 1452 | ) |
1386 | 1453 | ); |
1387 | 1454 | |
1388 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
1389 | - $reports[] = $row[0]; |
|
1455 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
1456 | + $reports[] = $row[0]; |
|
1457 | + } |
|
1390 | 1458 | |
1391 | 1459 | $smcFunc['db_free_result']($result); |
1392 | 1460 | |
@@ -1554,8 +1622,9 @@ discard block |
||
1554 | 1622 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
1555 | 1623 | |
1556 | 1624 | // Send the actual email. |
1557 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
1558 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1625 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
1626 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1627 | + } |
|
1559 | 1628 | |
1560 | 1629 | if ($notifyPrefs[$row['id_member']] & 0x01) |
1561 | 1630 | { |
@@ -1578,18 +1647,19 @@ discard block |
||
1578 | 1647 | } |
1579 | 1648 | |
1580 | 1649 | // Insert the alerts if any |
1581 | - if (!empty($alert_rows)) |
|
1582 | - $smcFunc['db_insert']('', |
|
1650 | + if (!empty($alert_rows)) { |
|
1651 | + $smcFunc['db_insert']('', |
|
1583 | 1652 | '{db_prefix}user_alerts', |
1584 | 1653 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
1585 | 1654 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
1586 | 1655 | $alert_rows, |
1587 | 1656 | array() |
1588 | 1657 | ); |
1658 | + } |
|
1589 | 1659 | |
1590 | 1660 | // Mark the reminder as sent. |
1591 | - if (!empty($subs_reminded)) |
|
1592 | - $smcFunc['db_query']('', ' |
|
1661 | + if (!empty($subs_reminded)) { |
|
1662 | + $smcFunc['db_query']('', ' |
|
1593 | 1663 | UPDATE {db_prefix}log_subscribed |
1594 | 1664 | SET reminder_sent = {int:reminder_sent} |
1595 | 1665 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1598,6 +1668,7 @@ discard block |
||
1598 | 1668 | 'reminder_sent' => 1, |
1599 | 1669 | ) |
1600 | 1670 | ); |
1671 | + } |
|
1601 | 1672 | |
1602 | 1673 | return true; |
1603 | 1674 | } |
@@ -1613,13 +1684,13 @@ discard block |
||
1613 | 1684 | // We need to know where this thing is going. |
1614 | 1685 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1615 | 1686 | { |
1616 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1617 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1687 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1688 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1689 | + } |
|
1618 | 1690 | |
1619 | 1691 | // Just use the current path for temp files. |
1620 | 1692 | $attach_dirs = $modSettings['attachmentUploadDir']; |
1621 | - } |
|
1622 | - else |
|
1693 | + } else |
|
1623 | 1694 | { |
1624 | 1695 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
1625 | 1696 | } |
@@ -1638,14 +1709,16 @@ discard block |
||
1638 | 1709 | |
1639 | 1710 | while ($file = readdir($dir)) |
1640 | 1711 | { |
1641 | - if ($file == '.' || $file == '..') |
|
1642 | - continue; |
|
1712 | + if ($file == '.' || $file == '..') { |
|
1713 | + continue; |
|
1714 | + } |
|
1643 | 1715 | |
1644 | 1716 | if (strpos($file, 'post_tmp_') !== false) |
1645 | 1717 | { |
1646 | 1718 | // Temp file is more than 5 hours old! |
1647 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1648 | - @unlink($attach_dir . '/' . $file); |
|
1719 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1720 | + @unlink($attach_dir . '/' . $file); |
|
1721 | + } |
|
1649 | 1722 | } |
1650 | 1723 | } |
1651 | 1724 | closedir($dir); |
@@ -1678,8 +1751,9 @@ discard block |
||
1678 | 1751 | ) |
1679 | 1752 | ); |
1680 | 1753 | |
1681 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1682 | - $topics[] = $row[0]; |
|
1754 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1755 | + $topics[] = $row[0]; |
|
1756 | + } |
|
1683 | 1757 | $smcFunc['db_free_result']($request); |
1684 | 1758 | |
1685 | 1759 | // Zap, your gone |
@@ -1699,8 +1773,9 @@ discard block |
||
1699 | 1773 | { |
1700 | 1774 | global $smcFunc, $sourcedir, $modSettings; |
1701 | 1775 | |
1702 | - if (empty($modSettings['drafts_keep_days'])) |
|
1703 | - return true; |
|
1776 | + if (empty($modSettings['drafts_keep_days'])) { |
|
1777 | + return true; |
|
1778 | + } |
|
1704 | 1779 | |
1705 | 1780 | // init |
1706 | 1781 | $drafts = array(); |
@@ -1718,8 +1793,9 @@ discard block |
||
1718 | 1793 | ) |
1719 | 1794 | ); |
1720 | 1795 | |
1721 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1722 | - $drafts[] = (int) $row[0]; |
|
1796 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1797 | + $drafts[] = (int) $row[0]; |
|
1798 | + } |
|
1723 | 1799 | $smcFunc['db_free_result']($request); |
1724 | 1800 | |
1725 | 1801 | // If we have old one, remove them |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | |
71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
72 | 73 | |
73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
74 | - $this->{$this->_sa}(); |
|
74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
75 | + $this->{$this->_sa}(); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | // Just send a generic message. |
77 | - else |
|
78 | - $this->setResponse(array( |
|
79 | + else { |
|
80 | + $this->setResponse(array( |
|
79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
80 | 82 | 'type' => 'error', |
81 | 83 | 'data' => false, |
82 | 84 | )); |
85 | + } |
|
83 | 86 | |
84 | 87 | // Back to the future, oh, to the browser! |
85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
96 | 99 | |
97 | 100 | // Need something to work with. |
98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
99 | - return $this->setResponse(array( |
|
101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
102 | + return $this->setResponse(array( |
|
100 | 103 | 'text' => 'attached_file_deleted_error', |
101 | 104 | 'type' => 'error', |
102 | 105 | 'data' => false, |
103 | 106 | )); |
107 | + } |
|
104 | 108 | |
105 | 109 | // Lets pass some params and see what happens :P |
106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
119 | 123 | public function add() |
120 | 124 | { |
121 | 125 | // You gotta be able to post attachments. |
122 | - if (!$this->_canPostAttachment) |
|
123 | - return $this->setResponse(array( |
|
126 | + if (!$this->_canPostAttachment) { |
|
127 | + return $this->setResponse(array( |
|
124 | 128 | 'text' => 'attached_file_cannot', |
125 | 129 | 'type' => 'error', |
126 | 130 | 'data' => false, |
127 | 131 | )); |
132 | + } |
|
128 | 133 | |
129 | 134 | // Process them at once! |
130 | 135 | $this->processAttachments(); |
131 | 136 | |
132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
133 | - if (!empty($_SESSION['temp_attachments'])) |
|
134 | - $this->createAtttach(); |
|
138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
139 | + $this->createAtttach(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | // Set the response. |
137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | { |
145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
146 | 152 | |
147 | - if (!isset($_FILES['attachment']['name'])) |
|
148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
153 | + if (!isset($_FILES['attachment']['name'])) { |
|
154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // If there are attachments, calculate the total size and how many. |
151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
155 | 162 | if (isset($_REQUEST['msg'])) |
156 | 163 | { |
157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
158 | - foreach ($context['current_attachments'] as $attachment) |
|
159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
165 | + foreach ($context['current_attachments'] as $attachment) { |
|
166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | // A bit of house keeping first. |
163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
164 | - unset($_SESSION['temp_attachments']); |
|
171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
172 | + unset($_SESSION['temp_attachments']); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
167 | - if (!isset($_SESSION['temp_attachments'])) |
|
168 | - $_SESSION['temp_attachments'] = array(); |
|
176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
177 | + $_SESSION['temp_attachments'] = array(); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Make sure we're uploading to the right place. |
171 | - if (!empty($modSettings['automanage_attachments'])) |
|
172 | - automanage_attachments_check_directory(); |
|
181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
182 | + automanage_attachments_check_directory(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | // Is the attachments folder actually there? |
175 | - if (!empty($context['dir_creation_error'])) |
|
176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
186 | + if (!empty($context['dir_creation_error'])) { |
|
187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | // The current attach folder ha some issues... |
179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
198 | 210 | ); |
199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
200 | 212 | $smcFunc['db_free_result']($request); |
201 | - } |
|
202 | - |
|
203 | - else |
|
204 | - $context['attachments'] = array( |
|
213 | + } else { |
|
214 | + $context['attachments'] = array( |
|
205 | 215 | 'quantity' => 0, |
206 | 216 | 'total_size' => 0, |
207 | 217 | ); |
218 | + } |
|
208 | 219 | |
209 | 220 | // Check for other general errors here. |
210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
212 | 223 | if (!empty($this->_generalErrors)) |
213 | 224 | { |
214 | 225 | // And delete the files 'cos they ain't going nowhere. |
215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
229 | + } |
|
218 | 230 | |
219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
227 | 239 | { |
228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
229 | - continue; |
|
240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
241 | + continue; |
|
242 | + } |
|
230 | 243 | |
231 | 244 | // First, let's first check for PHP upload errors. |
232 | 245 | $errors = array(); |
233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
234 | 247 | { |
235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
237 | - |
|
238 | - else |
|
239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
250 | + } else { |
|
251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
252 | + } |
|
240 | 253 | |
241 | 254 | // Log this one, because... |
242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
257 | + } |
|
244 | 258 | |
245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
246 | - if (empty($errors)) |
|
247 | - $errors[] = 'attach_php_error'; |
|
260 | + if (empty($errors)) { |
|
261 | + $errors[] = 'attach_php_error'; |
|
262 | + } |
|
248 | 263 | } |
249 | 264 | |
250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
256 | 271 | { |
257 | 272 | // The reported MIME type of the attachment might not be reliable. |
258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
259 | - if (function_exists('mime_content_type')) |
|
260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
274 | + if (function_exists('mime_content_type')) { |
|
275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
276 | + } |
|
261 | 277 | |
262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
269 | 285 | ); |
270 | 286 | |
271 | 287 | // Move the file to the attachments folder with a temp name for now. |
272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
273 | - smf_chmod($destName, 0644); |
|
288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
289 | + smf_chmod($destName, 0644); |
|
290 | + } |
|
274 | 291 | |
275 | 292 | // This is madness!! |
276 | 293 | else |
277 | 294 | { |
278 | 295 | // File couldn't be moved. |
279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
299 | + } |
|
282 | 300 | } |
283 | 301 | } |
284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
291 | 309 | 'errors' => $errors, |
292 | 310 | ); |
293 | 311 | |
294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
314 | + } |
|
296 | 315 | } |
297 | 316 | |
298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
300 | - attachmentChecks($attachID); |
|
318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
319 | + attachmentChecks($attachID); |
|
320 | + } |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
344 | 364 | |
345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
346 | 366 | |
347 | - if (!empty($attachmentOptions['thumb'])) |
|
348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
367 | + if (!empty($attachmentOptions['thumb'])) { |
|
368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
369 | + } |
|
349 | 370 | |
350 | - if ($this->_msg) |
|
351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
371 | + if ($this->_msg) { |
|
372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
373 | + } |
|
352 | 374 | } |
353 | - } |
|
354 | - else |
|
375 | + } else |
|
355 | 376 | { |
356 | 377 | // Sort out the errors for display and delete any associated files. |
357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
363 | 384 | if (!is_array($error)) |
364 | 385 | { |
365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
366 | - if (in_array($error, $log_these)) |
|
367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
387 | + if (in_array($error, $log_these)) { |
|
388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
389 | + } |
|
390 | + } else { |
|
391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
368 | 392 | } |
369 | - else |
|
370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
371 | 393 | } |
372 | - if (file_exists($attachment['tmp_name'])) |
|
373 | - unlink($attachment['tmp_name']); |
|
394 | + if (file_exists($attachment['tmp_name'])) { |
|
395 | + unlink($attachment['tmp_name']); |
|
396 | + } |
|
374 | 397 | } |
375 | 398 | |
376 | 399 | // You don't need to know. |
@@ -382,8 +405,9 @@ discard block |
||
382 | 405 | } |
383 | 406 | |
384 | 407 | // Temp save this on the db. |
385 | - if (!empty($_SESSION['already_attached'])) |
|
386 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
408 | + if (!empty($_SESSION['already_attached'])) { |
|
409 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
410 | + } |
|
387 | 411 | |
388 | 412 | unset($_SESSION['temp_attachments']); |
389 | 413 | } |
@@ -403,14 +427,16 @@ discard block |
||
403 | 427 | if ($this->_sa == 'add') |
404 | 428 | { |
405 | 429 | // Is there any generic errors? made some sense out of them! |
406 | - if ($this->_generalErrors) |
|
407 | - foreach ($this->_generalErrors as $k => $v) |
|
430 | + if ($this->_generalErrors) { |
|
431 | + foreach ($this->_generalErrors as $k => $v) |
|
408 | 432 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
433 | + } |
|
409 | 434 | |
410 | 435 | // Gotta urlencode the filename. |
411 | - if ($this->_attachResults) |
|
412 | - foreach ($this->_attachResults as $k => $v) |
|
436 | + if ($this->_attachResults) { |
|
437 | + foreach ($this->_attachResults as $k => $v) |
|
413 | 438 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
439 | + } |
|
414 | 440 | |
415 | 441 | $this->_response = array( |
416 | 442 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -419,9 +445,10 @@ discard block |
||
419 | 445 | } |
420 | 446 | |
421 | 447 | // Rest of us mere mortals gets no special treatment... |
422 | - elseif (!empty($data)) |
|
423 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
448 | + elseif (!empty($data)) { |
|
449 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
424 | 450 | $this->_response['text'] = $txt[$data['text']]; |
451 | + } |
|
425 | 452 | } |
426 | 453 | |
427 | 454 | protected function sendResponse() |
@@ -430,11 +457,11 @@ discard block |
||
430 | 457 | |
431 | 458 | ob_end_clean(); |
432 | 459 | |
433 | - if (!empty($modSettings['CompressedOutput'])) |
|
434 | - @ob_start('ob_gzhandler'); |
|
435 | - |
|
436 | - else |
|
437 | - ob_start(); |
|
460 | + if (!empty($modSettings['CompressedOutput'])) { |
|
461 | + @ob_start('ob_gzhandler'); |
|
462 | + } else { |
|
463 | + ob_start(); |
|
464 | + } |
|
438 | 465 | |
439 | 466 | // Set the header. |
440 | 467 | header('content-type: application/json; charset='. $context['character_set'] .''); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
30 | 31 | |
31 | 32 | // Is this an incoming AJAX check? |
32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
33 | - return RegisterCheckUsername(); |
|
33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
34 | + return RegisterCheckUsername(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // Check if the administrator has it disabled. |
36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
37 | - fatal_lang_error('registration_disabled', false); |
|
38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
39 | + fatal_lang_error('registration_disabled', false); |
|
40 | + } |
|
38 | 41 | |
39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
45 | + } |
|
42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
43 | - elseif (empty($user_info['is_guest'])) |
|
44 | - redirectexit(); |
|
47 | + elseif (empty($user_info['is_guest'])) { |
|
48 | + redirectexit(); |
|
49 | + } |
|
45 | 50 | |
46 | 51 | loadLanguage('Login'); |
47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
82 | 87 | } |
83 | 88 | } |
84 | 89 | // Make sure they don't squeeze through without agreeing. |
85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
86 | - $current_step = 1; |
|
90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
91 | + $current_step = 1; |
|
92 | + } |
|
87 | 93 | |
88 | 94 | // Show the user the right form. |
89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
91 | 97 | |
92 | 98 | // Kinda need this. |
93 | - if ($context['sub_template'] == 'registration_form') |
|
94 | - loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
99 | + if ($context['sub_template'] == 'registration_form') { |
|
100 | + loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
101 | + } |
|
95 | 102 | |
96 | 103 | // Add the register chain to the link tree. |
97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
100 | 107 | ); |
101 | 108 | |
102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
103 | - if (!isset($_SESSION['register'])) |
|
104 | - $_SESSION['register'] = array( |
|
110 | + if (!isset($_SESSION['register'])) { |
|
111 | + $_SESSION['register'] = array( |
|
105 | 112 | 'timenow' => time(), |
106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
107 | 114 | ); |
108 | - else |
|
109 | - $_SESSION['register']['timenow'] = time(); |
|
115 | + } else { |
|
116 | + $_SESSION['register']['timenow'] = time(); |
|
117 | + } |
|
110 | 118 | |
111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
112 | 120 | if ($context['require_agreement']) |
113 | 121 | { |
114 | 122 | // Have we got a localized one? |
115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
119 | - else |
|
120 | - $context['agreement'] = ''; |
|
123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
127 | + } else { |
|
128 | + $context['agreement'] = ''; |
|
129 | + } |
|
121 | 130 | |
122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
134 | 143 | |
135 | 144 | // Do we have any languages? |
136 | - if (empty($context['languages'])) |
|
137 | - getLanguages(); |
|
145 | + if (empty($context['languages'])) { |
|
146 | + getLanguages(); |
|
147 | + } |
|
138 | 148 | |
139 | 149 | // Try to find our selected language. |
140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
143 | 153 | |
144 | 154 | // Found it! |
145 | - if ($selectedLanguage == $lang['filename']) |
|
146 | - $context['languages'][$key]['selected'] = true; |
|
155 | + if ($selectedLanguage == $lang['filename']) { |
|
156 | + $context['languages'][$key]['selected'] = true; |
|
157 | + } |
|
147 | 158 | } |
148 | 159 | } |
149 | 160 | |
@@ -170,16 +181,19 @@ discard block |
||
170 | 181 | if (in_array('website', $reg_fields)) |
171 | 182 | { |
172 | 183 | unset($reg_fields['website']); |
173 | - if (isset($_POST['website_title'])) |
|
174 | - $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
175 | - if (isset($_POST['website_url'])) |
|
176 | - $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
184 | + if (isset($_POST['website_title'])) { |
|
185 | + $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
186 | + } |
|
187 | + if (isset($_POST['website_url'])) { |
|
188 | + $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
189 | + } |
|
177 | 190 | } |
178 | 191 | |
179 | 192 | // We might have had some submissions on this front - go check. |
180 | - foreach ($reg_fields as $field) |
|
181 | - if (isset($_POST[$field])) |
|
193 | + foreach ($reg_fields as $field) { |
|
194 | + if (isset($_POST[$field])) |
|
182 | 195 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
196 | + } |
|
183 | 197 | |
184 | 198 | // Load all the fields in question. |
185 | 199 | setupProfileContext($reg_fields); |
@@ -196,8 +210,9 @@ discard block |
||
196 | 210 | $context['visual_verification_id'] = $verificationOptions['id']; |
197 | 211 | } |
198 | 212 | // Otherwise we have nothing to show. |
199 | - else |
|
200 | - $context['visual_verification'] = false; |
|
213 | + else { |
|
214 | + $context['visual_verification'] = false; |
|
215 | + } |
|
201 | 216 | |
202 | 217 | |
203 | 218 | $context += array( |
@@ -208,8 +223,9 @@ discard block |
||
208 | 223 | |
209 | 224 | // Were there any errors? |
210 | 225 | $context['registration_errors'] = array(); |
211 | - if (!empty($reg_errors)) |
|
212 | - $context['registration_errors'] = $reg_errors; |
|
226 | + if (!empty($reg_errors)) { |
|
227 | + $context['registration_errors'] = $reg_errors; |
|
228 | + } |
|
213 | 229 | |
214 | 230 | createToken('register'); |
215 | 231 | } |
@@ -226,27 +242,32 @@ discard block |
||
226 | 242 | validateToken('register'); |
227 | 243 | |
228 | 244 | // Check to ensure we're forcing SSL for authentication |
229 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
230 | - fatal_lang_error('register_ssl_required'); |
|
245 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
246 | + fatal_lang_error('register_ssl_required'); |
|
247 | + } |
|
231 | 248 | |
232 | 249 | // Start collecting together any errors. |
233 | 250 | $reg_errors = array(); |
234 | 251 | |
235 | 252 | // You can't register if it's disabled. |
236 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
237 | - fatal_lang_error('registration_disabled', false); |
|
253 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
254 | + fatal_lang_error('registration_disabled', false); |
|
255 | + } |
|
238 | 256 | |
239 | 257 | // Well, if you don't agree, you can't register. |
240 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
241 | - redirectexit(); |
|
258 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
259 | + redirectexit(); |
|
260 | + } |
|
242 | 261 | |
243 | 262 | // Make sure they came from *somewhere*, have a session. |
244 | - if (!isset($_SESSION['old_url'])) |
|
245 | - redirectexit('action=signup'); |
|
263 | + if (!isset($_SESSION['old_url'])) { |
|
264 | + redirectexit('action=signup'); |
|
265 | + } |
|
246 | 266 | |
247 | 267 | // If we don't require an agreement, we need a extra check for coppa. |
248 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
249 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
268 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
269 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
270 | + } |
|
250 | 271 | // Are they under age, and under age users are banned? |
251 | 272 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
252 | 273 | { |
@@ -255,8 +276,9 @@ discard block |
||
255 | 276 | } |
256 | 277 | |
257 | 278 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
258 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
259 | - redirectexit('action=signup'); |
|
279 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
280 | + redirectexit('action=signup'); |
|
281 | + } |
|
260 | 282 | // Failing that, check the time on it. |
261 | 283 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
262 | 284 | { |
@@ -276,15 +298,17 @@ discard block |
||
276 | 298 | if (is_array($context['visual_verification'])) |
277 | 299 | { |
278 | 300 | loadLanguage('Errors'); |
279 | - foreach ($context['visual_verification'] as $error) |
|
280 | - $reg_errors[] = $txt['error_' . $error]; |
|
301 | + foreach ($context['visual_verification'] as $error) { |
|
302 | + $reg_errors[] = $txt['error_' . $error]; |
|
303 | + } |
|
281 | 304 | } |
282 | 305 | } |
283 | 306 | |
284 | 307 | foreach ($_POST as $key => $value) |
285 | 308 | { |
286 | - if (!is_array($_POST[$key])) |
|
287 | - $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
309 | + if (!is_array($_POST[$key])) { |
|
310 | + $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
311 | + } |
|
288 | 312 | } |
289 | 313 | |
290 | 314 | // Collect all extra registration fields someone might have filled in. |
@@ -314,12 +338,14 @@ discard block |
||
314 | 338 | $reg_fields = explode(',', $modSettings['registration_fields']); |
315 | 339 | |
316 | 340 | // Website is a little different |
317 | - if (in_array('website', $reg_fields)) |
|
318 | - $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
|
341 | + if (in_array('website', $reg_fields)) { |
|
342 | + $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
|
343 | + } |
|
319 | 344 | } |
320 | 345 | |
321 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
322 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
346 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
347 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
348 | + } |
|
323 | 349 | |
324 | 350 | // Needed for isReservedName() and registerMember(). |
325 | 351 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -328,8 +354,9 @@ discard block |
||
328 | 354 | if (isset($_POST['real_name'])) |
329 | 355 | { |
330 | 356 | // Are you already allowed to edit the displayed name? |
331 | - if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) |
|
332 | - $canEditDisplayName = true; |
|
357 | + if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) { |
|
358 | + $canEditDisplayName = true; |
|
359 | + } |
|
333 | 360 | |
334 | 361 | // If you are a guest, will you be allowed to once you register? |
335 | 362 | else |
@@ -353,33 +380,38 @@ discard block |
||
353 | 380 | $_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name'])); |
354 | 381 | |
355 | 382 | // Only set it if we are sure it is good |
356 | - if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
357 | - $possible_strings[] = 'real_name'; |
|
383 | + if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
384 | + $possible_strings[] = 'real_name'; |
|
385 | + } |
|
358 | 386 | } |
359 | 387 | } |
360 | 388 | |
361 | 389 | // Handle a string as a birthdate... |
362 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
363 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
390 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
391 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
392 | + } |
|
364 | 393 | // Or birthdate parts... |
365 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
366 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
394 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
395 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
396 | + } |
|
367 | 397 | |
368 | 398 | // Validate the passed language file. |
369 | 399 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
370 | 400 | { |
371 | 401 | // Do we have any languages? |
372 | - if (empty($context['languages'])) |
|
373 | - getLanguages(); |
|
402 | + if (empty($context['languages'])) { |
|
403 | + getLanguages(); |
|
404 | + } |
|
374 | 405 | |
375 | 406 | // Did we find it? |
376 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
377 | - $_SESSION['language'] = $_POST['lngfile']; |
|
378 | - else |
|
407 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
408 | + $_SESSION['language'] = $_POST['lngfile']; |
|
409 | + } else { |
|
410 | + unset($_POST['lngfile']); |
|
411 | + } |
|
412 | + } else { |
|
379 | 413 | unset($_POST['lngfile']); |
380 | 414 | } |
381 | - else |
|
382 | - unset($_POST['lngfile']); |
|
383 | 415 | |
384 | 416 | // Set the options needed for registration. |
385 | 417 | $regOptions = array( |
@@ -399,22 +431,27 @@ discard block |
||
399 | 431 | ); |
400 | 432 | |
401 | 433 | // Include the additional options that might have been filled in. |
402 | - foreach ($possible_strings as $var) |
|
403 | - if (isset($_POST[$var])) |
|
434 | + foreach ($possible_strings as $var) { |
|
435 | + if (isset($_POST[$var])) |
|
404 | 436 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
405 | - foreach ($possible_ints as $var) |
|
406 | - if (isset($_POST[$var])) |
|
437 | + } |
|
438 | + foreach ($possible_ints as $var) { |
|
439 | + if (isset($_POST[$var])) |
|
407 | 440 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
408 | - foreach ($possible_floats as $var) |
|
409 | - if (isset($_POST[$var])) |
|
441 | + } |
|
442 | + foreach ($possible_floats as $var) { |
|
443 | + if (isset($_POST[$var])) |
|
410 | 444 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
411 | - foreach ($possible_bools as $var) |
|
412 | - if (isset($_POST[$var])) |
|
445 | + } |
|
446 | + foreach ($possible_bools as $var) { |
|
447 | + if (isset($_POST[$var])) |
|
413 | 448 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
449 | + } |
|
414 | 450 | |
415 | 451 | // Registration options are always default options... |
416 | - if (isset($_POST['default_options'])) |
|
417 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
452 | + if (isset($_POST['default_options'])) { |
|
453 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
454 | + } |
|
418 | 455 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
419 | 456 | |
420 | 457 | // Make sure they are clean, dammit! |
@@ -434,12 +471,14 @@ discard block |
||
434 | 471 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
435 | 472 | { |
436 | 473 | // Don't allow overriding of the theme variables. |
437 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
438 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
474 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
475 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
476 | + } |
|
439 | 477 | |
440 | 478 | // Not actually showing it then? |
441 | - if (!$row['show_reg']) |
|
442 | - continue; |
|
479 | + if (!$row['show_reg']) { |
|
480 | + continue; |
|
481 | + } |
|
443 | 482 | |
444 | 483 | // Prepare the value! |
445 | 484 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -448,24 +487,27 @@ discard block |
||
448 | 487 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
449 | 488 | { |
450 | 489 | // Is it too long? |
451 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
452 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
490 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
491 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
492 | + } |
|
453 | 493 | |
454 | 494 | // Any masks to apply? |
455 | 495 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
456 | 496 | { |
457 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
458 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
459 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
460 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
461 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
462 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
497 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
498 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
499 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
500 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
501 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
502 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
503 | + } |
|
463 | 504 | } |
464 | 505 | } |
465 | 506 | |
466 | 507 | // Is this required but not there? |
467 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
468 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
508 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
509 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
510 | + } |
|
469 | 511 | } |
470 | 512 | $smcFunc['db_free_result']($request); |
471 | 513 | |
@@ -473,8 +515,9 @@ discard block |
||
473 | 515 | if (!empty($custom_field_errors)) |
474 | 516 | { |
475 | 517 | loadLanguage('Errors'); |
476 | - foreach ($custom_field_errors as $error) |
|
477 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
518 | + foreach ($custom_field_errors as $error) { |
|
519 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
520 | + } |
|
478 | 521 | } |
479 | 522 | |
480 | 523 | // Lets check for other errors before trying to register the member. |
@@ -519,8 +562,9 @@ discard block |
||
519 | 562 | } |
520 | 563 | |
521 | 564 | // If COPPA has been selected then things get complicated, setup the template. |
522 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
523 | - redirectexit('action=coppa;member=' . $memberID); |
|
565 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
566 | + redirectexit('action=coppa;member=' . $memberID); |
|
567 | + } |
|
524 | 568 | // Basic template variable setup. |
525 | 569 | elseif (!empty($modSettings['registration_method'])) |
526 | 570 | { |
@@ -532,8 +576,7 @@ discard block |
||
532 | 576 | 'sub_template' => 'after', |
533 | 577 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
534 | 578 | ); |
535 | - } |
|
536 | - else |
|
579 | + } else |
|
537 | 580 | { |
538 | 581 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
539 | 582 | |
@@ -553,16 +596,18 @@ discard block |
||
553 | 596 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
554 | 597 | |
555 | 598 | // Logged in users should not bother to activate their accounts |
556 | - if (!empty($user_info['id'])) |
|
557 | - redirectexit(); |
|
599 | + if (!empty($user_info['id'])) { |
|
600 | + redirectexit(); |
|
601 | + } |
|
558 | 602 | |
559 | 603 | loadLanguage('Login'); |
560 | 604 | loadTemplate('Login'); |
561 | 605 | |
562 | 606 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
563 | 607 | { |
564 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
565 | - fatal_lang_error('no_access', false); |
|
608 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
609 | + fatal_lang_error('no_access', false); |
|
610 | + } |
|
566 | 611 | |
567 | 612 | $context['member_id'] = 0; |
568 | 613 | $context['sub_template'] = 'resend'; |
@@ -602,11 +647,13 @@ discard block |
||
602 | 647 | // Change their email address? (they probably tried a fake one first :P.) |
603 | 648 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
604 | 649 | { |
605 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
606 | - fatal_lang_error('no_access', false); |
|
650 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
651 | + fatal_lang_error('no_access', false); |
|
652 | + } |
|
607 | 653 | |
608 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
609 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
654 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
655 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
656 | + } |
|
610 | 657 | |
611 | 658 | // Make sure their email isn't banned. |
612 | 659 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -622,8 +669,9 @@ discard block |
||
622 | 669 | ) |
623 | 670 | ); |
624 | 671 | |
625 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
626 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
672 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
673 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
674 | + } |
|
627 | 675 | $smcFunc['db_free_result']($request); |
628 | 676 | |
629 | 677 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -661,9 +709,9 @@ discard block |
||
661 | 709 | // Quit if this code is not right. |
662 | 710 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
663 | 711 | { |
664 | - if (!empty($row['is_activated'])) |
|
665 | - fatal_lang_error('already_activated', false); |
|
666 | - elseif ($row['validation_code'] == '') |
|
712 | + if (!empty($row['is_activated'])) { |
|
713 | + fatal_lang_error('already_activated', false); |
|
714 | + } elseif ($row['validation_code'] == '') |
|
667 | 715 | { |
668 | 716 | loadLanguage('Profile'); |
669 | 717 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -713,8 +761,9 @@ discard block |
||
713 | 761 | loadTemplate('Register'); |
714 | 762 | |
715 | 763 | // No User ID?? |
716 | - if (!isset($_GET['member'])) |
|
717 | - fatal_lang_error('no_access', false); |
|
764 | + if (!isset($_GET['member'])) { |
|
765 | + fatal_lang_error('no_access', false); |
|
766 | + } |
|
718 | 767 | |
719 | 768 | // Get the user details... |
720 | 769 | $request = $smcFunc['db_query']('', ' |
@@ -727,8 +776,9 @@ discard block |
||
727 | 776 | 'is_coppa' => 5, |
728 | 777 | ) |
729 | 778 | ); |
730 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
731 | - fatal_lang_error('no_access', false); |
|
779 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
780 | + fatal_lang_error('no_access', false); |
|
781 | + } |
|
732 | 782 | list ($username) = $smcFunc['db_fetch_row']($request); |
733 | 783 | $smcFunc['db_free_result']($request); |
734 | 784 | |
@@ -766,8 +816,7 @@ discard block |
||
766 | 816 | echo $data; |
767 | 817 | obExit(false); |
768 | 818 | } |
769 | - } |
|
770 | - else |
|
819 | + } else |
|
771 | 820 | { |
772 | 821 | $context += array( |
773 | 822 | 'page_title' => $txt['coppa_title'], |
@@ -820,8 +869,9 @@ discard block |
||
820 | 869 | { |
821 | 870 | require_once($sourcedir . '/Subs-Graphics.php'); |
822 | 871 | |
823 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
824 | - header('HTTP/1.1 400 Bad Request'); |
|
872 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
873 | + header('HTTP/1.1 400 Bad Request'); |
|
874 | + } |
|
825 | 875 | |
826 | 876 | // Otherwise just show a pre-defined letter. |
827 | 877 | elseif (isset($_REQUEST['letter'])) |
@@ -839,14 +889,13 @@ discard block |
||
839 | 889 | header('content-type: image/gif'); |
840 | 890 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
841 | 891 | } |
842 | - } |
|
843 | - |
|
844 | - elseif ($_REQUEST['format'] === '.wav') |
|
892 | + } elseif ($_REQUEST['format'] === '.wav') |
|
845 | 893 | { |
846 | 894 | require_once($sourcedir . '/Subs-Sound.php'); |
847 | 895 | |
848 | - if (!createWaveFile($code)) |
|
849 | - header('HTTP/1.1 400 Bad Request'); |
|
896 | + if (!createWaveFile($code)) { |
|
897 | + header('HTTP/1.1 400 Bad Request'); |
|
898 | + } |
|
850 | 899 | } |
851 | 900 | |
852 | 901 | // We all die one day... |
@@ -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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
43 | 44 | |
44 | 45 | // Is the security option off? |
45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
46 | - return; |
|
46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
50 | - return; |
|
51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
52 | + return; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | if (isset($_POST[$type . '_pass'])) |
56 | 59 | { |
57 | 60 | // Check to ensure we're forcing SSL for authentication |
58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
59 | - fatal_lang_error('login_ssl_required'); |
|
61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
62 | + fatal_lang_error('login_ssl_required'); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | checkSession(); |
62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
72 | 76 | } |
73 | 77 | |
74 | 78 | // Better be sure to remember the real referer |
75 | - if (empty($_SESSION['request_referer'])) |
|
76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
77 | - elseif (empty($_POST)) |
|
78 | - unset($_SESSION['request_referer']); |
|
79 | + if (empty($_SESSION['request_referer'])) { |
|
80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
81 | + } elseif (empty($_POST)) { |
|
82 | + unset($_SESSION['request_referer']); |
|
83 | + } |
|
79 | 84 | |
80 | 85 | // Need to type in a password for that, man. |
81 | - if (!isset($_GET['xml'])) |
|
82 | - adminLogin($type); |
|
83 | - else |
|
84 | - return 'session_verify_fail'; |
|
85 | -} |
|
86 | + if (!isset($_GET['xml'])) { |
|
87 | + adminLogin($type); |
|
88 | + } else { |
|
89 | + return 'session_verify_fail'; |
|
90 | + } |
|
91 | + } |
|
86 | 92 | |
87 | 93 | /** |
88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
97 | 103 | |
98 | 104 | // Luckily, this person isn't a guest. |
99 | - if (!$user_info['is_guest']) |
|
100 | - return; |
|
105 | + if (!$user_info['is_guest']) { |
|
106 | + return; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | // Log what they were trying to do didn't work) |
103 | - if (!empty($modSettings['who_enabled'])) |
|
104 | - $_GET['error'] = 'guest_login'; |
|
110 | + if (!empty($modSettings['who_enabled'])) { |
|
111 | + $_GET['error'] = 'guest_login'; |
|
112 | + } |
|
105 | 113 | writeLog(true); |
106 | 114 | |
107 | 115 | // Just die. |
108 | - if (isset($_REQUEST['xml'])) |
|
109 | - obExit(false); |
|
116 | + if (isset($_REQUEST['xml'])) { |
|
117 | + obExit(false); |
|
118 | + } |
|
110 | 119 | |
111 | 120 | // Attempt to detect if they came from dlattach. |
112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
113 | - loadTheme(); |
|
121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
122 | + loadTheme(); |
|
123 | + } |
|
114 | 124 | |
115 | 125 | // Never redirect to an attachment |
116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
128 | + } |
|
118 | 129 | |
119 | 130 | // Load the Login template and language file. |
120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
124 | 135 | { |
125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
126 | 137 | redirectexit('action=login'); |
127 | - } |
|
128 | - else |
|
138 | + } else |
|
129 | 139 | { |
130 | 140 | loadTemplate('Login'); |
131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
156 | 166 | |
157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
158 | - if ($user_info['is_admin']) |
|
159 | - return; |
|
168 | + if ($user_info['is_admin']) { |
|
169 | + return; |
|
170 | + } |
|
160 | 171 | |
161 | 172 | // Only check the ban every so often. (to reduce load.) |
162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
177 | 188 | // Check both IP addresses. |
178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
179 | 190 | { |
180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
181 | - continue; |
|
191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
192 | + continue; |
|
193 | + } |
|
182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
228 | 240 | // Store every type of ban that applies to you in your session. |
229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
230 | 242 | { |
231 | - foreach ($restrictions as $restriction) |
|
232 | - if (!empty($row[$restriction])) |
|
243 | + foreach ($restrictions as $restriction) { |
|
244 | + if (!empty($row[$restriction])) |
|
233 | 245 | { |
234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
247 | + } |
|
235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
251 | + } |
|
238 | 252 | |
239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
240 | - $flag_is_activated = true; |
|
253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
254 | + $flag_is_activated = true; |
|
255 | + } |
|
241 | 256 | } |
242 | 257 | } |
243 | 258 | $smcFunc['db_free_result']($request); |
244 | 259 | } |
245 | 260 | |
246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
261 | 277 | { |
262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
263 | - foreach ($bans as $key => $value) |
|
264 | - $bans[$key] = (int) $value; |
|
279 | + foreach ($bans as $key => $value) { |
|
280 | + $bans[$key] = (int) $value; |
|
281 | + } |
|
265 | 282 | $request = $smcFunc['db_query']('', ' |
266 | 283 | SELECT bi.id_ban, bg.reason |
267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -297,14 +314,15 @@ discard block |
||
297 | 314 | if (isset($_SESSION['ban']['cannot_access'])) |
298 | 315 | { |
299 | 316 | // We don't wanna see you! |
300 | - if (!$user_info['is_guest']) |
|
301 | - $smcFunc['db_query']('', ' |
|
317 | + if (!$user_info['is_guest']) { |
|
318 | + $smcFunc['db_query']('', ' |
|
302 | 319 | DELETE FROM {db_prefix}log_online |
303 | 320 | WHERE id_member = {int:current_member}', |
304 | 321 | array( |
305 | 322 | 'current_member' => $user_info['id'], |
306 | 323 | ) |
307 | 324 | ); |
325 | + } |
|
308 | 326 | |
309 | 327 | // 'Log' the user out. Can't have any funny business... (save the name!) |
310 | 328 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -390,9 +408,10 @@ discard block |
||
390 | 408 | } |
391 | 409 | |
392 | 410 | // Fix up the banning permissions. |
393 | - if (isset($user_info['permissions'])) |
|
394 | - banPermissions(); |
|
395 | -} |
|
411 | + if (isset($user_info['permissions'])) { |
|
412 | + banPermissions(); |
|
413 | + } |
|
414 | + } |
|
396 | 415 | |
397 | 416 | /** |
398 | 417 | * Fix permissions according to ban status. |
@@ -403,8 +422,9 @@ discard block |
||
403 | 422 | global $user_info, $sourcedir, $modSettings, $context; |
404 | 423 | |
405 | 424 | // Somehow they got here, at least take away all permissions... |
406 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
407 | - $user_info['permissions'] = array(); |
|
425 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
426 | + $user_info['permissions'] = array(); |
|
427 | + } |
|
408 | 428 | // Okay, well, you can watch, but don't touch a thing. |
409 | 429 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
410 | 430 | { |
@@ -446,19 +466,20 @@ discard block |
||
446 | 466 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
447 | 467 | foreach ($permission_change as $old => $new) |
448 | 468 | { |
449 | - if (!in_array($old, $user_info['permissions'])) |
|
450 | - unset($permission_change[$old]); |
|
451 | - else |
|
452 | - $user_info['permissions'][] = $new; |
|
469 | + if (!in_array($old, $user_info['permissions'])) { |
|
470 | + unset($permission_change[$old]); |
|
471 | + } else { |
|
472 | + $user_info['permissions'][] = $new; |
|
473 | + } |
|
453 | 474 | } |
454 | 475 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
455 | 476 | } |
456 | 477 | |
457 | 478 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
458 | 479 | // Finally, some bits we cache in the session because it saves queries. |
459 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
460 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
461 | - else |
|
480 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
481 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
482 | + } else |
|
462 | 483 | { |
463 | 484 | require_once($sourcedir . '/Subs-Auth.php'); |
464 | 485 | rebuildModCache(); |
@@ -469,14 +490,12 @@ discard block |
||
469 | 490 | { |
470 | 491 | $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
471 | 492 | $context['open_member_reports'] = $_SESSION['rc']['member_reports']; |
472 | - } |
|
473 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
493 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
474 | 494 | { |
475 | 495 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
476 | 496 | $context['open_mod_reports'] = recountOpenReports('posts'); |
477 | 497 | $context['open_member_reports'] = recountOpenReports('members'); |
478 | - } |
|
479 | - else |
|
498 | + } else |
|
480 | 499 | { |
481 | 500 | $context['open_mod_reports'] = 0; |
482 | 501 | $context['open_member_reports'] = 0; |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | global $user_info, $smcFunc; |
497 | 516 | |
498 | 517 | // Don't log web accelerators, it's very confusing... |
499 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
500 | - return; |
|
518 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
519 | + return; |
|
520 | + } |
|
501 | 521 | |
502 | 522 | $smcFunc['db_insert']('', |
503 | 523 | '{db_prefix}log_banned', |
@@ -507,8 +527,8 @@ discard block |
||
507 | 527 | ); |
508 | 528 | |
509 | 529 | // One extra point for these bans. |
510 | - if (!empty($ban_ids)) |
|
511 | - $smcFunc['db_query']('', ' |
|
530 | + if (!empty($ban_ids)) { |
|
531 | + $smcFunc['db_query']('', ' |
|
512 | 532 | UPDATE {db_prefix}ban_items |
513 | 533 | SET hits = hits + 1 |
514 | 534 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -516,7 +536,8 @@ discard block |
||
516 | 536 | 'ban_ids' => $ban_ids, |
517 | 537 | ) |
518 | 538 | ); |
519 | -} |
|
539 | + } |
|
540 | + } |
|
520 | 541 | |
521 | 542 | /** |
522 | 543 | * Checks if a given email address might be banned. |
@@ -532,8 +553,9 @@ discard block |
||
532 | 553 | global $txt, $smcFunc; |
533 | 554 | |
534 | 555 | // Can't ban an empty email |
535 | - if (empty($email) || trim($email) == '') |
|
536 | - return; |
|
556 | + if (empty($email) || trim($email) == '') { |
|
557 | + return; |
|
558 | + } |
|
537 | 559 | |
538 | 560 | // Let's start with the bans based on your IP/hostname/memberID... |
539 | 561 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -606,16 +628,18 @@ discard block |
||
606 | 628 | if ($type == 'post') |
607 | 629 | { |
608 | 630 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
609 | - if ($check !== $sc) |
|
610 | - $error = 'session_timeout'; |
|
631 | + if ($check !== $sc) { |
|
632 | + $error = 'session_timeout'; |
|
633 | + } |
|
611 | 634 | } |
612 | 635 | |
613 | 636 | // How about $_GET['sesc']? |
614 | 637 | elseif ($type == 'get') |
615 | 638 | { |
616 | 639 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
617 | - if ($check !== $sc) |
|
618 | - $error = 'session_verify_fail'; |
|
640 | + if ($check !== $sc) { |
|
641 | + $error = 'session_verify_fail'; |
|
642 | + } |
|
619 | 643 | } |
620 | 644 | |
621 | 645 | // Or can it be in either? |
@@ -623,13 +647,15 @@ discard block |
||
623 | 647 | { |
624 | 648 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
625 | 649 | |
626 | - if ($check !== $sc) |
|
627 | - $error = 'session_verify_fail'; |
|
650 | + if ($check !== $sc) { |
|
651 | + $error = 'session_verify_fail'; |
|
652 | + } |
|
628 | 653 | } |
629 | 654 | |
630 | 655 | // Verify that they aren't changing user agents on us - that could be bad. |
631 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
632 | - $error = 'session_verify_fail'; |
|
656 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
657 | + $error = 'session_verify_fail'; |
|
658 | + } |
|
633 | 659 | |
634 | 660 | // Make sure a page with session check requirement is not being prefetched. |
635 | 661 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -640,30 +666,35 @@ discard block |
||
640 | 666 | } |
641 | 667 | |
642 | 668 | // Check the referring site - it should be the same server at least! |
643 | - if (isset($_SESSION['request_referer'])) |
|
644 | - $referrer = $_SESSION['request_referer']; |
|
645 | - else |
|
646 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
669 | + if (isset($_SESSION['request_referer'])) { |
|
670 | + $referrer = $_SESSION['request_referer']; |
|
671 | + } else { |
|
672 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
673 | + } |
|
647 | 674 | if (!empty($referrer['host'])) |
648 | 675 | { |
649 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
650 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
651 | - else |
|
652 | - $real_host = $_SERVER['HTTP_HOST']; |
|
676 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
677 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
678 | + } else { |
|
679 | + $real_host = $_SERVER['HTTP_HOST']; |
|
680 | + } |
|
653 | 681 | |
654 | 682 | $parsed_url = parse_url($boardurl); |
655 | 683 | |
656 | 684 | // Are global cookies on? If so, let's check them ;). |
657 | 685 | if (!empty($modSettings['globalCookies'])) |
658 | 686 | { |
659 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
660 | - $parsed_url['host'] = $parts[1]; |
|
687 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
688 | + $parsed_url['host'] = $parts[1]; |
|
689 | + } |
|
661 | 690 | |
662 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
663 | - $referrer['host'] = $parts[1]; |
|
691 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
692 | + $referrer['host'] = $parts[1]; |
|
693 | + } |
|
664 | 694 | |
665 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
666 | - $real_host = $parts[1]; |
|
695 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
696 | + $real_host = $parts[1]; |
|
697 | + } |
|
667 | 698 | } |
668 | 699 | |
669 | 700 | // Okay: referrer must either match parsed_url or real_host. |
@@ -681,12 +712,14 @@ discard block |
||
681 | 712 | $log_error = true; |
682 | 713 | } |
683 | 714 | |
684 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
685 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
715 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
716 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
717 | + } |
|
686 | 718 | |
687 | 719 | // Everything is ok, return an empty string. |
688 | - if (!isset($error)) |
|
689 | - return ''; |
|
720 | + if (!isset($error)) { |
|
721 | + return ''; |
|
722 | + } |
|
690 | 723 | // A session error occurred, show the error. |
691 | 724 | elseif ($is_fatal) |
692 | 725 | { |
@@ -695,13 +728,14 @@ discard block |
||
695 | 728 | ob_end_clean(); |
696 | 729 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
697 | 730 | die; |
731 | + } else { |
|
732 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
698 | 733 | } |
699 | - else |
|
700 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
701 | 734 | } |
702 | 735 | // A session error occurred, return the error to the calling function. |
703 | - else |
|
704 | - return $error; |
|
736 | + else { |
|
737 | + return $error; |
|
738 | + } |
|
705 | 739 | |
706 | 740 | // We really should never fall through here, for very important reasons. Let's make sure. |
707 | 741 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -717,10 +751,9 @@ discard block |
||
717 | 751 | { |
718 | 752 | global $modSettings; |
719 | 753 | |
720 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
721 | - return true; |
|
722 | - |
|
723 | - else |
|
754 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
755 | + return true; |
|
756 | + } else |
|
724 | 757 | { |
725 | 758 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
726 | 759 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -771,9 +804,9 @@ discard block |
||
771 | 804 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
772 | 805 | unset($_SESSION['token'][$type . '-' . $action]); |
773 | 806 | return $return; |
807 | + } else { |
|
808 | + return ''; |
|
774 | 809 | } |
775 | - else |
|
776 | - return ''; |
|
777 | 810 | } |
778 | 811 | |
779 | 812 | // This nasty piece of code validates a token. |
@@ -804,12 +837,14 @@ discard block |
||
804 | 837 | fatal_lang_error('token_verify_fail', false); |
805 | 838 | } |
806 | 839 | // Remove this token as its useless |
807 | - else |
|
808 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
840 | + else { |
|
841 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
842 | + } |
|
809 | 843 | |
810 | 844 | // Randomly check if we should remove some older tokens. |
811 | - if (mt_rand(0, 138) == 23) |
|
812 | - cleanTokens(); |
|
845 | + if (mt_rand(0, 138) == 23) { |
|
846 | + cleanTokens(); |
|
847 | + } |
|
813 | 848 | |
814 | 849 | return false; |
815 | 850 | } |
@@ -824,14 +859,16 @@ discard block |
||
824 | 859 | function cleanTokens($complete = false) |
825 | 860 | { |
826 | 861 | // We appreciate cleaning up after yourselves. |
827 | - if (!isset($_SESSION['token'])) |
|
828 | - return; |
|
862 | + if (!isset($_SESSION['token'])) { |
|
863 | + return; |
|
864 | + } |
|
829 | 865 | |
830 | 866 | // Clean up tokens, trying to give enough time still. |
831 | - foreach ($_SESSION['token'] as $key => $data) |
|
832 | - if ($data[2] + 10800 < time() || $complete) |
|
867 | + foreach ($_SESSION['token'] as $key => $data) { |
|
868 | + if ($data[2] + 10800 < time() || $complete) |
|
833 | 869 | unset($_SESSION['token'][$key]); |
834 | -} |
|
870 | + } |
|
871 | + } |
|
835 | 872 | |
836 | 873 | /** |
837 | 874 | * Check whether a form has been submitted twice. |
@@ -849,37 +886,40 @@ discard block |
||
849 | 886 | { |
850 | 887 | global $context; |
851 | 888 | |
852 | - if (!isset($_SESSION['forms'])) |
|
853 | - $_SESSION['forms'] = array(); |
|
889 | + if (!isset($_SESSION['forms'])) { |
|
890 | + $_SESSION['forms'] = array(); |
|
891 | + } |
|
854 | 892 | |
855 | 893 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
856 | 894 | if ($action == 'register') |
857 | 895 | { |
858 | 896 | $context['form_sequence_number'] = 0; |
859 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
860 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
897 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
898 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
899 | + } |
|
861 | 900 | } |
862 | 901 | // Check whether the submitted number can be found in the session. |
863 | 902 | elseif ($action == 'check') |
864 | 903 | { |
865 | - if (!isset($_REQUEST['seqnum'])) |
|
866 | - return true; |
|
867 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
904 | + if (!isset($_REQUEST['seqnum'])) { |
|
905 | + return true; |
|
906 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
868 | 907 | { |
869 | 908 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
870 | 909 | return true; |
910 | + } elseif ($is_fatal) { |
|
911 | + fatal_lang_error('error_form_already_submitted', false); |
|
912 | + } else { |
|
913 | + return false; |
|
871 | 914 | } |
872 | - elseif ($is_fatal) |
|
873 | - fatal_lang_error('error_form_already_submitted', false); |
|
874 | - else |
|
875 | - return false; |
|
876 | 915 | } |
877 | 916 | // Don't check, just free the stack number. |
878 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
879 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
880 | - elseif ($action != 'free') |
|
881 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
882 | -} |
|
917 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
918 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
919 | + } elseif ($action != 'free') { |
|
920 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
921 | + } |
|
922 | + } |
|
883 | 923 | |
884 | 924 | /** |
885 | 925 | * Check the user's permissions. |
@@ -898,16 +938,19 @@ discard block |
||
898 | 938 | global $user_info, $smcFunc; |
899 | 939 | |
900 | 940 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
901 | - if (empty($permission)) |
|
902 | - return true; |
|
941 | + if (empty($permission)) { |
|
942 | + return true; |
|
943 | + } |
|
903 | 944 | |
904 | 945 | // You're never allowed to do something if your data hasn't been loaded yet! |
905 | - if (empty($user_info)) |
|
906 | - return false; |
|
946 | + if (empty($user_info)) { |
|
947 | + return false; |
|
948 | + } |
|
907 | 949 | |
908 | 950 | // Administrators are supermen :P. |
909 | - if ($user_info['is_admin']) |
|
910 | - return true; |
|
951 | + if ($user_info['is_admin']) { |
|
952 | + return true; |
|
953 | + } |
|
911 | 954 | |
912 | 955 | // Let's ensure this is an array. |
913 | 956 | $permission = (array) $permission; |
@@ -915,14 +958,16 @@ discard block |
||
915 | 958 | // Are we checking the _current_ board, or some other boards? |
916 | 959 | if ($boards === null) |
917 | 960 | { |
918 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
919 | - return true; |
|
961 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
962 | + return true; |
|
963 | + } |
|
920 | 964 | // You aren't allowed, by default. |
921 | - else |
|
922 | - return false; |
|
965 | + else { |
|
966 | + return false; |
|
967 | + } |
|
968 | + } elseif (!is_array($boards)) { |
|
969 | + $boards = array($boards); |
|
923 | 970 | } |
924 | - elseif (!is_array($boards)) |
|
925 | - $boards = array($boards); |
|
926 | 971 | |
927 | 972 | $request = $smcFunc['db_query']('', ' |
928 | 973 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -950,20 +995,23 @@ discard block |
||
950 | 995 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
951 | 996 | { |
952 | 997 | $result = !empty($row['add_deny']); |
953 | - if ($result == true) |
|
954 | - break; |
|
998 | + if ($result == true) { |
|
999 | + break; |
|
1000 | + } |
|
955 | 1001 | } |
956 | 1002 | $smcFunc['db_free_result']($request); |
957 | 1003 | return $result; |
958 | 1004 | } |
959 | 1005 | |
960 | 1006 | // Make sure they can do it on all of the boards. |
961 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
962 | - return false; |
|
1007 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
1008 | + return false; |
|
1009 | + } |
|
963 | 1010 | |
964 | 1011 | $result = true; |
965 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
966 | - $result &= !empty($row['add_deny']); |
|
1012 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1013 | + $result &= !empty($row['add_deny']); |
|
1014 | + } |
|
967 | 1015 | $smcFunc['db_free_result']($request); |
968 | 1016 | |
969 | 1017 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1030,9 +1078,10 @@ discard block |
||
1030 | 1078 | |
1031 | 1079 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
1032 | 1080 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
1033 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
1034 | - validateSession(); |
|
1035 | -} |
|
1081 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
1082 | + validateSession(); |
|
1083 | + } |
|
1084 | + } |
|
1036 | 1085 | |
1037 | 1086 | /** |
1038 | 1087 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1051,8 +1100,9 @@ discard block |
||
1051 | 1100 | global $user_info, $smcFunc; |
1052 | 1101 | |
1053 | 1102 | // Arrays are nice, most of the time. |
1054 | - if (!is_array($permissions)) |
|
1055 | - $permissions = array($permissions); |
|
1103 | + if (!is_array($permissions)) { |
|
1104 | + $permissions = array($permissions); |
|
1105 | + } |
|
1056 | 1106 | |
1057 | 1107 | /* |
1058 | 1108 | * Set $simple to true to use this function as it were in SMF 2.0.x. |
@@ -1064,13 +1114,14 @@ discard block |
||
1064 | 1114 | // Administrators are all powerful, sorry. |
1065 | 1115 | if ($user_info['is_admin']) |
1066 | 1116 | { |
1067 | - if ($simple) |
|
1068 | - return array(0); |
|
1069 | - else |
|
1117 | + if ($simple) { |
|
1118 | + return array(0); |
|
1119 | + } else |
|
1070 | 1120 | { |
1071 | 1121 | $boards = array(); |
1072 | - foreach ($permissions as $permission) |
|
1073 | - $boards[$permission] = array(0); |
|
1122 | + foreach ($permissions as $permission) { |
|
1123 | + $boards[$permission] = array(0); |
|
1124 | + } |
|
1074 | 1125 | |
1075 | 1126 | return $boards; |
1076 | 1127 | } |
@@ -1102,31 +1153,32 @@ discard block |
||
1102 | 1153 | { |
1103 | 1154 | if ($simple) |
1104 | 1155 | { |
1105 | - if (empty($row['add_deny'])) |
|
1106 | - $deny_boards[] = $row['id_board']; |
|
1107 | - else |
|
1108 | - $boards[] = $row['id_board']; |
|
1109 | - } |
|
1110 | - else |
|
1156 | + if (empty($row['add_deny'])) { |
|
1157 | + $deny_boards[] = $row['id_board']; |
|
1158 | + } else { |
|
1159 | + $boards[] = $row['id_board']; |
|
1160 | + } |
|
1161 | + } else |
|
1111 | 1162 | { |
1112 | - if (empty($row['add_deny'])) |
|
1113 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
1114 | - else |
|
1115 | - $boards[$row['permission']][] = $row['id_board']; |
|
1163 | + if (empty($row['add_deny'])) { |
|
1164 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
1165 | + } else { |
|
1166 | + $boards[$row['permission']][] = $row['id_board']; |
|
1167 | + } |
|
1116 | 1168 | } |
1117 | 1169 | } |
1118 | 1170 | $smcFunc['db_free_result']($request); |
1119 | 1171 | |
1120 | - if ($simple) |
|
1121 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1122 | - else |
|
1172 | + if ($simple) { |
|
1173 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1174 | + } else |
|
1123 | 1175 | { |
1124 | 1176 | foreach ($permissions as $permission) |
1125 | 1177 | { |
1126 | 1178 | // never had it to start with |
1127 | - if (empty($boards[$permission])) |
|
1128 | - $boards[$permission] = array(); |
|
1129 | - else |
|
1179 | + if (empty($boards[$permission])) { |
|
1180 | + $boards[$permission] = array(); |
|
1181 | + } else |
|
1130 | 1182 | { |
1131 | 1183 | // Or it may have been removed |
1132 | 1184 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1162,10 +1214,11 @@ discard block |
||
1162 | 1214 | |
1163 | 1215 | |
1164 | 1216 | // Moderators are free... |
1165 | - if (!allowedTo('moderate_board')) |
|
1166 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1167 | - else |
|
1168 | - $timeLimit = 2; |
|
1217 | + if (!allowedTo('moderate_board')) { |
|
1218 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1219 | + } else { |
|
1220 | + $timeLimit = 2; |
|
1221 | + } |
|
1169 | 1222 | |
1170 | 1223 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
1171 | 1224 | |
@@ -1192,8 +1245,9 @@ discard block |
||
1192 | 1245 | if ($smcFunc['db_affected_rows']() != 1) |
1193 | 1246 | { |
1194 | 1247 | // Spammer! You only have to wait a *few* seconds! |
1195 | - if (!$only_return_result) |
|
1196 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1248 | + if (!$only_return_result) { |
|
1249 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1250 | + } |
|
1197 | 1251 | |
1198 | 1252 | return true; |
1199 | 1253 | } |
@@ -1211,11 +1265,13 @@ discard block |
||
1211 | 1265 | */ |
1212 | 1266 | function secureDirectory($path, $attachments = false) |
1213 | 1267 | { |
1214 | - if (empty($path)) |
|
1215 | - return 'empty_path'; |
|
1268 | + if (empty($path)) { |
|
1269 | + return 'empty_path'; |
|
1270 | + } |
|
1216 | 1271 | |
1217 | - if (!is_writable($path)) |
|
1218 | - return 'path_not_writable'; |
|
1272 | + if (!is_writable($path)) { |
|
1273 | + return 'path_not_writable'; |
|
1274 | + } |
|
1219 | 1275 | |
1220 | 1276 | $directoryname = basename($path); |
1221 | 1277 | |
@@ -1227,9 +1283,9 @@ discard block |
||
1227 | 1283 | |
1228 | 1284 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
1229 | 1285 | |
1230 | - if (file_exists($path . '/.htaccess')) |
|
1231 | - $errors[] = 'htaccess_exists'; |
|
1232 | - else |
|
1286 | + if (file_exists($path . '/.htaccess')) { |
|
1287 | + $errors[] = 'htaccess_exists'; |
|
1288 | + } else |
|
1233 | 1289 | { |
1234 | 1290 | $fh = @fopen($path . '/.htaccess', 'w'); |
1235 | 1291 | if ($fh) { |
@@ -1241,9 +1297,9 @@ discard block |
||
1241 | 1297 | $errors[] = 'htaccess_cannot_create_file'; |
1242 | 1298 | } |
1243 | 1299 | |
1244 | - if (file_exists($path . '/index.php')) |
|
1245 | - $errors[] = 'index-php_exists'; |
|
1246 | - else |
|
1300 | + if (file_exists($path . '/index.php')) { |
|
1301 | + $errors[] = 'index-php_exists'; |
|
1302 | + } else |
|
1247 | 1303 | { |
1248 | 1304 | $fh = @fopen($path . '/index.php', 'w'); |
1249 | 1305 | if ($fh) { |
@@ -1270,11 +1326,12 @@ discard block |
||
1270 | 1326 | $errors[] = 'index-php_cannot_create_file'; |
1271 | 1327 | } |
1272 | 1328 | |
1273 | - if (!empty($errors)) |
|
1274 | - return $errors; |
|
1275 | - else |
|
1276 | - return true; |
|
1277 | -} |
|
1329 | + if (!empty($errors)) { |
|
1330 | + return $errors; |
|
1331 | + } else { |
|
1332 | + return true; |
|
1333 | + } |
|
1334 | + } |
|
1278 | 1335 | |
1279 | 1336 | /** |
1280 | 1337 | * This sets the X-Frame-Options header. |
@@ -1287,14 +1344,16 @@ discard block |
||
1287 | 1344 | global $modSettings; |
1288 | 1345 | |
1289 | 1346 | $option = 'SAMEORIGIN'; |
1290 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
1291 | - $option = $modSettings['frame_security']; |
|
1292 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
1293 | - $option = $override; |
|
1347 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
1348 | + $option = $modSettings['frame_security']; |
|
1349 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
1350 | + $option = $override; |
|
1351 | + } |
|
1294 | 1352 | |
1295 | 1353 | // Don't bother setting the header if we have disabled it. |
1296 | - if ($option == 'DISABLE') |
|
1297 | - return; |
|
1354 | + if ($option == 'DISABLE') { |
|
1355 | + return; |
|
1356 | + } |
|
1298 | 1357 | |
1299 | 1358 | // Finally set it. |
1300 | 1359 | header('x-frame-options: ' . $option); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main admin handling function.<br> |
@@ -444,8 +445,9 @@ discard block |
||
444 | 445 | foreach ($admin_includes as $include) |
445 | 446 | { |
446 | 447 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
447 | - if (file_exists($include)) |
|
448 | - require_once($include); |
|
448 | + if (file_exists($include)) { |
|
449 | + require_once($include); |
|
450 | + } |
|
449 | 451 | } |
450 | 452 | } |
451 | 453 | |
@@ -457,24 +459,27 @@ discard block |
||
457 | 459 | unset($admin_areas); |
458 | 460 | |
459 | 461 | // Nothing valid? |
460 | - if ($admin_include_data == false) |
|
461 | - fatal_lang_error('no_access', false); |
|
462 | + if ($admin_include_data == false) { |
|
463 | + fatal_lang_error('no_access', false); |
|
464 | + } |
|
462 | 465 | |
463 | 466 | // Build the link tree. |
464 | 467 | $context['linktree'][] = array( |
465 | 468 | 'url' => $scripturl . '?action=admin', |
466 | 469 | 'name' => $txt['admin_center'], |
467 | 470 | ); |
468 | - if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
|
469 | - $context['linktree'][] = array( |
|
471 | + if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') { |
|
472 | + $context['linktree'][] = array( |
|
470 | 473 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
471 | 474 | 'name' => $admin_include_data['label'], |
472 | 475 | ); |
473 | - if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
|
474 | - $context['linktree'][] = array( |
|
476 | + } |
|
477 | + if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) { |
|
478 | + $context['linktree'][] = array( |
|
475 | 479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
476 | 480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
477 | 481 | ); |
482 | + } |
|
478 | 483 | |
479 | 484 | // Make a note of the Unique ID for this menu. |
480 | 485 | $context['admin_menu_id'] = $context['max_menu_id']; |
@@ -484,16 +489,18 @@ discard block |
||
484 | 489 | $context['admin_area'] = $admin_include_data['current_area']; |
485 | 490 | |
486 | 491 | // Now - finally - call the right place! |
487 | - if (isset($admin_include_data['file'])) |
|
488 | - require_once($sourcedir . '/' . $admin_include_data['file']); |
|
492 | + if (isset($admin_include_data['file'])) { |
|
493 | + require_once($sourcedir . '/' . $admin_include_data['file']); |
|
494 | + } |
|
489 | 495 | |
490 | 496 | // Get the right callable. |
491 | 497 | $call = call_helper($admin_include_data['function'], true); |
492 | 498 | |
493 | 499 | // Is it valid? |
494 | - if (!empty($call)) |
|
495 | - call_user_func($call); |
|
496 | -} |
|
500 | + if (!empty($call)) { |
|
501 | + call_user_func($call); |
|
502 | + } |
|
503 | + } |
|
497 | 504 | |
498 | 505 | /** |
499 | 506 | * The main administration section. |
@@ -547,13 +554,14 @@ discard block |
||
547 | 554 | |
548 | 555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
549 | 556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
550 | - if ($context['admin_area'] != 'credits') |
|
551 | - $context[$context['admin_menu_name']]['tab_data'] = array( |
|
557 | + if ($context['admin_area'] != 'credits') { |
|
558 | + $context[$context['admin_menu_name']]['tab_data'] = array( |
|
552 | 559 | 'title' => $txt['admin_center'], |
553 | 560 | 'help' => '', |
554 | 561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
555 | 562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
556 | 563 | ); |
564 | + } |
|
557 | 565 | |
558 | 566 | // Lastly, fill in the blanks in the support resources paragraphs. |
559 | 567 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
@@ -571,9 +579,10 @@ discard block |
||
571 | 579 | 'https://www.simplemachines.org/redirect/customize_support' |
572 | 580 | ); |
573 | 581 | |
574 | - if ($context['admin_area'] == 'admin') |
|
575 | - loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
576 | -} |
|
582 | + if ($context['admin_area'] == 'admin') { |
|
583 | + loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
584 | + } |
|
585 | + } |
|
577 | 586 | |
578 | 587 | /** |
579 | 588 | * Get one of the admin information files from Simple Machines. |
@@ -584,8 +593,9 @@ discard block |
||
584 | 593 | |
585 | 594 | setMemoryLimit('32M'); |
586 | 595 | |
587 | - if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
|
588 | - fatal_lang_error('no_access', false); |
|
596 | + if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) { |
|
597 | + fatal_lang_error('no_access', false); |
|
598 | + } |
|
589 | 599 | |
590 | 600 | // Strip off the forum cache part or we won't find it... |
591 | 601 | $_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']); |
@@ -600,27 +610,30 @@ discard block |
||
600 | 610 | ) |
601 | 611 | ); |
602 | 612 | |
603 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
604 | - fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
614 | + fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
615 | + } |
|
605 | 616 | |
606 | 617 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
607 | 618 | $smcFunc['db_free_result']($request); |
608 | 619 | |
609 | 620 | // @todo Temp |
610 | 621 | // Figure out if sesc is still being used. |
611 | - if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
|
612 | - $file_data = ' |
|
622 | + if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') { |
|
623 | + $file_data = ' |
|
613 | 624 | if (!(\'smfForum_sessionvar\' in window)) |
614 | 625 | window.smfForum_sessionvar = \'sesc\'; |
615 | 626 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
627 | + } |
|
616 | 628 | |
617 | 629 | $context['template_layers'] = array(); |
618 | 630 | // Lets make sure we aren't going to output anything nasty. |
619 | 631 | @ob_end_clean(); |
620 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
621 | - @ob_start('ob_gzhandler'); |
|
622 | - else |
|
623 | - @ob_start(); |
|
632 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
633 | + @ob_start('ob_gzhandler'); |
|
634 | + } else { |
|
635 | + @ob_start(); |
|
636 | + } |
|
624 | 637 | |
625 | 638 | // Make sure they know what type of file we are. |
626 | 639 | header('content-type: ' . $filetype); |
@@ -660,11 +673,12 @@ discard block |
||
660 | 673 | updateAdminPreferences(); |
661 | 674 | } |
662 | 675 | |
663 | - if (trim($context['search_term']) == '') |
|
664 | - $context['search_results'] = array(); |
|
665 | - else |
|
666 | - call_helper($subActions[$context['search_type']]); |
|
667 | -} |
|
676 | + if (trim($context['search_term']) == '') { |
|
677 | + $context['search_results'] = array(); |
|
678 | + } else { |
|
679 | + call_helper($subActions[$context['search_type']]); |
|
680 | + } |
|
681 | + } |
|
668 | 682 | |
669 | 683 | /** |
670 | 684 | * A complicated but relatively quick internal search. |
@@ -728,8 +742,9 @@ discard block |
||
728 | 742 | |
729 | 743 | loadLanguage(implode('+', $language_files)); |
730 | 744 | |
731 | - foreach ($include_files as $file) |
|
732 | - require_once($sourcedir . '/' . $file . '.php'); |
|
745 | + foreach ($include_files as $file) { |
|
746 | + require_once($sourcedir . '/' . $file . '.php'); |
|
747 | + } |
|
733 | 748 | |
734 | 749 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
735 | 750 | 0 = Language index (Can be array of indexes) to search through for this setting. |
@@ -753,11 +768,12 @@ discard block |
||
753 | 768 | foreach ($section['areas'] as $menu_key => $menu_item) |
754 | 769 | { |
755 | 770 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
756 | - if (!empty($menu_item['subsections'])) |
|
757 | - foreach ($menu_item['subsections'] as $key => $sublabel) |
|
771 | + if (!empty($menu_item['subsections'])) { |
|
772 | + foreach ($menu_item['subsections'] as $key => $sublabel) |
|
758 | 773 | { |
759 | 774 | if (isset($sublabel['label'])) |
760 | 775 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
776 | + } |
|
761 | 777 | } |
762 | 778 | } |
763 | 779 | } |
@@ -767,9 +783,10 @@ discard block |
||
767 | 783 | // Get a list of their variables. |
768 | 784 | $config_vars = $setting_area[0](true); |
769 | 785 | |
770 | - foreach ($config_vars as $var) |
|
771 | - if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
786 | + foreach ($config_vars as $var) { |
|
787 | + if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
772 | 788 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : ''); |
789 | + } |
|
773 | 790 | } |
774 | 791 | |
775 | 792 | $context['page_title'] = $txt['admin_search_results']; |
@@ -782,8 +799,9 @@ discard block |
||
782 | 799 | foreach ($data as $item) |
783 | 800 | { |
784 | 801 | $found = false; |
785 | - if (!is_array($item[0])) |
|
786 | - $item[0] = array($item[0]); |
|
802 | + if (!is_array($item[0])) { |
|
803 | + $item[0] = array($item[0]); |
|
804 | + } |
|
787 | 805 | foreach ($item[0] as $term) |
788 | 806 | { |
789 | 807 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
@@ -841,8 +859,9 @@ discard block |
||
841 | 859 | $postVars = explode(' ', $context['search_term']); |
842 | 860 | |
843 | 861 | // Encode the search data. |
844 | - foreach ($postVars as $k => $v) |
|
845 | - $postVars[$k] = urlencode($v); |
|
862 | + foreach ($postVars as $k => $v) { |
|
863 | + $postVars[$k] = urlencode($v); |
|
864 | + } |
|
846 | 865 | |
847 | 866 | // This is what we will send. |
848 | 867 | $postVars = implode('+', $postVars); |
@@ -854,8 +873,9 @@ discard block |
||
854 | 873 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
855 | 874 | |
856 | 875 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
857 | - if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) |
|
858 | - fatal_lang_error('cannot_connect_doc_site'); |
|
876 | + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) { |
|
877 | + fatal_lang_error('cannot_connect_doc_site'); |
|
878 | + } |
|
859 | 879 | |
860 | 880 | $search_results = $matches[1]; |
861 | 881 | |
@@ -867,8 +887,9 @@ discard block |
||
867 | 887 | $results = new xmlArray($search_results, false); |
868 | 888 | |
869 | 889 | // Move through the api layer. |
870 | - if (!$results->exists('api')) |
|
871 | - fatal_lang_error('cannot_connect_doc_site'); |
|
890 | + if (!$results->exists('api')) { |
|
891 | + fatal_lang_error('cannot_connect_doc_site'); |
|
892 | + } |
|
872 | 893 | |
873 | 894 | // Are there actually some results? |
874 | 895 | if ($results->exists('api/query/search/p')) |
@@ -904,8 +925,9 @@ discard block |
||
904 | 925 | ); |
905 | 926 | |
906 | 927 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
907 | - if (!isset($_REQUEST['sa'])) |
|
908 | - $_REQUEST['desc'] = true; |
|
928 | + if (!isset($_REQUEST['sa'])) { |
|
929 | + $_REQUEST['desc'] = true; |
|
930 | + } |
|
909 | 931 | |
910 | 932 | // Setup some tab stuff. |
911 | 933 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -955,9 +977,10 @@ discard block |
||
955 | 977 | unset($_SESSION['admin_time']); |
956 | 978 | |
957 | 979 | // Clean any admin tokens as well. |
958 | - foreach ($_SESSION['token'] as $key => $token) |
|
959 | - if (strpos($key, '-admin') !== false) |
|
980 | + foreach ($_SESSION['token'] as $key => $token) { |
|
981 | + if (strpos($key, '-admin') !== false) |
|
960 | 982 | unset($_SESSION['token'][$key]); |
983 | + } |
|
961 | 984 | |
962 | 985 | redirectexit(); |
963 | 986 | } |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | /** |
103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
146 | 155 | ob_start('ob_sessrewrite'); |
147 | 156 | |
148 | 157 | // Start the session... known to scramble SSI includes in cases... |
149 | -if (!headers_sent()) |
|
158 | +if (!headers_sent()) { |
|
150 | 159 | loadSession(); |
151 | -else |
|
160 | +} else |
|
152 | 161 | { |
153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
183 | 192 | |
184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
185 | -if (!headers_sent()) |
|
194 | +if (!headers_sent()) { |
|
186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
196 | +} |
|
187 | 197 | |
188 | 198 | // Take care of any banning that needs to be done. |
189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
190 | 200 | is_not_banned(); |
201 | +} |
|
191 | 202 | |
192 | 203 | // Do we allow guests in here? |
193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
202 | 213 | { |
203 | 214 | $context['template_layers'] = $ssi_layers; |
204 | 215 | template_header(); |
205 | -} |
|
206 | -else |
|
216 | +} else { |
|
207 | 217 | setupThemeContext(); |
218 | +} |
|
208 | 219 | |
209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
223 | +} |
|
212 | 224 | |
213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
228 | +} |
|
216 | 229 | |
217 | 230 | // Have the ability to easily add functions to SSI. |
218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
222 | 235 | { |
223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
224 | - if (!isset($_GET['ssi_function'])) |
|
225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
237 | + if (!isset($_GET['ssi_function'])) { |
|
238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
239 | + } |
|
226 | 240 | // Call a function passed by GET. |
227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
243 | + } |
|
229 | 244 | exit; |
230 | 245 | } |
231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
242 | 257 | */ |
243 | 258 | function ssi_shutdown() |
244 | 259 | { |
245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
246 | - template_footer(); |
|
247 | -} |
|
260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
261 | + template_footer(); |
|
262 | + } |
|
263 | + } |
|
248 | 264 | |
249 | 265 | /** |
250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
257 | 273 | |
258 | 274 | if ($output_method == 'echo') |
259 | 275 | { |
260 | - if ($context['user']['is_guest']) |
|
261 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
262 | - else |
|
263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
276 | + if ($context['user']['is_guest']) { |
|
277 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
278 | + } else { |
|
279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
280 | + } |
|
264 | 281 | } |
265 | 282 | // Don't echo... then do what?! |
266 | - else |
|
267 | - return $context['user']; |
|
268 | -} |
|
283 | + else { |
|
284 | + return $context['user']; |
|
285 | + } |
|
286 | + } |
|
269 | 287 | |
270 | 288 | /** |
271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
276 | 294 | { |
277 | 295 | global $context; |
278 | 296 | |
279 | - if ($output_method == 'echo') |
|
280 | - template_menu(); |
|
297 | + if ($output_method == 'echo') { |
|
298 | + template_menu(); |
|
299 | + } |
|
281 | 300 | // What else could this do? |
282 | - else |
|
283 | - return $context['menu_buttons']; |
|
284 | -} |
|
301 | + else { |
|
302 | + return $context['menu_buttons']; |
|
303 | + } |
|
304 | + } |
|
285 | 305 | |
286 | 306 | /** |
287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
293 | 313 | { |
294 | 314 | global $context, $txt, $scripturl; |
295 | 315 | |
296 | - if ($redirect_to != '') |
|
297 | - $_SESSION['logout_url'] = $redirect_to; |
|
316 | + if ($redirect_to != '') { |
|
317 | + $_SESSION['logout_url'] = $redirect_to; |
|
318 | + } |
|
298 | 319 | |
299 | 320 | // Guests can't log out. |
300 | - if ($context['user']['is_guest']) |
|
301 | - return false; |
|
321 | + if ($context['user']['is_guest']) { |
|
322 | + return false; |
|
323 | + } |
|
302 | 324 | |
303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
304 | 326 | |
305 | - if ($output_method == 'echo') |
|
306 | - echo $link; |
|
307 | - else |
|
308 | - return $link; |
|
309 | -} |
|
327 | + if ($output_method == 'echo') { |
|
328 | + echo $link; |
|
329 | + } else { |
|
330 | + return $link; |
|
331 | + } |
|
332 | + } |
|
310 | 333 | |
311 | 334 | /** |
312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
322 | 345 | global $modSettings, $context; |
323 | 346 | |
324 | 347 | // Excluding certain boards... |
325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
327 | - else |
|
328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
350 | + } else { |
|
351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
352 | + } |
|
329 | 353 | |
330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
332 | 356 | { |
333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
334 | - } |
|
335 | - elseif ($include_boards != null) |
|
358 | + } elseif ($include_boards != null) |
|
336 | 359 | { |
337 | 360 | $include_boards = array(); |
338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
369 | 392 | { |
370 | 393 | global $modSettings; |
371 | 394 | |
372 | - if (empty($post_ids)) |
|
373 | - return; |
|
395 | + if (empty($post_ids)) { |
|
396 | + return; |
|
397 | + } |
|
374 | 398 | |
375 | 399 | // Allow the user to request more than one - why not? |
376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
405 | 429 | global $scripturl, $txt, $user_info; |
406 | 430 | global $modSettings, $smcFunc, $context; |
407 | 431 | |
408 | - if (!empty($modSettings['enable_likes'])) |
|
409 | - $context['can_like'] = allowedTo('likes_like'); |
|
432 | + if (!empty($modSettings['enable_likes'])) { |
|
433 | + $context['can_like'] = allowedTo('likes_like'); |
|
434 | + } |
|
410 | 435 | |
411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
472 | 497 | ); |
473 | 498 | |
474 | 499 | // Get the likes for each message. |
475 | - if (!empty($modSettings['enable_likes'])) |
|
476 | - $posts[$row['id_msg']]['likes'] = array( |
|
500 | + if (!empty($modSettings['enable_likes'])) { |
|
501 | + $posts[$row['id_msg']]['likes'] = array( |
|
477 | 502 | 'count' => $row['likes'], |
478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
480 | 505 | ); |
506 | + } |
|
481 | 507 | } |
482 | 508 | $smcFunc['db_free_result']($request); |
483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
486 | 512 | |
487 | 513 | // Just return it. |
488 | - if ($output_method != 'echo' || empty($posts)) |
|
489 | - return $posts; |
|
514 | + if ($output_method != 'echo' || empty($posts)) { |
|
515 | + return $posts; |
|
516 | + } |
|
490 | 517 | |
491 | 518 | echo ' |
492 | 519 | <table style="border: none" class="ssi_table">'; |
493 | - foreach ($posts as $post) |
|
494 | - echo ' |
|
520 | + foreach ($posts as $post) { |
|
521 | + echo ' |
|
495 | 522 | <tr> |
496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
505 | 532 | ', $post['time'], ' |
506 | 533 | </td> |
507 | 534 | </tr>'; |
535 | + } |
|
508 | 536 | echo ' |
509 | 537 | </table>'; |
510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
522 | 550 | global $settings, $scripturl, $txt, $user_info; |
523 | 551 | global $modSettings, $smcFunc, $context; |
524 | 552 | |
525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
527 | - else |
|
528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
555 | + } else { |
|
556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
557 | + } |
|
529 | 558 | |
530 | 559 | // Only some boards?. |
531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
532 | 561 | { |
533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
534 | - } |
|
535 | - elseif ($include_boards != null) |
|
563 | + } elseif ($include_boards != null) |
|
536 | 564 | { |
537 | 565 | $output_method = $include_boards; |
538 | 566 | $include_boards = array(); |
539 | 567 | } |
540 | 568 | |
541 | 569 | $icon_sources = array(); |
542 | - foreach ($context['stable_icons'] as $icon) |
|
543 | - $icon_sources[$icon] = 'images_url'; |
|
570 | + foreach ($context['stable_icons'] as $icon) { |
|
571 | + $icon_sources[$icon] = 'images_url'; |
|
572 | + } |
|
544 | 573 | |
545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
565 | 594 | ) |
566 | 595 | ); |
567 | 596 | $topics = array(); |
568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
569 | - $topics[$row['id_topic']] = $row; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
598 | + $topics[$row['id_topic']] = $row; |
|
599 | + } |
|
570 | 600 | $smcFunc['db_free_result']($request); |
571 | 601 | |
572 | 602 | // Did we find anything? If not, bail. |
573 | - if (empty($topics)) |
|
574 | - return array(); |
|
603 | + if (empty($topics)) { |
|
604 | + return array(); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
577 | 608 | |
@@ -599,19 +630,22 @@ discard block |
||
599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
600 | 631 | { |
601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
635 | + } |
|
604 | 636 | |
605 | 637 | // Censor the subject. |
606 | 638 | censorText($row['subject']); |
607 | 639 | censorText($row['body']); |
608 | 640 | |
609 | 641 | // Recycled icon |
610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
611 | - $row['icon'] = 'recycled'; |
|
642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
643 | + $row['icon'] = 'recycled'; |
|
644 | + } |
|
612 | 645 | |
613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
648 | + } |
|
615 | 649 | |
616 | 650 | // Build the array. |
617 | 651 | $posts[] = array( |
@@ -650,13 +684,14 @@ discard block |
||
650 | 684 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
651 | 685 | |
652 | 686 | // Just return it. |
653 | - if ($output_method != 'echo' || empty($posts)) |
|
654 | - return $posts; |
|
687 | + if ($output_method != 'echo' || empty($posts)) { |
|
688 | + return $posts; |
|
689 | + } |
|
655 | 690 | |
656 | 691 | echo ' |
657 | 692 | <table style="border: none" class="ssi_table">'; |
658 | - foreach ($posts as $post) |
|
659 | - echo ' |
|
693 | + foreach ($posts as $post) { |
|
694 | + echo ' |
|
660 | 695 | <tr> |
661 | 696 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
662 | 697 | [', $post['board']['link'], '] |
@@ -670,6 +705,7 @@ discard block |
||
670 | 705 | ', $post['time'], ' |
671 | 706 | </td> |
672 | 707 | </tr>'; |
708 | + } |
|
673 | 709 | echo ' |
674 | 710 | </table>'; |
675 | 711 | } |
@@ -694,27 +730,30 @@ discard block |
||
694 | 730 | ) |
695 | 731 | ); |
696 | 732 | $return = array(); |
697 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
698 | - $return[] = array( |
|
733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
734 | + $return[] = array( |
|
699 | 735 | 'id' => $row['id_member'], |
700 | 736 | 'name' => $row['real_name'], |
701 | 737 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
702 | 738 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
703 | 739 | 'posts' => $row['posts'] |
704 | 740 | ); |
741 | + } |
|
705 | 742 | $smcFunc['db_free_result']($request); |
706 | 743 | |
707 | 744 | // If mods want to do somthing with this list of members, let them do that now. |
708 | 745 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
709 | 746 | |
710 | 747 | // Just return all the top posters. |
711 | - if ($output_method != 'echo') |
|
712 | - return $return; |
|
748 | + if ($output_method != 'echo') { |
|
749 | + return $return; |
|
750 | + } |
|
713 | 751 | |
714 | 752 | // Make a quick array to list the links in. |
715 | 753 | $temp_array = array(); |
716 | - foreach ($return as $member) |
|
717 | - $temp_array[] = $member['link']; |
|
754 | + foreach ($return as $member) { |
|
755 | + $temp_array[] = $member['link']; |
|
756 | + } |
|
718 | 757 | |
719 | 758 | echo implode(', ', $temp_array); |
720 | 759 | } |
@@ -746,8 +785,8 @@ discard block |
||
746 | 785 | ) |
747 | 786 | ); |
748 | 787 | $boards = array(); |
749 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
750 | - $boards[] = array( |
|
788 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
789 | + $boards[] = array( |
|
751 | 790 | 'id' => $row['id_board'], |
752 | 791 | 'num_posts' => $row['num_posts'], |
753 | 792 | 'num_topics' => $row['num_topics'], |
@@ -756,14 +795,16 @@ discard block |
||
756 | 795 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
757 | 796 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
758 | 797 | ); |
798 | + } |
|
759 | 799 | $smcFunc['db_free_result']($request); |
760 | 800 | |
761 | 801 | // If mods want to do somthing with this list of boards, let them do that now. |
762 | 802 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
763 | 803 | |
764 | 804 | // If we shouldn't output or have nothing to output, just jump out. |
765 | - if ($output_method != 'echo' || empty($boards)) |
|
766 | - return $boards; |
|
805 | + if ($output_method != 'echo' || empty($boards)) { |
|
806 | + return $boards; |
|
807 | + } |
|
767 | 808 | |
768 | 809 | echo ' |
769 | 810 | <table class="ssi_table"> |
@@ -772,13 +813,14 @@ discard block |
||
772 | 813 | <th style="text-align: left">', $txt['board_topics'], '</th> |
773 | 814 | <th style="text-align: left">', $txt['posts'], '</th> |
774 | 815 | </tr>'; |
775 | - foreach ($boards as $sBoard) |
|
776 | - echo ' |
|
816 | + foreach ($boards as $sBoard) { |
|
817 | + echo ' |
|
777 | 818 | <tr> |
778 | 819 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
779 | 820 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
780 | 821 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
781 | 822 | </tr>'; |
823 | + } |
|
782 | 824 | echo ' |
783 | 825 | </table>'; |
784 | 826 | } |
@@ -811,12 +853,13 @@ discard block |
||
811 | 853 | ) |
812 | 854 | ); |
813 | 855 | $topic_ids = array(); |
814 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
815 | - $topic_ids[] = $row['id_topic']; |
|
856 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
857 | + $topic_ids[] = $row['id_topic']; |
|
858 | + } |
|
816 | 859 | $smcFunc['db_free_result']($request); |
860 | + } else { |
|
861 | + $topic_ids = array(); |
|
817 | 862 | } |
818 | - else |
|
819 | - $topic_ids = array(); |
|
820 | 863 | |
821 | 864 | $request = $smcFunc['db_query']('', ' |
822 | 865 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -855,8 +898,9 @@ discard block |
||
855 | 898 | // If mods want to do somthing with this list of topics, let them do that now. |
856 | 899 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
857 | 900 | |
858 | - if ($output_method != 'echo' || empty($topics)) |
|
859 | - return $topics; |
|
901 | + if ($output_method != 'echo' || empty($topics)) { |
|
902 | + return $topics; |
|
903 | + } |
|
860 | 904 | |
861 | 905 | echo ' |
862 | 906 | <table class="ssi_table"> |
@@ -865,8 +909,8 @@ discard block |
||
865 | 909 | <th style="text-align: left">', $txt['views'], '</th> |
866 | 910 | <th style="text-align: left">', $txt['replies'], '</th> |
867 | 911 | </tr>'; |
868 | - foreach ($topics as $sTopic) |
|
869 | - echo ' |
|
912 | + foreach ($topics as $sTopic) { |
|
913 | + echo ' |
|
870 | 914 | <tr> |
871 | 915 | <td style="text-align: left"> |
872 | 916 | ', $sTopic['link'], ' |
@@ -874,6 +918,7 @@ discard block |
||
874 | 918 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
875 | 919 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
876 | 920 | </tr>'; |
921 | + } |
|
877 | 922 | echo ' |
878 | 923 | </table>'; |
879 | 924 | } |
@@ -909,12 +954,13 @@ discard block |
||
909 | 954 | { |
910 | 955 | global $txt, $context; |
911 | 956 | |
912 | - if ($output_method == 'echo') |
|
913 | - echo ' |
|
957 | + if ($output_method == 'echo') { |
|
958 | + echo ' |
|
914 | 959 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
915 | - else |
|
916 | - return $context['common_stats']['latest_member']; |
|
917 | -} |
|
960 | + } else { |
|
961 | + return $context['common_stats']['latest_member']; |
|
962 | + } |
|
963 | + } |
|
918 | 964 | |
919 | 965 | /** |
920 | 966 | * Fetches a random member. |
@@ -963,8 +1009,9 @@ discard block |
||
963 | 1009 | } |
964 | 1010 | |
965 | 1011 | // Just to be sure put the random generator back to something... random. |
966 | - if ($random_type != '') |
|
967 | - mt_srand(time()); |
|
1012 | + if ($random_type != '') { |
|
1013 | + mt_srand(time()); |
|
1014 | + } |
|
968 | 1015 | |
969 | 1016 | return $result; |
970 | 1017 | } |
@@ -977,8 +1024,9 @@ discard block |
||
977 | 1024 | */ |
978 | 1025 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
979 | 1026 | { |
980 | - if (empty($member_ids)) |
|
981 | - return; |
|
1027 | + if (empty($member_ids)) { |
|
1028 | + return; |
|
1029 | + } |
|
982 | 1030 | |
983 | 1031 | // Can have more than one member if you really want... |
984 | 1032 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1003,8 +1051,9 @@ discard block |
||
1003 | 1051 | */ |
1004 | 1052 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
1005 | 1053 | { |
1006 | - if ($group_id === null) |
|
1007 | - return; |
|
1054 | + if ($group_id === null) { |
|
1055 | + return; |
|
1056 | + } |
|
1008 | 1057 | |
1009 | 1058 | $query_where = ' |
1010 | 1059 | id_group = {int:id_group} |
@@ -1031,8 +1080,9 @@ discard block |
||
1031 | 1080 | { |
1032 | 1081 | global $smcFunc, $memberContext; |
1033 | 1082 | |
1034 | - if ($query_where === null) |
|
1035 | - return; |
|
1083 | + if ($query_where === null) { |
|
1084 | + return; |
|
1085 | + } |
|
1036 | 1086 | |
1037 | 1087 | // Fetch the members in question. |
1038 | 1088 | $request = $smcFunc['db_query']('', ' |
@@ -1045,12 +1095,14 @@ discard block |
||
1045 | 1095 | )) |
1046 | 1096 | ); |
1047 | 1097 | $members = array(); |
1048 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1049 | - $members[] = $row['id_member']; |
|
1098 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1099 | + $members[] = $row['id_member']; |
|
1100 | + } |
|
1050 | 1101 | $smcFunc['db_free_result']($request); |
1051 | 1102 | |
1052 | - if (empty($members)) |
|
1053 | - return array(); |
|
1103 | + if (empty($members)) { |
|
1104 | + return array(); |
|
1105 | + } |
|
1054 | 1106 | |
1055 | 1107 | // If mods want to do somthing with this list of members, let them do that now. |
1056 | 1108 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1059,23 +1111,25 @@ discard block |
||
1059 | 1111 | loadMemberData($members); |
1060 | 1112 | |
1061 | 1113 | // Draw the table! |
1062 | - if ($output_method == 'echo') |
|
1063 | - echo ' |
|
1114 | + if ($output_method == 'echo') { |
|
1115 | + echo ' |
|
1064 | 1116 | <table style="border: none" class="ssi_table">'; |
1117 | + } |
|
1065 | 1118 | |
1066 | 1119 | $query_members = array(); |
1067 | 1120 | foreach ($members as $member) |
1068 | 1121 | { |
1069 | 1122 | // Load their context data. |
1070 | - if (!loadMemberContext($member)) |
|
1071 | - continue; |
|
1123 | + if (!loadMemberContext($member)) { |
|
1124 | + continue; |
|
1125 | + } |
|
1072 | 1126 | |
1073 | 1127 | // Store this member's information. |
1074 | 1128 | $query_members[$member] = $memberContext[$member]; |
1075 | 1129 | |
1076 | 1130 | // Only do something if we're echo'ing. |
1077 | - if ($output_method == 'echo') |
|
1078 | - echo ' |
|
1131 | + if ($output_method == 'echo') { |
|
1132 | + echo ' |
|
1079 | 1133 | <tr> |
1080 | 1134 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1081 | 1135 | ', $query_members[$member]['link'], ' |
@@ -1083,12 +1137,14 @@ discard block |
||
1083 | 1137 | <br>', $query_members[$member]['avatar']['image'], ' |
1084 | 1138 | </td> |
1085 | 1139 | </tr>'; |
1140 | + } |
|
1086 | 1141 | } |
1087 | 1142 | |
1088 | 1143 | // End the table if appropriate. |
1089 | - if ($output_method == 'echo') |
|
1090 | - echo ' |
|
1144 | + if ($output_method == 'echo') { |
|
1145 | + echo ' |
|
1091 | 1146 | </table>'; |
1147 | + } |
|
1092 | 1148 | |
1093 | 1149 | // Send back the data. |
1094 | 1150 | return $query_members; |
@@ -1103,8 +1159,9 @@ discard block |
||
1103 | 1159 | { |
1104 | 1160 | global $txt, $scripturl, $modSettings, $smcFunc; |
1105 | 1161 | |
1106 | - if (!allowedTo('view_stats')) |
|
1107 | - return; |
|
1162 | + if (!allowedTo('view_stats')) { |
|
1163 | + return; |
|
1164 | + } |
|
1108 | 1165 | |
1109 | 1166 | $totals = array( |
1110 | 1167 | 'members' => $modSettings['totalMembers'], |
@@ -1133,8 +1190,9 @@ discard block |
||
1133 | 1190 | // If mods want to do somthing with the board stats, let them do that now. |
1134 | 1191 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1135 | 1192 | |
1136 | - if ($output_method != 'echo') |
|
1137 | - return $totals; |
|
1193 | + if ($output_method != 'echo') { |
|
1194 | + return $totals; |
|
1195 | + } |
|
1138 | 1196 | |
1139 | 1197 | echo ' |
1140 | 1198 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1163,8 +1221,8 @@ discard block |
||
1163 | 1221 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1164 | 1222 | |
1165 | 1223 | // Add some redundancy for backwards compatibility reasons. |
1166 | - if ($output_method != 'echo') |
|
1167 | - return $return + array( |
|
1224 | + if ($output_method != 'echo') { |
|
1225 | + return $return + array( |
|
1168 | 1226 | 'users' => $return['users_online'], |
1169 | 1227 | 'guests' => $return['num_guests'], |
1170 | 1228 | 'hidden' => $return['num_users_hidden'], |
@@ -1172,29 +1230,35 @@ discard block |
||
1172 | 1230 | 'num_users' => $return['num_users_online'], |
1173 | 1231 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1174 | 1232 | ); |
1233 | + } |
|
1175 | 1234 | |
1176 | 1235 | echo ' |
1177 | 1236 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1178 | 1237 | |
1179 | 1238 | $bracketList = array(); |
1180 | - if (!empty($user_info['buddies'])) |
|
1181 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1182 | - if (!empty($return['num_spiders'])) |
|
1183 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1184 | - if (!empty($return['num_users_hidden'])) |
|
1185 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1239 | + if (!empty($user_info['buddies'])) { |
|
1240 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1241 | + } |
|
1242 | + if (!empty($return['num_spiders'])) { |
|
1243 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1244 | + } |
|
1245 | + if (!empty($return['num_users_hidden'])) { |
|
1246 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1247 | + } |
|
1186 | 1248 | |
1187 | - if (!empty($bracketList)) |
|
1188 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1249 | + if (!empty($bracketList)) { |
|
1250 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1251 | + } |
|
1189 | 1252 | |
1190 | 1253 | echo '<br> |
1191 | 1254 | ', implode(', ', $return['list_users_online']); |
1192 | 1255 | |
1193 | 1256 | // Showing membergroups? |
1194 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1195 | - echo '<br> |
|
1257 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1258 | + echo '<br> |
|
1196 | 1259 | [' . implode('] [', $return['membergroups']) . ']'; |
1197 | -} |
|
1260 | + } |
|
1261 | + } |
|
1198 | 1262 | |
1199 | 1263 | /** |
1200 | 1264 | * Just like whosOnline except it also logs the online presence. |
@@ -1205,11 +1269,12 @@ discard block |
||
1205 | 1269 | { |
1206 | 1270 | writeLog(); |
1207 | 1271 | |
1208 | - if ($output_method != 'echo') |
|
1209 | - return ssi_whosOnline($output_method); |
|
1210 | - else |
|
1211 | - ssi_whosOnline($output_method); |
|
1212 | -} |
|
1272 | + if ($output_method != 'echo') { |
|
1273 | + return ssi_whosOnline($output_method); |
|
1274 | + } else { |
|
1275 | + ssi_whosOnline($output_method); |
|
1276 | + } |
|
1277 | + } |
|
1213 | 1278 | |
1214 | 1279 | // Shows a login box. |
1215 | 1280 | /** |
@@ -1222,11 +1287,13 @@ discard block |
||
1222 | 1287 | { |
1223 | 1288 | global $scripturl, $txt, $user_info, $context; |
1224 | 1289 | |
1225 | - if ($redirect_to != '') |
|
1226 | - $_SESSION['login_url'] = $redirect_to; |
|
1290 | + if ($redirect_to != '') { |
|
1291 | + $_SESSION['login_url'] = $redirect_to; |
|
1292 | + } |
|
1227 | 1293 | |
1228 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1229 | - return $user_info['is_guest']; |
|
1294 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1295 | + return $user_info['is_guest']; |
|
1296 | + } |
|
1230 | 1297 | |
1231 | 1298 | // Create a login token |
1232 | 1299 | createToken('login'); |
@@ -1278,8 +1345,9 @@ discard block |
||
1278 | 1345 | |
1279 | 1346 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1280 | 1347 | |
1281 | - if (empty($boardsAllowed)) |
|
1282 | - return array(); |
|
1348 | + if (empty($boardsAllowed)) { |
|
1349 | + return array(); |
|
1350 | + } |
|
1283 | 1351 | |
1284 | 1352 | $request = $smcFunc['db_query']('', ' |
1285 | 1353 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1312,12 +1380,14 @@ discard block |
||
1312 | 1380 | $smcFunc['db_free_result']($request); |
1313 | 1381 | |
1314 | 1382 | // This user has voted on all the polls. |
1315 | - if (empty($row) || !is_array($row)) |
|
1316 | - return array(); |
|
1383 | + if (empty($row) || !is_array($row)) { |
|
1384 | + return array(); |
|
1385 | + } |
|
1317 | 1386 | |
1318 | 1387 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1319 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1320 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1388 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1389 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1390 | + } |
|
1321 | 1391 | |
1322 | 1392 | $request = $smcFunc['db_query']('', ' |
1323 | 1393 | SELECT COUNT(DISTINCT id_member) |
@@ -1381,8 +1451,9 @@ discard block |
||
1381 | 1451 | // If mods want to do somthing with this list of polls, let them do that now. |
1382 | 1452 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1383 | 1453 | |
1384 | - if ($output_method != 'echo') |
|
1385 | - return $return; |
|
1454 | + if ($output_method != 'echo') { |
|
1455 | + return $return; |
|
1456 | + } |
|
1386 | 1457 | |
1387 | 1458 | if ($allow_view_results) |
1388 | 1459 | { |
@@ -1391,19 +1462,20 @@ discard block |
||
1391 | 1462 | <strong>', $return['question'], '</strong><br> |
1392 | 1463 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1393 | 1464 | |
1394 | - foreach ($return['options'] as $option) |
|
1395 | - echo ' |
|
1465 | + foreach ($return['options'] as $option) { |
|
1466 | + echo ' |
|
1396 | 1467 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1468 | + } |
|
1397 | 1469 | |
1398 | 1470 | echo ' |
1399 | 1471 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1400 | 1472 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1401 | 1473 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1402 | 1474 | </form>'; |
1475 | + } else { |
|
1476 | + echo $txt['poll_cannot_see']; |
|
1477 | + } |
|
1403 | 1478 | } |
1404 | - else |
|
1405 | - echo $txt['poll_cannot_see']; |
|
1406 | -} |
|
1407 | 1479 | |
1408 | 1480 | /** |
1409 | 1481 | * Shows the poll from the specified topic |
@@ -1417,13 +1489,15 @@ discard block |
||
1417 | 1489 | |
1418 | 1490 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1419 | 1491 | |
1420 | - if (empty($boardsAllowed)) |
|
1421 | - return array(); |
|
1492 | + if (empty($boardsAllowed)) { |
|
1493 | + return array(); |
|
1494 | + } |
|
1422 | 1495 | |
1423 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1424 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1425 | - else |
|
1426 | - $topic = (int) $topic; |
|
1496 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1497 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1498 | + } else { |
|
1499 | + $topic = (int) $topic; |
|
1500 | + } |
|
1427 | 1501 | |
1428 | 1502 | $request = $smcFunc['db_query']('', ' |
1429 | 1503 | SELECT |
@@ -1444,17 +1518,18 @@ discard block |
||
1444 | 1518 | ); |
1445 | 1519 | |
1446 | 1520 | // Either this topic has no poll, or the user cannot view it. |
1447 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1448 | - return array(); |
|
1521 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1522 | + return array(); |
|
1523 | + } |
|
1449 | 1524 | |
1450 | 1525 | $row = $smcFunc['db_fetch_assoc']($request); |
1451 | 1526 | $smcFunc['db_free_result']($request); |
1452 | 1527 | |
1453 | 1528 | // Check if they can vote. |
1454 | 1529 | $already_voted = false; |
1455 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1456 | - $allow_vote = false; |
|
1457 | - elseif ($user_info['is_guest']) |
|
1530 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1531 | + $allow_vote = false; |
|
1532 | + } elseif ($user_info['is_guest']) |
|
1458 | 1533 | { |
1459 | 1534 | // There's a difference between "allowed to vote" and "already voted"... |
1460 | 1535 | $allow_vote = $row['guest_vote']; |
@@ -1464,10 +1539,9 @@ discard block |
||
1464 | 1539 | { |
1465 | 1540 | $already_voted = true; |
1466 | 1541 | } |
1467 | - } |
|
1468 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1469 | - $allow_vote = false; |
|
1470 | - else |
|
1542 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1543 | + $allow_vote = false; |
|
1544 | + } else |
|
1471 | 1545 | { |
1472 | 1546 | $request = $smcFunc['db_query']('', ' |
1473 | 1547 | SELECT id_member |
@@ -1549,8 +1623,9 @@ discard block |
||
1549 | 1623 | // If mods want to do somthing with this poll, let them do that now. |
1550 | 1624 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1551 | 1625 | |
1552 | - if ($output_method != 'echo') |
|
1553 | - return $return; |
|
1626 | + if ($output_method != 'echo') { |
|
1627 | + return $return; |
|
1628 | + } |
|
1554 | 1629 | |
1555 | 1630 | if ($return['allow_vote']) |
1556 | 1631 | { |
@@ -1559,17 +1634,17 @@ discard block |
||
1559 | 1634 | <strong>', $return['question'], '</strong><br> |
1560 | 1635 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1561 | 1636 | |
1562 | - foreach ($return['options'] as $option) |
|
1563 | - echo ' |
|
1637 | + foreach ($return['options'] as $option) { |
|
1638 | + echo ' |
|
1564 | 1639 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1640 | + } |
|
1565 | 1641 | |
1566 | 1642 | echo ' |
1567 | 1643 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1568 | 1644 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1569 | 1645 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1570 | 1646 | </form>'; |
1571 | - } |
|
1572 | - else |
|
1647 | + } else |
|
1573 | 1648 | { |
1574 | 1649 | echo ' |
1575 | 1650 | <div class="ssi_poll"> |
@@ -1649,27 +1724,32 @@ discard block |
||
1649 | 1724 | 'is_approved' => 1, |
1650 | 1725 | ) |
1651 | 1726 | ); |
1652 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1653 | - die; |
|
1727 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1728 | + die; |
|
1729 | + } |
|
1654 | 1730 | $row = $smcFunc['db_fetch_assoc']($request); |
1655 | 1731 | $smcFunc['db_free_result']($request); |
1656 | 1732 | |
1657 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1658 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1733 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1734 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1735 | + } |
|
1659 | 1736 | |
1660 | 1737 | // Too many options checked? |
1661 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1662 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1738 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1739 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1740 | + } |
|
1663 | 1741 | |
1664 | 1742 | // It's a guest who has already voted? |
1665 | 1743 | if ($user_info['is_guest']) |
1666 | 1744 | { |
1667 | 1745 | // Guest voting disabled? |
1668 | - if (!$row['guest_vote']) |
|
1669 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1746 | + if (!$row['guest_vote']) { |
|
1747 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1748 | + } |
|
1670 | 1749 | // Already voted? |
1671 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1672 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1750 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1751 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1752 | + } |
|
1673 | 1753 | } |
1674 | 1754 | |
1675 | 1755 | $sOptions = array(); |
@@ -1723,11 +1803,13 @@ discard block |
||
1723 | 1803 | { |
1724 | 1804 | global $scripturl, $txt, $context; |
1725 | 1805 | |
1726 | - if (!allowedTo('search_posts')) |
|
1727 | - return; |
|
1806 | + if (!allowedTo('search_posts')) { |
|
1807 | + return; |
|
1808 | + } |
|
1728 | 1809 | |
1729 | - if ($output_method != 'echo') |
|
1730 | - return $scripturl . '?action=search'; |
|
1810 | + if ($output_method != 'echo') { |
|
1811 | + return $scripturl . '?action=search'; |
|
1812 | + } |
|
1731 | 1813 | |
1732 | 1814 | echo ' |
1733 | 1815 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1749,8 +1831,9 @@ discard block |
||
1749 | 1831 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1750 | 1832 | call_integration_hook('integrate_ssi_news'); |
1751 | 1833 | |
1752 | - if ($output_method != 'echo') |
|
1753 | - return $context['random_news_line']; |
|
1834 | + if ($output_method != 'echo') { |
|
1835 | + return $context['random_news_line']; |
|
1836 | + } |
|
1754 | 1837 | |
1755 | 1838 | echo $context['random_news_line']; |
1756 | 1839 | } |
@@ -1764,8 +1847,9 @@ discard block |
||
1764 | 1847 | { |
1765 | 1848 | global $scripturl, $modSettings, $user_info; |
1766 | 1849 | |
1767 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1768 | - return; |
|
1850 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1851 | + return; |
|
1852 | + } |
|
1769 | 1853 | |
1770 | 1854 | $eventOptions = array( |
1771 | 1855 | 'include_birthdays' => true, |
@@ -1776,13 +1860,15 @@ discard block |
||
1776 | 1860 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1777 | 1861 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1778 | 1862 | |
1779 | - if ($output_method != 'echo') |
|
1780 | - return $return['calendar_birthdays']; |
|
1863 | + if ($output_method != 'echo') { |
|
1864 | + return $return['calendar_birthdays']; |
|
1865 | + } |
|
1781 | 1866 | |
1782 | - foreach ($return['calendar_birthdays'] as $member) |
|
1783 | - echo ' |
|
1867 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1868 | + echo ' |
|
1784 | 1869 | <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'] ? ', ' : ''); |
1785 | -} |
|
1870 | + } |
|
1871 | + } |
|
1786 | 1872 | |
1787 | 1873 | /** |
1788 | 1874 | * Shows today's holidays. |
@@ -1793,8 +1879,9 @@ discard block |
||
1793 | 1879 | { |
1794 | 1880 | global $modSettings, $user_info; |
1795 | 1881 | |
1796 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1797 | - return; |
|
1882 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1883 | + return; |
|
1884 | + } |
|
1798 | 1885 | |
1799 | 1886 | $eventOptions = array( |
1800 | 1887 | 'include_holidays' => true, |
@@ -1805,8 +1892,9 @@ discard block |
||
1805 | 1892 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1806 | 1893 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1807 | 1894 | |
1808 | - if ($output_method != 'echo') |
|
1809 | - return $return['calendar_holidays']; |
|
1895 | + if ($output_method != 'echo') { |
|
1896 | + return $return['calendar_holidays']; |
|
1897 | + } |
|
1810 | 1898 | |
1811 | 1899 | echo ' |
1812 | 1900 | ', implode(', ', $return['calendar_holidays']); |
@@ -1820,8 +1908,9 @@ discard block |
||
1820 | 1908 | { |
1821 | 1909 | global $modSettings, $user_info; |
1822 | 1910 | |
1823 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1824 | - return; |
|
1911 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1912 | + return; |
|
1913 | + } |
|
1825 | 1914 | |
1826 | 1915 | $eventOptions = array( |
1827 | 1916 | 'include_events' => true, |
@@ -1832,14 +1921,16 @@ discard block |
||
1832 | 1921 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1833 | 1922 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1834 | 1923 | |
1835 | - if ($output_method != 'echo') |
|
1836 | - return $return['calendar_events']; |
|
1924 | + if ($output_method != 'echo') { |
|
1925 | + return $return['calendar_events']; |
|
1926 | + } |
|
1837 | 1927 | |
1838 | 1928 | foreach ($return['calendar_events'] as $event) |
1839 | 1929 | { |
1840 | - if ($event['can_edit']) |
|
1841 | - echo ' |
|
1930 | + if ($event['can_edit']) { |
|
1931 | + echo ' |
|
1842 | 1932 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1933 | + } |
|
1843 | 1934 | echo ' |
1844 | 1935 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1845 | 1936 | } |
@@ -1854,8 +1945,9 @@ discard block |
||
1854 | 1945 | { |
1855 | 1946 | global $modSettings, $txt, $scripturl, $user_info; |
1856 | 1947 | |
1857 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1858 | - return; |
|
1948 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1949 | + return; |
|
1950 | + } |
|
1859 | 1951 | |
1860 | 1952 | $eventOptions = array( |
1861 | 1953 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1868,19 +1960,22 @@ discard block |
||
1868 | 1960 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1869 | 1961 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1870 | 1962 | |
1871 | - if ($output_method != 'echo') |
|
1872 | - return $return; |
|
1963 | + if ($output_method != 'echo') { |
|
1964 | + return $return; |
|
1965 | + } |
|
1873 | 1966 | |
1874 | - if (!empty($return['calendar_holidays'])) |
|
1875 | - echo ' |
|
1967 | + if (!empty($return['calendar_holidays'])) { |
|
1968 | + echo ' |
|
1876 | 1969 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1970 | + } |
|
1877 | 1971 | if (!empty($return['calendar_birthdays'])) |
1878 | 1972 | { |
1879 | 1973 | echo ' |
1880 | 1974 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1881 | - foreach ($return['calendar_birthdays'] as $member) |
|
1882 | - echo ' |
|
1975 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1976 | + echo ' |
|
1883 | 1977 | <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'] ? ', ' : ''; |
1978 | + } |
|
1884 | 1979 | echo ' |
1885 | 1980 | <br>'; |
1886 | 1981 | } |
@@ -1890,9 +1985,10 @@ discard block |
||
1890 | 1985 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1891 | 1986 | foreach ($return['calendar_events'] as $event) |
1892 | 1987 | { |
1893 | - if ($event['can_edit']) |
|
1894 | - echo ' |
|
1988 | + if ($event['can_edit']) { |
|
1989 | + echo ' |
|
1895 | 1990 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1991 | + } |
|
1896 | 1992 | echo ' |
1897 | 1993 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1898 | 1994 | } |
@@ -1916,25 +2012,29 @@ discard block |
||
1916 | 2012 | loadLanguage('Stats'); |
1917 | 2013 | |
1918 | 2014 | // Must be integers.... |
1919 | - if ($limit === null) |
|
1920 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1921 | - else |
|
1922 | - $limit = (int) $limit; |
|
1923 | - |
|
1924 | - if ($start === null) |
|
1925 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1926 | - else |
|
1927 | - $start = (int) $start; |
|
1928 | - |
|
1929 | - if ($board !== null) |
|
1930 | - $board = (int) $board; |
|
1931 | - elseif (isset($_GET['board'])) |
|
1932 | - $board = (int) $_GET['board']; |
|
1933 | - |
|
1934 | - if ($length === null) |
|
1935 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1936 | - else |
|
1937 | - $length = (int) $length; |
|
2015 | + if ($limit === null) { |
|
2016 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
2017 | + } else { |
|
2018 | + $limit = (int) $limit; |
|
2019 | + } |
|
2020 | + |
|
2021 | + if ($start === null) { |
|
2022 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
2023 | + } else { |
|
2024 | + $start = (int) $start; |
|
2025 | + } |
|
2026 | + |
|
2027 | + if ($board !== null) { |
|
2028 | + $board = (int) $board; |
|
2029 | + } elseif (isset($_GET['board'])) { |
|
2030 | + $board = (int) $_GET['board']; |
|
2031 | + } |
|
2032 | + |
|
2033 | + if ($length === null) { |
|
2034 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
2035 | + } else { |
|
2036 | + $length = (int) $length; |
|
2037 | + } |
|
1938 | 2038 | |
1939 | 2039 | $limit = max(0, $limit); |
1940 | 2040 | $start = max(0, $start); |
@@ -1952,17 +2052,19 @@ discard block |
||
1952 | 2052 | ); |
1953 | 2053 | if ($smcFunc['db_num_rows']($request) == 0) |
1954 | 2054 | { |
1955 | - if ($output_method == 'echo') |
|
1956 | - die($txt['ssi_no_guests']); |
|
1957 | - else |
|
1958 | - return array(); |
|
2055 | + if ($output_method == 'echo') { |
|
2056 | + die($txt['ssi_no_guests']); |
|
2057 | + } else { |
|
2058 | + return array(); |
|
2059 | + } |
|
1959 | 2060 | } |
1960 | 2061 | list ($board) = $smcFunc['db_fetch_row']($request); |
1961 | 2062 | $smcFunc['db_free_result']($request); |
1962 | 2063 | |
1963 | 2064 | $icon_sources = array(); |
1964 | - foreach ($context['stable_icons'] as $icon) |
|
1965 | - $icon_sources[$icon] = 'images_url'; |
|
2065 | + foreach ($context['stable_icons'] as $icon) { |
|
2066 | + $icon_sources[$icon] = 'images_url'; |
|
2067 | + } |
|
1966 | 2068 | |
1967 | 2069 | if (!empty($modSettings['enable_likes'])) |
1968 | 2070 | { |
@@ -1985,12 +2087,14 @@ discard block |
||
1985 | 2087 | ) |
1986 | 2088 | ); |
1987 | 2089 | $posts = array(); |
1988 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1989 | - $posts[] = $row['id_first_msg']; |
|
2090 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2091 | + $posts[] = $row['id_first_msg']; |
|
2092 | + } |
|
1990 | 2093 | $smcFunc['db_free_result']($request); |
1991 | 2094 | |
1992 | - if (empty($posts)) |
|
1993 | - return array(); |
|
2095 | + if (empty($posts)) { |
|
2096 | + return array(); |
|
2097 | + } |
|
1994 | 2098 | |
1995 | 2099 | // Find the posts. |
1996 | 2100 | $request = $smcFunc['db_query']('', ' |
@@ -2020,24 +2124,28 @@ discard block |
||
2020 | 2124 | $last_space = strrpos($row['body'], ' '); |
2021 | 2125 | $last_open = strrpos($row['body'], '<'); |
2022 | 2126 | $last_close = strrpos($row['body'], '>'); |
2023 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
2024 | - $cutoff = $last_open; |
|
2025 | - elseif (empty($last_close) || $last_close < $last_open) |
|
2026 | - $cutoff = $last_space; |
|
2127 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2128 | + $cutoff = $last_open; |
|
2129 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2130 | + $cutoff = $last_space; |
|
2131 | + } |
|
2027 | 2132 | |
2028 | - if ($cutoff !== false) |
|
2029 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2133 | + if ($cutoff !== false) { |
|
2134 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2135 | + } |
|
2030 | 2136 | $row['body'] .= '...'; |
2031 | 2137 | } |
2032 | 2138 | |
2033 | 2139 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
2034 | 2140 | |
2035 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
2036 | - $row['icon'] = 'recycled'; |
|
2141 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2142 | + $row['icon'] = 'recycled'; |
|
2143 | + } |
|
2037 | 2144 | |
2038 | 2145 | // Check that this message icon is there... |
2039 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
2040 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2146 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2147 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2148 | + } |
|
2041 | 2149 | |
2042 | 2150 | censorText($row['subject']); |
2043 | 2151 | censorText($row['body']); |
@@ -2074,16 +2182,18 @@ discard block |
||
2074 | 2182 | } |
2075 | 2183 | $smcFunc['db_free_result']($request); |
2076 | 2184 | |
2077 | - if (empty($return)) |
|
2078 | - return $return; |
|
2185 | + if (empty($return)) { |
|
2186 | + return $return; |
|
2187 | + } |
|
2079 | 2188 | |
2080 | 2189 | $return[count($return) - 1]['is_last'] = true; |
2081 | 2190 | |
2082 | 2191 | // If mods want to do somthing with this list of posts, let them do that now. |
2083 | 2192 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2084 | 2193 | |
2085 | - if ($output_method != 'echo') |
|
2086 | - return $return; |
|
2194 | + if ($output_method != 'echo') { |
|
2195 | + return $return; |
|
2196 | + } |
|
2087 | 2197 | |
2088 | 2198 | foreach ($return as $news) |
2089 | 2199 | { |
@@ -2135,9 +2245,10 @@ discard block |
||
2135 | 2245 | echo ' |
2136 | 2246 | </div>'; |
2137 | 2247 | |
2138 | - if (!$news['is_last']) |
|
2139 | - echo ' |
|
2248 | + if (!$news['is_last']) { |
|
2249 | + echo ' |
|
2140 | 2250 | <hr>'; |
2251 | + } |
|
2141 | 2252 | } |
2142 | 2253 | } |
2143 | 2254 | |
@@ -2151,8 +2262,9 @@ discard block |
||
2151 | 2262 | { |
2152 | 2263 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2153 | 2264 | |
2154 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2155 | - return; |
|
2265 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2266 | + return; |
|
2267 | + } |
|
2156 | 2268 | |
2157 | 2269 | // Find all events which are happening in the near future that the member can see. |
2158 | 2270 | $request = $smcFunc['db_query']('', ' |
@@ -2178,20 +2290,23 @@ discard block |
||
2178 | 2290 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2179 | 2291 | { |
2180 | 2292 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2181 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2182 | - continue; |
|
2293 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2294 | + continue; |
|
2295 | + } |
|
2183 | 2296 | |
2184 | 2297 | // Censor the title. |
2185 | 2298 | censorText($row['title']); |
2186 | 2299 | |
2187 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2188 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2189 | - else |
|
2190 | - $date = $row['start_date']; |
|
2300 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2301 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2302 | + } else { |
|
2303 | + $date = $row['start_date']; |
|
2304 | + } |
|
2191 | 2305 | |
2192 | 2306 | // If the topic it is attached to is not approved then don't link it. |
2193 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2194 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2307 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2308 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2309 | + } |
|
2195 | 2310 | |
2196 | 2311 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2197 | 2312 | |
@@ -2217,24 +2332,27 @@ discard block |
||
2217 | 2332 | } |
2218 | 2333 | $smcFunc['db_free_result']($request); |
2219 | 2334 | |
2220 | - foreach ($return as $mday => $array) |
|
2221 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2335 | + foreach ($return as $mday => $array) { |
|
2336 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2337 | + } |
|
2222 | 2338 | |
2223 | 2339 | // If mods want to do somthing with this list of events, let them do that now. |
2224 | 2340 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2225 | 2341 | |
2226 | - if ($output_method != 'echo' || empty($return)) |
|
2227 | - return $return; |
|
2342 | + if ($output_method != 'echo' || empty($return)) { |
|
2343 | + return $return; |
|
2344 | + } |
|
2228 | 2345 | |
2229 | 2346 | // Well the output method is echo. |
2230 | 2347 | echo ' |
2231 | 2348 | <span class="event">' . $txt['events'] . '</span> '; |
2232 | - foreach ($return as $mday => $array) |
|
2233 | - foreach ($array as $event) |
|
2349 | + foreach ($return as $mday => $array) { |
|
2350 | + foreach ($array as $event) |
|
2234 | 2351 | { |
2235 | 2352 | if ($event['can_edit']) |
2236 | 2353 | echo ' |
2237 | 2354 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2355 | + } |
|
2238 | 2356 | |
2239 | 2357 | echo ' |
2240 | 2358 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2253,8 +2371,9 @@ discard block |
||
2253 | 2371 | global $smcFunc; |
2254 | 2372 | |
2255 | 2373 | // If $id is null, this was most likely called from a query string and should do nothing. |
2256 | - if ($id === null) |
|
2257 | - return; |
|
2374 | + if ($id === null) { |
|
2375 | + return; |
|
2376 | + } |
|
2258 | 2377 | |
2259 | 2378 | $request = $smcFunc['db_query']('', ' |
2260 | 2379 | SELECT passwd, member_name, is_activated |
@@ -2286,8 +2405,9 @@ discard block |
||
2286 | 2405 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2287 | 2406 | |
2288 | 2407 | // No boards? Adios amigo. |
2289 | - if (empty($attachments_boards)) |
|
2290 | - return array(); |
|
2408 | + if (empty($attachments_boards)) { |
|
2409 | + return array(); |
|
2410 | + } |
|
2291 | 2411 | |
2292 | 2412 | // Is it an array? |
2293 | 2413 | $attachment_ext = (array) $attachment_ext; |
@@ -2371,8 +2491,9 @@ discard block |
||
2371 | 2491 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2372 | 2492 | |
2373 | 2493 | // So you just want an array? Here you can have it. |
2374 | - if ($output_method == 'array' || empty($attachments)) |
|
2375 | - return $attachments; |
|
2494 | + if ($output_method == 'array' || empty($attachments)) { |
|
2495 | + return $attachments; |
|
2496 | + } |
|
2376 | 2497 | |
2377 | 2498 | // Give them the default. |
2378 | 2499 | echo ' |
@@ -2383,14 +2504,15 @@ discard block |
||
2383 | 2504 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2384 | 2505 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2385 | 2506 | </tr>'; |
2386 | - foreach ($attachments as $attach) |
|
2387 | - echo ' |
|
2507 | + foreach ($attachments as $attach) { |
|
2508 | + echo ' |
|
2388 | 2509 | <tr> |
2389 | 2510 | <td>', $attach['file']['link'], '</td> |
2390 | 2511 | <td>', $attach['member']['link'], '</td> |
2391 | 2512 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2392 | 2513 | <td>', $attach['file']['filesize'], '</td> |
2393 | 2514 | </tr>'; |
2515 | + } |
|
2394 | 2516 | echo ' |
2395 | 2517 | </table>'; |
2396 | 2518 | } |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting for fatal errors. |
154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
230 | 239 | // Now just redirect to a blank.png... |
231 | 240 | $secure = false; |
232 | 241 | |
233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
234 | - $secure = true; |
|
235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
236 | - $secure = true; |
|
242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
243 | + $secure = true; |
|
244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
245 | + $secure = true; |
|
246 | + } |
|
237 | 247 | |
238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | { |
245 | 255 | // Get PHP's default timezone, if set |
246 | 256 | $ini_tz = ini_get('date.timezone'); |
247 | - if (!empty($ini_tz)) |
|
248 | - $timezone_id = $ini_tz; |
|
249 | - else |
|
250 | - $timezone_id = ''; |
|
257 | + if (!empty($ini_tz)) { |
|
258 | + $timezone_id = $ini_tz; |
|
259 | + } else { |
|
260 | + $timezone_id = ''; |
|
261 | + } |
|
251 | 262 | |
252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
278 | 289 | while ($entry = $dir->read()) |
279 | 290 | { |
280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
293 | + } |
|
282 | 294 | } |
283 | 295 | $dir->close(); |
284 | 296 | } |
@@ -313,10 +325,11 @@ discard block |
||
313 | 325 | } |
314 | 326 | |
315 | 327 | // Override the language file? |
316 | - if (isset($_GET['lang_file'])) |
|
317 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
318 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
319 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
328 | + if (isset($_GET['lang_file'])) { |
|
329 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
330 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
331 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
332 | + } |
|
320 | 333 | |
321 | 334 | // Make sure it exists, if it doesn't reset it. |
322 | 335 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -325,8 +338,9 @@ discard block |
||
325 | 338 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
326 | 339 | |
327 | 340 | // If we have english and some other language, use the other language. We Americans hate english :P. |
328 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
329 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
341 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
342 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
343 | + } |
|
330 | 344 | } |
331 | 345 | |
332 | 346 | // And now include the actual language file itself. |
@@ -343,15 +357,18 @@ discard block |
||
343 | 357 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
344 | 358 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
345 | 359 | |
346 | - if (empty($sourcedir)) |
|
347 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
360 | + if (empty($sourcedir)) { |
|
361 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
362 | + } |
|
348 | 363 | |
349 | 364 | // Need this to check whether we need the database password. |
350 | 365 | require(dirname(__FILE__) . '/Settings.php'); |
351 | - if (!defined('SMF')) |
|
352 | - define('SMF', 1); |
|
353 | - if (empty($smcFunc)) |
|
354 | - $smcFunc = array(); |
|
366 | + if (!defined('SMF')) { |
|
367 | + define('SMF', 1); |
|
368 | + } |
|
369 | + if (empty($smcFunc)) { |
|
370 | + $smcFunc = array(); |
|
371 | + } |
|
355 | 372 | |
356 | 373 | $modSettings['disableQueryCheck'] = true; |
357 | 374 | |
@@ -359,8 +376,9 @@ discard block |
||
359 | 376 | if (!$db_connection) |
360 | 377 | { |
361 | 378 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
362 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
363 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
379 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
380 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
381 | + } |
|
364 | 382 | |
365 | 383 | $db_options = array('persist' => $db_persist); |
366 | 384 | $port = ''; |
@@ -371,19 +389,20 @@ discard block |
||
371 | 389 | if ($db_type == 'mysql') |
372 | 390 | { |
373 | 391 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
374 | - } |
|
375 | - elseif ($db_type == 'postgresql') |
|
392 | + } elseif ($db_type == 'postgresql') |
|
376 | 393 | { |
377 | 394 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
378 | 395 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
379 | 396 | } |
380 | 397 | } |
381 | 398 | |
382 | - if (!empty($port)) |
|
383 | - $db_options['port'] = $port; |
|
399 | + if (!empty($port)) { |
|
400 | + $db_options['port'] = $port; |
|
401 | + } |
|
384 | 402 | |
385 | - if (!$db_connection) |
|
386 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
403 | + if (!$db_connection) { |
|
404 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
405 | + } |
|
387 | 406 | } |
388 | 407 | } |
389 | 408 | |
@@ -411,8 +430,9 @@ discard block |
||
411 | 430 | // @todo REMOVE THIS!! |
412 | 431 | else |
413 | 432 | { |
414 | - if (function_exists('doStep' . $_GET['step'])) |
|
415 | - call_user_func('doStep' . $_GET['step']); |
|
433 | + if (function_exists('doStep' . $_GET['step'])) { |
|
434 | + call_user_func('doStep' . $_GET['step']); |
|
435 | + } |
|
416 | 436 | } |
417 | 437 | // Show the footer. |
418 | 438 | template_install_below(); |
@@ -430,8 +450,9 @@ discard block |
||
430 | 450 | $incontext['sub_template'] = 'welcome_message'; |
431 | 451 | |
432 | 452 | // Done the submission? |
433 | - if (isset($_POST['contbutt'])) |
|
434 | - return true; |
|
453 | + if (isset($_POST['contbutt'])) { |
|
454 | + return true; |
|
455 | + } |
|
435 | 456 | |
436 | 457 | // See if we think they have already installed it? |
437 | 458 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -439,14 +460,17 @@ discard block |
||
439 | 460 | $probably_installed = 0; |
440 | 461 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
441 | 462 | { |
442 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
443 | - $probably_installed++; |
|
444 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
445 | - $probably_installed++; |
|
463 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
464 | + $probably_installed++; |
|
465 | + } |
|
466 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
467 | + $probably_installed++; |
|
468 | + } |
|
446 | 469 | } |
447 | 470 | |
448 | - if ($probably_installed == 2) |
|
449 | - $incontext['warning'] = $txt['error_already_installed']; |
|
471 | + if ($probably_installed == 2) { |
|
472 | + $incontext['warning'] = $txt['error_already_installed']; |
|
473 | + } |
|
450 | 474 | } |
451 | 475 | |
452 | 476 | // Is some database support even compiled in? |
@@ -461,45 +485,54 @@ discard block |
||
461 | 485 | $databases[$key]['supported'] = false; |
462 | 486 | $notFoundSQLFile = true; |
463 | 487 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
488 | + } else { |
|
489 | + $incontext['supported_databases'][] = $db; |
|
464 | 490 | } |
465 | - else |
|
466 | - $incontext['supported_databases'][] = $db; |
|
467 | 491 | } |
468 | 492 | } |
469 | 493 | |
470 | 494 | // Check the PHP version. |
471 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
472 | - $error = 'error_php_too_low'; |
|
495 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
496 | + $error = 'error_php_too_low'; |
|
497 | + } |
|
473 | 498 | // Make sure we have a supported database |
474 | - elseif (empty($incontext['supported_databases'])) |
|
475 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
499 | + elseif (empty($incontext['supported_databases'])) { |
|
500 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
501 | + } |
|
476 | 502 | // How about session support? Some crazy sysadmin remove it? |
477 | - elseif (!function_exists('session_start')) |
|
478 | - $error = 'error_session_missing'; |
|
503 | + elseif (!function_exists('session_start')) { |
|
504 | + $error = 'error_session_missing'; |
|
505 | + } |
|
479 | 506 | // Make sure they uploaded all the files. |
480 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
481 | - $error = 'error_missing_files'; |
|
507 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
508 | + $error = 'error_missing_files'; |
|
509 | + } |
|
482 | 510 | // Very simple check on the session.save_path for Windows. |
483 | 511 | // @todo Move this down later if they don't use database-driven sessions? |
484 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
485 | - $error = 'error_session_save_path'; |
|
512 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
513 | + $error = 'error_session_save_path'; |
|
514 | + } |
|
486 | 515 | |
487 | 516 | // Since each of the three messages would look the same, anyway... |
488 | - if (isset($error)) |
|
489 | - $incontext['error'] = $txt[$error]; |
|
517 | + if (isset($error)) { |
|
518 | + $incontext['error'] = $txt[$error]; |
|
519 | + } |
|
490 | 520 | |
491 | 521 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
492 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
493 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
522 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
523 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
524 | + } |
|
494 | 525 | |
495 | 526 | // Confirm mbstring is loaded... |
496 | - if (!extension_loaded('mbstring')) |
|
497 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
527 | + if (!extension_loaded('mbstring')) { |
|
528 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
529 | + } |
|
498 | 530 | |
499 | 531 | // Check for https stream support. |
500 | 532 | $supported_streams = stream_get_wrappers(); |
501 | - if (!in_array('https', $supported_streams)) |
|
502 | - $incontext['warning'] = $txt['install_no_https']; |
|
533 | + if (!in_array('https', $supported_streams)) { |
|
534 | + $incontext['warning'] = $txt['install_no_https']; |
|
535 | + } |
|
503 | 536 | |
504 | 537 | return false; |
505 | 538 | } |
@@ -524,12 +557,14 @@ discard block |
||
524 | 557 | 'Settings_bak.php', |
525 | 558 | ); |
526 | 559 | |
527 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
528 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
560 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
561 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
562 | + } |
|
529 | 563 | |
530 | 564 | // With mod_security installed, we could attempt to fix it with .htaccess. |
531 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
532 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
565 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
566 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
567 | + } |
|
533 | 568 | |
534 | 569 | $failed_files = array(); |
535 | 570 | |
@@ -541,20 +576,23 @@ discard block |
||
541 | 576 | foreach ($writable_files as $file) |
542 | 577 | { |
543 | 578 | // Some files won't exist, try to address up front |
544 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
545 | - @touch(dirname(__FILE__) . '/' . $file); |
|
579 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
580 | + @touch(dirname(__FILE__) . '/' . $file); |
|
581 | + } |
|
546 | 582 | // NOW do the writable check... |
547 | 583 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
548 | 584 | { |
549 | 585 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
550 | 586 | |
551 | 587 | // Well, 755 hopefully worked... if not, try 777. |
552 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
553 | - $failed_files[] = $file; |
|
588 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
589 | + $failed_files[] = $file; |
|
590 | + } |
|
554 | 591 | } |
555 | 592 | } |
556 | - foreach ($extra_files as $file) |
|
557 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
593 | + foreach ($extra_files as $file) { |
|
594 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
595 | + } |
|
558 | 596 | } |
559 | 597 | // Windows is trickier. Let's try opening for r+... |
560 | 598 | else |
@@ -564,30 +602,35 @@ discard block |
||
564 | 602 | foreach ($writable_files as $file) |
565 | 603 | { |
566 | 604 | // Folders can't be opened for write... but the index.php in them can ;) |
567 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
568 | - $file .= '/index.php'; |
|
605 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
606 | + $file .= '/index.php'; |
|
607 | + } |
|
569 | 608 | |
570 | 609 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
571 | 610 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
572 | 611 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
573 | 612 | |
574 | 613 | // Hmm, okay, try just for write in that case... |
575 | - if (!is_resource($fp)) |
|
576 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
614 | + if (!is_resource($fp)) { |
|
615 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
616 | + } |
|
577 | 617 | |
578 | - if (!is_resource($fp)) |
|
579 | - $failed_files[] = $file; |
|
618 | + if (!is_resource($fp)) { |
|
619 | + $failed_files[] = $file; |
|
620 | + } |
|
580 | 621 | |
581 | 622 | @fclose($fp); |
582 | 623 | } |
583 | - foreach ($extra_files as $file) |
|
584 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
624 | + foreach ($extra_files as $file) { |
|
625 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
626 | + } |
|
585 | 627 | } |
586 | 628 | |
587 | 629 | $failure = count($failed_files) >= 1; |
588 | 630 | |
589 | - if (!isset($_SERVER)) |
|
590 | - return !$failure; |
|
631 | + if (!isset($_SERVER)) { |
|
632 | + return !$failure; |
|
633 | + } |
|
591 | 634 | |
592 | 635 | // Put the list into context. |
593 | 636 | $incontext['failed_files'] = $failed_files; |
@@ -635,19 +678,23 @@ discard block |
||
635 | 678 | |
636 | 679 | if (!isset($ftp) || $ftp->error !== false) |
637 | 680 | { |
638 | - if (!isset($ftp)) |
|
639 | - $ftp = new ftp_connection(null); |
|
681 | + if (!isset($ftp)) { |
|
682 | + $ftp = new ftp_connection(null); |
|
683 | + } |
|
640 | 684 | // Save the error so we can mess with listing... |
641 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
642 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
685 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
686 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
687 | + } |
|
643 | 688 | |
644 | 689 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
645 | 690 | |
646 | - if (empty($_POST['ftp_path']) && $found_path) |
|
647 | - $_POST['ftp_path'] = $detect_path; |
|
691 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
692 | + $_POST['ftp_path'] = $detect_path; |
|
693 | + } |
|
648 | 694 | |
649 | - if (!isset($_POST['ftp_username'])) |
|
650 | - $_POST['ftp_username'] = $username; |
|
695 | + if (!isset($_POST['ftp_username'])) { |
|
696 | + $_POST['ftp_username'] = $username; |
|
697 | + } |
|
651 | 698 | |
652 | 699 | // Set the username etc, into context. |
653 | 700 | $incontext['ftp'] = array( |
@@ -659,8 +706,7 @@ discard block |
||
659 | 706 | ); |
660 | 707 | |
661 | 708 | return false; |
662 | - } |
|
663 | - else |
|
709 | + } else |
|
664 | 710 | { |
665 | 711 | $_SESSION['installer_temp_ftp'] = array( |
666 | 712 | 'server' => $_POST['ftp_server'], |
@@ -674,10 +720,12 @@ discard block |
||
674 | 720 | |
675 | 721 | foreach ($failed_files as $file) |
676 | 722 | { |
677 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
678 | - $ftp->chmod($file, 0755); |
|
679 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
680 | - $ftp->chmod($file, 0777); |
|
723 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
724 | + $ftp->chmod($file, 0755); |
|
725 | + } |
|
726 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
727 | + $ftp->chmod($file, 0777); |
|
728 | + } |
|
681 | 729 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
682 | 730 | { |
683 | 731 | $failed_files_updated[] = $file; |
@@ -733,15 +781,17 @@ discard block |
||
733 | 781 | |
734 | 782 | if (!$foundOne) |
735 | 783 | { |
736 | - if (isset($db['default_host'])) |
|
737 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
784 | + if (isset($db['default_host'])) { |
|
785 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
786 | + } |
|
738 | 787 | if (isset($db['default_user'])) |
739 | 788 | { |
740 | 789 | $incontext['db']['user'] = ini_get($db['default_user']); |
741 | 790 | $incontext['db']['name'] = ini_get($db['default_user']); |
742 | 791 | } |
743 | - if (isset($db['default_password'])) |
|
744 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
792 | + if (isset($db['default_password'])) { |
|
793 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
794 | + } |
|
745 | 795 | |
746 | 796 | // For simplicity and less confusion, leave the port blank by default |
747 | 797 | $incontext['db']['port'] = ''; |
@@ -760,10 +810,10 @@ discard block |
||
760 | 810 | $incontext['db']['server'] = $_POST['db_server']; |
761 | 811 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
762 | 812 | |
763 | - if (!empty($_POST['db_port'])) |
|
764 | - $incontext['db']['port'] = $_POST['db_port']; |
|
765 | - } |
|
766 | - else |
|
813 | + if (!empty($_POST['db_port'])) { |
|
814 | + $incontext['db']['port'] = $_POST['db_port']; |
|
815 | + } |
|
816 | + } else |
|
767 | 817 | { |
768 | 818 | $incontext['db']['prefix'] = 'smf_'; |
769 | 819 | } |
@@ -799,10 +849,11 @@ discard block |
||
799 | 849 | if (!empty($_POST['db_port'])) |
800 | 850 | { |
801 | 851 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
802 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
803 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
804 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
805 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
852 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
853 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
854 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
855 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
856 | + } |
|
806 | 857 | } |
807 | 858 | |
808 | 859 | // God I hope it saved! |
@@ -815,8 +866,9 @@ discard block |
||
815 | 866 | // Make sure it works. |
816 | 867 | require(dirname(__FILE__) . '/Settings.php'); |
817 | 868 | |
818 | - if (empty($sourcedir)) |
|
819 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
869 | + if (empty($sourcedir)) { |
|
870 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
871 | + } |
|
820 | 872 | |
821 | 873 | // Better find the database file! |
822 | 874 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -826,18 +878,21 @@ discard block |
||
826 | 878 | } |
827 | 879 | |
828 | 880 | // Now include it for database functions! |
829 | - if (!defined('SMF')) |
|
830 | - define('SMF', 1); |
|
881 | + if (!defined('SMF')) { |
|
882 | + define('SMF', 1); |
|
883 | + } |
|
831 | 884 | |
832 | 885 | $modSettings['disableQueryCheck'] = true; |
833 | - if (empty($smcFunc)) |
|
834 | - $smcFunc = array(); |
|
886 | + if (empty($smcFunc)) { |
|
887 | + $smcFunc = array(); |
|
888 | + } |
|
835 | 889 | |
836 | 890 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
837 | 891 | |
838 | 892 | // What - running PHP4? The shame! |
839 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
840 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
893 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
894 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
895 | + } |
|
841 | 896 | |
842 | 897 | // Attempt a connection. |
843 | 898 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -925,12 +980,14 @@ discard block |
||
925 | 980 | $incontext['page_title'] = $txt['install_settings']; |
926 | 981 | |
927 | 982 | // Let's see if we got the database type correct. |
928 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
929 | - $db_type = $_POST['db_type']; |
|
983 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
984 | + $db_type = $_POST['db_type']; |
|
985 | + } |
|
930 | 986 | |
931 | 987 | // Else we'd better be able to get the connection. |
932 | - else |
|
933 | - load_database(); |
|
988 | + else { |
|
989 | + load_database(); |
|
990 | + } |
|
934 | 991 | |
935 | 992 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
936 | 993 | |
@@ -939,10 +996,11 @@ discard block |
||
939 | 996 | |
940 | 997 | $secure = false; |
941 | 998 | |
942 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
943 | - $secure = true; |
|
944 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
945 | - $secure = true; |
|
999 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
1000 | + $secure = true; |
|
1001 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
1002 | + $secure = true; |
|
1003 | + } |
|
946 | 1004 | |
947 | 1005 | // Now, to put what we've learned together... and add a path. |
948 | 1006 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -974,18 +1032,21 @@ discard block |
||
974 | 1032 | // Submitting? |
975 | 1033 | if (isset($_POST['boardurl'])) |
976 | 1034 | { |
977 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
978 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
979 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
980 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
981 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
982 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1035 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1036 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1037 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1038 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1039 | + } |
|
1040 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1041 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1042 | + } |
|
983 | 1043 | |
984 | 1044 | //Make sure boardurl is aligned with ssl setting |
985 | - if (empty($_POST['force_ssl'])) |
|
986 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
987 | - else |
|
988 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1045 | + if (empty($_POST['force_ssl'])) { |
|
1046 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1047 | + } else { |
|
1048 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1049 | + } |
|
989 | 1050 | |
990 | 1051 | // Save these variables. |
991 | 1052 | $vars = array( |
@@ -1024,10 +1085,10 @@ discard block |
||
1024 | 1085 | { |
1025 | 1086 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1026 | 1087 | return false; |
1027 | - } |
|
1028 | - else |
|
1029 | - // Set the character set here. |
|
1088 | + } else { |
|
1089 | + // Set the character set here. |
|
1030 | 1090 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1091 | + } |
|
1031 | 1092 | } |
1032 | 1093 | |
1033 | 1094 | // Good, skip on. |
@@ -1047,8 +1108,9 @@ discard block |
||
1047 | 1108 | $incontext['continue'] = 1; |
1048 | 1109 | |
1049 | 1110 | // Already done? |
1050 | - if (isset($_POST['pop_done'])) |
|
1051 | - return true; |
|
1111 | + if (isset($_POST['pop_done'])) { |
|
1112 | + return true; |
|
1113 | + } |
|
1052 | 1114 | |
1053 | 1115 | // Reload settings. |
1054 | 1116 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1066,8 +1128,9 @@ discard block |
||
1066 | 1128 | $modSettings = array(); |
1067 | 1129 | if ($result !== false) |
1068 | 1130 | { |
1069 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1070 | - $modSettings[$row['variable']] = $row['value']; |
|
1131 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1132 | + $modSettings[$row['variable']] = $row['value']; |
|
1133 | + } |
|
1071 | 1134 | $smcFunc['db_free_result']($result); |
1072 | 1135 | |
1073 | 1136 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1080,20 +1143,22 @@ discard block |
||
1080 | 1143 | $modSettings['disableQueryCheck'] = true; |
1081 | 1144 | |
1082 | 1145 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1083 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1084 | - $smcFunc['db_query']('', ' |
|
1146 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1147 | + $smcFunc['db_query']('', ' |
|
1085 | 1148 | SET NAMES {string:utf8}', |
1086 | 1149 | array( |
1087 | 1150 | 'db_error_skip' => true, |
1088 | 1151 | 'utf8' => 'utf8', |
1089 | 1152 | ) |
1090 | 1153 | ); |
1154 | + } |
|
1091 | 1155 | |
1092 | 1156 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1093 | - if (substr(__DIR__, -1) == '\\') |
|
1094 | - $attachdir = __DIR__ . 'attachments'; |
|
1095 | - else |
|
1096 | - $attachdir = __DIR__ . '/attachments'; |
|
1157 | + if (substr(__DIR__, -1) == '\\') { |
|
1158 | + $attachdir = __DIR__ . 'attachments'; |
|
1159 | + } else { |
|
1160 | + $attachdir = __DIR__ . '/attachments'; |
|
1161 | + } |
|
1097 | 1162 | |
1098 | 1163 | $replaces = array( |
1099 | 1164 | '{$db_prefix}' => $db_prefix, |
@@ -1110,8 +1175,9 @@ discard block |
||
1110 | 1175 | |
1111 | 1176 | foreach ($txt as $key => $value) |
1112 | 1177 | { |
1113 | - if (substr($key, 0, 8) == 'default_') |
|
1114 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1178 | + if (substr($key, 0, 8) == 'default_') { |
|
1179 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1180 | + } |
|
1115 | 1181 | } |
1116 | 1182 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1117 | 1183 | |
@@ -1126,8 +1192,9 @@ discard block |
||
1126 | 1192 | |
1127 | 1193 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1128 | 1194 | { |
1129 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1130 | - $engines[] = $row['Engine']; |
|
1195 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1196 | + $engines[] = $row['Engine']; |
|
1197 | + } |
|
1131 | 1198 | } |
1132 | 1199 | |
1133 | 1200 | // Done with this now |
@@ -1151,8 +1218,7 @@ discard block |
||
1151 | 1218 | $replaces['START TRANSACTION;'] = ''; |
1152 | 1219 | $replaces['COMMIT;'] = ''; |
1153 | 1220 | } |
1154 | - } |
|
1155 | - else |
|
1221 | + } else |
|
1156 | 1222 | { |
1157 | 1223 | $has_innodb = false; |
1158 | 1224 | } |
@@ -1174,21 +1240,24 @@ discard block |
||
1174 | 1240 | foreach ($sql_lines as $count => $line) |
1175 | 1241 | { |
1176 | 1242 | // No comments allowed! |
1177 | - if (substr(trim($line), 0, 1) != '#') |
|
1178 | - $current_statement .= "\n" . rtrim($line); |
|
1243 | + if (substr(trim($line), 0, 1) != '#') { |
|
1244 | + $current_statement .= "\n" . rtrim($line); |
|
1245 | + } |
|
1179 | 1246 | |
1180 | 1247 | // Is this the end of the query string? |
1181 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1182 | - continue; |
|
1248 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1249 | + continue; |
|
1250 | + } |
|
1183 | 1251 | |
1184 | 1252 | // Does this table already exist? If so, don't insert more data into it! |
1185 | 1253 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1186 | 1254 | { |
1187 | 1255 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1188 | - if (!empty($matches[0])) |
|
1189 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1190 | - else |
|
1191 | - $incontext['sql_results']['insert_dups']++; |
|
1256 | + if (!empty($matches[0])) { |
|
1257 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1258 | + } else { |
|
1259 | + $incontext['sql_results']['insert_dups']++; |
|
1260 | + } |
|
1192 | 1261 | |
1193 | 1262 | $current_statement = ''; |
1194 | 1263 | continue; |
@@ -1197,8 +1266,9 @@ discard block |
||
1197 | 1266 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1198 | 1267 | { |
1199 | 1268 | // Use the appropriate function based on the DB type |
1200 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1201 | - $db_errorno = $db_type . '_errno'; |
|
1269 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1270 | + $db_errorno = $db_type . '_errno'; |
|
1271 | + } |
|
1202 | 1272 | |
1203 | 1273 | // Error 1050: Table already exists! |
1204 | 1274 | // @todo Needs to be made better! |
@@ -1213,18 +1283,18 @@ discard block |
||
1213 | 1283 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1214 | 1284 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1215 | 1285 | } |
1216 | - } |
|
1217 | - else |
|
1286 | + } else |
|
1218 | 1287 | { |
1219 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1220 | - $incontext['sql_results']['tables']++; |
|
1221 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1288 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1289 | + $incontext['sql_results']['tables']++; |
|
1290 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1222 | 1291 | { |
1223 | 1292 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1224 | - if (!empty($matches[0])) |
|
1225 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1226 | - else |
|
1227 | - $incontext['sql_results']['inserts']++; |
|
1293 | + if (!empty($matches[0])) { |
|
1294 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1295 | + } else { |
|
1296 | + $incontext['sql_results']['inserts']++; |
|
1297 | + } |
|
1228 | 1298 | } |
1229 | 1299 | } |
1230 | 1300 | |
@@ -1237,15 +1307,17 @@ discard block |
||
1237 | 1307 | // Sort out the context for the SQL. |
1238 | 1308 | foreach ($incontext['sql_results'] as $key => $number) |
1239 | 1309 | { |
1240 | - if ($number == 0) |
|
1241 | - unset($incontext['sql_results'][$key]); |
|
1242 | - else |
|
1243 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1310 | + if ($number == 0) { |
|
1311 | + unset($incontext['sql_results'][$key]); |
|
1312 | + } else { |
|
1313 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1314 | + } |
|
1244 | 1315 | } |
1245 | 1316 | |
1246 | 1317 | // Make sure UTF will be used globally. |
1247 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1248 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1318 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1319 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1320 | + } |
|
1249 | 1321 | |
1250 | 1322 | // Auto-detect local & global cookie settings |
1251 | 1323 | $url_parts = parse_url($boardurl); |
@@ -1274,15 +1346,19 @@ discard block |
||
1274 | 1346 | |
1275 | 1347 | // Look for subfolder, if found, set localCookie |
1276 | 1348 | // Checking for len > 1 ensures you don't have just a slash... |
1277 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
1278 | - $localCookies = '1'; |
|
1349 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
1350 | + $localCookies = '1'; |
|
1351 | + } |
|
1279 | 1352 | |
1280 | - if (isset($globalCookies)) |
|
1281 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
1282 | - if (isset($globalCookiesDomain)) |
|
1283 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1284 | - if (isset($localCookies)) |
|
1285 | - $newSettings[] = array('localCookies', $localCookies); |
|
1353 | + if (isset($globalCookies)) { |
|
1354 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
1355 | + } |
|
1356 | + if (isset($globalCookiesDomain)) { |
|
1357 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1358 | + } |
|
1359 | + if (isset($localCookies)) { |
|
1360 | + $newSettings[] = array('localCookies', $localCookies); |
|
1361 | + } |
|
1286 | 1362 | } |
1287 | 1363 | |
1288 | 1364 | // Are we allowing stat collection? |
@@ -1300,16 +1376,17 @@ discard block |
||
1300 | 1376 | fwrite($fp, $out); |
1301 | 1377 | |
1302 | 1378 | $return_data = ''; |
1303 | - while (!feof($fp)) |
|
1304 | - $return_data .= fgets($fp, 128); |
|
1379 | + while (!feof($fp)) { |
|
1380 | + $return_data .= fgets($fp, 128); |
|
1381 | + } |
|
1305 | 1382 | |
1306 | 1383 | fclose($fp); |
1307 | 1384 | |
1308 | 1385 | // Get the unique site ID. |
1309 | 1386 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1310 | 1387 | |
1311 | - if (!empty($ID[1])) |
|
1312 | - $smcFunc['db_insert']('replace', |
|
1388 | + if (!empty($ID[1])) { |
|
1389 | + $smcFunc['db_insert']('replace', |
|
1313 | 1390 | $db_prefix . 'settings', |
1314 | 1391 | array('variable' => 'string', 'value' => 'string'), |
1315 | 1392 | array( |
@@ -1318,11 +1395,12 @@ discard block |
||
1318 | 1395 | ), |
1319 | 1396 | array('variable') |
1320 | 1397 | ); |
1398 | + } |
|
1321 | 1399 | } |
1322 | 1400 | } |
1323 | 1401 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1324 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1325 | - $smcFunc['db_query']('', ' |
|
1402 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1403 | + $smcFunc['db_query']('', ' |
|
1326 | 1404 | DELETE FROM {db_prefix}settings |
1327 | 1405 | WHERE variable = {string:enable_sm_stats}', |
1328 | 1406 | array( |
@@ -1330,20 +1408,23 @@ discard block |
||
1330 | 1408 | 'db_error_skip' => true, |
1331 | 1409 | ) |
1332 | 1410 | ); |
1411 | + } |
|
1333 | 1412 | |
1334 | 1413 | // Are we enabling SSL? |
1335 | - if (!empty($_POST['force_ssl'])) |
|
1336 | - $newSettings[] = array('force_ssl', 1); |
|
1414 | + if (!empty($_POST['force_ssl'])) { |
|
1415 | + $newSettings[] = array('force_ssl', 1); |
|
1416 | + } |
|
1337 | 1417 | |
1338 | 1418 | // Setting a timezone is required. |
1339 | 1419 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1340 | 1420 | { |
1341 | 1421 | // Get PHP's default timezone, if set |
1342 | 1422 | $ini_tz = ini_get('date.timezone'); |
1343 | - if (!empty($ini_tz)) |
|
1344 | - $timezone_id = $ini_tz; |
|
1345 | - else |
|
1346 | - $timezone_id = ''; |
|
1423 | + if (!empty($ini_tz)) { |
|
1424 | + $timezone_id = $ini_tz; |
|
1425 | + } else { |
|
1426 | + $timezone_id = ''; |
|
1427 | + } |
|
1347 | 1428 | |
1348 | 1429 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1349 | 1430 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1352,8 +1433,9 @@ discard block |
||
1352 | 1433 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1353 | 1434 | } |
1354 | 1435 | |
1355 | - if (date_default_timezone_set($timezone_id)) |
|
1356 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1436 | + if (date_default_timezone_set($timezone_id)) { |
|
1437 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1438 | + } |
|
1357 | 1439 | } |
1358 | 1440 | |
1359 | 1441 | if (!empty($newSettings)) |
@@ -1384,16 +1466,18 @@ discard block |
||
1384 | 1466 | } |
1385 | 1467 | |
1386 | 1468 | // MySQL specific stuff |
1387 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1388 | - return false; |
|
1469 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1470 | + return false; |
|
1471 | + } |
|
1389 | 1472 | |
1390 | 1473 | // Find database user privileges. |
1391 | 1474 | $privs = array(); |
1392 | 1475 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1393 | 1476 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1394 | 1477 | { |
1395 | - if ($row['Privilege'] == 'Alter') |
|
1396 | - $privs[] = $row['Privilege']; |
|
1478 | + if ($row['Privilege'] == 'Alter') { |
|
1479 | + $privs[] = $row['Privilege']; |
|
1480 | + } |
|
1397 | 1481 | } |
1398 | 1482 | $smcFunc['db_free_result']($get_privs); |
1399 | 1483 | |
@@ -1423,8 +1507,9 @@ discard block |
||
1423 | 1507 | $incontext['continue'] = 1; |
1424 | 1508 | |
1425 | 1509 | // Skipping? |
1426 | - if (!empty($_POST['skip'])) |
|
1427 | - return true; |
|
1510 | + if (!empty($_POST['skip'])) { |
|
1511 | + return true; |
|
1512 | + } |
|
1428 | 1513 | |
1429 | 1514 | // Need this to check whether we need the database password. |
1430 | 1515 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1441,18 +1526,22 @@ discard block |
||
1441 | 1526 | // We need this to properly hash the password for Admin |
1442 | 1527 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1443 | 1528 | global $sourcedir; |
1444 | - if (function_exists('mb_strtolower')) |
|
1445 | - return mb_strtolower($string, 'UTF-8'); |
|
1529 | + if (function_exists('mb_strtolower')) { |
|
1530 | + return mb_strtolower($string, 'UTF-8'); |
|
1531 | + } |
|
1446 | 1532 | require_once($sourcedir . '/Subs-Charset.php'); |
1447 | 1533 | return utf8_strtolower($string); |
1448 | 1534 | }; |
1449 | 1535 | |
1450 | - if (!isset($_POST['username'])) |
|
1451 | - $_POST['username'] = ''; |
|
1452 | - if (!isset($_POST['email'])) |
|
1453 | - $_POST['email'] = ''; |
|
1454 | - if (!isset($_POST['server_email'])) |
|
1455 | - $_POST['server_email'] = ''; |
|
1536 | + if (!isset($_POST['username'])) { |
|
1537 | + $_POST['username'] = ''; |
|
1538 | + } |
|
1539 | + if (!isset($_POST['email'])) { |
|
1540 | + $_POST['email'] = ''; |
|
1541 | + } |
|
1542 | + if (!isset($_POST['server_email'])) { |
|
1543 | + $_POST['server_email'] = ''; |
|
1544 | + } |
|
1456 | 1545 | |
1457 | 1546 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1458 | 1547 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1471,8 +1560,9 @@ discard block |
||
1471 | 1560 | 'admin_group' => 1, |
1472 | 1561 | ) |
1473 | 1562 | ); |
1474 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1475 | - $incontext['skip'] = 1; |
|
1563 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1564 | + $incontext['skip'] = 1; |
|
1565 | + } |
|
1476 | 1566 | $smcFunc['db_free_result']($request); |
1477 | 1567 | |
1478 | 1568 | // Trying to create an account? |
@@ -1503,8 +1593,9 @@ discard block |
||
1503 | 1593 | } |
1504 | 1594 | |
1505 | 1595 | // Update the webmaster's email? |
1506 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1507 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1596 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1597 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1598 | + } |
|
1508 | 1599 | |
1509 | 1600 | // Work out whether we're going to have dodgy characters and remove them. |
1510 | 1601 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1527,32 +1618,27 @@ discard block |
||
1527 | 1618 | $smcFunc['db_free_result']($result); |
1528 | 1619 | |
1529 | 1620 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1530 | - } |
|
1531 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1621 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1532 | 1622 | { |
1533 | 1623 | // Try the previous step again. |
1534 | 1624 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1535 | 1625 | return false; |
1536 | - } |
|
1537 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1626 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1538 | 1627 | { |
1539 | 1628 | // Try the previous step again. |
1540 | 1629 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1541 | 1630 | return false; |
1542 | - } |
|
1543 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1631 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1544 | 1632 | { |
1545 | 1633 | // One step back, this time fill out a proper admin email address. |
1546 | 1634 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1547 | 1635 | return false; |
1548 | - } |
|
1549 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1636 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1550 | 1637 | { |
1551 | 1638 | // One step back, this time fill out a proper admin email address. |
1552 | 1639 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1553 | 1640 | return false; |
1554 | - } |
|
1555 | - elseif ($_POST['username'] != '') |
|
1641 | + } elseif ($_POST['username'] != '') |
|
1556 | 1642 | { |
1557 | 1643 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1558 | 1644 | |
@@ -1620,17 +1706,19 @@ discard block |
||
1620 | 1706 | reloadSettings(); |
1621 | 1707 | |
1622 | 1708 | // Bring a warning over. |
1623 | - if (!empty($incontext['account_existed'])) |
|
1624 | - $incontext['warning'] = $incontext['account_existed']; |
|
1709 | + if (!empty($incontext['account_existed'])) { |
|
1710 | + $incontext['warning'] = $incontext['account_existed']; |
|
1711 | + } |
|
1625 | 1712 | |
1626 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1627 | - $smcFunc['db_query']('', ' |
|
1713 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1714 | + $smcFunc['db_query']('', ' |
|
1628 | 1715 | SET NAMES {string:db_character_set}', |
1629 | 1716 | array( |
1630 | 1717 | 'db_character_set' => $db_character_set, |
1631 | 1718 | 'db_error_skip' => true, |
1632 | 1719 | ) |
1633 | 1720 | ); |
1721 | + } |
|
1634 | 1722 | |
1635 | 1723 | // As track stats is by default enabled let's add some activity. |
1636 | 1724 | $smcFunc['db_insert']('ignore', |
@@ -1651,14 +1739,16 @@ discard block |
||
1651 | 1739 | // Only proceed if we can load the data. |
1652 | 1740 | if ($request) |
1653 | 1741 | { |
1654 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1655 | - $modSettings[$row[0]] = $row[1]; |
|
1742 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1743 | + $modSettings[$row[0]] = $row[1]; |
|
1744 | + } |
|
1656 | 1745 | $smcFunc['db_free_result']($request); |
1657 | 1746 | } |
1658 | 1747 | |
1659 | 1748 | // Automatically log them in ;) |
1660 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1661 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1749 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1750 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1751 | + } |
|
1662 | 1752 | |
1663 | 1753 | $result = $smcFunc['db_query']('', ' |
1664 | 1754 | SELECT value |
@@ -1669,13 +1759,14 @@ discard block |
||
1669 | 1759 | 'db_error_skip' => true, |
1670 | 1760 | ) |
1671 | 1761 | ); |
1672 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1673 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1762 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1763 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1764 | + } |
|
1674 | 1765 | $smcFunc['db_free_result']($result); |
1675 | 1766 | |
1676 | - if (empty($db_sessions)) |
|
1677 | - $_SESSION['admin_time'] = time(); |
|
1678 | - else |
|
1767 | + if (empty($db_sessions)) { |
|
1768 | + $_SESSION['admin_time'] = time(); |
|
1769 | + } else |
|
1679 | 1770 | { |
1680 | 1771 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1681 | 1772 | |
@@ -1699,8 +1790,9 @@ discard block |
||
1699 | 1790 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1700 | 1791 | function($string){ |
1701 | 1792 | global $sourcedir; |
1702 | - if (function_exists('mb_strtolower')) |
|
1703 | - return mb_strtolower($string, 'UTF-8'); |
|
1793 | + if (function_exists('mb_strtolower')) { |
|
1794 | + return mb_strtolower($string, 'UTF-8'); |
|
1795 | + } |
|
1704 | 1796 | require_once($sourcedir . '/Subs-Charset.php'); |
1705 | 1797 | return utf8_strtolower($string); |
1706 | 1798 | }; |
@@ -1716,8 +1808,9 @@ discard block |
||
1716 | 1808 | ) |
1717 | 1809 | ); |
1718 | 1810 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1719 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1720 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1811 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1812 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1813 | + } |
|
1721 | 1814 | $smcFunc['db_free_result']($request); |
1722 | 1815 | |
1723 | 1816 | // Now is the perfect time to fetch the SM files. |
@@ -1736,8 +1829,9 @@ discard block |
||
1736 | 1829 | |
1737 | 1830 | // Check if we need some stupid MySQL fix. |
1738 | 1831 | $server_version = $smcFunc['db_server_info'](); |
1739 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1740 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1832 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1833 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1834 | + } |
|
1741 | 1835 | |
1742 | 1836 | // Some final context for the template. |
1743 | 1837 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1757,8 +1851,9 @@ discard block |
||
1757 | 1851 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1758 | 1852 | |
1759 | 1853 | // @todo Do we just want to read the file in clean, and split it this way always? |
1760 | - if (count($settingsArray) == 1) |
|
1761 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1854 | + if (count($settingsArray) == 1) { |
|
1855 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1856 | + } |
|
1762 | 1857 | |
1763 | 1858 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1764 | 1859 | { |
@@ -1766,25 +1861,29 @@ discard block |
||
1766 | 1861 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
1767 | 1862 | { |
1768 | 1863 | // Set the ten lines to nothing. |
1769 | - for ($j=0; $j < 10; $j++) |
|
1770 | - $settingsArray[$i++] = ''; |
|
1864 | + for ($j=0; $j < 10; $j++) { |
|
1865 | + $settingsArray[$i++] = ''; |
|
1866 | + } |
|
1771 | 1867 | |
1772 | 1868 | continue; |
1773 | 1869 | } |
1774 | 1870 | |
1775 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1776 | - $settingsArray[$i] = ''; |
|
1871 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1872 | + $settingsArray[$i] = ''; |
|
1873 | + } |
|
1777 | 1874 | |
1778 | 1875 | // Don't trim or bother with it if it's not a variable. |
1779 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1780 | - continue; |
|
1876 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1877 | + continue; |
|
1878 | + } |
|
1781 | 1879 | |
1782 | 1880 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1783 | 1881 | |
1784 | - foreach ($vars as $var => $val) |
|
1785 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1882 | + foreach ($vars as $var => $val) { |
|
1883 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1786 | 1884 | { |
1787 | 1885 | $comment = strstr($settingsArray[$i], '#'); |
1886 | + } |
|
1788 | 1887 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1789 | 1888 | unset($vars[$var]); |
1790 | 1889 | } |
@@ -1794,36 +1893,41 @@ discard block |
||
1794 | 1893 | if (!empty($vars)) |
1795 | 1894 | { |
1796 | 1895 | $settingsArray[$i++] = ''; |
1797 | - foreach ($vars as $var => $val) |
|
1798 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1896 | + foreach ($vars as $var => $val) { |
|
1897 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1898 | + } |
|
1799 | 1899 | } |
1800 | 1900 | |
1801 | 1901 | // Blank out the file - done to fix a oddity with some servers. |
1802 | 1902 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1803 | - if (!$fp) |
|
1804 | - return false; |
|
1903 | + if (!$fp) { |
|
1904 | + return false; |
|
1905 | + } |
|
1805 | 1906 | fclose($fp); |
1806 | 1907 | |
1807 | 1908 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1808 | 1909 | |
1809 | 1910 | // Gotta have one of these ;) |
1810 | - if (trim($settingsArray[0]) != '<?php') |
|
1811 | - fwrite($fp, "<?php\n"); |
|
1911 | + if (trim($settingsArray[0]) != '<?php') { |
|
1912 | + fwrite($fp, "<?php\n"); |
|
1913 | + } |
|
1812 | 1914 | |
1813 | 1915 | $lines = count($settingsArray); |
1814 | 1916 | for ($i = 0; $i < $lines - 1; $i++) |
1815 | 1917 | { |
1816 | 1918 | // Don't just write a bunch of blank lines. |
1817 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1818 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1919 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1920 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1921 | + } |
|
1819 | 1922 | } |
1820 | 1923 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1821 | 1924 | fclose($fp); |
1822 | 1925 | |
1823 | 1926 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1824 | 1927 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1825 | - if (function_exists('opcache_invalidate')) |
|
1826 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1928 | + if (function_exists('opcache_invalidate')) { |
|
1929 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1930 | + } |
|
1827 | 1931 | |
1828 | 1932 | return true; |
1829 | 1933 | } |
@@ -1833,10 +1937,11 @@ discard block |
||
1833 | 1937 | global $cachedir; |
1834 | 1938 | |
1835 | 1939 | // Write out the db_last_error file with the error timestamp |
1836 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
1837 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1838 | - else |
|
1839 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1940 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
1941 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1942 | + } else { |
|
1943 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1944 | + } |
|
1840 | 1945 | |
1841 | 1946 | return true; |
1842 | 1947 | } |
@@ -1853,9 +1958,9 @@ discard block |
||
1853 | 1958 | SecFilterScanPOST Off |
1854 | 1959 | </IfModule>'; |
1855 | 1960 | |
1856 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1857 | - return true; |
|
1858 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1961 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1962 | + return true; |
|
1963 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1859 | 1964 | { |
1860 | 1965 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1861 | 1966 | |
@@ -1867,29 +1972,28 @@ discard block |
||
1867 | 1972 | fwrite($ht_handle, $htaccess_addition); |
1868 | 1973 | fclose($ht_handle); |
1869 | 1974 | return true; |
1975 | + } else { |
|
1976 | + return false; |
|
1870 | 1977 | } |
1871 | - else |
|
1872 | - return false; |
|
1978 | + } else { |
|
1979 | + return true; |
|
1873 | 1980 | } |
1874 | - else |
|
1875 | - return true; |
|
1876 | - } |
|
1877 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1878 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1879 | - elseif (is_writable(dirname(__FILE__))) |
|
1981 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1982 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1983 | + } elseif (is_writable(dirname(__FILE__))) |
|
1880 | 1984 | { |
1881 | 1985 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1882 | 1986 | { |
1883 | 1987 | fwrite($ht_handle, $htaccess_addition); |
1884 | 1988 | fclose($ht_handle); |
1885 | 1989 | return true; |
1990 | + } else { |
|
1991 | + return false; |
|
1886 | 1992 | } |
1887 | - else |
|
1993 | + } else { |
|
1888 | 1994 | return false; |
1889 | 1995 | } |
1890 | - else |
|
1891 | - return false; |
|
1892 | -} |
|
1996 | + } |
|
1893 | 1997 | |
1894 | 1998 | function template_install_above() |
1895 | 1999 | { |
@@ -1927,9 +2031,10 @@ discard block |
||
1927 | 2031 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1928 | 2032 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1929 | 2033 | |
1930 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1931 | - echo ' |
|
2034 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2035 | + echo ' |
|
1932 | 2036 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
2037 | + } |
|
1933 | 2038 | |
1934 | 2039 | echo ' |
1935 | 2040 | </select> |
@@ -1949,9 +2054,10 @@ discard block |
||
1949 | 2054 | <h2>', $txt['upgrade_progress'], '</h2> |
1950 | 2055 | <ul>'; |
1951 | 2056 | |
1952 | - foreach ($incontext['steps'] as $num => $step) |
|
1953 | - echo ' |
|
2057 | + foreach ($incontext['steps'] as $num => $step) { |
|
2058 | + echo ' |
|
1954 | 2059 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2060 | + } |
|
1955 | 2061 | |
1956 | 2062 | echo ' |
1957 | 2063 | </ul> |
@@ -1976,20 +2082,23 @@ discard block |
||
1976 | 2082 | echo ' |
1977 | 2083 | <div class="floatright">'; |
1978 | 2084 | |
1979 | - if (!empty($incontext['continue'])) |
|
1980 | - echo ' |
|
2085 | + if (!empty($incontext['continue'])) { |
|
2086 | + echo ' |
|
1981 | 2087 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
1982 | - if (!empty($incontext['skip'])) |
|
1983 | - echo ' |
|
2088 | + } |
|
2089 | + if (!empty($incontext['skip'])) { |
|
2090 | + echo ' |
|
1984 | 2091 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
2092 | + } |
|
1985 | 2093 | echo ' |
1986 | 2094 | </div>'; |
1987 | 2095 | } |
1988 | 2096 | |
1989 | 2097 | // Show the closing form tag and other data only if not in the last step |
1990 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1991 | - echo ' |
|
2098 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2099 | + echo ' |
|
1992 | 2100 | </form>'; |
2101 | + } |
|
1993 | 2102 | |
1994 | 2103 | echo ' |
1995 | 2104 | </div> |
@@ -2024,13 +2133,15 @@ discard block |
||
2024 | 2133 | </div>'; |
2025 | 2134 | |
2026 | 2135 | // Show the warnings, or not. |
2027 | - if (template_warning_divs()) |
|
2028 | - echo ' |
|
2136 | + if (template_warning_divs()) { |
|
2137 | + echo ' |
|
2029 | 2138 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2139 | + } |
|
2030 | 2140 | |
2031 | 2141 | // Say we want the continue button! |
2032 | - if (empty($incontext['error'])) |
|
2033 | - $incontext['continue'] = 1; |
|
2142 | + if (empty($incontext['error'])) { |
|
2143 | + $incontext['continue'] = 1; |
|
2144 | + } |
|
2034 | 2145 | |
2035 | 2146 | // For the latest version stuff. |
2036 | 2147 | echo ' |
@@ -2064,8 +2175,8 @@ discard block |
||
2064 | 2175 | global $txt, $incontext; |
2065 | 2176 | |
2066 | 2177 | // Errors are very serious.. |
2067 | - if (!empty($incontext['error'])) |
|
2068 | - echo ' |
|
2178 | + if (!empty($incontext['error'])) { |
|
2179 | + echo ' |
|
2069 | 2180 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2070 | 2181 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2071 | 2182 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2073,9 +2184,10 @@ discard block |
||
2073 | 2184 | ', $incontext['error'], ' |
2074 | 2185 | </div> |
2075 | 2186 | </div>'; |
2187 | + } |
|
2076 | 2188 | // A warning message? |
2077 | - elseif (!empty($incontext['warning'])) |
|
2078 | - echo ' |
|
2189 | + elseif (!empty($incontext['warning'])) { |
|
2190 | + echo ' |
|
2079 | 2191 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2080 | 2192 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2081 | 2193 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2083,6 +2195,7 @@ discard block |
||
2083 | 2195 | ', $incontext['warning'], ' |
2084 | 2196 | </div> |
2085 | 2197 | </div>'; |
2198 | + } |
|
2086 | 2199 | |
2087 | 2200 | return empty($incontext['error']) && empty($incontext['warning']); |
2088 | 2201 | } |
@@ -2098,27 +2211,30 @@ discard block |
||
2098 | 2211 | <li>', $incontext['failed_files']), '</li> |
2099 | 2212 | </ul>'; |
2100 | 2213 | |
2101 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2102 | - echo ' |
|
2214 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2215 | + echo ' |
|
2103 | 2216 | <hr> |
2104 | 2217 | <p>', $txt['chmod_linux_info'], '</p> |
2105 | 2218 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2219 | + } |
|
2106 | 2220 | |
2107 | 2221 | // This is serious! |
2108 | - if (!template_warning_divs()) |
|
2109 | - return; |
|
2222 | + if (!template_warning_divs()) { |
|
2223 | + return; |
|
2224 | + } |
|
2110 | 2225 | |
2111 | 2226 | echo ' |
2112 | 2227 | <hr> |
2113 | 2228 | <p>', $txt['ftp_setup_info'], '</p>'; |
2114 | 2229 | |
2115 | - if (!empty($incontext['ftp_errors'])) |
|
2116 | - echo ' |
|
2230 | + if (!empty($incontext['ftp_errors'])) { |
|
2231 | + echo ' |
|
2117 | 2232 | <div class="error_message"> |
2118 | 2233 | ', $txt['error_ftp_no_connect'], '<br><br> |
2119 | 2234 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2120 | 2235 | </div> |
2121 | 2236 | <br>'; |
2237 | + } |
|
2122 | 2238 | |
2123 | 2239 | echo ' |
2124 | 2240 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2178,17 +2294,17 @@ discard block |
||
2178 | 2294 | <td> |
2179 | 2295 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2180 | 2296 | |
2181 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2182 | - echo ' |
|
2297 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2298 | + echo ' |
|
2183 | 2299 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2300 | + } |
|
2184 | 2301 | |
2185 | 2302 | echo ' |
2186 | 2303 | </select> |
2187 | 2304 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2188 | 2305 | </td> |
2189 | 2306 | </tr>'; |
2190 | - } |
|
2191 | - else |
|
2307 | + } else |
|
2192 | 2308 | { |
2193 | 2309 | echo ' |
2194 | 2310 | <tr style="display: none;"> |
@@ -2381,9 +2497,10 @@ discard block |
||
2381 | 2497 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2382 | 2498 | <ul>'; |
2383 | 2499 | |
2384 | - foreach ($incontext['failures'] as $line => $fail) |
|
2385 | - echo ' |
|
2500 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2501 | + echo ' |
|
2386 | 2502 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2503 | + } |
|
2387 | 2504 | |
2388 | 2505 | echo ' |
2389 | 2506 | </ul>'; |
@@ -2444,15 +2561,16 @@ discard block |
||
2444 | 2561 | </tr> |
2445 | 2562 | </table>'; |
2446 | 2563 | |
2447 | - if ($incontext['require_db_confirm']) |
|
2448 | - echo ' |
|
2564 | + if ($incontext['require_db_confirm']) { |
|
2565 | + echo ' |
|
2449 | 2566 | <h2>', $txt['user_settings_database'], '</h2> |
2450 | 2567 | <p>', $txt['user_settings_database_info'], '</p> |
2451 | 2568 | |
2452 | 2569 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2453 | 2570 | <input type="password" name="password3" size="30" /> |
2454 | 2571 | </div>'; |
2455 | -} |
|
2572 | + } |
|
2573 | + } |
|
2456 | 2574 | |
2457 | 2575 | // Tell them it's done, and to delete. |
2458 | 2576 | function template_delete_install() |
@@ -2465,14 +2583,15 @@ discard block |
||
2465 | 2583 | template_warning_divs(); |
2466 | 2584 | |
2467 | 2585 | // Install directory still writable? |
2468 | - if ($incontext['dir_still_writable']) |
|
2469 | - echo ' |
|
2586 | + if ($incontext['dir_still_writable']) { |
|
2587 | + echo ' |
|
2470 | 2588 | <em>', $txt['still_writable'], '</em><br> |
2471 | 2589 | <br>'; |
2590 | + } |
|
2472 | 2591 | |
2473 | 2592 | // Don't show the box if it's like 99% sure it won't work :P. |
2474 | - if ($incontext['probably_delete_install']) |
|
2475 | - echo ' |
|
2593 | + if ($incontext['probably_delete_install']) { |
|
2594 | + echo ' |
|
2476 | 2595 | <div style="margin: 1ex; font-weight: bold;"> |
2477 | 2596 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2478 | 2597 | </div> |
@@ -2488,6 +2607,7 @@ discard block |
||
2488 | 2607 | } |
2489 | 2608 | </script> |
2490 | 2609 | <br>'; |
2610 | + } |
|
2491 | 2611 | |
2492 | 2612 | echo ' |
2493 | 2613 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -185,17 +185,21 @@ discard block |
||
185 | 185 | $tasksdir = $sourcedir . '/tasks'; |
186 | 186 | |
187 | 187 | # Make sure the paths are correct... at least try to fix them. |
188 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
188 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
189 | 189 | $boarddir = dirname(__FILE__); |
190 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
190 | +} |
|
191 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
191 | 192 | $sourcedir = $boarddir . '/Sources'; |
192 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
193 | +} |
|
194 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
193 | 195 | $cachedir = $boarddir . '/cache'; |
196 | +} |
|
194 | 197 | |
195 | 198 | ########## Error-Catching ########## |
196 | 199 | # Note: You shouldn't touch these settings. |
197 | -if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) |
|
200 | +if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) { |
|
198 | 201 | include((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php'); |
202 | +} |
|
199 | 203 | |
200 | 204 | if (!isset($db_last_error)) |
201 | 205 | { |
@@ -207,10 +211,11 @@ discard block |
||
207 | 211 | if (file_exists(dirname(__FILE__) . '/install.php')) |
208 | 212 | { |
209 | 213 | $secure = false; |
210 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
211 | - $secure = true; |
|
212 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
213 | - $secure = true; |
|
214 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
215 | + $secure = true; |
|
216 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
217 | + $secure = true; |
|
218 | + } |
|
214 | 219 | |
215 | 220 | header('location: http' . ($secure ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit; |
216 | 221 | } |