@@ -18,10 +18,10 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Update_TLD_Regex extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * This executes the task. It just calls set_tld_regex() in Subs.php |
|
| 23 | - * @return bool Always returns true |
|
| 24 | - */ |
|
| 21 | + /** |
|
| 22 | + * This executes the task. It just calls set_tld_regex() in Subs.php |
|
| 23 | + * @return bool Always returns true |
|
| 24 | + */ |
|
| 25 | 25 | public function execute() |
| 26 | 26 | { |
| 27 | 27 | global $sourcedir; |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | class MemberReportReply_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | 24 | * @return bool Always returns true. |
| 25 | 25 | */ |
| 26 | 26 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | 'last_comment' => $this->_details['comment_id'], |
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 44 | - $possible_members[] = $row[0]; |
|
| 43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 44 | + $possible_members[] = $row[0]; |
|
| 45 | + } |
|
| 45 | 46 | $smcFunc['db_free_result']($request); |
| 46 | 47 | |
| 47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
| 51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
| 52 | 53 | } |
| 53 | - if (empty($possible_members)) |
|
| 54 | - return true; |
|
| 54 | + if (empty($possible_members)) { |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
| 57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | { |
| 74 | 76 | foreach ($alert_bits as $type => $bitvalue) |
| 75 | 77 | { |
| 76 | - if ($pref_option['member_report_reply'] & $bitvalue) |
|
| 77 | - $notifies[$type][] = $member; |
|
| 78 | + if ($pref_option['member_report_reply'] & $bitvalue) { |
|
| 79 | + $notifies[$type][] = $member; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | 83 | |
@@ -136,8 +139,9 @@ discard block |
||
| 136 | 139 | ); |
| 137 | 140 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 138 | 141 | { |
| 139 | - if (empty($row['lngfile'])) |
|
| 140 | - $row['lngfile'] = $language; |
|
| 142 | + if (empty($row['lngfile'])) { |
|
| 143 | + $row['lngfile'] = $language; |
|
| 144 | + } |
|
| 141 | 145 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 142 | 146 | } |
| 143 | 147 | $smcFunc['db_free_result']($request); |
@@ -155,8 +159,9 @@ discard block |
||
| 155 | 159 | $emaildata = loadEmailTemplate('reply_to_user_reports', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 156 | 160 | |
| 157 | 161 | // And do the actual sending... |
| 158 | - foreach ($recipients as $id_member => $email_address) |
|
| 159 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 162 | + foreach ($recipients as $id_member => $email_address) { |
|
| 163 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 164 | + } |
|
| 160 | 165 | } |
| 161 | 166 | } |
| 162 | 167 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | class ApproveReply_Notify_Background extends SMF_BackgroundTask |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
| 21 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
| 22 | 22 | * @return bool Always returns true. |
| 23 | 23 | */ |
| 24 | 24 | public function execute() |
@@ -96,14 +96,15 @@ |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Insert the alerts if any |
| 99 | - if (!empty($alert_rows)) |
|
| 100 | - $smcFunc['db_insert']('', |
|
| 99 | + if (!empty($alert_rows)) { |
|
| 100 | + $smcFunc['db_insert']('', |
|
| 101 | 101 | '{db_prefix}user_alerts', |
| 102 | 102 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 103 | 103 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 104 | 104 | $alert_rows, |
| 105 | 105 | array() |
| 106 | 106 | ); |
| 107 | + } |
|
| 107 | 108 | |
| 108 | 109 | return true; |
| 109 | 110 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | class GroupReq_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
| 24 | 24 | * @return bool Always returns true. |
| 25 | 25 | */ |
| 26 | 26 | public function execute() |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | 39 | $moderators = array(); |
| 40 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 41 | - $moderators[] = $row['id_member']; |
|
| 40 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 41 | + $moderators[] = $row['id_member']; |
|
| 42 | + } |
|
| 42 | 43 | $smcFunc['db_free_result']($request); |
| 43 | 44 | |
| 44 | 45 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -59,11 +60,13 @@ discard block |
||
| 59 | 60 | { |
| 60 | 61 | if (!empty($prefs[$mod]['request_group'])) |
| 61 | 62 | { |
| 62 | - if ($prefs[$mod]['request_group'] & 0x01) |
|
| 63 | - $data['alert'][] = $mod; |
|
| 63 | + if ($prefs[$mod]['request_group'] & 0x01) { |
|
| 64 | + $data['alert'][] = $mod; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | - if ($prefs[$mod]['request_group'] & 0x02) |
|
| 66 | - $data['email'][] = $mod; |
|
| 67 | + if ($prefs[$mod]['request_group'] & 0x02) { |
|
| 68 | + $data['email'][] = $mod; |
|
| 69 | + } |
|
| 67 | 70 | } |
| 68 | 71 | } |
| 69 | 72 | |
@@ -240,8 +240,8 @@ |
||
| 240 | 240 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
| 241 | 241 | |
| 242 | 242 | $js_time_string = str_replace( |
| 243 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 244 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 243 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 244 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 245 | 245 | $time_string |
| 246 | 246 | ); |
| 247 | 247 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
| 47 | 48 | 'post' => 'CalendarPost', |
| 48 | 49 | ); |
| 49 | 50 | |
| 50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
| 51 | - return call_helper($subActions[$_GET['sa']]); |
|
| 51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
| 52 | + return call_helper($subActions[$_GET['sa']]); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | // You can't do anything if the calendar is off. |
| 54 | - if (empty($modSettings['cal_enabled'])) |
|
| 55 | - fatal_lang_error('calendar_off', false); |
|
| 56 | + if (empty($modSettings['cal_enabled'])) { |
|
| 57 | + fatal_lang_error('calendar_off', false); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | // This is gonna be needed... |
| 58 | 61 | loadTemplate('Calendar'); |
@@ -88,22 +91,25 @@ discard block |
||
| 88 | 91 | $context['page_title'] = $txt['calendar']; |
| 89 | 92 | |
| 90 | 93 | // Ensure a default view is defined |
| 91 | - if (empty($modSettings['calendar_default_view'])) |
|
| 92 | - $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 94 | + if (empty($modSettings['calendar_default_view'])) { |
|
| 95 | + $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | // What view do we want? |
| 95 | - if (isset($_GET['viewweek'])) |
|
| 96 | - $context['calendar_view'] = 'viewweek'; |
|
| 97 | - elseif (isset($_GET['viewmonth'])) |
|
| 98 | - $context['calendar_view'] = 'viewmonth'; |
|
| 99 | - elseif (isset($_GET['viewlist'])) |
|
| 100 | - $context['calendar_view'] = 'viewlist'; |
|
| 101 | - else |
|
| 102 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 99 | + if (isset($_GET['viewweek'])) { |
|
| 100 | + $context['calendar_view'] = 'viewweek'; |
|
| 101 | + } elseif (isset($_GET['viewmonth'])) { |
|
| 102 | + $context['calendar_view'] = 'viewmonth'; |
|
| 103 | + } elseif (isset($_GET['viewlist'])) { |
|
| 104 | + $context['calendar_view'] = 'viewlist'; |
|
| 105 | + } else { |
|
| 106 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // Don't let search engines index the non-default calendar pages |
| 105 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
| 106 | - $context['robot_no_index'] = true; |
|
| 110 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
| 111 | + $context['robot_no_index'] = true; |
|
| 112 | + } |
|
| 107 | 113 | |
| 108 | 114 | // Get the current day of month... |
| 109 | 115 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -164,16 +170,19 @@ discard block |
||
| 164 | 170 | ); |
| 165 | 171 | |
| 166 | 172 | // Make sure the year and month are in valid ranges. |
| 167 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
| 168 | - fatal_lang_error('invalid_month', false); |
|
| 169 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
| 170 | - fatal_lang_error('invalid_year', false); |
|
| 173 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
| 174 | + fatal_lang_error('invalid_month', false); |
|
| 175 | + } |
|
| 176 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
| 177 | + fatal_lang_error('invalid_year', false); |
|
| 178 | + } |
|
| 171 | 179 | // If we have a day clean that too. |
| 172 | 180 | if ($context['calendar_view'] != 'viewmonth') |
| 173 | 181 | { |
| 174 | 182 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
| 175 | - if (!$isValid) |
|
| 176 | - fatal_lang_error('invalid_day', false); |
|
| 183 | + if (!$isValid) { |
|
| 184 | + fatal_lang_error('invalid_day', false); |
|
| 185 | + } |
|
| 177 | 186 | } |
| 178 | 187 | |
| 179 | 188 | // Load all the context information needed to show the calendar grid. |
@@ -195,23 +204,26 @@ discard block |
||
| 195 | 204 | ); |
| 196 | 205 | |
| 197 | 206 | // Load up the main view. |
| 198 | - if ($context['calendar_view'] == 'viewlist') |
|
| 199 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 200 | - elseif ($context['calendar_view'] == 'viewweek') |
|
| 201 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 202 | - else |
|
| 203 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 207 | + if ($context['calendar_view'] == 'viewlist') { |
|
| 208 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 209 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
| 210 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 211 | + } else { |
|
| 212 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 213 | + } |
|
| 204 | 214 | |
| 205 | 215 | // Load up the previous and next months. |
| 206 | 216 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
| 207 | 217 | |
| 208 | 218 | // Only show previous month if it isn't pre-January of the min-year |
| 209 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
| 210 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 219 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
| 220 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 221 | + } |
|
| 211 | 222 | |
| 212 | 223 | // Only show next month if it isn't post-December of the max-year |
| 213 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
| 214 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 224 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
| 225 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 226 | + } |
|
| 215 | 227 | |
| 216 | 228 | // Basic template stuff. |
| 217 | 229 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -231,8 +243,9 @@ discard block |
||
| 231 | 243 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
| 232 | 244 | |
| 233 | 245 | // Set the page title to mention the month or week, too |
| 234 | - if ($context['calendar_view'] != 'viewlist') |
|
| 235 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 246 | + if ($context['calendar_view'] != 'viewlist') { |
|
| 247 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 248 | + } |
|
| 236 | 249 | |
| 237 | 250 | // Load up the linktree! |
| 238 | 251 | $context['linktree'][] = array( |
@@ -245,17 +258,19 @@ discard block |
||
| 245 | 258 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
| 246 | 259 | ); |
| 247 | 260 | // If applicable, add the current week to the linktree. |
| 248 | - if ($context['calendar_view'] == 'viewweek') |
|
| 249 | - $context['linktree'][] = array( |
|
| 261 | + if ($context['calendar_view'] == 'viewweek') { |
|
| 262 | + $context['linktree'][] = array( |
|
| 250 | 263 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 251 | 264 | 'name' => $context['calendar_grid_main']['week_title'], |
| 252 | 265 | ); |
| 266 | + } |
|
| 253 | 267 | |
| 254 | 268 | // Build the calendar button array. |
| 255 | 269 | $context['calendar_buttons'] = array(); |
| 256 | 270 | |
| 257 | - if ($context['can_post']) |
|
| 258 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 271 | + if ($context['can_post']) { |
|
| 272 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 273 | + } |
|
| 259 | 274 | |
| 260 | 275 | // Allow mods to add additional buttons here |
| 261 | 276 | call_integration_hook('integrate_calendar_buttons'); |
@@ -284,14 +299,16 @@ discard block |
||
| 284 | 299 | require_once($sourcedir . '/Subs.php'); |
| 285 | 300 | |
| 286 | 301 | // Cast this for safety... |
| 287 | - if (isset($_REQUEST['eventid'])) |
|
| 288 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 302 | + if (isset($_REQUEST['eventid'])) { |
|
| 303 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 304 | + } |
|
| 289 | 305 | |
| 290 | 306 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 291 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 292 | - $time_string = '%k:%M'; |
|
| 293 | - else |
|
| 294 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 307 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 308 | + $time_string = '%k:%M'; |
|
| 309 | + } else { |
|
| 310 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 311 | + } |
|
| 295 | 312 | |
| 296 | 313 | $js_time_string = str_replace( |
| 297 | 314 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -305,12 +322,14 @@ discard block |
||
| 305 | 322 | checkSession(); |
| 306 | 323 | |
| 307 | 324 | // Validate the post... |
| 308 | - if (!isset($_POST['link_to_board'])) |
|
| 309 | - validateEventPost(); |
|
| 325 | + if (!isset($_POST['link_to_board'])) { |
|
| 326 | + validateEventPost(); |
|
| 327 | + } |
|
| 310 | 328 | |
| 311 | 329 | // If you're not allowed to edit any events, you have to be the poster. |
| 312 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
| 313 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 330 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
| 331 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 332 | + } |
|
| 314 | 333 | |
| 315 | 334 | // New - and directing? |
| 316 | 335 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -333,8 +352,9 @@ discard block |
||
| 333 | 352 | } |
| 334 | 353 | |
| 335 | 354 | // Deleting... |
| 336 | - elseif (isset($_REQUEST['deleteevent'])) |
|
| 337 | - removeEvent($_REQUEST['eventid']); |
|
| 355 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
| 356 | + removeEvent($_REQUEST['eventid']); |
|
| 357 | + } |
|
| 338 | 358 | |
| 339 | 359 | // ... or just update it? |
| 340 | 360 | else |
@@ -357,15 +377,13 @@ discard block |
||
| 357 | 377 | $year = $d['year']; |
| 358 | 378 | $month = $d['month']; |
| 359 | 379 | $day = $d['day']; |
| 360 | - } |
|
| 361 | - elseif (isset($_POST['start_datetime'])) |
|
| 380 | + } elseif (isset($_POST['start_datetime'])) |
|
| 362 | 381 | { |
| 363 | 382 | $d = date_parse($_POST['start_datetime']); |
| 364 | 383 | $year = $d['year']; |
| 365 | 384 | $month = $d['month']; |
| 366 | 385 | $day = $d['day']; |
| 367 | - } |
|
| 368 | - else |
|
| 386 | + } else |
|
| 369 | 387 | { |
| 370 | 388 | $today = getdate(); |
| 371 | 389 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -399,13 +417,13 @@ discard block |
||
| 399 | 417 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
| 400 | 418 | |
| 401 | 419 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
| 402 | - } |
|
| 403 | - else |
|
| 420 | + } else |
|
| 404 | 421 | { |
| 405 | 422 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
| 406 | 423 | |
| 407 | - if ($context['event'] === false) |
|
| 408 | - fatal_lang_error('no_access', false); |
|
| 424 | + if ($context['event'] === false) { |
|
| 425 | + fatal_lang_error('no_access', false); |
|
| 426 | + } |
|
| 409 | 427 | |
| 410 | 428 | // If it has a board, then they should be editing it within the topic. |
| 411 | 429 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -416,10 +434,11 @@ discard block |
||
| 416 | 434 | } |
| 417 | 435 | |
| 418 | 436 | // Make sure the user is allowed to edit this event. |
| 419 | - if ($context['event']['member'] != $user_info['id']) |
|
| 420 | - isAllowedTo('calendar_edit_any'); |
|
| 421 | - elseif (!allowedTo('calendar_edit_any')) |
|
| 422 | - isAllowedTo('calendar_edit_own'); |
|
| 437 | + if ($context['event']['member'] != $user_info['id']) { |
|
| 438 | + isAllowedTo('calendar_edit_any'); |
|
| 439 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
| 440 | + isAllowedTo('calendar_edit_own'); |
|
| 441 | + } |
|
| 423 | 442 | } |
| 424 | 443 | |
| 425 | 444 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -453,8 +472,7 @@ discard block |
||
| 453 | 472 | { |
| 454 | 473 | // You can post new events but can't link them to anything... |
| 455 | 474 | $context['event']['categories'] = array(); |
| 456 | - } |
|
| 457 | - else |
|
| 475 | + } else |
|
| 458 | 476 | { |
| 459 | 477 | // Load the list of boards and categories in the context. |
| 460 | 478 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -541,12 +559,14 @@ discard block |
||
| 541 | 559 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
| 542 | 560 | |
| 543 | 561 | // You can't export if the calendar export feature is off. |
| 544 | - if (empty($modSettings['cal_export'])) |
|
| 545 | - fatal_lang_error('calendar_export_off', false); |
|
| 562 | + if (empty($modSettings['cal_export'])) { |
|
| 563 | + fatal_lang_error('calendar_export_off', false); |
|
| 564 | + } |
|
| 546 | 565 | |
| 547 | 566 | // Goes without saying that this is required. |
| 548 | - if (!isset($_REQUEST['eventid'])) |
|
| 549 | - fatal_lang_error('no_access', false); |
|
| 567 | + if (!isset($_REQUEST['eventid'])) { |
|
| 568 | + fatal_lang_error('no_access', false); |
|
| 569 | + } |
|
| 550 | 570 | |
| 551 | 571 | // This is kinda wanted. |
| 552 | 572 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -554,15 +574,17 @@ discard block |
||
| 554 | 574 | // Load up the event in question and check it exists. |
| 555 | 575 | $event = getEventProperties($_REQUEST['eventid']); |
| 556 | 576 | |
| 557 | - if ($event === false) |
|
| 558 | - fatal_lang_error('no_access', false); |
|
| 577 | + if ($event === false) { |
|
| 578 | + fatal_lang_error('no_access', false); |
|
| 579 | + } |
|
| 559 | 580 | |
| 560 | 581 | // Check the title isn't too long - iCal requires some formatting if so. |
| 561 | 582 | $title = str_split($event['title'], 30); |
| 562 | 583 | foreach ($title as $id => $line) |
| 563 | 584 | { |
| 564 | - if ($id != 0) |
|
| 565 | - $title[$id] = ' ' . $title[$id]; |
|
| 585 | + if ($id != 0) { |
|
| 586 | + $title[$id] = ' ' . $title[$id]; |
|
| 587 | + } |
|
| 566 | 588 | $title[$id] .= "\n"; |
| 567 | 589 | } |
| 568 | 590 | |
@@ -575,8 +597,7 @@ discard block |
||
| 575 | 597 | { |
| 576 | 598 | $datestart = date_format($start_date, 'Ymd\THis'); |
| 577 | 599 | $dateend = date_format($end_date, 'Ymd\THis'); |
| 578 | - } |
|
| 579 | - else |
|
| 600 | + } else |
|
| 580 | 601 | { |
| 581 | 602 | $datestart = date_format($start_date, 'Ymd'); |
| 582 | 603 | |
@@ -597,15 +618,18 @@ discard block |
||
| 597 | 618 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
| 598 | 619 | |
| 599 | 620 | // event has a duration |
| 600 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
| 601 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 621 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
| 622 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 623 | + } |
|
| 602 | 624 | |
| 603 | 625 | // event has changed? advance the sequence for this UID |
| 604 | - if ($event['sequence'] > 0) |
|
| 605 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 626 | + if ($event['sequence'] > 0) { |
|
| 627 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 628 | + } |
|
| 606 | 629 | |
| 607 | - if (!empty($event['location'])) |
|
| 608 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 630 | + if (!empty($event['location'])) { |
|
| 631 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 632 | + } |
|
| 609 | 633 | |
| 610 | 634 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 611 | 635 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -614,23 +638,26 @@ discard block |
||
| 614 | 638 | |
| 615 | 639 | // Send some standard headers. |
| 616 | 640 | ob_end_clean(); |
| 617 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 618 | - @ob_start('ob_gzhandler'); |
|
| 619 | - else |
|
| 620 | - ob_start(); |
|
| 641 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 642 | + @ob_start('ob_gzhandler'); |
|
| 643 | + } else { |
|
| 644 | + ob_start(); |
|
| 645 | + } |
|
| 621 | 646 | |
| 622 | 647 | // Send the file headers |
| 623 | 648 | header('Pragma: '); |
| 624 | 649 | header('Cache-Control: no-cache'); |
| 625 | - if (!isBrowser('gecko')) |
|
| 626 | - header('Content-Transfer-Encoding: binary'); |
|
| 650 | + if (!isBrowser('gecko')) { |
|
| 651 | + header('Content-Transfer-Encoding: binary'); |
|
| 652 | + } |
|
| 627 | 653 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 628 | 654 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
| 629 | 655 | header('Accept-Ranges: bytes'); |
| 630 | 656 | header('Connection: close'); |
| 631 | 657 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 632 | - if (empty($modSettings['enableCompressedOutput'])) |
|
| 633 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 658 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
| 659 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 660 | + } |
|
| 634 | 661 | |
| 635 | 662 | // This is a calendar item! |
| 636 | 663 | header('Content-Type: text/calendar'); |
@@ -669,20 +696,17 @@ discard block |
||
| 669 | 696 | $context['sub_template'] = 'bcd'; |
| 670 | 697 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
| 671 | 698 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true); |
| 672 | - } |
|
| 673 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 699 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 674 | 700 | { |
| 675 | 701 | $context['sub_template'] = 'hms'; |
| 676 | 702 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
| 677 | 703 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true); |
| 678 | - } |
|
| 679 | - elseif ($omfg) |
|
| 704 | + } elseif ($omfg) |
|
| 680 | 705 | { |
| 681 | 706 | $context['sub_template'] = 'omfg'; |
| 682 | 707 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
| 683 | 708 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true); |
| 684 | - } |
|
| 685 | - elseif (isset($_REQUEST['time'])) |
|
| 709 | + } elseif (isset($_REQUEST['time'])) |
|
| 686 | 710 | { |
| 687 | 711 | $context['sub_template'] = 'thetime'; |
| 688 | 712 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -736,12 +760,13 @@ discard block |
||
| 736 | 760 | ), |
| 737 | 761 | ); |
| 738 | 762 | |
| 739 | - foreach ($context['clockicons'] as $t => $vs) |
|
| 740 | - foreach ($vs as $v => $dumb) |
|
| 763 | + foreach ($context['clockicons'] as $t => $vs) { |
|
| 764 | + foreach ($vs as $v => $dumb) |
|
| 741 | 765 | { |
| 742 | 766 | if ($$t >= $v) |
| 743 | 767 | { |
| 744 | 768 | $$t -= $v; |
| 769 | + } |
|
| 745 | 770 | $context['clockicons'][$t][$v] = true; |
| 746 | 771 | } |
| 747 | 772 | } |
@@ -1622,8 +1622,7 @@ |
||
| 1622 | 1622 | updateStats('topic'); |
| 1623 | 1623 | |
| 1624 | 1624 | // This function is needed to do the updateStats('subject') call. |
| 1625 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
| 1626 | - function($string){ |
|
| 1625 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
| 1627 | 1626 | global $sourcedir; |
| 1628 | 1627 | if (function_exists('mb_strtolower')) |
| 1629 | 1628 | return mb_strtolower($string, 'UTF-8'); |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
| 237 | 246 | { |
| 238 | 247 | // Get PHP's default timezone, if set |
| 239 | 248 | $ini_tz = ini_get('date.timezone'); |
| 240 | - if (!empty($ini_tz)) |
|
| 241 | - $timezone_id = $ini_tz; |
|
| 242 | - else |
|
| 243 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
| 270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 271 | 281 | while ($entry = $dir->read()) |
| 272 | 282 | { |
| 273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 275 | 286 | } |
| 276 | 287 | $dir->close(); |
| 277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
| 306 | 317 | } |
| 307 | 318 | |
| 308 | 319 | // Override the language file? |
| 309 | - if (isset($_GET['lang_file'])) |
|
| 310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 313 | 325 | |
| 314 | 326 | // Make sure it exists, if it doesn't reset it. |
| 315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
| 318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 319 | 331 | |
| 320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 323 | 336 | } |
| 324 | 337 | |
| 325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
| 332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 334 | 347 | |
| 335 | - if (empty($sourcedir)) |
|
| 336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // Need this to check whether we need the database password. |
| 339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 340 | - if (!defined('SMF')) |
|
| 341 | - define('SMF', 1); |
|
| 342 | - if (empty($smcFunc)) |
|
| 343 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 344 | 360 | |
| 345 | 361 | $modSettings['disableQueryCheck'] = true; |
| 346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
| 348 | 364 | if (!$db_connection) |
| 349 | 365 | { |
| 350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 353 | 370 | |
| 354 | 371 | $db_options = array('persist' => $db_persist); |
| 355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
| 360 | 377 | if ($db_type == 'mysql') |
| 361 | 378 | { |
| 362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 363 | - } |
|
| 364 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 365 | 381 | { |
| 366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 368 | 384 | } |
| 369 | 385 | } |
| 370 | 386 | |
| 371 | - if (!empty($port)) |
|
| 372 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 373 | 390 | |
| 374 | - if (!$db_connection) |
|
| 375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 376 | 394 | } |
| 377 | 395 | } |
| 378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
| 400 | 418 | // @todo REMOVE THIS!! |
| 401 | 419 | else |
| 402 | 420 | { |
| 403 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 404 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 405 | 424 | } |
| 406 | 425 | // Show the footer. |
| 407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
| 419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 420 | 439 | |
| 421 | 440 | // Done the submission? |
| 422 | - if (isset($_POST['contbutt'])) |
|
| 423 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 424 | 444 | |
| 425 | 445 | // See if we think they have already installed it? |
| 426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
| 428 | 448 | $probably_installed = 0; |
| 429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 430 | 450 | { |
| 431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 432 | - $probably_installed++; |
|
| 433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 434 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 435 | 457 | } |
| 436 | 458 | |
| 437 | - if ($probably_installed == 2) |
|
| 438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 439 | 462 | } |
| 440 | 463 | |
| 441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
| 450 | 473 | $databases[$key]['supported'] = false; |
| 451 | 474 | $notFoundSQLFile = true; |
| 452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 453 | 478 | } |
| 454 | - else |
|
| 455 | - $incontext['supported_databases'][] = $db; |
|
| 456 | 479 | } |
| 457 | 480 | } |
| 458 | 481 | |
| 459 | 482 | // Check the PHP version. |
| 460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 461 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 462 | 486 | // Make sure we have a supported database |
| 463 | - elseif (empty($incontext['supported_databases'])) |
|
| 464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 465 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 466 | - elseif (!function_exists('session_start')) |
|
| 467 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 468 | 494 | // Make sure they uploaded all the files. |
| 469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 470 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 471 | 498 | // Very simple check on the session.save_path for Windows. |
| 472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 474 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 475 | 503 | |
| 476 | 504 | // Since each of the three messages would look the same, anyway... |
| 477 | - if (isset($error)) |
|
| 478 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 479 | 508 | |
| 480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 483 | 513 | |
| 484 | 514 | // Confirm mbstring is loaded... |
| 485 | - if (!extension_loaded('mbstring')) |
|
| 486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 515 | + if (!extension_loaded('mbstring')) { |
|
| 516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Check for https stream support. |
| 489 | 520 | $supported_streams = stream_get_wrappers(); |
| 490 | - if (!in_array('https', $supported_streams)) |
|
| 491 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 521 | + if (!in_array('https', $supported_streams)) { |
|
| 522 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | return false; |
| 494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
| 514 | 546 | 'db_last_error.php', |
| 515 | 547 | ); |
| 516 | 548 | |
| 517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 551 | + } |
|
| 519 | 552 | |
| 520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 556 | + } |
|
| 523 | 557 | |
| 524 | 558 | $failed_files = array(); |
| 525 | 559 | |
@@ -531,20 +565,23 @@ discard block |
||
| 531 | 565 | foreach ($writable_files as $file) |
| 532 | 566 | { |
| 533 | 567 | // Some files won't exist, try to address up front |
| 534 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 535 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 568 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 569 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 570 | + } |
|
| 536 | 571 | // NOW do the writable check... |
| 537 | 572 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 538 | 573 | { |
| 539 | 574 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 540 | 575 | |
| 541 | 576 | // Well, 755 hopefully worked... if not, try 777. |
| 542 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 543 | - $failed_files[] = $file; |
|
| 577 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 578 | + $failed_files[] = $file; |
|
| 579 | + } |
|
| 544 | 580 | } |
| 545 | 581 | } |
| 546 | - foreach ($extra_files as $file) |
|
| 547 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 582 | + foreach ($extra_files as $file) { |
|
| 583 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 584 | + } |
|
| 548 | 585 | } |
| 549 | 586 | // Windows is trickier. Let's try opening for r+... |
| 550 | 587 | else |
@@ -554,30 +591,35 @@ discard block |
||
| 554 | 591 | foreach ($writable_files as $file) |
| 555 | 592 | { |
| 556 | 593 | // Folders can't be opened for write... but the index.php in them can ;) |
| 557 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 558 | - $file .= '/index.php'; |
|
| 594 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 595 | + $file .= '/index.php'; |
|
| 596 | + } |
|
| 559 | 597 | |
| 560 | 598 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 561 | 599 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 562 | 600 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 563 | 601 | |
| 564 | 602 | // Hmm, okay, try just for write in that case... |
| 565 | - if (!is_resource($fp)) |
|
| 566 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 603 | + if (!is_resource($fp)) { |
|
| 604 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 605 | + } |
|
| 567 | 606 | |
| 568 | - if (!is_resource($fp)) |
|
| 569 | - $failed_files[] = $file; |
|
| 607 | + if (!is_resource($fp)) { |
|
| 608 | + $failed_files[] = $file; |
|
| 609 | + } |
|
| 570 | 610 | |
| 571 | 611 | @fclose($fp); |
| 572 | 612 | } |
| 573 | - foreach ($extra_files as $file) |
|
| 574 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 613 | + foreach ($extra_files as $file) { |
|
| 614 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 615 | + } |
|
| 575 | 616 | } |
| 576 | 617 | |
| 577 | 618 | $failure = count($failed_files) >= 1; |
| 578 | 619 | |
| 579 | - if (!isset($_SERVER)) |
|
| 580 | - return !$failure; |
|
| 620 | + if (!isset($_SERVER)) { |
|
| 621 | + return !$failure; |
|
| 622 | + } |
|
| 581 | 623 | |
| 582 | 624 | // Put the list into context. |
| 583 | 625 | $incontext['failed_files'] = $failed_files; |
@@ -625,19 +667,23 @@ discard block |
||
| 625 | 667 | |
| 626 | 668 | if (!isset($ftp) || $ftp->error !== false) |
| 627 | 669 | { |
| 628 | - if (!isset($ftp)) |
|
| 629 | - $ftp = new ftp_connection(null); |
|
| 670 | + if (!isset($ftp)) { |
|
| 671 | + $ftp = new ftp_connection(null); |
|
| 672 | + } |
|
| 630 | 673 | // Save the error so we can mess with listing... |
| 631 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 632 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 674 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 675 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 676 | + } |
|
| 633 | 677 | |
| 634 | 678 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 635 | 679 | |
| 636 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 637 | - $_POST['ftp_path'] = $detect_path; |
|
| 680 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 681 | + $_POST['ftp_path'] = $detect_path; |
|
| 682 | + } |
|
| 638 | 683 | |
| 639 | - if (!isset($_POST['ftp_username'])) |
|
| 640 | - $_POST['ftp_username'] = $username; |
|
| 684 | + if (!isset($_POST['ftp_username'])) { |
|
| 685 | + $_POST['ftp_username'] = $username; |
|
| 686 | + } |
|
| 641 | 687 | |
| 642 | 688 | // Set the username etc, into context. |
| 643 | 689 | $incontext['ftp'] = array( |
@@ -649,8 +695,7 @@ discard block |
||
| 649 | 695 | ); |
| 650 | 696 | |
| 651 | 697 | return false; |
| 652 | - } |
|
| 653 | - else |
|
| 698 | + } else |
|
| 654 | 699 | { |
| 655 | 700 | $_SESSION['installer_temp_ftp'] = array( |
| 656 | 701 | 'server' => $_POST['ftp_server'], |
@@ -664,10 +709,12 @@ discard block |
||
| 664 | 709 | |
| 665 | 710 | foreach ($failed_files as $file) |
| 666 | 711 | { |
| 667 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 668 | - $ftp->chmod($file, 0755); |
|
| 669 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 670 | - $ftp->chmod($file, 0777); |
|
| 712 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 713 | + $ftp->chmod($file, 0755); |
|
| 714 | + } |
|
| 715 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 716 | + $ftp->chmod($file, 0777); |
|
| 717 | + } |
|
| 671 | 718 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 672 | 719 | { |
| 673 | 720 | $failed_files_updated[] = $file; |
@@ -723,15 +770,17 @@ discard block |
||
| 723 | 770 | |
| 724 | 771 | if (!$foundOne) |
| 725 | 772 | { |
| 726 | - if (isset($db['default_host'])) |
|
| 727 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 773 | + if (isset($db['default_host'])) { |
|
| 774 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 775 | + } |
|
| 728 | 776 | if (isset($db['default_user'])) |
| 729 | 777 | { |
| 730 | 778 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 731 | 779 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 732 | 780 | } |
| 733 | - if (isset($db['default_password'])) |
|
| 734 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 781 | + if (isset($db['default_password'])) { |
|
| 782 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 783 | + } |
|
| 735 | 784 | |
| 736 | 785 | // For simplicity and less confusion, leave the port blank by default |
| 737 | 786 | $incontext['db']['port'] = ''; |
@@ -750,10 +799,10 @@ discard block |
||
| 750 | 799 | $incontext['db']['server'] = $_POST['db_server']; |
| 751 | 800 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 752 | 801 | |
| 753 | - if (!empty($_POST['db_port'])) |
|
| 754 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 755 | - } |
|
| 756 | - else |
|
| 802 | + if (!empty($_POST['db_port'])) { |
|
| 803 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 804 | + } |
|
| 805 | + } else |
|
| 757 | 806 | { |
| 758 | 807 | $incontext['db']['prefix'] = 'smf_'; |
| 759 | 808 | } |
@@ -789,10 +838,11 @@ discard block |
||
| 789 | 838 | if (!empty($_POST['db_port'])) |
| 790 | 839 | { |
| 791 | 840 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 792 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 793 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 794 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 795 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 841 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 842 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 843 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 844 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 845 | + } |
|
| 796 | 846 | } |
| 797 | 847 | |
| 798 | 848 | // God I hope it saved! |
@@ -805,8 +855,9 @@ discard block |
||
| 805 | 855 | // Make sure it works. |
| 806 | 856 | require(dirname(__FILE__) . '/Settings.php'); |
| 807 | 857 | |
| 808 | - if (empty($sourcedir)) |
|
| 809 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 858 | + if (empty($sourcedir)) { |
|
| 859 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 860 | + } |
|
| 810 | 861 | |
| 811 | 862 | // Better find the database file! |
| 812 | 863 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -816,18 +867,21 @@ discard block |
||
| 816 | 867 | } |
| 817 | 868 | |
| 818 | 869 | // Now include it for database functions! |
| 819 | - if (!defined('SMF')) |
|
| 820 | - define('SMF', 1); |
|
| 870 | + if (!defined('SMF')) { |
|
| 871 | + define('SMF', 1); |
|
| 872 | + } |
|
| 821 | 873 | |
| 822 | 874 | $modSettings['disableQueryCheck'] = true; |
| 823 | - if (empty($smcFunc)) |
|
| 824 | - $smcFunc = array(); |
|
| 875 | + if (empty($smcFunc)) { |
|
| 876 | + $smcFunc = array(); |
|
| 877 | + } |
|
| 825 | 878 | |
| 826 | 879 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 827 | 880 | |
| 828 | 881 | // What - running PHP4? The shame! |
| 829 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 830 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 882 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 883 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 884 | + } |
|
| 831 | 885 | |
| 832 | 886 | // Attempt a connection. |
| 833 | 887 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -915,12 +969,14 @@ discard block |
||
| 915 | 969 | $incontext['page_title'] = $txt['install_settings']; |
| 916 | 970 | |
| 917 | 971 | // Let's see if we got the database type correct. |
| 918 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 919 | - $db_type = $_POST['db_type']; |
|
| 972 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 973 | + $db_type = $_POST['db_type']; |
|
| 974 | + } |
|
| 920 | 975 | |
| 921 | 976 | // Else we'd better be able to get the connection. |
| 922 | - else |
|
| 923 | - load_database(); |
|
| 977 | + else { |
|
| 978 | + load_database(); |
|
| 979 | + } |
|
| 924 | 980 | |
| 925 | 981 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 926 | 982 | |
@@ -957,18 +1013,21 @@ discard block |
||
| 957 | 1013 | // Submitting? |
| 958 | 1014 | if (isset($_POST['boardurl'])) |
| 959 | 1015 | { |
| 960 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 961 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 962 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 963 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 964 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 965 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1016 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1017 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1018 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1019 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1020 | + } |
|
| 1021 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1022 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1023 | + } |
|
| 966 | 1024 | |
| 967 | 1025 | //Make sure boardurl is aligned with ssl setting |
| 968 | - if (empty($_POST['force_ssl'])) |
|
| 969 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 970 | - else |
|
| 971 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1026 | + if (empty($_POST['force_ssl'])) { |
|
| 1027 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1028 | + } else { |
|
| 1029 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1030 | + } |
|
| 972 | 1031 | |
| 973 | 1032 | // Save these variables. |
| 974 | 1033 | $vars = array( |
@@ -1007,10 +1066,10 @@ discard block |
||
| 1007 | 1066 | { |
| 1008 | 1067 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1009 | 1068 | return false; |
| 1010 | - } |
|
| 1011 | - else |
|
| 1012 | - // Set the character set here. |
|
| 1069 | + } else { |
|
| 1070 | + // Set the character set here. |
|
| 1013 | 1071 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1072 | + } |
|
| 1014 | 1073 | } |
| 1015 | 1074 | |
| 1016 | 1075 | // Good, skip on. |
@@ -1030,8 +1089,9 @@ discard block |
||
| 1030 | 1089 | $incontext['continue'] = 1; |
| 1031 | 1090 | |
| 1032 | 1091 | // Already done? |
| 1033 | - if (isset($_POST['pop_done'])) |
|
| 1034 | - return true; |
|
| 1092 | + if (isset($_POST['pop_done'])) { |
|
| 1093 | + return true; |
|
| 1094 | + } |
|
| 1035 | 1095 | |
| 1036 | 1096 | // Reload settings. |
| 1037 | 1097 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1049,8 +1109,9 @@ discard block |
||
| 1049 | 1109 | $modSettings = array(); |
| 1050 | 1110 | if ($result !== false) |
| 1051 | 1111 | { |
| 1052 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1053 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1112 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1113 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1114 | + } |
|
| 1054 | 1115 | $smcFunc['db_free_result']($result); |
| 1055 | 1116 | |
| 1056 | 1117 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1063,20 +1124,22 @@ discard block |
||
| 1063 | 1124 | $modSettings['disableQueryCheck'] = true; |
| 1064 | 1125 | |
| 1065 | 1126 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1066 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1067 | - $smcFunc['db_query']('', ' |
|
| 1127 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1128 | + $smcFunc['db_query']('', ' |
|
| 1068 | 1129 | SET NAMES {string:utf8}', |
| 1069 | 1130 | array( |
| 1070 | 1131 | 'db_error_skip' => true, |
| 1071 | 1132 | 'utf8' => 'utf8', |
| 1072 | 1133 | ) |
| 1073 | 1134 | ); |
| 1135 | + } |
|
| 1074 | 1136 | |
| 1075 | 1137 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1076 | - if (substr(__DIR__, -1) == '\\') |
|
| 1077 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1078 | - else |
|
| 1079 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1138 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1139 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1140 | + } else { |
|
| 1141 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1142 | + } |
|
| 1080 | 1143 | |
| 1081 | 1144 | $replaces = array( |
| 1082 | 1145 | '{$db_prefix}' => $db_prefix, |
@@ -1093,8 +1156,9 @@ discard block |
||
| 1093 | 1156 | |
| 1094 | 1157 | foreach ($txt as $key => $value) |
| 1095 | 1158 | { |
| 1096 | - if (substr($key, 0, 8) == 'default_') |
|
| 1097 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1159 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1160 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1161 | + } |
|
| 1098 | 1162 | } |
| 1099 | 1163 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1100 | 1164 | |
@@ -1109,8 +1173,9 @@ discard block |
||
| 1109 | 1173 | |
| 1110 | 1174 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1111 | 1175 | { |
| 1112 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1113 | - $engines[] = $row['Engine']; |
|
| 1176 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1177 | + $engines[] = $row['Engine']; |
|
| 1178 | + } |
|
| 1114 | 1179 | } |
| 1115 | 1180 | |
| 1116 | 1181 | // Done with this now |
@@ -1134,8 +1199,7 @@ discard block |
||
| 1134 | 1199 | $replaces['START TRANSACTION;'] = ''; |
| 1135 | 1200 | $replaces['COMMIT;'] = ''; |
| 1136 | 1201 | } |
| 1137 | - } |
|
| 1138 | - else |
|
| 1202 | + } else |
|
| 1139 | 1203 | { |
| 1140 | 1204 | $has_innodb = false; |
| 1141 | 1205 | } |
@@ -1157,21 +1221,24 @@ discard block |
||
| 1157 | 1221 | foreach ($sql_lines as $count => $line) |
| 1158 | 1222 | { |
| 1159 | 1223 | // No comments allowed! |
| 1160 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1161 | - $current_statement .= "\n" . rtrim($line); |
|
| 1224 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1225 | + $current_statement .= "\n" . rtrim($line); |
|
| 1226 | + } |
|
| 1162 | 1227 | |
| 1163 | 1228 | // Is this the end of the query string? |
| 1164 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1165 | - continue; |
|
| 1229 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1230 | + continue; |
|
| 1231 | + } |
|
| 1166 | 1232 | |
| 1167 | 1233 | // Does this table already exist? If so, don't insert more data into it! |
| 1168 | 1234 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1169 | 1235 | { |
| 1170 | 1236 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1171 | - if (!empty($matches[0])) |
|
| 1172 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1173 | - else |
|
| 1174 | - $incontext['sql_results']['insert_dups']++; |
|
| 1237 | + if (!empty($matches[0])) { |
|
| 1238 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1239 | + } else { |
|
| 1240 | + $incontext['sql_results']['insert_dups']++; |
|
| 1241 | + } |
|
| 1175 | 1242 | |
| 1176 | 1243 | $current_statement = ''; |
| 1177 | 1244 | continue; |
@@ -1180,8 +1247,9 @@ discard block |
||
| 1180 | 1247 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1181 | 1248 | { |
| 1182 | 1249 | // Use the appropriate function based on the DB type |
| 1183 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1184 | - $db_errorno = $db_type . '_errno'; |
|
| 1250 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1251 | + $db_errorno = $db_type . '_errno'; |
|
| 1252 | + } |
|
| 1185 | 1253 | |
| 1186 | 1254 | // Error 1050: Table already exists! |
| 1187 | 1255 | // @todo Needs to be made better! |
@@ -1196,18 +1264,18 @@ discard block |
||
| 1196 | 1264 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1197 | 1265 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1198 | 1266 | } |
| 1199 | - } |
|
| 1200 | - else |
|
| 1267 | + } else |
|
| 1201 | 1268 | { |
| 1202 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1203 | - $incontext['sql_results']['tables']++; |
|
| 1204 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1269 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1270 | + $incontext['sql_results']['tables']++; |
|
| 1271 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1205 | 1272 | { |
| 1206 | 1273 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1207 | - if (!empty($matches[0])) |
|
| 1208 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1209 | - else |
|
| 1210 | - $incontext['sql_results']['inserts']++; |
|
| 1274 | + if (!empty($matches[0])) { |
|
| 1275 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1276 | + } else { |
|
| 1277 | + $incontext['sql_results']['inserts']++; |
|
| 1278 | + } |
|
| 1211 | 1279 | } |
| 1212 | 1280 | } |
| 1213 | 1281 | |
@@ -1220,15 +1288,17 @@ discard block |
||
| 1220 | 1288 | // Sort out the context for the SQL. |
| 1221 | 1289 | foreach ($incontext['sql_results'] as $key => $number) |
| 1222 | 1290 | { |
| 1223 | - if ($number == 0) |
|
| 1224 | - unset($incontext['sql_results'][$key]); |
|
| 1225 | - else |
|
| 1226 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1291 | + if ($number == 0) { |
|
| 1292 | + unset($incontext['sql_results'][$key]); |
|
| 1293 | + } else { |
|
| 1294 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1295 | + } |
|
| 1227 | 1296 | } |
| 1228 | 1297 | |
| 1229 | 1298 | // Make sure UTF will be used globally. |
| 1230 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1231 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1299 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1300 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1301 | + } |
|
| 1232 | 1302 | |
| 1233 | 1303 | // Auto-detect local & global cookie settings |
| 1234 | 1304 | $url_parts = parse_url($boardurl); |
@@ -1254,15 +1324,19 @@ discard block |
||
| 1254 | 1324 | |
| 1255 | 1325 | // Look for subfolder, if found, set localCookie |
| 1256 | 1326 | // Checking for len > 1 ensures you don't have just a slash... |
| 1257 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
| 1258 | - $localCookies = '1'; |
|
| 1327 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
| 1328 | + $localCookies = '1'; |
|
| 1329 | + } |
|
| 1259 | 1330 | |
| 1260 | - if (isset($globalCookies)) |
|
| 1261 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1262 | - if (isset($globalCookiesDomain)) |
|
| 1263 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1264 | - if (isset($localCookies)) |
|
| 1265 | - $newSettings[] = array('localCookies', $localCookies); |
|
| 1331 | + if (isset($globalCookies)) { |
|
| 1332 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1333 | + } |
|
| 1334 | + if (isset($globalCookiesDomain)) { |
|
| 1335 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1336 | + } |
|
| 1337 | + if (isset($localCookies)) { |
|
| 1338 | + $newSettings[] = array('localCookies', $localCookies); |
|
| 1339 | + } |
|
| 1266 | 1340 | } |
| 1267 | 1341 | |
| 1268 | 1342 | // Are we allowing stat collection? |
@@ -1280,16 +1354,17 @@ discard block |
||
| 1280 | 1354 | fwrite($fp, $out); |
| 1281 | 1355 | |
| 1282 | 1356 | $return_data = ''; |
| 1283 | - while (!feof($fp)) |
|
| 1284 | - $return_data .= fgets($fp, 128); |
|
| 1357 | + while (!feof($fp)) { |
|
| 1358 | + $return_data .= fgets($fp, 128); |
|
| 1359 | + } |
|
| 1285 | 1360 | |
| 1286 | 1361 | fclose($fp); |
| 1287 | 1362 | |
| 1288 | 1363 | // Get the unique site ID. |
| 1289 | 1364 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1290 | 1365 | |
| 1291 | - if (!empty($ID[1])) |
|
| 1292 | - $smcFunc['db_insert']('replace', |
|
| 1366 | + if (!empty($ID[1])) { |
|
| 1367 | + $smcFunc['db_insert']('replace', |
|
| 1293 | 1368 | $db_prefix . 'settings', |
| 1294 | 1369 | array('variable' => 'string', 'value' => 'string'), |
| 1295 | 1370 | array( |
@@ -1298,11 +1373,12 @@ discard block |
||
| 1298 | 1373 | ), |
| 1299 | 1374 | array('variable') |
| 1300 | 1375 | ); |
| 1376 | + } |
|
| 1301 | 1377 | } |
| 1302 | 1378 | } |
| 1303 | 1379 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1304 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1305 | - $smcFunc['db_query']('', ' |
|
| 1380 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1381 | + $smcFunc['db_query']('', ' |
|
| 1306 | 1382 | DELETE FROM {db_prefix}settings |
| 1307 | 1383 | WHERE variable = {string:enable_sm_stats}', |
| 1308 | 1384 | array( |
@@ -1310,20 +1386,23 @@ discard block |
||
| 1310 | 1386 | 'db_error_skip' => true, |
| 1311 | 1387 | ) |
| 1312 | 1388 | ); |
| 1389 | + } |
|
| 1313 | 1390 | |
| 1314 | 1391 | // Are we enabling SSL? |
| 1315 | - if (!empty($_POST['force_ssl'])) |
|
| 1316 | - $newSettings[] = array('force_ssl', 2); |
|
| 1392 | + if (!empty($_POST['force_ssl'])) { |
|
| 1393 | + $newSettings[] = array('force_ssl', 2); |
|
| 1394 | + } |
|
| 1317 | 1395 | |
| 1318 | 1396 | // Setting a timezone is required. |
| 1319 | 1397 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1320 | 1398 | { |
| 1321 | 1399 | // Get PHP's default timezone, if set |
| 1322 | 1400 | $ini_tz = ini_get('date.timezone'); |
| 1323 | - if (!empty($ini_tz)) |
|
| 1324 | - $timezone_id = $ini_tz; |
|
| 1325 | - else |
|
| 1326 | - $timezone_id = ''; |
|
| 1401 | + if (!empty($ini_tz)) { |
|
| 1402 | + $timezone_id = $ini_tz; |
|
| 1403 | + } else { |
|
| 1404 | + $timezone_id = ''; |
|
| 1405 | + } |
|
| 1327 | 1406 | |
| 1328 | 1407 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1329 | 1408 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1332,8 +1411,9 @@ discard block |
||
| 1332 | 1411 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1333 | 1412 | } |
| 1334 | 1413 | |
| 1335 | - if (date_default_timezone_set($timezone_id)) |
|
| 1336 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1414 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1415 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1416 | + } |
|
| 1337 | 1417 | } |
| 1338 | 1418 | |
| 1339 | 1419 | if (!empty($newSettings)) |
@@ -1364,16 +1444,18 @@ discard block |
||
| 1364 | 1444 | } |
| 1365 | 1445 | |
| 1366 | 1446 | // MySQL specific stuff |
| 1367 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1368 | - return false; |
|
| 1447 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1448 | + return false; |
|
| 1449 | + } |
|
| 1369 | 1450 | |
| 1370 | 1451 | // Find database user privileges. |
| 1371 | 1452 | $privs = array(); |
| 1372 | 1453 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1373 | 1454 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1374 | 1455 | { |
| 1375 | - if ($row['Privilege'] == 'Alter') |
|
| 1376 | - $privs[] = $row['Privilege']; |
|
| 1456 | + if ($row['Privilege'] == 'Alter') { |
|
| 1457 | + $privs[] = $row['Privilege']; |
|
| 1458 | + } |
|
| 1377 | 1459 | } |
| 1378 | 1460 | $smcFunc['db_free_result']($get_privs); |
| 1379 | 1461 | |
@@ -1403,8 +1485,9 @@ discard block |
||
| 1403 | 1485 | $incontext['continue'] = 1; |
| 1404 | 1486 | |
| 1405 | 1487 | // Skipping? |
| 1406 | - if (!empty($_POST['skip'])) |
|
| 1407 | - return true; |
|
| 1488 | + if (!empty($_POST['skip'])) { |
|
| 1489 | + return true; |
|
| 1490 | + } |
|
| 1408 | 1491 | |
| 1409 | 1492 | // Need this to check whether we need the database password. |
| 1410 | 1493 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1421,18 +1504,22 @@ discard block |
||
| 1421 | 1504 | // We need this to properly hash the password for Admin |
| 1422 | 1505 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1423 | 1506 | global $sourcedir; |
| 1424 | - if (function_exists('mb_strtolower')) |
|
| 1425 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1507 | + if (function_exists('mb_strtolower')) { |
|
| 1508 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1509 | + } |
|
| 1426 | 1510 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1427 | 1511 | return utf8_strtolower($string); |
| 1428 | 1512 | }; |
| 1429 | 1513 | |
| 1430 | - if (!isset($_POST['username'])) |
|
| 1431 | - $_POST['username'] = ''; |
|
| 1432 | - if (!isset($_POST['email'])) |
|
| 1433 | - $_POST['email'] = ''; |
|
| 1434 | - if (!isset($_POST['server_email'])) |
|
| 1435 | - $_POST['server_email'] = ''; |
|
| 1514 | + if (!isset($_POST['username'])) { |
|
| 1515 | + $_POST['username'] = ''; |
|
| 1516 | + } |
|
| 1517 | + if (!isset($_POST['email'])) { |
|
| 1518 | + $_POST['email'] = ''; |
|
| 1519 | + } |
|
| 1520 | + if (!isset($_POST['server_email'])) { |
|
| 1521 | + $_POST['server_email'] = ''; |
|
| 1522 | + } |
|
| 1436 | 1523 | |
| 1437 | 1524 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1438 | 1525 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1451,8 +1538,9 @@ discard block |
||
| 1451 | 1538 | 'admin_group' => 1, |
| 1452 | 1539 | ) |
| 1453 | 1540 | ); |
| 1454 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1455 | - $incontext['skip'] = 1; |
|
| 1541 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1542 | + $incontext['skip'] = 1; |
|
| 1543 | + } |
|
| 1456 | 1544 | $smcFunc['db_free_result']($request); |
| 1457 | 1545 | |
| 1458 | 1546 | // Trying to create an account? |
@@ -1483,8 +1571,9 @@ discard block |
||
| 1483 | 1571 | } |
| 1484 | 1572 | |
| 1485 | 1573 | // Update the webmaster's email? |
| 1486 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1487 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1574 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1575 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1576 | + } |
|
| 1488 | 1577 | |
| 1489 | 1578 | // Work out whether we're going to have dodgy characters and remove them. |
| 1490 | 1579 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1507,32 +1596,27 @@ discard block |
||
| 1507 | 1596 | $smcFunc['db_free_result']($result); |
| 1508 | 1597 | |
| 1509 | 1598 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1510 | - } |
|
| 1511 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1599 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1512 | 1600 | { |
| 1513 | 1601 | // Try the previous step again. |
| 1514 | 1602 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1515 | 1603 | return false; |
| 1516 | - } |
|
| 1517 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1604 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1518 | 1605 | { |
| 1519 | 1606 | // Try the previous step again. |
| 1520 | 1607 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1521 | 1608 | return false; |
| 1522 | - } |
|
| 1523 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1609 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1524 | 1610 | { |
| 1525 | 1611 | // One step back, this time fill out a proper admin email address. |
| 1526 | 1612 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1527 | 1613 | return false; |
| 1528 | - } |
|
| 1529 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1614 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1530 | 1615 | { |
| 1531 | 1616 | // One step back, this time fill out a proper admin email address. |
| 1532 | 1617 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1533 | 1618 | return false; |
| 1534 | - } |
|
| 1535 | - elseif ($_POST['username'] != '') |
|
| 1619 | + } elseif ($_POST['username'] != '') |
|
| 1536 | 1620 | { |
| 1537 | 1621 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1538 | 1622 | |
@@ -1600,17 +1684,19 @@ discard block |
||
| 1600 | 1684 | reloadSettings(); |
| 1601 | 1685 | |
| 1602 | 1686 | // Bring a warning over. |
| 1603 | - if (!empty($incontext['account_existed'])) |
|
| 1604 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1687 | + if (!empty($incontext['account_existed'])) { |
|
| 1688 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1689 | + } |
|
| 1605 | 1690 | |
| 1606 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1607 | - $smcFunc['db_query']('', ' |
|
| 1691 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1692 | + $smcFunc['db_query']('', ' |
|
| 1608 | 1693 | SET NAMES {string:db_character_set}', |
| 1609 | 1694 | array( |
| 1610 | 1695 | 'db_character_set' => $db_character_set, |
| 1611 | 1696 | 'db_error_skip' => true, |
| 1612 | 1697 | ) |
| 1613 | 1698 | ); |
| 1699 | + } |
|
| 1614 | 1700 | |
| 1615 | 1701 | // As track stats is by default enabled let's add some activity. |
| 1616 | 1702 | $smcFunc['db_insert']('ignore', |
@@ -1631,14 +1717,16 @@ discard block |
||
| 1631 | 1717 | // Only proceed if we can load the data. |
| 1632 | 1718 | if ($request) |
| 1633 | 1719 | { |
| 1634 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1635 | - $modSettings[$row[0]] = $row[1]; |
|
| 1720 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1721 | + $modSettings[$row[0]] = $row[1]; |
|
| 1722 | + } |
|
| 1636 | 1723 | $smcFunc['db_free_result']($request); |
| 1637 | 1724 | } |
| 1638 | 1725 | |
| 1639 | 1726 | // Automatically log them in ;) |
| 1640 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1641 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1727 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1728 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1729 | + } |
|
| 1642 | 1730 | |
| 1643 | 1731 | $result = $smcFunc['db_query']('', ' |
| 1644 | 1732 | SELECT value |
@@ -1649,13 +1737,14 @@ discard block |
||
| 1649 | 1737 | 'db_error_skip' => true, |
| 1650 | 1738 | ) |
| 1651 | 1739 | ); |
| 1652 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1653 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1740 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1741 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1742 | + } |
|
| 1654 | 1743 | $smcFunc['db_free_result']($result); |
| 1655 | 1744 | |
| 1656 | - if (empty($db_sessions)) |
|
| 1657 | - $_SESSION['admin_time'] = time(); |
|
| 1658 | - else |
|
| 1745 | + if (empty($db_sessions)) { |
|
| 1746 | + $_SESSION['admin_time'] = time(); |
|
| 1747 | + } else |
|
| 1659 | 1748 | { |
| 1660 | 1749 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1661 | 1750 | |
@@ -1679,8 +1768,9 @@ discard block |
||
| 1679 | 1768 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1680 | 1769 | function($string){ |
| 1681 | 1770 | global $sourcedir; |
| 1682 | - if (function_exists('mb_strtolower')) |
|
| 1683 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1771 | + if (function_exists('mb_strtolower')) { |
|
| 1772 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1773 | + } |
|
| 1684 | 1774 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1685 | 1775 | return utf8_strtolower($string); |
| 1686 | 1776 | }; |
@@ -1696,8 +1786,9 @@ discard block |
||
| 1696 | 1786 | ) |
| 1697 | 1787 | ); |
| 1698 | 1788 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1699 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1700 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1789 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1790 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1791 | + } |
|
| 1701 | 1792 | $smcFunc['db_free_result']($request); |
| 1702 | 1793 | |
| 1703 | 1794 | // Now is the perfect time to fetch the SM files. |
@@ -1716,8 +1807,9 @@ discard block |
||
| 1716 | 1807 | |
| 1717 | 1808 | // Check if we need some stupid MySQL fix. |
| 1718 | 1809 | $server_version = $smcFunc['db_server_info'](); |
| 1719 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1720 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1810 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1811 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1812 | + } |
|
| 1721 | 1813 | |
| 1722 | 1814 | // Some final context for the template. |
| 1723 | 1815 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1737,8 +1829,9 @@ discard block |
||
| 1737 | 1829 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1738 | 1830 | |
| 1739 | 1831 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1740 | - if (count($settingsArray) == 1) |
|
| 1741 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1832 | + if (count($settingsArray) == 1) { |
|
| 1833 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1834 | + } |
|
| 1742 | 1835 | |
| 1743 | 1836 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1744 | 1837 | { |
@@ -1753,19 +1846,22 @@ discard block |
||
| 1753 | 1846 | continue; |
| 1754 | 1847 | } |
| 1755 | 1848 | |
| 1756 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1757 | - $settingsArray[$i] = ''; |
|
| 1849 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1850 | + $settingsArray[$i] = ''; |
|
| 1851 | + } |
|
| 1758 | 1852 | |
| 1759 | 1853 | // Don't trim or bother with it if it's not a variable. |
| 1760 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1761 | - continue; |
|
| 1854 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1855 | + continue; |
|
| 1856 | + } |
|
| 1762 | 1857 | |
| 1763 | 1858 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1764 | 1859 | |
| 1765 | - foreach ($vars as $var => $val) |
|
| 1766 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1860 | + foreach ($vars as $var => $val) { |
|
| 1861 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1767 | 1862 | { |
| 1768 | 1863 | $comment = strstr($settingsArray[$i], '#'); |
| 1864 | + } |
|
| 1769 | 1865 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1770 | 1866 | unset($vars[$var]); |
| 1771 | 1867 | } |
@@ -1775,36 +1871,41 @@ discard block |
||
| 1775 | 1871 | if (!empty($vars)) |
| 1776 | 1872 | { |
| 1777 | 1873 | $settingsArray[$i++] = ''; |
| 1778 | - foreach ($vars as $var => $val) |
|
| 1779 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1874 | + foreach ($vars as $var => $val) { |
|
| 1875 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1876 | + } |
|
| 1780 | 1877 | } |
| 1781 | 1878 | |
| 1782 | 1879 | // Blank out the file - done to fix a oddity with some servers. |
| 1783 | 1880 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1784 | - if (!$fp) |
|
| 1785 | - return false; |
|
| 1881 | + if (!$fp) { |
|
| 1882 | + return false; |
|
| 1883 | + } |
|
| 1786 | 1884 | fclose($fp); |
| 1787 | 1885 | |
| 1788 | 1886 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1789 | 1887 | |
| 1790 | 1888 | // Gotta have one of these ;) |
| 1791 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1792 | - fwrite($fp, "<?php\n"); |
|
| 1889 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1890 | + fwrite($fp, "<?php\n"); |
|
| 1891 | + } |
|
| 1793 | 1892 | |
| 1794 | 1893 | $lines = count($settingsArray); |
| 1795 | 1894 | for ($i = 0; $i < $lines - 1; $i++) |
| 1796 | 1895 | { |
| 1797 | 1896 | // Don't just write a bunch of blank lines. |
| 1798 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1799 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1897 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1898 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1899 | + } |
|
| 1800 | 1900 | } |
| 1801 | 1901 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1802 | 1902 | fclose($fp); |
| 1803 | 1903 | |
| 1804 | 1904 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1805 | 1905 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1806 | - if (function_exists('opcache_invalidate')) |
|
| 1807 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1906 | + if (function_exists('opcache_invalidate')) { |
|
| 1907 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1908 | + } |
|
| 1808 | 1909 | |
| 1809 | 1910 | return true; |
| 1810 | 1911 | } |
@@ -1829,9 +1930,9 @@ discard block |
||
| 1829 | 1930 | SecFilterScanPOST Off |
| 1830 | 1931 | </IfModule>'; |
| 1831 | 1932 | |
| 1832 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1833 | - return true; |
|
| 1834 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1933 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1934 | + return true; |
|
| 1935 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1835 | 1936 | { |
| 1836 | 1937 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1837 | 1938 | |
@@ -1843,29 +1944,28 @@ discard block |
||
| 1843 | 1944 | fwrite($ht_handle, $htaccess_addition); |
| 1844 | 1945 | fclose($ht_handle); |
| 1845 | 1946 | return true; |
| 1947 | + } else { |
|
| 1948 | + return false; |
|
| 1846 | 1949 | } |
| 1847 | - else |
|
| 1848 | - return false; |
|
| 1950 | + } else { |
|
| 1951 | + return true; |
|
| 1849 | 1952 | } |
| 1850 | - else |
|
| 1851 | - return true; |
|
| 1852 | - } |
|
| 1853 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1854 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1855 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1953 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1954 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1955 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1856 | 1956 | { |
| 1857 | 1957 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1858 | 1958 | { |
| 1859 | 1959 | fwrite($ht_handle, $htaccess_addition); |
| 1860 | 1960 | fclose($ht_handle); |
| 1861 | 1961 | return true; |
| 1962 | + } else { |
|
| 1963 | + return false; |
|
| 1862 | 1964 | } |
| 1863 | - else |
|
| 1965 | + } else { |
|
| 1864 | 1966 | return false; |
| 1865 | 1967 | } |
| 1866 | - else |
|
| 1867 | - return false; |
|
| 1868 | -} |
|
| 1968 | + } |
|
| 1869 | 1969 | |
| 1870 | 1970 | function template_install_above() |
| 1871 | 1971 | { |
@@ -1903,9 +2003,10 @@ discard block |
||
| 1903 | 2003 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1904 | 2004 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1905 | 2005 | |
| 1906 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1907 | - echo ' |
|
| 2006 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 2007 | + echo ' |
|
| 1908 | 2008 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2009 | + } |
|
| 1909 | 2010 | |
| 1910 | 2011 | echo ' |
| 1911 | 2012 | </select> |
@@ -1925,9 +2026,10 @@ discard block |
||
| 1925 | 2026 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1926 | 2027 | <ul>'; |
| 1927 | 2028 | |
| 1928 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1929 | - echo ' |
|
| 2029 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2030 | + echo ' |
|
| 1930 | 2031 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2032 | + } |
|
| 1931 | 2033 | |
| 1932 | 2034 | echo ' |
| 1933 | 2035 | </ul> |
@@ -1952,20 +2054,23 @@ discard block |
||
| 1952 | 2054 | echo ' |
| 1953 | 2055 | <div class="floatright">'; |
| 1954 | 2056 | |
| 1955 | - if (!empty($incontext['continue'])) |
|
| 1956 | - echo ' |
|
| 2057 | + if (!empty($incontext['continue'])) { |
|
| 2058 | + echo ' |
|
| 1957 | 2059 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 1958 | - if (!empty($incontext['skip'])) |
|
| 1959 | - echo ' |
|
| 2060 | + } |
|
| 2061 | + if (!empty($incontext['skip'])) { |
|
| 2062 | + echo ' |
|
| 1960 | 2063 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 2064 | + } |
|
| 1961 | 2065 | echo ' |
| 1962 | 2066 | </div>'; |
| 1963 | 2067 | } |
| 1964 | 2068 | |
| 1965 | 2069 | // Show the closing form tag and other data only if not in the last step |
| 1966 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1967 | - echo ' |
|
| 2070 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2071 | + echo ' |
|
| 1968 | 2072 | </form>'; |
| 2073 | + } |
|
| 1969 | 2074 | |
| 1970 | 2075 | echo ' |
| 1971 | 2076 | </div> |
@@ -2000,13 +2105,15 @@ discard block |
||
| 2000 | 2105 | </div>'; |
| 2001 | 2106 | |
| 2002 | 2107 | // Show the warnings, or not. |
| 2003 | - if (template_warning_divs()) |
|
| 2004 | - echo ' |
|
| 2108 | + if (template_warning_divs()) { |
|
| 2109 | + echo ' |
|
| 2005 | 2110 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2111 | + } |
|
| 2006 | 2112 | |
| 2007 | 2113 | // Say we want the continue button! |
| 2008 | - if (empty($incontext['error'])) |
|
| 2009 | - $incontext['continue'] = 1; |
|
| 2114 | + if (empty($incontext['error'])) { |
|
| 2115 | + $incontext['continue'] = 1; |
|
| 2116 | + } |
|
| 2010 | 2117 | |
| 2011 | 2118 | // For the latest version stuff. |
| 2012 | 2119 | echo ' |
@@ -2040,8 +2147,8 @@ discard block |
||
| 2040 | 2147 | global $txt, $incontext; |
| 2041 | 2148 | |
| 2042 | 2149 | // Errors are very serious.. |
| 2043 | - if (!empty($incontext['error'])) |
|
| 2044 | - echo ' |
|
| 2150 | + if (!empty($incontext['error'])) { |
|
| 2151 | + echo ' |
|
| 2045 | 2152 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2046 | 2153 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2047 | 2154 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2049,9 +2156,10 @@ discard block |
||
| 2049 | 2156 | ', $incontext['error'], ' |
| 2050 | 2157 | </div> |
| 2051 | 2158 | </div>'; |
| 2159 | + } |
|
| 2052 | 2160 | // A warning message? |
| 2053 | - elseif (!empty($incontext['warning'])) |
|
| 2054 | - echo ' |
|
| 2161 | + elseif (!empty($incontext['warning'])) { |
|
| 2162 | + echo ' |
|
| 2055 | 2163 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2056 | 2164 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2057 | 2165 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2059,6 +2167,7 @@ discard block |
||
| 2059 | 2167 | ', $incontext['warning'], ' |
| 2060 | 2168 | </div> |
| 2061 | 2169 | </div>'; |
| 2170 | + } |
|
| 2062 | 2171 | |
| 2063 | 2172 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2064 | 2173 | } |
@@ -2074,27 +2183,30 @@ discard block |
||
| 2074 | 2183 | <li>', $incontext['failed_files']), '</li> |
| 2075 | 2184 | </ul>'; |
| 2076 | 2185 | |
| 2077 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2078 | - echo ' |
|
| 2186 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2187 | + echo ' |
|
| 2079 | 2188 | <hr> |
| 2080 | 2189 | <p>', $txt['chmod_linux_info'], '</p> |
| 2081 | 2190 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2191 | + } |
|
| 2082 | 2192 | |
| 2083 | 2193 | // This is serious! |
| 2084 | - if (!template_warning_divs()) |
|
| 2085 | - return; |
|
| 2194 | + if (!template_warning_divs()) { |
|
| 2195 | + return; |
|
| 2196 | + } |
|
| 2086 | 2197 | |
| 2087 | 2198 | echo ' |
| 2088 | 2199 | <hr> |
| 2089 | 2200 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2090 | 2201 | |
| 2091 | - if (!empty($incontext['ftp_errors'])) |
|
| 2092 | - echo ' |
|
| 2202 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2203 | + echo ' |
|
| 2093 | 2204 | <div class="error_message"> |
| 2094 | 2205 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2095 | 2206 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2096 | 2207 | </div> |
| 2097 | 2208 | <br>'; |
| 2209 | + } |
|
| 2098 | 2210 | |
| 2099 | 2211 | echo ' |
| 2100 | 2212 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2154,17 +2266,17 @@ discard block |
||
| 2154 | 2266 | <td> |
| 2155 | 2267 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2156 | 2268 | |
| 2157 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2158 | - echo ' |
|
| 2269 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2270 | + echo ' |
|
| 2159 | 2271 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2272 | + } |
|
| 2160 | 2273 | |
| 2161 | 2274 | echo ' |
| 2162 | 2275 | </select> |
| 2163 | 2276 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2164 | 2277 | </td> |
| 2165 | 2278 | </tr>'; |
| 2166 | - } |
|
| 2167 | - else |
|
| 2279 | + } else |
|
| 2168 | 2280 | { |
| 2169 | 2281 | echo ' |
| 2170 | 2282 | <tr style="display: none;"> |
@@ -2357,9 +2469,10 @@ discard block |
||
| 2357 | 2469 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2358 | 2470 | <ul>'; |
| 2359 | 2471 | |
| 2360 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2361 | - echo ' |
|
| 2472 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2473 | + echo ' |
|
| 2362 | 2474 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2475 | + } |
|
| 2363 | 2476 | |
| 2364 | 2477 | echo ' |
| 2365 | 2478 | </ul>'; |
@@ -2420,15 +2533,16 @@ discard block |
||
| 2420 | 2533 | </tr> |
| 2421 | 2534 | </table>'; |
| 2422 | 2535 | |
| 2423 | - if ($incontext['require_db_confirm']) |
|
| 2424 | - echo ' |
|
| 2536 | + if ($incontext['require_db_confirm']) { |
|
| 2537 | + echo ' |
|
| 2425 | 2538 | <h2>', $txt['user_settings_database'], '</h2> |
| 2426 | 2539 | <p>', $txt['user_settings_database_info'], '</p> |
| 2427 | 2540 | |
| 2428 | 2541 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2429 | 2542 | <input type="password" name="password3" size="30" /> |
| 2430 | 2543 | </div>'; |
| 2431 | -} |
|
| 2544 | + } |
|
| 2545 | + } |
|
| 2432 | 2546 | |
| 2433 | 2547 | // Tell them it's done, and to delete. |
| 2434 | 2548 | function template_delete_install() |
@@ -2441,14 +2555,15 @@ discard block |
||
| 2441 | 2555 | template_warning_divs(); |
| 2442 | 2556 | |
| 2443 | 2557 | // Install directory still writable? |
| 2444 | - if ($incontext['dir_still_writable']) |
|
| 2445 | - echo ' |
|
| 2558 | + if ($incontext['dir_still_writable']) { |
|
| 2559 | + echo ' |
|
| 2446 | 2560 | <em>', $txt['still_writable'], '</em><br> |
| 2447 | 2561 | <br>'; |
| 2562 | + } |
|
| 2448 | 2563 | |
| 2449 | 2564 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2450 | - if ($incontext['probably_delete_install']) |
|
| 2451 | - echo ' |
|
| 2565 | + if ($incontext['probably_delete_install']) { |
|
| 2566 | + echo ' |
|
| 2452 | 2567 | <div style="margin: 1ex; font-weight: bold;"> |
| 2453 | 2568 | <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> |
| 2454 | 2569 | </div> |
@@ -2464,6 +2579,7 @@ discard block |
||
| 2464 | 2579 | } |
| 2465 | 2580 | </script> |
| 2466 | 2581 | <br>'; |
| 2582 | + } |
|
| 2467 | 2583 | |
| 2468 | 2584 | echo ' |
| 2469 | 2585 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | <div id="recent" class="main_section"> |
| 22 | 22 | <div class="cat_bar"> |
| 23 | 23 | <h3 class="catbg"> |
| 24 | - <span class="xx"></span>',$txt['recent_posts'],' |
|
| 24 | + <span class="xx"></span>',$txt['recent_posts'], ' |
|
| 25 | 25 | </h3> |
| 26 | 26 | </div> |
| 27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
@@ -26,9 +26,10 @@ discard block |
||
| 26 | 26 | </div> |
| 27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
| 28 | 28 | |
| 29 | - if (empty($context['posts'])) |
|
| 30 | - echo ' |
|
| 29 | + if (empty($context['posts'])) { |
|
| 30 | + echo ' |
|
| 31 | 31 | <div class="windowbg">', $txt['no_messages'], '</div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | foreach ($context['posts'] as $post) |
| 34 | 35 | { |
@@ -41,28 +42,33 @@ discard block |
||
| 41 | 42 | </div> |
| 42 | 43 | <div class="list_posts">', $post['message'], '</div>'; |
| 43 | 44 | |
| 44 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 45 | - echo ' |
|
| 45 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 46 | + echo ' |
|
| 46 | 47 | <ul class="quickbuttons">'; |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // If they *can* reply? |
| 49 | - if ($post['can_reply']) |
|
| 50 | - echo ' |
|
| 51 | + if ($post['can_reply']) { |
|
| 52 | + echo ' |
|
| 51 | 53 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // If they *can* quote? |
| 54 | - if ($post['can_quote']) |
|
| 55 | - echo ' |
|
| 57 | + if ($post['can_quote']) { |
|
| 58 | + echo ' |
|
| 56 | 59 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // How about... even... remove it entirely?! |
| 59 | - if ($post['can_delete']) |
|
| 60 | - echo ' |
|
| 63 | + if ($post['can_delete']) { |
|
| 64 | + echo ' |
|
| 61 | 65 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 66 | + } |
|
| 62 | 67 | |
| 63 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 64 | - echo ' |
|
| 68 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 69 | + echo ' |
|
| 65 | 70 | </ul>'; |
| 71 | + } |
|
| 66 | 72 | |
| 67 | 73 | echo ' |
| 68 | 74 | </div><!-- $post[css_class] -->'; |
@@ -84,12 +90,13 @@ discard block |
||
| 84 | 90 | echo ' |
| 85 | 91 | <div id="recent" class="main_content">'; |
| 86 | 92 | |
| 87 | - if ($context['showCheckboxes']) |
|
| 88 | - echo ' |
|
| 93 | + if ($context['showCheckboxes']) { |
|
| 94 | + echo ' |
|
| 89 | 95 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
| 90 | 96 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 91 | 97 | <input type="hidden" name="qaction" value="markread"> |
| 92 | 98 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
| 99 | + } |
|
| 93 | 100 | |
| 94 | 101 | if (!empty($context['topics'])) |
| 95 | 102 | { |
@@ -118,11 +125,12 @@ discard block |
||
| 118 | 125 | </div>'; |
| 119 | 126 | |
| 120 | 127 | // Show a "select all" box for quick moderation? |
| 121 | - if ($context['showCheckboxes']) |
|
| 122 | - echo ' |
|
| 128 | + if ($context['showCheckboxes']) { |
|
| 129 | + echo ' |
|
| 123 | 130 | <div class="moderation"> |
| 124 | 131 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 125 | 132 | </div>'; |
| 133 | + } |
|
| 126 | 134 | |
| 127 | 135 | echo ' |
| 128 | 136 | </div><!-- #topic_header --> |
@@ -142,17 +150,20 @@ discard block |
||
| 142 | 150 | echo ' |
| 143 | 151 | <div class="icons floatright">'; |
| 144 | 152 | |
| 145 | - if ($topic['is_locked']) |
|
| 146 | - echo ' |
|
| 153 | + if ($topic['is_locked']) { |
|
| 154 | + echo ' |
|
| 147 | 155 | <span class="generic_icons lock"></span>'; |
| 156 | + } |
|
| 148 | 157 | |
| 149 | - if ($topic['is_sticky']) |
|
| 150 | - echo ' |
|
| 158 | + if ($topic['is_sticky']) { |
|
| 159 | + echo ' |
|
| 151 | 160 | <span class="generic_icons sticky"></span>'; |
| 161 | + } |
|
| 152 | 162 | |
| 153 | - if ($topic['is_poll']) |
|
| 154 | - echo ' |
|
| 163 | + if ($topic['is_poll']) { |
|
| 164 | + echo ' |
|
| 155 | 165 | <span class="generic_icons poll"></span>'; |
| 166 | + } |
|
| 156 | 167 | |
| 157 | 168 | echo ' |
| 158 | 169 | </div>'; |
@@ -178,19 +189,21 @@ discard block |
||
| 178 | 189 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
| 179 | 190 | </div>'; |
| 180 | 191 | |
| 181 | - if ($context['showCheckboxes']) |
|
| 182 | - echo ' |
|
| 192 | + if ($context['showCheckboxes']) { |
|
| 193 | + echo ' |
|
| 183 | 194 | <div class="moderation"> |
| 184 | 195 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
| 185 | 196 | </div>'; |
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | echo ' |
| 188 | 200 | </div><!-- $topic[css_class] -->'; |
| 189 | 201 | } |
| 190 | 202 | |
| 191 | - if (empty($context['topics'])) |
|
| 192 | - echo ' |
|
| 203 | + if (empty($context['topics'])) { |
|
| 204 | + echo ' |
|
| 193 | 205 | <div style="display: none;"></div>'; |
| 206 | + } |
|
| 194 | 207 | |
| 195 | 208 | echo ' |
| 196 | 209 | </div><!-- #topic_container --> |
@@ -205,25 +218,27 @@ discard block |
||
| 205 | 218 | ', $context['page_index'], ' |
| 206 | 219 | </div> |
| 207 | 220 | </div>'; |
| 208 | - } |
|
| 209 | - else |
|
| 210 | - echo ' |
|
| 221 | + } else { |
|
| 222 | + echo ' |
|
| 211 | 223 | <div class="cat_bar"> |
| 212 | 224 | <h3 class="catbg centertext"> |
| 213 | 225 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
| 214 | 226 | </h3> |
| 215 | 227 | </div>'; |
| 228 | + } |
|
| 216 | 229 | |
| 217 | - if ($context['showCheckboxes']) |
|
| 218 | - echo ' |
|
| 230 | + if ($context['showCheckboxes']) { |
|
| 231 | + echo ' |
|
| 219 | 232 | </form>'; |
| 233 | + } |
|
| 220 | 234 | |
| 221 | 235 | echo ' |
| 222 | 236 | </div><!-- #recent -->'; |
| 223 | 237 | |
| 224 | - if (empty($context['no_topic_listing'])) |
|
| 225 | - template_topic_legend(); |
|
| 226 | -} |
|
| 238 | + if (empty($context['no_topic_listing'])) { |
|
| 239 | + template_topic_legend(); |
|
| 240 | + } |
|
| 241 | + } |
|
| 227 | 242 | |
| 228 | 243 | /** |
| 229 | 244 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -235,12 +250,13 @@ discard block |
||
| 235 | 250 | echo ' |
| 236 | 251 | <div id="recent">'; |
| 237 | 252 | |
| 238 | - if ($context['showCheckboxes']) |
|
| 239 | - echo ' |
|
| 253 | + if ($context['showCheckboxes']) { |
|
| 254 | + echo ' |
|
| 240 | 255 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
| 241 | 256 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 242 | 257 | <input type="hidden" name="qaction" value="markread"> |
| 243 | 258 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
| 259 | + } |
|
| 244 | 260 | |
| 245 | 261 | if (!empty($context['topics'])) |
| 246 | 262 | { |
@@ -269,11 +285,12 @@ discard block |
||
| 269 | 285 | </div>'; |
| 270 | 286 | |
| 271 | 287 | // Show a "select all" box for quick moderation? |
| 272 | - if ($context['showCheckboxes']) |
|
| 273 | - echo ' |
|
| 288 | + if ($context['showCheckboxes']) { |
|
| 289 | + echo ' |
|
| 274 | 290 | <div class="moderation"> |
| 275 | 291 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 276 | 292 | </div>'; |
| 293 | + } |
|
| 277 | 294 | |
| 278 | 295 | echo ' |
| 279 | 296 | </div><!-- #topic_header --> |
@@ -293,17 +310,20 @@ discard block |
||
| 293 | 310 | echo ' |
| 294 | 311 | <div class="icons floatright">'; |
| 295 | 312 | |
| 296 | - if ($topic['is_locked']) |
|
| 297 | - echo ' |
|
| 313 | + if ($topic['is_locked']) { |
|
| 314 | + echo ' |
|
| 298 | 315 | <span class="generic_icons lock"></span>'; |
| 316 | + } |
|
| 299 | 317 | |
| 300 | - if ($topic['is_sticky']) |
|
| 301 | - echo ' |
|
| 318 | + if ($topic['is_sticky']) { |
|
| 319 | + echo ' |
|
| 302 | 320 | <span class="generic_icons sticky"></span>'; |
| 321 | + } |
|
| 303 | 322 | |
| 304 | - if ($topic['is_poll']) |
|
| 305 | - echo ' |
|
| 323 | + if ($topic['is_poll']) { |
|
| 324 | + echo ' |
|
| 306 | 325 | <span class="generic_icons poll"></span>'; |
| 326 | + } |
|
| 307 | 327 | |
| 308 | 328 | echo ' |
| 309 | 329 | </div>'; |
@@ -329,11 +349,12 @@ discard block |
||
| 329 | 349 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
| 330 | 350 | </div>'; |
| 331 | 351 | |
| 332 | - if ($context['showCheckboxes']) |
|
| 333 | - echo ' |
|
| 352 | + if ($context['showCheckboxes']) { |
|
| 353 | + echo ' |
|
| 334 | 354 | <div class="moderation"> |
| 335 | 355 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
| 336 | 356 | </div>'; |
| 357 | + } |
|
| 337 | 358 | |
| 338 | 359 | echo ' |
| 339 | 360 | </div><!-- $topic[css_class] -->'; |
@@ -350,24 +371,26 @@ discard block |
||
| 350 | 371 | ', $context['page_index'], ' |
| 351 | 372 | </div> |
| 352 | 373 | </div>'; |
| 353 | - } |
|
| 354 | - else |
|
| 355 | - echo ' |
|
| 374 | + } else { |
|
| 375 | + echo ' |
|
| 356 | 376 | <div class="cat_bar"> |
| 357 | 377 | <h3 class="catbg centertext"> |
| 358 | 378 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
| 359 | 379 | </h3> |
| 360 | 380 | </div>'; |
| 381 | + } |
|
| 361 | 382 | |
| 362 | - if ($context['showCheckboxes']) |
|
| 363 | - echo ' |
|
| 383 | + if ($context['showCheckboxes']) { |
|
| 384 | + echo ' |
|
| 364 | 385 | </form>'; |
| 386 | + } |
|
| 365 | 387 | |
| 366 | 388 | echo ' |
| 367 | 389 | </div><!-- #recent -->'; |
| 368 | 390 | |
| 369 | - if (empty($context['no_topic_listing'])) |
|
| 370 | - template_topic_legend(); |
|
| 371 | -} |
|
| 391 | + if (empty($context['no_topic_listing'])) { |
|
| 392 | + template_topic_legend(); |
|
| 393 | + } |
|
| 394 | + } |
|
| 372 | 395 | |
| 373 | 396 | ?> |
| 374 | 397 | \ No newline at end of file |
@@ -673,7 +673,7 @@ |
||
| 673 | 673 | 'Nikola "Dzonny" Novaković', |
| 674 | 674 | // Localizers |
| 675 | 675 | 'Dr. Deejay', |
| 676 | - 'd3vcho', |
|
| 676 | + 'd3vcho', |
|
| 677 | 677 | // Former Localizers |
| 678 | 678 | 'Relyana', |
| 679 | 679 | ), |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | 'Shitiz "Dragooon" Garg', |
| 591 | 591 | 'Karl "RegularExpression" Benson', |
| 592 | 592 | 'Matthew "Labradoodle-360" Kerle', |
| 593 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
| 593 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
| 594 | 594 | 'Michael "Thantos" Miller', |
| 595 | 595 | 'Norv', |
| 596 | 596 | 'Peter "Arantor" Spicer', |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | $credit_info = $smcFunc['json_decode']($row['credits'], true); |
| 815 | 815 | |
| 816 | 816 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
| 817 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 817 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 818 | 818 | $version = $txt['credits_version'] . ' ' . $row['version']; |
| 819 | 819 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
| 820 | 820 | |
| 821 | 821 | // build this one out and stash it away |
| 822 | 822 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
| 823 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 823 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 824 | 824 | } |
| 825 | 825 | cache_put_data('mods_credits', $mods, 86400); |
| 826 | 826 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = $smcFunc['json_decode']($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = $smcFunc['json_decode']($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -710,8 +740,8 @@ discard block |
||
| 710 | 740 | ); |
| 711 | 741 | |
| 712 | 742 | // Give the translators some credit for their hard work. |
| 713 | - if (!empty($txt['translation_credits'])) |
|
| 714 | - $context['credits'][] = array( |
|
| 743 | + if (!empty($txt['translation_credits'])) { |
|
| 744 | + $context['credits'][] = array( |
|
| 715 | 745 | 'title' => $txt['credits_groups_translation'], |
| 716 | 746 | 'groups' => array( |
| 717 | 747 | array( |
@@ -720,6 +750,7 @@ discard block |
||
| 720 | 750 | ), |
| 721 | 751 | ), |
| 722 | 752 | ); |
| 753 | + } |
|
| 723 | 754 | |
| 724 | 755 | $context['credits'][] = array( |
| 725 | 756 | 'title' => $txt['credits_special'], |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | * |
| 105 | 105 | * @param string $class The fully-qualified class name. |
| 106 | 106 | */ |
| 107 | -spl_autoload_register(function ($class) use ($sourcedir) |
|
| 107 | +spl_autoload_register(function($class) use ($sourcedir) |
|
| 108 | 108 | { |
| 109 | 109 | $classMap = array( |
| 110 | 110 | 'ReCaptcha\\' => 'ReCaptcha/', |
@@ -32,16 +32,18 @@ discard block |
||
| 32 | 32 | ob_start(); |
| 33 | 33 | |
| 34 | 34 | // Do some cleaning, just in case. |
| 35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 36 | 36 | if (isset($GLOBALS[$variable])) |
| 37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 38 | +} |
|
| 38 | 39 | |
| 39 | 40 | // Load the settings... |
| 40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 41 | 42 | |
| 42 | 43 | // Make absolutely sure the cache directory is defined. |
| 43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 44 | 45 | $cachedir = $boarddir . '/cache'; |
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | // Without those we can't go anywhere |
| 47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | require_once($sourcedir . '/Load.php'); |
| 52 | 54 | |
| 53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 54 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 55 | 57 | display_maintenance_message(); |
| 58 | +} |
|
| 56 | 59 | |
| 57 | 60 | // Create a variable to store some SMF specific functions in. |
| 58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | cleanRequest(); |
| 68 | 71 | |
| 69 | 72 | // Seed the random generator. |
| 70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 71 | 74 | smf_seed_generator(); |
| 75 | +} |
|
| 72 | 76 | |
| 73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
| 88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 89 | 93 | { |
| 90 | 94 | // If zlib is being used, turn off output compression. |
| 91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 93 | - else |
|
| 95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 97 | + } else |
|
| 94 | 98 | { |
| 95 | 99 | ob_end_clean(); |
| 96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
| 182 | 186 | loadPermissions(); |
| 183 | 187 | |
| 184 | 188 | // Attachments don't require the entire theme to be loaded. |
| 185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 186 | - detectBrowser(); |
|
| 189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 190 | + detectBrowser(); |
|
| 191 | + } |
|
| 187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 188 | - else |
|
| 189 | - loadTheme(); |
|
| 193 | + else { |
|
| 194 | + loadTheme(); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | // Check if the user should be disallowed access. |
| 192 | 198 | is_not_banned(); |
| 193 | 199 | |
| 194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 196 | - fatal_lang_error('not_a_topic', false); |
|
| 201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 202 | + fatal_lang_error('not_a_topic', false); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | writeLog(); |
| 205 | 212 | |
| 206 | 213 | // Track forum statistics and hits...? |
| 207 | - if (!empty($modSettings['hitStats'])) |
|
| 208 | - trackStats(array('hits' => '+')); |
|
| 214 | + if (!empty($modSettings['hitStats'])) { |
|
| 215 | + trackStats(array('hits' => '+')); |
|
| 216 | + } |
|
| 209 | 217 | } |
| 210 | 218 | unset($no_stat_actions); |
| 211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
| 219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 220 | 228 | } |
| 221 | 229 | // Don't even try it, sonny. |
| 222 | - else |
|
| 223 | - return 'InMaintenance'; |
|
| 230 | + else { |
|
| 231 | + return 'InMaintenance'; |
|
| 232 | + } |
|
| 224 | 233 | } |
| 225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
| 226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 227 | - return 'KickGuest'; |
|
| 228 | - elseif (empty($_REQUEST['action'])) |
|
| 235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 236 | + return 'KickGuest'; |
|
| 237 | + } elseif (empty($_REQUEST['action'])) |
|
| 229 | 238 | { |
| 230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
| 239 | 248 | |
| 240 | 249 | $call = call_helper($defaultAction, true); |
| 241 | 250 | |
| 242 | - if (!empty($call)) |
|
| 243 | - return $call; |
|
| 251 | + if (!empty($call)) { |
|
| 252 | + return $call; |
|
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | |
| 371 | 381 | $call = call_helper($fallbackAction, true); |
| 372 | 382 | |
| 373 | - if (!empty($call)) |
|
| 374 | - return $call; |
|
| 383 | + if (!empty($call)) { |
|
| 384 | + return $call; |
|
| 385 | + } |
|
| 375 | 386 | } |
| 376 | 387 | |
| 377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // Otherwise, it was set - so let's go to that action. |
| 385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
| 386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
| 397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 398 | + } |
|
| 387 | 399 | |
| 388 | 400 | // Do the right thing. |
| 389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |