@@ -96,8 +96,9 @@ discard block |
||
| 96 | 96 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 97 | 97 | { |
| 98 | 98 | $groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups']))); |
| 99 | - if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) |
|
| 100 | - continue; |
|
| 99 | + if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) { |
|
| 100 | + continue; |
|
| 101 | + } |
|
| 101 | 102 | |
| 102 | 103 | $members[] = $row['id_member']; |
| 103 | 104 | $watched[$row['id_member']] = $row; |
@@ -105,8 +106,9 @@ discard block |
||
| 105 | 106 | |
| 106 | 107 | $smcFunc['db_free_result']($request); |
| 107 | 108 | |
| 108 | - if (empty($members)) |
|
| 109 | - return true; |
|
| 109 | + if (empty($members)) { |
|
| 110 | + return true; |
|
| 111 | + } |
|
| 110 | 112 | |
| 111 | 113 | $members = array_unique($members); |
| 112 | 114 | $prefs = getNotifyPrefs($members, '', true); |
@@ -122,8 +124,9 @@ discard block |
||
| 122 | 124 | self::handleQuoteNotifications($msgOptions, $posterOptions, $quotedMembers, $prefs, $done_members, $alert_rows); |
| 123 | 125 | |
| 124 | 126 | // Save ourselves a bit of work in the big loop below |
| 125 | - foreach ($done_members as $done_member) |
|
| 126 | - unset($watched[$done_member]); |
|
| 127 | + foreach ($done_members as $done_member) { |
|
| 128 | + unset($watched[$done_member]); |
|
| 129 | + } |
|
| 127 | 130 | |
| 128 | 131 | // Handle rest of the notifications for watched topics and boards |
| 129 | 132 | foreach ($watched as $member => $data) |
@@ -132,26 +135,31 @@ discard block |
||
| 132 | 135 | $notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : self::NOTIFY_TYPE_REPLY_AND_MODIFY; |
| 133 | 136 | |
| 134 | 137 | // Don't send a notification if the watching member ignored the member who made the action. |
| 135 | - if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) |
|
| 136 | - continue; |
|
| 137 | - if (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING && $member != $data['id_member_started']) |
|
| 138 | - continue; |
|
| 139 | - elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) |
|
| 140 | - continue; |
|
| 141 | - elseif (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_ONLY_REPLIES) |
|
| 142 | - continue; |
|
| 143 | - elseif ($notify_types == self::NOTIFY_TYPE_NOTHING) |
|
| 144 | - continue; |
|
| 138 | + if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) { |
|
| 139 | + continue; |
|
| 140 | + } |
|
| 141 | + if (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING && $member != $data['id_member_started']) { |
|
| 142 | + continue; |
|
| 143 | + } elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) { |
|
| 144 | + continue; |
|
| 145 | + } elseif (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_ONLY_REPLIES) { |
|
| 146 | + continue; |
|
| 147 | + } elseif ($notify_types == self::NOTIFY_TYPE_NOTHING) { |
|
| 148 | + continue; |
|
| 149 | + } |
|
| 145 | 150 | |
| 146 | 151 | // Don't send a notification if they don't want any... |
| 147 | - if (in_array($frequency, array(self::FREQUENCY_NOTHING, self::FREQUENCY_DAILY_DIGEST, self::FREQUENCY_WEEKLY_DIGEST))) |
|
| 148 | - continue; |
|
| 152 | + if (in_array($frequency, array(self::FREQUENCY_NOTHING, self::FREQUENCY_DAILY_DIGEST, self::FREQUENCY_WEEKLY_DIGEST))) { |
|
| 153 | + continue; |
|
| 154 | + } |
|
| 149 | 155 | // ... or if we already sent one and they don't want more... |
| 150 | - elseif ($frequency === self::FREQUENCY_FIRST_UNREAD_MSG && $data['sent']) |
|
| 151 | - continue; |
|
| 156 | + elseif ($frequency === self::FREQUENCY_FIRST_UNREAD_MSG && $data['sent']) { |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 152 | 159 | // ... or if they aren't on the bouncer's list. |
| 153 | - elseif (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])) |
|
| 154 | - continue; |
|
| 160 | + elseif (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])) { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 155 | 163 | |
| 156 | 164 | // Watched topic? |
| 157 | 165 | if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member])) |
@@ -161,10 +169,12 @@ discard block |
||
| 161 | 169 | |
| 162 | 170 | if ($type == 'reply') |
| 163 | 171 | { |
| 164 | - if (!empty($prefs[$member]['msg_receive_body'])) |
|
| 165 | - $message_type .= '_body'; |
|
| 166 | - if (!empty($frequency)) |
|
| 167 | - $message_type .= '_once'; |
|
| 172 | + if (!empty($prefs[$member]['msg_receive_body'])) { |
|
| 173 | + $message_type .= '_body'; |
|
| 174 | + } |
|
| 175 | + if (!empty($frequency)) { |
|
| 176 | + $message_type .= '_once'; |
|
| 177 | + } |
|
| 168 | 178 | } |
| 169 | 179 | |
| 170 | 180 | $content_type = 'topic'; |
@@ -177,12 +187,14 @@ discard block |
||
| 177 | 187 | $content_type = 'board'; |
| 178 | 188 | |
| 179 | 189 | $message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards'; |
| 180 | - if (!empty($prefs[$member]['msg_receive_body'])) |
|
| 181 | - $message_type .= '_body'; |
|
| 190 | + if (!empty($prefs[$member]['msg_receive_body'])) { |
|
| 191 | + $message_type .= '_body'; |
|
| 192 | + } |
|
| 182 | 193 | } |
| 183 | 194 | // If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip |
| 184 | - else |
|
| 185 | - continue; |
|
| 195 | + else { |
|
| 196 | + continue; |
|
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | // Bitwise check: Receiving a email notification? |
| 188 | 200 | if ($pref & self::RECEIVE_NOTIFY_EMAIL) |
@@ -199,8 +211,9 @@ discard block |
||
| 199 | 211 | $mail_result = sendmail($data['email_address'], $emaildata['subject'], $emaildata['body'], null, 'm' . $topicOptions['id'], $emaildata['is_html']); |
| 200 | 212 | |
| 201 | 213 | // We failed, don't trigger a alert as we don't have a way to attempt to resend just the email currently. |
| 202 | - if ($mail_result === false) |
|
| 203 | - continue; |
|
| 214 | + if ($mail_result === false) { |
|
| 215 | + continue; |
|
| 216 | + } |
|
| 204 | 217 | } |
| 205 | 218 | |
| 206 | 219 | // Bitwise check: Receiving a alert? |
@@ -251,14 +264,15 @@ discard block |
||
| 251 | 264 | ); |
| 252 | 265 | |
| 253 | 266 | // Insert the alerts if any |
| 254 | - if (!empty($alert_rows)) |
|
| 255 | - $smcFunc['db_insert']('', |
|
| 267 | + if (!empty($alert_rows)) { |
|
| 268 | + $smcFunc['db_insert']('', |
|
| 256 | 269 | '{db_prefix}user_alerts', |
| 257 | 270 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 258 | 271 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 259 | 272 | $alert_rows, |
| 260 | 273 | array() |
| 261 | 274 | ); |
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | return true; |
| 264 | 278 | } |
@@ -269,8 +283,9 @@ discard block |
||
| 269 | 283 | |
| 270 | 284 | foreach ($quotedMembers as $id => $member) |
| 271 | 285 | { |
| 272 | - if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) |
|
| 273 | - continue; |
|
| 286 | + if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) { |
|
| 287 | + continue; |
|
| 288 | + } |
|
| 274 | 289 | |
| 275 | 290 | $done_members[] = $id; |
| 276 | 291 | |
@@ -324,32 +339,35 @@ discard block |
||
| 324 | 339 | { |
| 325 | 340 | if (preg_match('/\[quote(.*)?\]/i', $block, $matches)) |
| 326 | 341 | { |
| 327 | - if ($quote_level == 0) |
|
| 328 | - $message .= '[quote' . $matches[1] . ']'; |
|
| 342 | + if ($quote_level == 0) { |
|
| 343 | + $message .= '[quote' . $matches[1] . ']'; |
|
| 344 | + } |
|
| 329 | 345 | $quote_level++; |
| 330 | - } |
|
| 331 | - elseif (preg_match('/\[\/quote\]/i', $block)) |
|
| 346 | + } elseif (preg_match('/\[\/quote\]/i', $block)) |
|
| 332 | 347 | { |
| 333 | - if ($quote_level <= 1) |
|
| 334 | - $message .= '[/quote]'; |
|
| 348 | + if ($quote_level <= 1) { |
|
| 349 | + $message .= '[/quote]'; |
|
| 350 | + } |
|
| 335 | 351 | if ($quote_level >= 1) |
| 336 | 352 | { |
| 337 | 353 | $quote_level--; |
| 338 | 354 | $message .= "\n"; |
| 339 | 355 | } |
| 356 | + } elseif ($quote_level <= 1) { |
|
| 357 | + $message .= $block; |
|
| 340 | 358 | } |
| 341 | - elseif ($quote_level <= 1) |
|
| 342 | - $message .= $block; |
|
| 343 | 359 | } |
| 344 | 360 | |
| 345 | 361 | preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches); |
| 346 | 362 | |
| 347 | 363 | $id_msgs = $matches[1]; |
| 348 | - foreach ($id_msgs as $k => $id_msg) |
|
| 349 | - $id_msgs[$k] = (int) $id_msg; |
|
| 364 | + foreach ($id_msgs as $k => $id_msg) { |
|
| 365 | + $id_msgs[$k] = (int) $id_msg; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | - if (empty($id_msgs)) |
|
| 352 | - return array(); |
|
| 368 | + if (empty($id_msgs)) { |
|
| 369 | + return array(); |
|
| 370 | + } |
|
| 353 | 371 | |
| 354 | 372 | // Get the messages |
| 355 | 373 | $request = $smcFunc['db_query']('', ' |
@@ -367,8 +385,9 @@ discard block |
||
| 367 | 385 | $members = array(); |
| 368 | 386 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 369 | 387 | { |
| 370 | - if ($posterOptions['id'] == $row['id_member']) |
|
| 371 | - continue; |
|
| 388 | + if ($posterOptions['id'] == $row['id_member']) { |
|
| 389 | + continue; |
|
| 390 | + } |
|
| 372 | 391 | |
| 373 | 392 | $members[$row['id_member']] = $row; |
| 374 | 393 | } |
@@ -382,10 +401,11 @@ discard block |
||
| 382 | 401 | |
| 383 | 402 | foreach ($members as $id => $member) |
| 384 | 403 | { |
| 385 | - if (!empty($prefs[$id]['msg_mention'])) |
|
| 386 | - $done_members[] = $id; |
|
| 387 | - else |
|
| 388 | - continue; |
|
| 404 | + if (!empty($prefs[$id]['msg_mention'])) { |
|
| 405 | + $done_members[] = $id; |
|
| 406 | + } else { |
|
| 407 | + continue; |
|
| 408 | + } |
|
| 389 | 409 | |
| 390 | 410 | // Alerts' emails are always instant |
| 391 | 411 | if ($prefs[$id]['msg_mention'] & self::RECEIVE_NOTIFY_EMAIL) |
@@ -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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -60,12 +63,14 @@ discard block |
||
| 60 | 63 | { |
| 61 | 64 | // Get ids of all the boards they can post in. |
| 62 | 65 | $post_permissions = array('post_new'); |
| 63 | - if ($modSettings['postmod_active']) |
|
| 64 | - $post_permissions[] = 'post_unapproved_topics'; |
|
| 66 | + if ($modSettings['postmod_active']) { |
|
| 67 | + $post_permissions[] = 'post_unapproved_topics'; |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | $boards = boardsAllowedTo($post_permissions); |
| 67 | - if (empty($boards)) |
|
| 68 | - fatal_lang_error('cannot_post_new', false); |
|
| 71 | + if (empty($boards)) { |
|
| 72 | + fatal_lang_error('cannot_post_new', false); |
|
| 73 | + } |
|
| 69 | 74 | |
| 70 | 75 | // Get a list of boards for the select menu |
| 71 | 76 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -78,8 +83,9 @@ discard block |
||
| 78 | 83 | $board_list = getBoardList($boardListOptions); |
| 79 | 84 | } |
| 80 | 85 | // Let's keep things simple for ourselves below |
| 81 | - else |
|
| 82 | - $boards = array($board); |
|
| 86 | + else { |
|
| 87 | + $boards = array($board); |
|
| 88 | + } |
|
| 83 | 89 | |
| 84 | 90 | require_once($sourcedir . '/Subs-Post.php'); |
| 85 | 91 | |
@@ -102,10 +108,11 @@ discard block |
||
| 102 | 108 | array( |
| 103 | 109 | 'msg' => (int) $_REQUEST['msg'], |
| 104 | 110 | )); |
| 105 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 106 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 107 | - else |
|
| 108 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 111 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 112 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 113 | + } else { |
|
| 114 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 115 | + } |
|
| 109 | 116 | $smcFunc['db_free_result']($request); |
| 110 | 117 | } |
| 111 | 118 | |
@@ -132,33 +139,36 @@ discard block |
||
| 132 | 139 | $smcFunc['db_free_result']($request); |
| 133 | 140 | |
| 134 | 141 | // If this topic already has a poll, they sure can't add another. |
| 135 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 136 | - unset($_REQUEST['poll']); |
|
| 142 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 143 | + unset($_REQUEST['poll']); |
|
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | if (empty($_REQUEST['msg'])) |
| 139 | 147 | { |
| 140 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 141 | - is_not_guest(); |
|
| 148 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 149 | + is_not_guest(); |
|
| 150 | + } |
|
| 142 | 151 | |
| 143 | 152 | // By default the reply will be approved... |
| 144 | 153 | $context['becomes_approved'] = true; |
| 145 | 154 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 146 | 155 | { |
| 147 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 148 | - $context['becomes_approved'] = false; |
|
| 149 | - else |
|
| 150 | - isAllowedTo('post_reply_any'); |
|
| 151 | - } |
|
| 152 | - elseif (!allowedTo('post_reply_any')) |
|
| 156 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 157 | + $context['becomes_approved'] = false; |
|
| 158 | + } else { |
|
| 159 | + isAllowedTo('post_reply_any'); |
|
| 160 | + } |
|
| 161 | + } elseif (!allowedTo('post_reply_any')) |
|
| 153 | 162 | { |
| 154 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 155 | - $context['becomes_approved'] = false; |
|
| 156 | - else |
|
| 157 | - isAllowedTo('post_reply_own'); |
|
| 163 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 164 | + $context['becomes_approved'] = false; |
|
| 165 | + } else { |
|
| 166 | + isAllowedTo('post_reply_own'); |
|
| 167 | + } |
|
| 158 | 168 | } |
| 169 | + } else { |
|
| 170 | + $context['becomes_approved'] = true; |
|
| 159 | 171 | } |
| 160 | - else |
|
| 161 | - $context['becomes_approved'] = true; |
|
| 162 | 172 | |
| 163 | 173 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 164 | 174 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -173,17 +183,18 @@ discard block |
||
| 173 | 183 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 174 | 184 | |
| 175 | 185 | // Check whether this is a really old post being bumped... |
| 176 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 177 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 178 | - } |
|
| 179 | - else |
|
| 186 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 187 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 188 | + } |
|
| 189 | + } else |
|
| 180 | 190 | { |
| 181 | 191 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
| 182 | 192 | $context['becomes_approved'] = true; |
| 183 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
| 184 | - $context['becomes_approved'] = false; |
|
| 185 | - else |
|
| 186 | - isAllowedTo('post_new', $boards, true); |
|
| 193 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
| 194 | + $context['becomes_approved'] = false; |
|
| 195 | + } else { |
|
| 196 | + isAllowedTo('post_new', $boards, true); |
|
| 197 | + } |
|
| 187 | 198 | |
| 188 | 199 | $locked = 0; |
| 189 | 200 | $context['already_locked'] = 0; |
@@ -213,27 +224,32 @@ discard block |
||
| 213 | 224 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
| 214 | 225 | { |
| 215 | 226 | require_once($sourcedir . '/ManageAttachments.php'); |
| 216 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 217 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 227 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 228 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 229 | + } |
|
| 218 | 230 | |
| 219 | 231 | unset($_SESSION['already_attached']); |
| 220 | 232 | } |
| 221 | 233 | |
| 222 | 234 | // Don't allow a post if it's locked and you aren't all powerful. |
| 223 | - if ($locked && !allowedTo('moderate_board')) |
|
| 224 | - fatal_lang_error('topic_locked', false); |
|
| 235 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 236 | + fatal_lang_error('topic_locked', false); |
|
| 237 | + } |
|
| 225 | 238 | // Check the users permissions - is the user allowed to add or post a poll? |
| 226 | 239 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 227 | 240 | { |
| 228 | 241 | // New topic, new poll. |
| 229 | - if (empty($topic)) |
|
| 230 | - isAllowedTo('poll_post'); |
|
| 242 | + if (empty($topic)) { |
|
| 243 | + isAllowedTo('poll_post'); |
|
| 244 | + } |
|
| 231 | 245 | // This is an old topic - but it is yours! Can you add to it? |
| 232 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 233 | - isAllowedTo('poll_add_own'); |
|
| 246 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 247 | + isAllowedTo('poll_add_own'); |
|
| 248 | + } |
|
| 234 | 249 | // If you're not the owner, can you add to any poll? |
| 235 | - else |
|
| 236 | - isAllowedTo('poll_add_any'); |
|
| 250 | + else { |
|
| 251 | + isAllowedTo('poll_add_any'); |
|
| 252 | + } |
|
| 237 | 253 | |
| 238 | 254 | if (!empty($board)) |
| 239 | 255 | { |
@@ -242,8 +258,9 @@ discard block |
||
| 242 | 258 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
| 243 | 259 | } |
| 244 | 260 | // No board, so we'll have to check this again in Post2 |
| 245 | - else |
|
| 246 | - $guest_vote_enabled = true; |
|
| 261 | + else { |
|
| 262 | + $guest_vote_enabled = true; |
|
| 263 | + } |
|
| 247 | 264 | |
| 248 | 265 | // Set up the poll options. |
| 249 | 266 | $context['poll_options'] = array( |
@@ -269,8 +286,9 @@ discard block |
||
| 269 | 286 | if ($context['make_event']) |
| 270 | 287 | { |
| 271 | 288 | // They might want to pick a board. |
| 272 | - if (!isset($context['current_board'])) |
|
| 273 | - $context['current_board'] = 0; |
|
| 289 | + if (!isset($context['current_board'])) { |
|
| 290 | + $context['current_board'] = 0; |
|
| 291 | + } |
|
| 274 | 292 | |
| 275 | 293 | // Start loading up the event info. |
| 276 | 294 | $context['event'] = array(); |
@@ -284,10 +302,11 @@ discard block |
||
| 284 | 302 | isAllowedTo('calendar_post'); |
| 285 | 303 | |
| 286 | 304 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 287 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 288 | - $time_string = '%k:%M'; |
|
| 289 | - else |
|
| 290 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 305 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 306 | + $time_string = '%k:%M'; |
|
| 307 | + } else { |
|
| 308 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 309 | + } |
|
| 291 | 310 | |
| 292 | 311 | $js_time_string = str_replace( |
| 293 | 312 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -309,8 +328,7 @@ discard block |
||
| 309 | 328 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 310 | 329 | $eventProperties = getEventProperties($context['event']['id']); |
| 311 | 330 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 312 | - } |
|
| 313 | - else |
|
| 331 | + } else |
|
| 314 | 332 | { |
| 315 | 333 | // Get the current event information. |
| 316 | 334 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -318,10 +336,12 @@ discard block |
||
| 318 | 336 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 319 | 337 | |
| 320 | 338 | // Make sure the year and month are in the valid range. |
| 321 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 322 | - fatal_lang_error('invalid_month', false); |
|
| 323 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 324 | - fatal_lang_error('invalid_year', false); |
|
| 339 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 340 | + fatal_lang_error('invalid_month', false); |
|
| 341 | + } |
|
| 342 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 343 | + fatal_lang_error('invalid_year', false); |
|
| 344 | + } |
|
| 325 | 345 | |
| 326 | 346 | $context['event']['categories'] = $board_list; |
| 327 | 347 | } |
@@ -432,10 +452,11 @@ discard block |
||
| 432 | 452 | |
| 433 | 453 | if (!empty($context['new_replies'])) |
| 434 | 454 | { |
| 435 | - if ($context['new_replies'] == 1) |
|
| 436 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 437 | - else |
|
| 438 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 455 | + if ($context['new_replies'] == 1) { |
|
| 456 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 457 | + } else { |
|
| 458 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 459 | + } |
|
| 439 | 460 | |
| 440 | 461 | $post_errors[] = 'new_replies'; |
| 441 | 462 | |
@@ -447,9 +468,9 @@ discard block |
||
| 447 | 468 | // Get a response prefix (like 'Re:') in the default forum language. |
| 448 | 469 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 449 | 470 | { |
| 450 | - if ($language === $user_info['language']) |
|
| 451 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 452 | - else |
|
| 471 | + if ($language === $user_info['language']) { |
|
| 472 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 473 | + } else |
|
| 453 | 474 | { |
| 454 | 475 | loadLanguage('index', $language, false); |
| 455 | 476 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -462,23 +483,26 @@ discard block |
||
| 462 | 483 | // Do we have a body, but an error happened. |
| 463 | 484 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 464 | 485 | { |
| 465 | - if (isset($_REQUEST['quickReply'])) |
|
| 466 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 486 | + if (isset($_REQUEST['quickReply'])) { |
|
| 487 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 488 | + } |
|
| 467 | 489 | |
| 468 | 490 | // Validate inputs. |
| 469 | 491 | if (empty($context['post_error'])) |
| 470 | 492 | { |
| 471 | 493 | // This means they didn't click Post and get an error. |
| 472 | 494 | $really_previewing = true; |
| 473 | - } |
|
| 474 | - else |
|
| 495 | + } else |
|
| 475 | 496 | { |
| 476 | - if (!isset($_REQUEST['subject'])) |
|
| 477 | - $_REQUEST['subject'] = ''; |
|
| 478 | - if (!isset($_REQUEST['message'])) |
|
| 479 | - $_REQUEST['message'] = ''; |
|
| 480 | - if (!isset($_REQUEST['icon'])) |
|
| 481 | - $_REQUEST['icon'] = 'xx'; |
|
| 497 | + if (!isset($_REQUEST['subject'])) { |
|
| 498 | + $_REQUEST['subject'] = ''; |
|
| 499 | + } |
|
| 500 | + if (!isset($_REQUEST['message'])) { |
|
| 501 | + $_REQUEST['message'] = ''; |
|
| 502 | + } |
|
| 503 | + if (!isset($_REQUEST['icon'])) { |
|
| 504 | + $_REQUEST['icon'] = 'xx'; |
|
| 505 | + } |
|
| 482 | 506 | |
| 483 | 507 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 484 | 508 | $really_previewing = !empty($_POST['preview']); |
@@ -494,8 +518,9 @@ discard block |
||
| 494 | 518 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 495 | 519 | |
| 496 | 520 | // Make sure the subject isn't too long - taking into account special characters. |
| 497 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 498 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 521 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 522 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 523 | + } |
|
| 499 | 524 | |
| 500 | 525 | if (isset($_REQUEST['poll'])) |
| 501 | 526 | { |
@@ -507,8 +532,9 @@ discard block |
||
| 507 | 532 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 508 | 533 | foreach ($_POST['options'] as $option) |
| 509 | 534 | { |
| 510 | - if (trim($option) == '') |
|
| 511 | - continue; |
|
| 535 | + if (trim($option) == '') { |
|
| 536 | + continue; |
|
| 537 | + } |
|
| 512 | 538 | |
| 513 | 539 | $context['choices'][] = array( |
| 514 | 540 | 'id' => $choice_id++, |
@@ -570,13 +596,14 @@ discard block |
||
| 570 | 596 | $context['preview_subject'] = $form_subject; |
| 571 | 597 | |
| 572 | 598 | censorText($context['preview_subject']); |
| 599 | + } else { |
|
| 600 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 573 | 601 | } |
| 574 | - else |
|
| 575 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 576 | 602 | |
| 577 | 603 | // Protect any CDATA blocks. |
| 578 | - if (isset($_REQUEST['xml'])) |
|
| 579 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 604 | + if (isset($_REQUEST['xml'])) { |
|
| 605 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 619 | - fatal_lang_error('no_board', false); |
|
| 645 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 646 | + fatal_lang_error('no_board', false); |
|
| 647 | + } |
|
| 620 | 648 | $row = $smcFunc['db_fetch_assoc']($request); |
| 621 | 649 | |
| 622 | 650 | $attachment_stuff = array($row); |
| 623 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 624 | - $attachment_stuff[] = $row2; |
|
| 651 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 652 | + $attachment_stuff[] = $row2; |
|
| 653 | + } |
|
| 625 | 654 | $smcFunc['db_free_result']($request); |
| 626 | 655 | |
| 627 | 656 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 628 | 657 | { |
| 629 | 658 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 630 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 631 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 632 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 633 | - isAllowedTo('modify_replies'); |
|
| 634 | - else |
|
| 635 | - isAllowedTo('modify_own'); |
|
| 659 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 660 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 661 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 662 | + isAllowedTo('modify_replies'); |
|
| 663 | + } else { |
|
| 664 | + isAllowedTo('modify_own'); |
|
| 665 | + } |
|
| 666 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 667 | + isAllowedTo('modify_replies'); |
|
| 668 | + } else { |
|
| 669 | + isAllowedTo('modify_any'); |
|
| 636 | 670 | } |
| 637 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 638 | - isAllowedTo('modify_replies'); |
|
| 639 | - else |
|
| 640 | - isAllowedTo('modify_any'); |
|
| 641 | 671 | |
| 642 | 672 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 643 | 673 | { |
@@ -661,8 +691,9 @@ discard block |
||
| 661 | 691 | |
| 662 | 692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 663 | 693 | { |
| 664 | - if ($row['filesize'] <= 0) |
|
| 665 | - continue; |
|
| 694 | + if ($row['filesize'] <= 0) { |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 666 | 697 | $context['current_attachments'][$row['id_attach']] = array( |
| 667 | 698 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 668 | 699 | 'size' => $row['filesize'], |
@@ -732,29 +763,32 @@ discard block |
||
| 732 | 763 | ) |
| 733 | 764 | ); |
| 734 | 765 | // The message they were trying to edit was most likely deleted. |
| 735 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 736 | - fatal_lang_error('no_message', false); |
|
| 766 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 767 | + fatal_lang_error('no_message', false); |
|
| 768 | + } |
|
| 737 | 769 | $row = $smcFunc['db_fetch_assoc']($request); |
| 738 | 770 | |
| 739 | 771 | $attachment_stuff = array($row); |
| 740 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 741 | - $attachment_stuff[] = $row2; |
|
| 772 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 773 | + $attachment_stuff[] = $row2; |
|
| 774 | + } |
|
| 742 | 775 | $smcFunc['db_free_result']($request); |
| 743 | 776 | |
| 744 | 777 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 745 | 778 | { |
| 746 | 779 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 747 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 748 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 749 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 750 | - isAllowedTo('modify_replies'); |
|
| 751 | - else |
|
| 752 | - isAllowedTo('modify_own'); |
|
| 780 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 781 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 782 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 783 | + isAllowedTo('modify_replies'); |
|
| 784 | + } else { |
|
| 785 | + isAllowedTo('modify_own'); |
|
| 786 | + } |
|
| 787 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 788 | + isAllowedTo('modify_replies'); |
|
| 789 | + } else { |
|
| 790 | + isAllowedTo('modify_any'); |
|
| 753 | 791 | } |
| 754 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 755 | - isAllowedTo('modify_replies'); |
|
| 756 | - else |
|
| 757 | - isAllowedTo('modify_any'); |
|
| 758 | 792 | |
| 759 | 793 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 760 | 794 | { |
@@ -781,15 +815,17 @@ discard block |
||
| 781 | 815 | $context['icon'] = $row['icon']; |
| 782 | 816 | |
| 783 | 817 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 784 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 785 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 818 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 819 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // Sort the attachments so they are in the order saved |
| 788 | 823 | $temp = array(); |
| 789 | 824 | foreach ($attachment_stuff as $attachment) |
| 790 | 825 | { |
| 791 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 792 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 826 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 827 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 828 | + } |
|
| 793 | 829 | } |
| 794 | 830 | ksort($temp); |
| 795 | 831 | |
@@ -850,14 +886,16 @@ discard block |
||
| 850 | 886 | 'is_approved' => 1, |
| 851 | 887 | ) |
| 852 | 888 | ); |
| 853 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 854 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 889 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 890 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 891 | + } |
|
| 855 | 892 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 856 | 893 | $smcFunc['db_free_result']($request); |
| 857 | 894 | |
| 858 | 895 | // Add 'Re: ' to the front of the quoted subject. |
| 859 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 860 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 896 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 897 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 898 | + } |
|
| 861 | 899 | |
| 862 | 900 | // Censor the message and subject. |
| 863 | 901 | censorText($form_message); |
@@ -870,10 +908,11 @@ discard block |
||
| 870 | 908 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 871 | 909 | { |
| 872 | 910 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 873 | - if ($i % 4 == 0) |
|
| 874 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 911 | + if ($i % 4 == 0) { |
|
| 912 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 875 | 913 | { |
| 876 | 914 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 915 | + } |
|
| 877 | 916 | }, $parts[$i]); |
| 878 | 917 | } |
| 879 | 918 | $form_message = implode('', $parts); |
@@ -882,8 +921,9 @@ discard block |
||
| 882 | 921 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 883 | 922 | |
| 884 | 923 | // Remove any nested quotes, if necessary. |
| 885 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 886 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 924 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 925 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 926 | + } |
|
| 887 | 927 | |
| 888 | 928 | // Add a quote string on the front and end. |
| 889 | 929 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -895,15 +935,15 @@ discard block |
||
| 895 | 935 | $form_subject = $first_subject; |
| 896 | 936 | |
| 897 | 937 | // Add 'Re: ' to the front of the subject. |
| 898 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 899 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 938 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 939 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 940 | + } |
|
| 900 | 941 | |
| 901 | 942 | // Censor the subject. |
| 902 | 943 | censorText($form_subject); |
| 903 | 944 | |
| 904 | 945 | $form_message = ''; |
| 905 | - } |
|
| 906 | - else |
|
| 946 | + } else |
|
| 907 | 947 | { |
| 908 | 948 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 909 | 949 | $form_message = ''; |
@@ -922,13 +962,15 @@ discard block |
||
| 922 | 962 | if (isset($_REQUEST['msg'])) |
| 923 | 963 | { |
| 924 | 964 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 925 | - foreach ($context['current_attachments'] as $attachment) |
|
| 926 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 965 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 966 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 967 | + } |
|
| 927 | 968 | } |
| 928 | 969 | |
| 929 | 970 | // A bit of house keeping first. |
| 930 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 931 | - unset($_SESSION['temp_attachments']); |
|
| 971 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 972 | + unset($_SESSION['temp_attachments']); |
|
| 973 | + } |
|
| 932 | 974 | |
| 933 | 975 | if (!empty($_SESSION['temp_attachments'])) |
| 934 | 976 | { |
@@ -937,9 +979,10 @@ discard block |
||
| 937 | 979 | { |
| 938 | 980 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 939 | 981 | { |
| 940 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 941 | - if (file_exists($attachment['tmp_name'])) |
|
| 982 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 983 | + if (file_exists($attachment['tmp_name'])) |
|
| 942 | 984 | unlink($attachment['tmp_name']); |
| 985 | + } |
|
| 943 | 986 | } |
| 944 | 987 | $post_errors[] = 'temp_attachments_gone'; |
| 945 | 988 | $_SESSION['temp_attachments'] = array(); |
@@ -953,8 +996,9 @@ discard block |
||
| 953 | 996 | // See if any files still exist before showing the warning message and the files attached. |
| 954 | 997 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 955 | 998 | { |
| 956 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 957 | - continue; |
|
| 999 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1000 | + continue; |
|
| 1001 | + } |
|
| 958 | 1002 | |
| 959 | 1003 | if (file_exists($attachment['tmp_name'])) |
| 960 | 1004 | { |
@@ -964,20 +1008,21 @@ discard block |
||
| 964 | 1008 | break; |
| 965 | 1009 | } |
| 966 | 1010 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1011 | + } else |
|
| 969 | 1012 | { |
| 970 | 1013 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 971 | - if (!empty($topic)) |
|
| 972 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 973 | - else |
|
| 974 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1014 | + if (!empty($topic)) { |
|
| 1015 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 1016 | + } else { |
|
| 1017 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1018 | + } |
|
| 975 | 1019 | |
| 976 | 1020 | // Compile a list of the files to show the user. |
| 977 | 1021 | $file_list = array(); |
| 978 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 979 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1022 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1023 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 980 | 1024 | $file_list[] = $attachment['name']; |
| 1025 | + } |
|
| 981 | 1026 | |
| 982 | 1027 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 983 | 1028 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -989,8 +1034,7 @@ discard block |
||
| 989 | 1034 | |
| 990 | 1035 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 991 | 1036 | $context['ignore_temp_attachments'] = true; |
| 992 | - } |
|
| 993 | - else |
|
| 1037 | + } else |
|
| 994 | 1038 | { |
| 995 | 1039 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 996 | 1040 | $context['ignore_temp_attachments'] = true; |
@@ -998,16 +1042,19 @@ discard block |
||
| 998 | 1042 | } |
| 999 | 1043 | } |
| 1000 | 1044 | |
| 1001 | - if (!empty($context['we_are_history'])) |
|
| 1002 | - $post_errors[] = $context['we_are_history']; |
|
| 1045 | + if (!empty($context['we_are_history'])) { |
|
| 1046 | + $post_errors[] = $context['we_are_history']; |
|
| 1047 | + } |
|
| 1003 | 1048 | |
| 1004 | 1049 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1005 | 1050 | { |
| 1006 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 1007 | - break; |
|
| 1051 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1052 | + break; |
|
| 1053 | + } |
|
| 1008 | 1054 | |
| 1009 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1010 | - continue; |
|
| 1055 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1011 | 1058 | |
| 1012 | 1059 | if ($attachID == 'initial_error') |
| 1013 | 1060 | { |
@@ -1022,15 +1069,17 @@ discard block |
||
| 1022 | 1069 | { |
| 1023 | 1070 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1024 | 1071 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1025 | - foreach ($attachment['errors'] as $error) |
|
| 1026 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1072 | + foreach ($attachment['errors'] as $error) { |
|
| 1073 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1074 | + } |
|
| 1027 | 1075 | $txt['error_attach_errors'] .= '</div>'; |
| 1028 | 1076 | $post_errors[] = 'attach_errors'; |
| 1029 | 1077 | |
| 1030 | 1078 | // Take out the trash. |
| 1031 | 1079 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1032 | - if (file_exists($attachment['tmp_name'])) |
|
| 1033 | - unlink($attachment['tmp_name']); |
|
| 1080 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1081 | + unlink($attachment['tmp_name']); |
|
| 1082 | + } |
|
| 1034 | 1083 | continue; |
| 1035 | 1084 | } |
| 1036 | 1085 | |
@@ -1043,8 +1092,9 @@ discard block |
||
| 1043 | 1092 | |
| 1044 | 1093 | $context['attachments']['quantity']++; |
| 1045 | 1094 | $context['attachments']['total_size'] += $attachment['size']; |
| 1046 | - if (!isset($context['files_in_session_warning'])) |
|
| 1047 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1095 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1096 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1097 | + } |
|
| 1048 | 1098 | |
| 1049 | 1099 | $context['current_attachments'][$attachID] = array( |
| 1050 | 1100 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1072,8 +1122,9 @@ discard block |
||
| 1072 | 1122 | } |
| 1073 | 1123 | |
| 1074 | 1124 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1075 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1076 | - $post_errors[] = 'need_qr_verification'; |
|
| 1125 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1126 | + $post_errors[] = 'need_qr_verification'; |
|
| 1127 | + } |
|
| 1077 | 1128 | |
| 1078 | 1129 | /* |
| 1079 | 1130 | * There are two error types: serious and minor. Serious errors |
@@ -1090,52 +1141,56 @@ discard block |
||
| 1090 | 1141 | { |
| 1091 | 1142 | loadLanguage('Errors'); |
| 1092 | 1143 | $context['error_type'] = 'minor'; |
| 1093 | - foreach ($post_errors as $post_error) |
|
| 1094 | - if (is_array($post_error)) |
|
| 1144 | + foreach ($post_errors as $post_error) { |
|
| 1145 | + if (is_array($post_error)) |
|
| 1095 | 1146 | { |
| 1096 | 1147 | $post_error_id = $post_error[0]; |
| 1148 | + } |
|
| 1097 | 1149 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1098 | 1150 | |
| 1099 | 1151 | // If it's not a minor error flag it as such. |
| 1100 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1101 | - $context['error_type'] = 'serious'; |
|
| 1102 | - } |
|
| 1103 | - else |
|
| 1152 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1153 | + $context['error_type'] = 'serious'; |
|
| 1154 | + } |
|
| 1155 | + } else |
|
| 1104 | 1156 | { |
| 1105 | 1157 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1106 | 1158 | |
| 1107 | 1159 | // If it's not a minor error flag it as such. |
| 1108 | - if (!in_array($post_error, $minor_errors)) |
|
| 1109 | - $context['error_type'] = 'serious'; |
|
| 1160 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1161 | + $context['error_type'] = 'serious'; |
|
| 1162 | + } |
|
| 1110 | 1163 | } |
| 1111 | 1164 | } |
| 1112 | 1165 | |
| 1113 | 1166 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1114 | - if (isset($_REQUEST['poll'])) |
|
| 1115 | - $context['page_title'] = $txt['new_poll']; |
|
| 1116 | - elseif ($context['make_event']) |
|
| 1117 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1118 | - elseif (isset($_REQUEST['msg'])) |
|
| 1119 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1120 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1121 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1122 | - elseif (empty($topic)) |
|
| 1123 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1124 | - else |
|
| 1125 | - $context['page_title'] = $txt['post_reply']; |
|
| 1167 | + if (isset($_REQUEST['poll'])) { |
|
| 1168 | + $context['page_title'] = $txt['new_poll']; |
|
| 1169 | + } elseif ($context['make_event']) { |
|
| 1170 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1171 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1172 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1173 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1174 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1175 | + } elseif (empty($topic)) { |
|
| 1176 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1177 | + } else { |
|
| 1178 | + $context['page_title'] = $txt['post_reply']; |
|
| 1179 | + } |
|
| 1126 | 1180 | |
| 1127 | 1181 | // Build the link tree. |
| 1128 | - if (empty($topic)) |
|
| 1129 | - $context['linktree'][] = array( |
|
| 1182 | + if (empty($topic)) { |
|
| 1183 | + $context['linktree'][] = array( |
|
| 1130 | 1184 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1131 | 1185 | ); |
| 1132 | - else |
|
| 1133 | - $context['linktree'][] = array( |
|
| 1186 | + } else { |
|
| 1187 | + $context['linktree'][] = array( |
|
| 1134 | 1188 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1135 | 1189 | 'name' => $form_subject, |
| 1136 | 1190 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1137 | 1191 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1138 | 1192 | ); |
| 1193 | + } |
|
| 1139 | 1194 | |
| 1140 | 1195 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1141 | 1196 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1179,8 +1234,9 @@ discard block |
||
| 1179 | 1234 | // Message icons - customized icons are off? |
| 1180 | 1235 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
| 1181 | 1236 | |
| 1182 | - if (!empty($context['icons'])) |
|
| 1183 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1237 | + if (!empty($context['icons'])) { |
|
| 1238 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1239 | + } |
|
| 1184 | 1240 | |
| 1185 | 1241 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1186 | 1242 | if (isset($_REQUEST['poll'])) |
@@ -1200,8 +1256,9 @@ discard block |
||
| 1200 | 1256 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1201 | 1257 | { |
| 1202 | 1258 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1203 | - if ($context['icons'][$i]['selected']) |
|
| 1204 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1259 | + if ($context['icons'][$i]['selected']) { |
|
| 1260 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1261 | + } |
|
| 1205 | 1262 | } |
| 1206 | 1263 | if (empty($context['icon_url'])) |
| 1207 | 1264 | { |
@@ -1215,8 +1272,9 @@ discard block |
||
| 1215 | 1272 | )); |
| 1216 | 1273 | } |
| 1217 | 1274 | |
| 1218 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1219 | - getTopic(); |
|
| 1275 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1276 | + getTopic(); |
|
| 1277 | + } |
|
| 1220 | 1278 | |
| 1221 | 1279 | // If the user can post attachments prepare the warning labels. |
| 1222 | 1280 | if ($context['can_post_attachment']) |
@@ -1227,12 +1285,13 @@ discard block |
||
| 1227 | 1285 | $context['attachment_restrictions'] = array(); |
| 1228 | 1286 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1229 | 1287 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1230 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1231 | - if (!empty($modSettings[$type])) |
|
| 1288 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1289 | + if (!empty($modSettings[$type])) |
|
| 1232 | 1290 | { |
| 1233 | 1291 | // Show the max number of attachments if not 0. |
| 1234 | 1292 | if ($type == 'attachmentNumPerPostLimit') |
| 1235 | 1293 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1294 | + } |
|
| 1236 | 1295 | } |
| 1237 | 1296 | } |
| 1238 | 1297 | |
@@ -1266,8 +1325,8 @@ discard block |
||
| 1266 | 1325 | |
| 1267 | 1326 | if (!empty($context['current_attachments'])) |
| 1268 | 1327 | { |
| 1269 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1270 | - addInlineJavaScript(' |
|
| 1328 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1329 | + addInlineJavaScript(' |
|
| 1271 | 1330 | current_attachments.push({ |
| 1272 | 1331 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1273 | 1332 | size: '. $mock['size'] . ', |
@@ -1276,6 +1335,7 @@ discard block |
||
| 1276 | 1335 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1277 | 1336 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1278 | 1337 | });'); |
| 1338 | + } |
|
| 1279 | 1339 | } |
| 1280 | 1340 | |
| 1281 | 1341 | // File Upload. |
@@ -1374,12 +1434,13 @@ discard block |
||
| 1374 | 1434 | { |
| 1375 | 1435 | $context['posting_fields']['board']['input']['options'][$category['name']] = array('options' => array()); |
| 1376 | 1436 | |
| 1377 | - foreach ($category['boards'] as $brd) |
|
| 1378 | - $context['posting_fields']['board']['input']['options'][$category['name']]['options'][$brd['name']]['attributes'] = array( |
|
| 1437 | + foreach ($category['boards'] as $brd) { |
|
| 1438 | + $context['posting_fields']['board']['input']['options'][$category['name']]['options'][$brd['name']]['attributes'] = array( |
|
| 1379 | 1439 | 'value' => $brd['id'], |
| 1380 | 1440 | 'selected' => (bool) $brd['selected'], |
| 1381 | 1441 | 'label' => ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'], |
| 1382 | 1442 | ); |
| 1443 | + } |
|
| 1383 | 1444 | } |
| 1384 | 1445 | } |
| 1385 | 1446 | |
@@ -1425,8 +1486,9 @@ discard block |
||
| 1425 | 1486 | |
| 1426 | 1487 | |
| 1427 | 1488 | // Finally, load the template. |
| 1428 | - if (!isset($_REQUEST['xml'])) |
|
| 1429 | - loadTemplate('Post'); |
|
| 1489 | + if (!isset($_REQUEST['xml'])) { |
|
| 1490 | + loadTemplate('Post'); |
|
| 1491 | + } |
|
| 1430 | 1492 | |
| 1431 | 1493 | call_integration_hook('integrate_post_end'); |
| 1432 | 1494 | } |
@@ -1447,13 +1509,14 @@ discard block |
||
| 1447 | 1509 | // Sneaking off, are we? |
| 1448 | 1510 | if (empty($_POST) && empty($topic)) |
| 1449 | 1511 | { |
| 1450 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1451 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1452 | - else |
|
| 1453 | - fatal_lang_error('post_upload_error', false); |
|
| 1512 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1513 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1514 | + } else { |
|
| 1515 | + fatal_lang_error('post_upload_error', false); |
|
| 1516 | + } |
|
| 1517 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1518 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1454 | 1519 | } |
| 1455 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1456 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1457 | 1520 | |
| 1458 | 1521 | // No need! |
| 1459 | 1522 | $context['robot_no_index'] = true; |
@@ -1465,8 +1528,9 @@ discard block |
||
| 1465 | 1528 | $post_errors = array(); |
| 1466 | 1529 | |
| 1467 | 1530 | // If the session has timed out, let the user re-submit their form. |
| 1468 | - if (checkSession('post', '', false) != '') |
|
| 1469 | - $post_errors[] = 'session_timeout'; |
|
| 1531 | + if (checkSession('post', '', false) != '') { |
|
| 1532 | + $post_errors[] = 'session_timeout'; |
|
| 1533 | + } |
|
| 1470 | 1534 | |
| 1471 | 1535 | // Wrong verification code? |
| 1472 | 1536 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1476,8 +1540,9 @@ discard block |
||
| 1476 | 1540 | 'id' => 'post', |
| 1477 | 1541 | ); |
| 1478 | 1542 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1479 | - if (is_array($context['require_verification'])) |
|
| 1480 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1543 | + if (is_array($context['require_verification'])) { |
|
| 1544 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1545 | + } |
|
| 1481 | 1546 | } |
| 1482 | 1547 | |
| 1483 | 1548 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -1486,25 +1551,29 @@ discard block |
||
| 1486 | 1551 | call_integration_hook('integrate_post2_start'); |
| 1487 | 1552 | |
| 1488 | 1553 | // Drafts enabled and needed? |
| 1489 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1490 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1554 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1555 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1556 | + } |
|
| 1491 | 1557 | |
| 1492 | 1558 | // First check to see if they are trying to delete any current attachments. |
| 1493 | 1559 | if (isset($_POST['attach_del'])) |
| 1494 | 1560 | { |
| 1495 | 1561 | $keep_temp = array(); |
| 1496 | 1562 | $keep_ids = array(); |
| 1497 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1498 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1563 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1564 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1499 | 1565 | $keep_temp[] = $dummy; |
| 1500 | - else |
|
| 1501 | - $keep_ids[] = (int) $dummy; |
|
| 1566 | + } |
|
| 1567 | + else { |
|
| 1568 | + $keep_ids[] = (int) $dummy; |
|
| 1569 | + } |
|
| 1502 | 1570 | |
| 1503 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1504 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1571 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1572 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1505 | 1573 | { |
| 1506 | 1574 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1507 | 1575 | continue; |
| 1576 | + } |
|
| 1508 | 1577 | |
| 1509 | 1578 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1510 | 1579 | unlink($attachment['tmp_name']); |
@@ -1536,8 +1605,9 @@ discard block |
||
| 1536 | 1605 | { |
| 1537 | 1606 | require_once($sourcedir . '/ManageAttachments.php'); |
| 1538 | 1607 | |
| 1539 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 1540 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 1608 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 1609 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 1610 | + } |
|
| 1541 | 1611 | |
| 1542 | 1612 | unset($_SESSION['already_attached']); |
| 1543 | 1613 | |
@@ -1560,12 +1630,14 @@ discard block |
||
| 1560 | 1630 | $smcFunc['db_free_result']($request); |
| 1561 | 1631 | |
| 1562 | 1632 | // Though the topic should be there, it might have vanished. |
| 1563 | - if (!is_array($topic_info)) |
|
| 1564 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1633 | + if (!is_array($topic_info)) { |
|
| 1634 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1635 | + } |
|
| 1565 | 1636 | |
| 1566 | 1637 | // Did this topic suddenly move? Just checking... |
| 1567 | - if ($topic_info['id_board'] != $board) |
|
| 1568 | - fatal_lang_error('not_a_topic'); |
|
| 1638 | + if ($topic_info['id_board'] != $board) { |
|
| 1639 | + fatal_lang_error('not_a_topic'); |
|
| 1640 | + } |
|
| 1569 | 1641 | |
| 1570 | 1642 | // Do the permissions and approval stuff... |
| 1571 | 1643 | $becomesApproved = true; |
@@ -1588,49 +1660,50 @@ discard block |
||
| 1588 | 1660 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1589 | 1661 | { |
| 1590 | 1662 | // Don't allow a post if it's locked. |
| 1591 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1592 | - fatal_lang_error('topic_locked', false); |
|
| 1663 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1664 | + fatal_lang_error('topic_locked', false); |
|
| 1665 | + } |
|
| 1593 | 1666 | |
| 1594 | 1667 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1595 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1596 | - unset($_REQUEST['poll']); |
|
| 1597 | - |
|
| 1598 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1599 | - { |
|
| 1600 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1601 | - $becomesApproved = false; |
|
| 1602 | - |
|
| 1603 | - else |
|
| 1604 | - isAllowedTo('post_reply_any'); |
|
| 1605 | - } |
|
| 1606 | - elseif (!allowedTo('post_reply_any')) |
|
| 1668 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1669 | + unset($_REQUEST['poll']); |
|
| 1670 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1671 | + { |
|
| 1672 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1673 | + $becomesApproved = false; |
|
| 1674 | + } else { |
|
| 1675 | + isAllowedTo('post_reply_any'); |
|
| 1676 | + } |
|
| 1677 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1607 | 1678 | { |
| 1608 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1609 | - $becomesApproved = false; |
|
| 1610 | - |
|
| 1611 | - else |
|
| 1612 | - isAllowedTo('post_reply_own'); |
|
| 1679 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1680 | + $becomesApproved = false; |
|
| 1681 | + } else { |
|
| 1682 | + isAllowedTo('post_reply_own'); |
|
| 1683 | + } |
|
| 1613 | 1684 | } |
| 1614 | 1685 | |
| 1615 | 1686 | if (isset($_POST['lock'])) |
| 1616 | 1687 | { |
| 1617 | 1688 | // Nothing is changed to the lock. |
| 1618 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
| 1619 | - unset($_POST['lock']); |
|
| 1689 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
| 1690 | + unset($_POST['lock']); |
|
| 1691 | + } |
|
| 1620 | 1692 | |
| 1621 | 1693 | // You're have no permission to lock this topic. |
| 1622 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1623 | - unset($_POST['lock']); |
|
| 1694 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1695 | + unset($_POST['lock']); |
|
| 1696 | + } |
|
| 1624 | 1697 | |
| 1625 | 1698 | // You are allowed to (un)lock your own topic only. |
| 1626 | 1699 | elseif (!allowedTo('lock_any')) |
| 1627 | 1700 | { |
| 1628 | 1701 | // You cannot override a moderator lock. |
| 1629 | - if ($topic_info['locked'] == 1) |
|
| 1630 | - unset($_POST['lock']); |
|
| 1631 | - |
|
| 1632 | - else |
|
| 1633 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1702 | + if ($topic_info['locked'] == 1) { |
|
| 1703 | + unset($_POST['lock']); |
|
| 1704 | + } else { |
|
| 1705 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1706 | + } |
|
| 1634 | 1707 | } |
| 1635 | 1708 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1636 | 1709 | else |
@@ -1638,19 +1711,21 @@ discard block |
||
| 1638 | 1711 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1639 | 1712 | |
| 1640 | 1713 | // Did someone (un)lock this while you were posting? |
| 1641 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1642 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1714 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1715 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1716 | + } |
|
| 1643 | 1717 | } |
| 1644 | 1718 | } |
| 1645 | 1719 | |
| 1646 | 1720 | // So you wanna (un)sticky this...let's see. |
| 1647 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1648 | - unset($_POST['sticky']); |
|
| 1649 | - elseif (isset($_POST['sticky'])) |
|
| 1721 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1722 | + unset($_POST['sticky']); |
|
| 1723 | + } elseif (isset($_POST['sticky'])) |
|
| 1650 | 1724 | { |
| 1651 | 1725 | // Did someone (un)sticky this while you were posting? |
| 1652 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1653 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1726 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1727 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1728 | + } |
|
| 1654 | 1729 | } |
| 1655 | 1730 | |
| 1656 | 1731 | // If drafts are enabled, then pass this off |
@@ -1677,26 +1752,31 @@ discard block |
||
| 1677 | 1752 | |
| 1678 | 1753 | // Do like, the permissions, for safety and stuff... |
| 1679 | 1754 | $becomesApproved = true; |
| 1680 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1681 | - $becomesApproved = false; |
|
| 1682 | - else |
|
| 1683 | - isAllowedTo('post_new'); |
|
| 1755 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1756 | + $becomesApproved = false; |
|
| 1757 | + } else { |
|
| 1758 | + isAllowedTo('post_new'); |
|
| 1759 | + } |
|
| 1684 | 1760 | |
| 1685 | 1761 | if (isset($_POST['lock'])) |
| 1686 | 1762 | { |
| 1687 | 1763 | // New topics are by default not locked. |
| 1688 | - if (empty($_POST['lock'])) |
|
| 1689 | - unset($_POST['lock']); |
|
| 1764 | + if (empty($_POST['lock'])) { |
|
| 1765 | + unset($_POST['lock']); |
|
| 1766 | + } |
|
| 1690 | 1767 | // Besides, you need permission. |
| 1691 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1692 | - unset($_POST['lock']); |
|
| 1768 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1769 | + unset($_POST['lock']); |
|
| 1770 | + } |
|
| 1693 | 1771 | // A moderator-lock (1) can override a user-lock (2). |
| 1694 | - else |
|
| 1695 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1772 | + else { |
|
| 1773 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1774 | + } |
|
| 1696 | 1775 | } |
| 1697 | 1776 | |
| 1698 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1699 | - unset($_POST['sticky']); |
|
| 1777 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1778 | + unset($_POST['sticky']); |
|
| 1779 | + } |
|
| 1700 | 1780 | |
| 1701 | 1781 | // Saving your new topic as a draft first? |
| 1702 | 1782 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1721,31 +1801,37 @@ discard block |
||
| 1721 | 1801 | 'id_msg' => $_REQUEST['msg'], |
| 1722 | 1802 | ) |
| 1723 | 1803 | ); |
| 1724 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1725 | - fatal_lang_error('cant_find_messages', false); |
|
| 1804 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1805 | + fatal_lang_error('cant_find_messages', false); |
|
| 1806 | + } |
|
| 1726 | 1807 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1727 | 1808 | $smcFunc['db_free_result']($request); |
| 1728 | 1809 | |
| 1729 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1730 | - fatal_lang_error('topic_locked', false); |
|
| 1810 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1811 | + fatal_lang_error('topic_locked', false); |
|
| 1812 | + } |
|
| 1731 | 1813 | |
| 1732 | 1814 | if (isset($_POST['lock'])) |
| 1733 | 1815 | { |
| 1734 | 1816 | // Nothing changes to the lock status. |
| 1735 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1736 | - unset($_POST['lock']); |
|
| 1817 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1818 | + unset($_POST['lock']); |
|
| 1819 | + } |
|
| 1737 | 1820 | // You're simply not allowed to (un)lock this. |
| 1738 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1739 | - unset($_POST['lock']); |
|
| 1821 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1822 | + unset($_POST['lock']); |
|
| 1823 | + } |
|
| 1740 | 1824 | // You're only allowed to lock your own topics. |
| 1741 | 1825 | elseif (!allowedTo('lock_any')) |
| 1742 | 1826 | { |
| 1743 | 1827 | // You're not allowed to break a moderator's lock. |
| 1744 | - if ($topic_info['locked'] == 1) |
|
| 1745 | - unset($_POST['lock']); |
|
| 1828 | + if ($topic_info['locked'] == 1) { |
|
| 1829 | + unset($_POST['lock']); |
|
| 1830 | + } |
|
| 1746 | 1831 | // Lock it with a soft lock or unlock it. |
| 1747 | - else |
|
| 1748 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1832 | + else { |
|
| 1833 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1834 | + } |
|
| 1749 | 1835 | } |
| 1750 | 1836 | // You must be the moderator. |
| 1751 | 1837 | else |
@@ -1753,44 +1839,46 @@ discard block |
||
| 1753 | 1839 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1754 | 1840 | |
| 1755 | 1841 | // Did someone (un)lock this while you were posting? |
| 1756 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1757 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1842 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1843 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1844 | + } |
|
| 1758 | 1845 | } |
| 1759 | 1846 | } |
| 1760 | 1847 | |
| 1761 | 1848 | // Change the sticky status of this topic? |
| 1762 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1763 | - unset($_POST['sticky']); |
|
| 1764 | - elseif (isset($_POST['sticky'])) |
|
| 1849 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1850 | + unset($_POST['sticky']); |
|
| 1851 | + } elseif (isset($_POST['sticky'])) |
|
| 1765 | 1852 | { |
| 1766 | 1853 | // Did someone (un)sticky this while you were posting? |
| 1767 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1768 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1854 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1855 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1856 | + } |
|
| 1769 | 1857 | } |
| 1770 | 1858 | |
| 1771 | 1859 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1772 | 1860 | { |
| 1773 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1774 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1775 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1776 | - isAllowedTo('modify_replies'); |
|
| 1777 | - else |
|
| 1778 | - isAllowedTo('modify_own'); |
|
| 1779 | - } |
|
| 1780 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1861 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1862 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1863 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1864 | + isAllowedTo('modify_replies'); |
|
| 1865 | + } else { |
|
| 1866 | + isAllowedTo('modify_own'); |
|
| 1867 | + } |
|
| 1868 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1781 | 1869 | { |
| 1782 | 1870 | isAllowedTo('modify_replies'); |
| 1783 | 1871 | |
| 1784 | 1872 | // If you're modifying a reply, I say it better be logged... |
| 1785 | 1873 | $moderationAction = true; |
| 1786 | - } |
|
| 1787 | - else |
|
| 1874 | + } else |
|
| 1788 | 1875 | { |
| 1789 | 1876 | isAllowedTo('modify_any'); |
| 1790 | 1877 | |
| 1791 | 1878 | // Log it, assuming you're not modifying your own post. |
| 1792 | - if ($row['id_member'] != $user_info['id']) |
|
| 1793 | - $moderationAction = true; |
|
| 1879 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1880 | + $moderationAction = true; |
|
| 1881 | + } |
|
| 1794 | 1882 | } |
| 1795 | 1883 | |
| 1796 | 1884 | // If drafts are enabled, then lets send this off to save |
@@ -1817,8 +1905,9 @@ discard block |
||
| 1817 | 1905 | // Update search api |
| 1818 | 1906 | require_once($sourcedir . '/Search.php'); |
| 1819 | 1907 | $searchAPI = findSearchAPI(); |
| 1820 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
| 1821 | - $searchAPI->postRemoved($_REQUEST['msg']); |
|
| 1908 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
| 1909 | + $searchAPI->postRemoved($_REQUEST['msg']); |
|
| 1910 | + } |
|
| 1822 | 1911 | |
| 1823 | 1912 | } |
| 1824 | 1913 | |
@@ -1836,20 +1925,24 @@ discard block |
||
| 1836 | 1925 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1837 | 1926 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1838 | 1927 | |
| 1839 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1840 | - $post_errors[] = 'no_name'; |
|
| 1841 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1842 | - $post_errors[] = 'long_name'; |
|
| 1928 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1929 | + $post_errors[] = 'no_name'; |
|
| 1930 | + } |
|
| 1931 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1932 | + $post_errors[] = 'long_name'; |
|
| 1933 | + } |
|
| 1843 | 1934 | |
| 1844 | 1935 | if (empty($modSettings['guest_post_no_email'])) |
| 1845 | 1936 | { |
| 1846 | 1937 | // Only check if they changed it! |
| 1847 | 1938 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1848 | 1939 | { |
| 1849 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1850 | - $post_errors[] = 'no_email'; |
|
| 1851 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1852 | - $post_errors[] = 'bad_email'; |
|
| 1940 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1941 | + $post_errors[] = 'no_email'; |
|
| 1942 | + } |
|
| 1943 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1944 | + $post_errors[] = 'bad_email'; |
|
| 1945 | + } |
|
| 1853 | 1946 | } |
| 1854 | 1947 | |
| 1855 | 1948 | // Now make sure this email address is not banned from posting. |
@@ -1865,76 +1958,90 @@ discard block |
||
| 1865 | 1958 | } |
| 1866 | 1959 | |
| 1867 | 1960 | // Coming from the quickReply? |
| 1868 | - if (isset($_POST['quickReply'])) |
|
| 1869 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1961 | + if (isset($_POST['quickReply'])) { |
|
| 1962 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1963 | + } |
|
| 1870 | 1964 | |
| 1871 | 1965 | // Check the subject and message. |
| 1872 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1873 | - $post_errors[] = 'no_subject'; |
|
| 1874 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1875 | - $post_errors[] = 'no_message'; |
|
| 1876 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1877 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1878 | - else |
|
| 1966 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1967 | + $post_errors[] = 'no_subject'; |
|
| 1968 | + } |
|
| 1969 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1970 | + $post_errors[] = 'no_message'; |
|
| 1971 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1972 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1973 | + } else |
|
| 1879 | 1974 | { |
| 1880 | 1975 | // Prepare the message a bit for some additional testing. |
| 1881 | 1976 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1882 | 1977 | |
| 1883 | 1978 | // Preparse code. (Zef) |
| 1884 | - if ($user_info['is_guest']) |
|
| 1885 | - $user_info['name'] = $_POST['guestname']; |
|
| 1979 | + if ($user_info['is_guest']) { |
|
| 1980 | + $user_info['name'] = $_POST['guestname']; |
|
| 1981 | + } |
|
| 1886 | 1982 | preparsecode($_POST['message']); |
| 1887 | 1983 | |
| 1888 | 1984 | // Let's see if there's still some content left without the tags. |
| 1889 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1890 | - $post_errors[] = 'no_message'; |
|
| 1985 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1986 | + $post_errors[] = 'no_message'; |
|
| 1987 | + } |
|
| 1891 | 1988 | |
| 1892 | 1989 | } |
| 1893 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1894 | - $post_errors[] = 'no_event'; |
|
| 1990 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1991 | + $post_errors[] = 'no_event'; |
|
| 1992 | + } |
|
| 1895 | 1993 | // You are not! |
| 1896 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1897 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1994 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1995 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1996 | + } |
|
| 1898 | 1997 | |
| 1899 | 1998 | // Validate the poll... |
| 1900 | 1999 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1901 | 2000 | { |
| 1902 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1903 | - fatal_lang_error('no_access', false); |
|
| 2001 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 2002 | + fatal_lang_error('no_access', false); |
|
| 2003 | + } |
|
| 1904 | 2004 | |
| 1905 | 2005 | // This is a new topic... so it's a new poll. |
| 1906 | - if (empty($topic)) |
|
| 1907 | - isAllowedTo('poll_post'); |
|
| 2006 | + if (empty($topic)) { |
|
| 2007 | + isAllowedTo('poll_post'); |
|
| 2008 | + } |
|
| 1908 | 2009 | // Can you add to your own topics? |
| 1909 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1910 | - isAllowedTo('poll_add_own'); |
|
| 2010 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 2011 | + isAllowedTo('poll_add_own'); |
|
| 2012 | + } |
|
| 1911 | 2013 | // Can you add polls to any topic, then? |
| 1912 | - else |
|
| 1913 | - isAllowedTo('poll_add_any'); |
|
| 2014 | + else { |
|
| 2015 | + isAllowedTo('poll_add_any'); |
|
| 2016 | + } |
|
| 1914 | 2017 | |
| 1915 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1916 | - $post_errors[] = 'no_question'; |
|
| 2018 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 2019 | + $post_errors[] = 'no_question'; |
|
| 2020 | + } |
|
| 1917 | 2021 | |
| 1918 | 2022 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1919 | 2023 | |
| 1920 | 2024 | // Get rid of empty ones. |
| 1921 | - foreach ($_POST['options'] as $k => $option) |
|
| 1922 | - if ($option == '') |
|
| 2025 | + foreach ($_POST['options'] as $k => $option) { |
|
| 2026 | + if ($option == '') |
|
| 1923 | 2027 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 2028 | + } |
|
| 1924 | 2029 | |
| 1925 | 2030 | // What are you going to vote between with one choice?!? |
| 1926 | - if (count($_POST['options']) < 2) |
|
| 1927 | - $post_errors[] = 'poll_few'; |
|
| 1928 | - elseif (count($_POST['options']) > 256) |
|
| 1929 | - $post_errors[] = 'poll_many'; |
|
| 2031 | + if (count($_POST['options']) < 2) { |
|
| 2032 | + $post_errors[] = 'poll_few'; |
|
| 2033 | + } elseif (count($_POST['options']) > 256) { |
|
| 2034 | + $post_errors[] = 'poll_many'; |
|
| 2035 | + } |
|
| 1930 | 2036 | } |
| 1931 | 2037 | |
| 1932 | 2038 | if ($posterIsGuest) |
| 1933 | 2039 | { |
| 1934 | 2040 | // If user is a guest, make sure the chosen name isn't taken. |
| 1935 | 2041 | require_once($sourcedir . '/Subs-Members.php'); |
| 1936 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1937 | - $post_errors[] = 'bad_name'; |
|
| 2042 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 2043 | + $post_errors[] = 'bad_name'; |
|
| 2044 | + } |
|
| 1938 | 2045 | } |
| 1939 | 2046 | // If the user isn't a guest, get his or her name and email. |
| 1940 | 2047 | elseif (!isset($_REQUEST['msg'])) |
@@ -1965,8 +2072,9 @@ discard block |
||
| 1965 | 2072 | } |
| 1966 | 2073 | |
| 1967 | 2074 | // Make sure the user isn't spamming the board. |
| 1968 | - if (!isset($_REQUEST['msg'])) |
|
| 1969 | - spamProtection('post'); |
|
| 2075 | + if (!isset($_REQUEST['msg'])) { |
|
| 2076 | + spamProtection('post'); |
|
| 2077 | + } |
|
| 1970 | 2078 | |
| 1971 | 2079 | // At about this point, we're posting and that's that. |
| 1972 | 2080 | ignore_user_abort(true); |
@@ -1979,32 +2087,36 @@ discard block |
||
| 1979 | 2087 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1980 | 2088 | |
| 1981 | 2089 | // At this point, we want to make sure the subject isn't too long. |
| 1982 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1983 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2090 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2091 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2092 | + } |
|
| 1984 | 2093 | |
| 1985 | 2094 | // Same with the "why did you edit this" text. |
| 1986 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1987 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2095 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2096 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2097 | + } |
|
| 1988 | 2098 | |
| 1989 | 2099 | // Make the poll... |
| 1990 | 2100 | if (isset($_REQUEST['poll'])) |
| 1991 | 2101 | { |
| 1992 | 2102 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1993 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1994 | - $_POST['poll_max_votes'] = 1; |
|
| 1995 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1996 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1997 | - else |
|
| 1998 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2103 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 2104 | + $_POST['poll_max_votes'] = 1; |
|
| 2105 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 2106 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 2107 | + } else { |
|
| 2108 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2109 | + } |
|
| 1999 | 2110 | |
| 2000 | 2111 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 2001 | 2112 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 2002 | 2113 | |
| 2003 | 2114 | // Just set it to zero if it's not there.. |
| 2004 | - if (!isset($_POST['poll_hide'])) |
|
| 2005 | - $_POST['poll_hide'] = 0; |
|
| 2006 | - else |
|
| 2007 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2115 | + if (!isset($_POST['poll_hide'])) { |
|
| 2116 | + $_POST['poll_hide'] = 0; |
|
| 2117 | + } else { |
|
| 2118 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2119 | + } |
|
| 2008 | 2120 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 2009 | 2121 | |
| 2010 | 2122 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -2013,16 +2125,19 @@ discard block |
||
| 2013 | 2125 | { |
| 2014 | 2126 | require_once($sourcedir . '/Subs-Members.php'); |
| 2015 | 2127 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 2016 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 2017 | - $_POST['poll_guest_vote'] = 0; |
|
| 2128 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2129 | + $_POST['poll_guest_vote'] = 0; |
|
| 2130 | + } |
|
| 2018 | 2131 | } |
| 2019 | 2132 | |
| 2020 | 2133 | // If the user tries to set the poll too far in advance, don't let them. |
| 2021 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 2022 | - fatal_lang_error('poll_range_error', false); |
|
| 2134 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2135 | + fatal_lang_error('poll_range_error', false); |
|
| 2136 | + } |
|
| 2023 | 2137 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 2024 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 2025 | - $_POST['poll_hide'] = 1; |
|
| 2138 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2139 | + $_POST['poll_hide'] = 1; |
|
| 2140 | + } |
|
| 2026 | 2141 | |
| 2027 | 2142 | // Clean up the question and answers. |
| 2028 | 2143 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -2036,13 +2151,15 @@ discard block |
||
| 2036 | 2151 | { |
| 2037 | 2152 | $attachIDs = array(); |
| 2038 | 2153 | $attach_errors = array(); |
| 2039 | - if (!empty($context['we_are_history'])) |
|
| 2040 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2154 | + if (!empty($context['we_are_history'])) { |
|
| 2155 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2156 | + } |
|
| 2041 | 2157 | |
| 2042 | 2158 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 2043 | 2159 | { |
| 2044 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 2045 | - continue; |
|
| 2160 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2161 | + continue; |
|
| 2162 | + } |
|
| 2046 | 2163 | |
| 2047 | 2164 | // If there was an initial error just show that message. |
| 2048 | 2165 | if ($attachID == 'initial_error') |
@@ -2071,12 +2188,13 @@ discard block |
||
| 2071 | 2188 | if (createAttachment($attachmentOptions)) |
| 2072 | 2189 | { |
| 2073 | 2190 | $attachIDs[] = $attachmentOptions['id']; |
| 2074 | - if (!empty($attachmentOptions['thumb'])) |
|
| 2075 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2191 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2192 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2193 | + } |
|
| 2076 | 2194 | } |
| 2195 | + } else { |
|
| 2196 | + $attach_errors[] = '<dt> </dt>'; |
|
| 2077 | 2197 | } |
| 2078 | - else |
|
| 2079 | - $attach_errors[] = '<dt> </dt>'; |
|
| 2080 | 2198 | |
| 2081 | 2199 | if (!empty($attachmentOptions['errors'])) |
| 2082 | 2200 | { |
@@ -2088,14 +2206,16 @@ discard block |
||
| 2088 | 2206 | if (!is_array($error)) |
| 2089 | 2207 | { |
| 2090 | 2208 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 2091 | - if (in_array($error, $log_these)) |
|
| 2092 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2209 | + if (in_array($error, $log_these)) { |
|
| 2210 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2211 | + } |
|
| 2212 | + } else { |
|
| 2213 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2093 | 2214 | } |
| 2094 | - else |
|
| 2095 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2096 | 2215 | } |
| 2097 | - if (file_exists($attachment['tmp_name'])) |
|
| 2098 | - unlink($attachment['tmp_name']); |
|
| 2216 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2217 | + unlink($attachment['tmp_name']); |
|
| 2218 | + } |
|
| 2099 | 2219 | } |
| 2100 | 2220 | } |
| 2101 | 2221 | unset($_SESSION['temp_attachments']); |
@@ -2136,24 +2256,24 @@ discard block |
||
| 2136 | 2256 | ); |
| 2137 | 2257 | |
| 2138 | 2258 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2259 | + } else { |
|
| 2260 | + $id_poll = 0; |
|
| 2139 | 2261 | } |
| 2140 | - else |
|
| 2141 | - $id_poll = 0; |
|
| 2142 | 2262 | |
| 2143 | 2263 | // Creating a new topic? |
| 2144 | 2264 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2145 | 2265 | |
| 2146 | 2266 | // Check the icon. |
| 2147 | - if (!isset($_POST['icon'])) |
|
| 2148 | - $_POST['icon'] = 'xx'; |
|
| 2149 | - |
|
| 2150 | - else |
|
| 2267 | + if (!isset($_POST['icon'])) { |
|
| 2268 | + $_POST['icon'] = 'xx'; |
|
| 2269 | + } else |
|
| 2151 | 2270 | { |
| 2152 | 2271 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2153 | 2272 | |
| 2154 | 2273 | // Need to figure it out if this is a valid icon name. |
| 2155 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2156 | - $_POST['icon'] = 'xx'; |
|
| 2274 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2275 | + $_POST['icon'] = 'xx'; |
|
| 2276 | + } |
|
| 2157 | 2277 | } |
| 2158 | 2278 | |
| 2159 | 2279 | // Collect all parameters for the creation or modification of a post. |
@@ -2194,8 +2314,9 @@ discard block |
||
| 2194 | 2314 | } |
| 2195 | 2315 | |
| 2196 | 2316 | // This will save some time... |
| 2197 | - if (empty($approve_has_changed)) |
|
| 2198 | - unset($msgOptions['approved']); |
|
| 2317 | + if (empty($approve_has_changed)) { |
|
| 2318 | + unset($msgOptions['approved']); |
|
| 2319 | + } |
|
| 2199 | 2320 | |
| 2200 | 2321 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2201 | 2322 | } |
@@ -2204,8 +2325,9 @@ discard block |
||
| 2204 | 2325 | { |
| 2205 | 2326 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2206 | 2327 | |
| 2207 | - if (isset($topicOptions['id'])) |
|
| 2208 | - $topic = $topicOptions['id']; |
|
| 2328 | + if (isset($topicOptions['id'])) { |
|
| 2329 | + $topic = $topicOptions['id']; |
|
| 2330 | + } |
|
| 2209 | 2331 | } |
| 2210 | 2332 | |
| 2211 | 2333 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2217,8 +2339,9 @@ discard block |
||
| 2217 | 2339 | } |
| 2218 | 2340 | |
| 2219 | 2341 | // If we had a draft for this, its time to remove it since it was just posted |
| 2220 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2221 | - DeleteDraft($_POST['id_draft']); |
|
| 2342 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2343 | + DeleteDraft($_POST['id_draft']); |
|
| 2344 | + } |
|
| 2222 | 2345 | |
| 2223 | 2346 | // Editing or posting an event? |
| 2224 | 2347 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2237,8 +2360,7 @@ discard block |
||
| 2237 | 2360 | 'member' => $user_info['id'], |
| 2238 | 2361 | ); |
| 2239 | 2362 | insertEvent($eventOptions); |
| 2240 | - } |
|
| 2241 | - elseif (isset($_POST['calendar'])) |
|
| 2363 | + } elseif (isset($_POST['calendar'])) |
|
| 2242 | 2364 | { |
| 2243 | 2365 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2244 | 2366 | |
@@ -2266,14 +2388,15 @@ discard block |
||
| 2266 | 2388 | } |
| 2267 | 2389 | |
| 2268 | 2390 | // Delete it? |
| 2269 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2270 | - $smcFunc['db_query']('', ' |
|
| 2391 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2392 | + $smcFunc['db_query']('', ' |
|
| 2271 | 2393 | DELETE FROM {db_prefix}calendar |
| 2272 | 2394 | WHERE id_event = {int:id_event}', |
| 2273 | 2395 | array( |
| 2274 | 2396 | 'id_event' => $_REQUEST['eventid'], |
| 2275 | 2397 | ) |
| 2276 | 2398 | ); |
| 2399 | + } |
|
| 2277 | 2400 | // ... or just update it? |
| 2278 | 2401 | else |
| 2279 | 2402 | { |
@@ -2315,9 +2438,8 @@ discard block |
||
| 2315 | 2438 | array($user_info['id'], $topic, 0), |
| 2316 | 2439 | array('id_member', 'id_topic', 'id_board') |
| 2317 | 2440 | ); |
| 2318 | - } |
|
| 2319 | - elseif (!$newTopic) |
|
| 2320 | - $smcFunc['db_query']('', ' |
|
| 2441 | + } elseif (!$newTopic) { |
|
| 2442 | + $smcFunc['db_query']('', ' |
|
| 2321 | 2443 | DELETE FROM {db_prefix}log_notify |
| 2322 | 2444 | WHERE id_member = {int:current_member} |
| 2323 | 2445 | AND id_topic = {int:current_topic}', |
@@ -2326,16 +2448,20 @@ discard block |
||
| 2326 | 2448 | 'current_topic' => $topic, |
| 2327 | 2449 | ) |
| 2328 | 2450 | ); |
| 2451 | + } |
|
| 2329 | 2452 | |
| 2330 | 2453 | // Log an act of moderation - modifying. |
| 2331 | - if (!empty($moderationAction)) |
|
| 2332 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2454 | + if (!empty($moderationAction)) { |
|
| 2455 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2456 | + } |
|
| 2333 | 2457 | |
| 2334 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2335 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2458 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2459 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2460 | + } |
|
| 2336 | 2461 | |
| 2337 | - if (isset($_POST['sticky'])) |
|
| 2338 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2462 | + if (isset($_POST['sticky'])) { |
|
| 2463 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2464 | + } |
|
| 2339 | 2465 | |
| 2340 | 2466 | // Returning to the topic? |
| 2341 | 2467 | if (!empty($_REQUEST['goback'])) |
@@ -2354,26 +2480,31 @@ discard block |
||
| 2354 | 2480 | ); |
| 2355 | 2481 | } |
| 2356 | 2482 | |
| 2357 | - if ($board_info['num_topics'] == 0) |
|
| 2358 | - cache_put_data('board-' . $board, null, 120); |
|
| 2483 | + if ($board_info['num_topics'] == 0) { |
|
| 2484 | + cache_put_data('board-' . $board, null, 120); |
|
| 2485 | + } |
|
| 2359 | 2486 | |
| 2360 | 2487 | call_integration_hook('integrate_post2_end'); |
| 2361 | 2488 | |
| 2362 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
| 2363 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2489 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
| 2490 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2491 | + } |
|
| 2364 | 2492 | |
| 2365 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2366 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2493 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2494 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2495 | + } |
|
| 2367 | 2496 | |
| 2368 | 2497 | // Return to post if the mod is on. |
| 2369 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2370 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2371 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2372 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2498 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2499 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2500 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2501 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2502 | + } |
|
| 2373 | 2503 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2374 | - else |
|
| 2375 | - redirectexit('board=' . $board . '.0'); |
|
| 2376 | -} |
|
| 2504 | + else { |
|
| 2505 | + redirectexit('board=' . $board . '.0'); |
|
| 2506 | + } |
|
| 2507 | + } |
|
| 2377 | 2508 | |
| 2378 | 2509 | /** |
| 2379 | 2510 | * Handle the announce topic function (action=announce). |
@@ -2391,8 +2522,9 @@ discard block |
||
| 2391 | 2522 | |
| 2392 | 2523 | validateSession(); |
| 2393 | 2524 | |
| 2394 | - if (empty($topic)) |
|
| 2395 | - fatal_lang_error('topic_gone', false); |
|
| 2525 | + if (empty($topic)) { |
|
| 2526 | + fatal_lang_error('topic_gone', false); |
|
| 2527 | + } |
|
| 2396 | 2528 | |
| 2397 | 2529 | loadLanguage('Post'); |
| 2398 | 2530 | loadTemplate('Post'); |
@@ -2419,8 +2551,9 @@ discard block |
||
| 2419 | 2551 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2420 | 2552 | |
| 2421 | 2553 | $groups = array_merge($board_info['groups'], array(1)); |
| 2422 | - foreach ($groups as $id => $group) |
|
| 2423 | - $groups[$id] = (int) $group; |
|
| 2554 | + foreach ($groups as $id => $group) { |
|
| 2555 | + $groups[$id] = (int) $group; |
|
| 2556 | + } |
|
| 2424 | 2557 | |
| 2425 | 2558 | $context['groups'] = array(); |
| 2426 | 2559 | if (in_array(0, $groups)) |
@@ -2463,8 +2596,9 @@ discard block |
||
| 2463 | 2596 | 'group_list' => $groups, |
| 2464 | 2597 | ) |
| 2465 | 2598 | ); |
| 2466 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2467 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2600 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2601 | + } |
|
| 2468 | 2602 | $smcFunc['db_free_result']($request); |
| 2469 | 2603 | |
| 2470 | 2604 | // Get the subject of the topic we're about to announce. |
@@ -2506,16 +2640,19 @@ discard block |
||
| 2506 | 2640 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2507 | 2641 | $groups = array_merge($board_info['groups'], array(1)); |
| 2508 | 2642 | |
| 2509 | - if (isset($_POST['membergroups'])) |
|
| 2510 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2643 | + if (isset($_POST['membergroups'])) { |
|
| 2644 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2645 | + } |
|
| 2511 | 2646 | |
| 2512 | 2647 | // Check whether at least one membergroup was selected. |
| 2513 | - if (empty($_POST['who'])) |
|
| 2514 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2648 | + if (empty($_POST['who'])) { |
|
| 2649 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2650 | + } |
|
| 2515 | 2651 | |
| 2516 | 2652 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2517 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2518 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2653 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2654 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2655 | + } |
|
| 2519 | 2656 | |
| 2520 | 2657 | // Get the topic subject and censor it. |
| 2521 | 2658 | $request = $smcFunc['db_query']('', ' |
@@ -2561,12 +2698,13 @@ discard block |
||
| 2561 | 2698 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2562 | 2699 | { |
| 2563 | 2700 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2564 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2565 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2566 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2567 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2568 | - else |
|
| 2569 | - redirectexit('board=' . $board . '.0'); |
|
| 2701 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2702 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2703 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2704 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2705 | + } else { |
|
| 2706 | + redirectexit('board=' . $board . '.0'); |
|
| 2707 | + } |
|
| 2570 | 2708 | } |
| 2571 | 2709 | |
| 2572 | 2710 | $announcements = array(); |
@@ -2585,8 +2723,9 @@ discard block |
||
| 2585 | 2723 | foreach ($rows as $row) |
| 2586 | 2724 | { |
| 2587 | 2725 | // Force them to have it? |
| 2588 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2589 | - continue; |
|
| 2726 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2727 | + continue; |
|
| 2728 | + } |
|
| 2590 | 2729 | |
| 2591 | 2730 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2592 | 2731 | |
@@ -2614,8 +2753,9 @@ discard block |
||
| 2614 | 2753 | } |
| 2615 | 2754 | |
| 2616 | 2755 | // For each language send a different mail - low priority... |
| 2617 | - foreach ($announcements as $lang => $mail) |
|
| 2618 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2756 | + foreach ($announcements as $lang => $mail) { |
|
| 2757 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2758 | + } |
|
| 2619 | 2759 | |
| 2620 | 2760 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2621 | 2761 | |
@@ -2625,9 +2765,10 @@ discard block |
||
| 2625 | 2765 | $context['sub_template'] = 'announcement_send'; |
| 2626 | 2766 | |
| 2627 | 2767 | // Go back to the correct language for the user ;). |
| 2628 | - if (!empty($modSettings['userLanguage'])) |
|
| 2629 | - loadLanguage('Post'); |
|
| 2630 | -} |
|
| 2768 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2769 | + loadLanguage('Post'); |
|
| 2770 | + } |
|
| 2771 | + } |
|
| 2631 | 2772 | |
| 2632 | 2773 | /** |
| 2633 | 2774 | * Get the topic for display purposes. |
@@ -2640,12 +2781,13 @@ discard block |
||
| 2640 | 2781 | { |
| 2641 | 2782 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2642 | 2783 | |
| 2643 | - if (isset($_REQUEST['xml'])) |
|
| 2644 | - $limit = ' |
|
| 2784 | + if (isset($_REQUEST['xml'])) { |
|
| 2785 | + $limit = ' |
|
| 2645 | 2786 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2646 | - else |
|
| 2647 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2787 | + } else { |
|
| 2788 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2648 | 2789 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2790 | + } |
|
| 2649 | 2791 | |
| 2650 | 2792 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2651 | 2793 | $request = $smcFunc['db_query']('', ' |
@@ -2683,8 +2825,9 @@ discard block |
||
| 2683 | 2825 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2684 | 2826 | ); |
| 2685 | 2827 | |
| 2686 | - if (!empty($context['new_replies'])) |
|
| 2687 | - $context['new_replies']--; |
|
| 2828 | + if (!empty($context['new_replies'])) { |
|
| 2829 | + $context['new_replies']--; |
|
| 2830 | + } |
|
| 2688 | 2831 | } |
| 2689 | 2832 | $smcFunc['db_free_result']($request); |
| 2690 | 2833 | } |
@@ -2701,8 +2844,9 @@ discard block |
||
| 2701 | 2844 | global $sourcedir, $smcFunc; |
| 2702 | 2845 | |
| 2703 | 2846 | loadLanguage('Post'); |
| 2704 | - if (!isset($_REQUEST['xml'])) |
|
| 2705 | - loadTemplate('Post'); |
|
| 2847 | + if (!isset($_REQUEST['xml'])) { |
|
| 2848 | + loadTemplate('Post'); |
|
| 2849 | + } |
|
| 2706 | 2850 | |
| 2707 | 2851 | include_once($sourcedir . '/Subs-Post.php'); |
| 2708 | 2852 | |
@@ -2733,8 +2877,9 @@ discard block |
||
| 2733 | 2877 | $smcFunc['db_free_result']($request); |
| 2734 | 2878 | |
| 2735 | 2879 | $context['sub_template'] = 'quotefast'; |
| 2736 | - if (!empty($row)) |
|
| 2737 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2880 | + if (!empty($row)) { |
|
| 2881 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2882 | + } |
|
| 2738 | 2883 | |
| 2739 | 2884 | if (!empty($can_view_post)) |
| 2740 | 2885 | { |
@@ -2767,8 +2912,9 @@ discard block |
||
| 2767 | 2912 | } |
| 2768 | 2913 | |
| 2769 | 2914 | // Remove any nested quotes. |
| 2770 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2771 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2915 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2916 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2917 | + } |
|
| 2772 | 2918 | |
| 2773 | 2919 | $lb = "\n"; |
| 2774 | 2920 | |
@@ -2794,14 +2940,14 @@ discard block |
||
| 2794 | 2940 | 'time' => '', |
| 2795 | 2941 | ), |
| 2796 | 2942 | ); |
| 2797 | - } |
|
| 2798 | - else |
|
| 2799 | - $context['quote'] = array( |
|
| 2943 | + } else { |
|
| 2944 | + $context['quote'] = array( |
|
| 2800 | 2945 | 'xml' => '', |
| 2801 | 2946 | 'mozilla' => '', |
| 2802 | 2947 | 'text' => '', |
| 2803 | 2948 | ); |
| 2804 | -} |
|
| 2949 | + } |
|
| 2950 | + } |
|
| 2805 | 2951 | |
| 2806 | 2952 | /** |
| 2807 | 2953 | * Used to edit the body or subject of a message inline |
@@ -2813,8 +2959,9 @@ discard block |
||
| 2813 | 2959 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2814 | 2960 | |
| 2815 | 2961 | // We have to have a topic! |
| 2816 | - if (empty($topic)) |
|
| 2817 | - obExit(false); |
|
| 2962 | + if (empty($topic)) { |
|
| 2963 | + obExit(false); |
|
| 2964 | + } |
|
| 2818 | 2965 | |
| 2819 | 2966 | checkSession('get'); |
| 2820 | 2967 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2840,31 +2987,35 @@ discard block |
||
| 2840 | 2987 | 'guest_id' => 0, |
| 2841 | 2988 | ) |
| 2842 | 2989 | ); |
| 2843 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2844 | - fatal_lang_error('no_board', false); |
|
| 2990 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2991 | + fatal_lang_error('no_board', false); |
|
| 2992 | + } |
|
| 2845 | 2993 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2846 | 2994 | $smcFunc['db_free_result']($request); |
| 2847 | 2995 | |
| 2848 | 2996 | // Change either body or subject requires permissions to modify messages. |
| 2849 | 2997 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2850 | 2998 | { |
| 2851 | - if (!empty($row['locked'])) |
|
| 2852 | - isAllowedTo('moderate_board'); |
|
| 2999 | + if (!empty($row['locked'])) { |
|
| 3000 | + isAllowedTo('moderate_board'); |
|
| 3001 | + } |
|
| 2853 | 3002 | |
| 2854 | 3003 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2855 | 3004 | { |
| 2856 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2857 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2858 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2859 | - isAllowedTo('modify_replies'); |
|
| 2860 | - else |
|
| 2861 | - isAllowedTo('modify_own'); |
|
| 3005 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 3006 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 3007 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 3008 | + isAllowedTo('modify_replies'); |
|
| 3009 | + } else { |
|
| 3010 | + isAllowedTo('modify_own'); |
|
| 3011 | + } |
|
| 2862 | 3012 | } |
| 2863 | 3013 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2864 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2865 | - isAllowedTo('modify_replies'); |
|
| 2866 | - else |
|
| 2867 | - isAllowedTo('modify_any'); |
|
| 3014 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 3015 | + isAllowedTo('modify_replies'); |
|
| 3016 | + } else { |
|
| 3017 | + isAllowedTo('modify_any'); |
|
| 3018 | + } |
|
| 2868 | 3019 | |
| 2869 | 3020 | // Only log this action if it wasn't your message. |
| 2870 | 3021 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2876,10 +3027,10 @@ discard block |
||
| 2876 | 3027 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2877 | 3028 | |
| 2878 | 3029 | // Maximum number of characters. |
| 2879 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2880 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2881 | - } |
|
| 2882 | - elseif (isset($_POST['subject'])) |
|
| 3030 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 3031 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 3032 | + } |
|
| 3033 | + } elseif (isset($_POST['subject'])) |
|
| 2883 | 3034 | { |
| 2884 | 3035 | $post_errors[] = 'no_subject'; |
| 2885 | 3036 | unset($_POST['subject']); |
@@ -2891,13 +3042,11 @@ discard block |
||
| 2891 | 3042 | { |
| 2892 | 3043 | $post_errors[] = 'no_message'; |
| 2893 | 3044 | unset($_POST['message']); |
| 2894 | - } |
|
| 2895 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 3045 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2896 | 3046 | { |
| 2897 | 3047 | $post_errors[] = 'long_message'; |
| 2898 | 3048 | unset($_POST['message']); |
| 2899 | - } |
|
| 2900 | - else |
|
| 3049 | + } else |
|
| 2901 | 3050 | { |
| 2902 | 3051 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2903 | 3052 | |
@@ -2913,31 +3062,34 @@ discard block |
||
| 2913 | 3062 | |
| 2914 | 3063 | if (isset($_POST['lock'])) |
| 2915 | 3064 | { |
| 2916 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2917 | - unset($_POST['lock']); |
|
| 2918 | - elseif (!allowedTo('lock_any')) |
|
| 3065 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 3066 | + unset($_POST['lock']); |
|
| 3067 | + } elseif (!allowedTo('lock_any')) |
|
| 2919 | 3068 | { |
| 2920 | - if ($row['locked'] == 1) |
|
| 2921 | - unset($_POST['lock']); |
|
| 2922 | - else |
|
| 2923 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3069 | + if ($row['locked'] == 1) { |
|
| 3070 | + unset($_POST['lock']); |
|
| 3071 | + } else { |
|
| 3072 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3073 | + } |
|
| 3074 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 3075 | + unset($_POST['lock']); |
|
| 3076 | + } else { |
|
| 3077 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2924 | 3078 | } |
| 2925 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2926 | - unset($_POST['lock']); |
|
| 2927 | - else |
|
| 2928 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2929 | 3079 | } |
| 2930 | 3080 | |
| 2931 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2932 | - unset($_POST['sticky']); |
|
| 3081 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 3082 | + unset($_POST['sticky']); |
|
| 3083 | + } |
|
| 2933 | 3084 | |
| 2934 | 3085 | if (isset($_POST['modify_reason'])) |
| 2935 | 3086 | { |
| 2936 | 3087 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2937 | 3088 | |
| 2938 | 3089 | // Maximum number of characters. |
| 2939 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2940 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3090 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 3091 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3092 | + } |
|
| 2941 | 3093 | } |
| 2942 | 3094 | |
| 2943 | 3095 | if (empty($post_errors)) |
@@ -2974,8 +3126,9 @@ discard block |
||
| 2974 | 3126 | } |
| 2975 | 3127 | } |
| 2976 | 3128 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2977 | - else |
|
| 2978 | - $moderationAction = false; |
|
| 3129 | + else { |
|
| 3130 | + $moderationAction = false; |
|
| 3131 | + } |
|
| 2979 | 3132 | |
| 2980 | 3133 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2981 | 3134 | |
@@ -2993,9 +3146,9 @@ discard block |
||
| 2993 | 3146 | // Get the proper (default language) response prefix first. |
| 2994 | 3147 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2995 | 3148 | { |
| 2996 | - if ($language === $user_info['language']) |
|
| 2997 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2998 | - else |
|
| 3149 | + if ($language === $user_info['language']) { |
|
| 3150 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3151 | + } else |
|
| 2999 | 3152 | { |
| 3000 | 3153 | loadLanguage('index', $language, false); |
| 3001 | 3154 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -3017,8 +3170,9 @@ discard block |
||
| 3017 | 3170 | ); |
| 3018 | 3171 | } |
| 3019 | 3172 | |
| 3020 | - if (!empty($moderationAction)) |
|
| 3021 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3173 | + if (!empty($moderationAction)) { |
|
| 3174 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3175 | + } |
|
| 3022 | 3176 | } |
| 3023 | 3177 | |
| 3024 | 3178 | if (isset($_REQUEST['xml'])) |
@@ -3059,8 +3213,7 @@ discard block |
||
| 3059 | 3213 | ); |
| 3060 | 3214 | |
| 3061 | 3215 | censorText($context['message']['subject']); |
| 3062 | - } |
|
| 3063 | - else |
|
| 3216 | + } else |
|
| 3064 | 3217 | { |
| 3065 | 3218 | $context['message'] = array( |
| 3066 | 3219 | 'id' => $row['id_msg'], |
@@ -3072,15 +3225,16 @@ discard block |
||
| 3072 | 3225 | loadLanguage('Errors'); |
| 3073 | 3226 | foreach ($post_errors as $post_error) |
| 3074 | 3227 | { |
| 3075 | - if ($post_error == 'long_message') |
|
| 3076 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3077 | - else |
|
| 3078 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3228 | + if ($post_error == 'long_message') { |
|
| 3229 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3230 | + } else { |
|
| 3231 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3232 | + } |
|
| 3079 | 3233 | } |
| 3080 | 3234 | } |
| 3235 | + } else { |
|
| 3236 | + obExit(false); |
|
| 3237 | + } |
|
| 3081 | 3238 | } |
| 3082 | - else |
|
| 3083 | - obExit(false); |
|
| 3084 | -} |
|
| 3085 | 3239 | |
| 3086 | 3240 | ?> |
| 3087 | 3241 | \ No newline at end of file |
@@ -34,11 +34,12 @@ discard block |
||
| 34 | 34 | </div>'; |
| 35 | 35 | |
| 36 | 36 | // If this is an existing set, and there are still un-added smileys - offer an import opportunity. |
| 37 | - if (!empty($context['current_set']['can_import'])) |
|
| 38 | - echo ' |
|
| 37 | + if (!empty($context['current_set']['can_import'])) { |
|
| 38 | + echo ' |
|
| 39 | 39 | <div class="information noup"> |
| 40 | 40 | ', $context['current_set']['can_import'] == 1 ? sprintf($txt['smiley_set_import_single'], $context['current_set']['import_url']) : sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import'], $context['current_set']['import_url']), ' |
| 41 | 41 | </div>'; |
| 42 | + } |
|
| 42 | 43 | |
| 43 | 44 | echo ' |
| 44 | 45 | <div class="windowbg noup"> |
@@ -67,17 +68,18 @@ discard block |
||
| 67 | 68 | <dd> |
| 68 | 69 | ', $modSettings['smileys_url'], '/'; |
| 69 | 70 | |
| 70 | - if (empty($context['smiley_set_dirs'])) |
|
| 71 | - echo ' |
|
| 71 | + if (empty($context['smiley_set_dirs'])) { |
|
| 72 | + echo ' |
|
| 72 | 73 | <input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> '; |
| 73 | - else |
|
| 74 | + } else |
|
| 74 | 75 | { |
| 75 | 76 | echo ' |
| 76 | 77 | <select name="smiley_sets_path" id="smiley_sets_path">'; |
| 77 | 78 | |
| 78 | - foreach ($context['smiley_set_dirs'] as $smiley_set_dir) |
|
| 79 | - echo ' |
|
| 79 | + foreach ($context['smiley_set_dirs'] as $smiley_set_dir) { |
|
| 80 | + echo ' |
|
| 80 | 81 | <option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>'; |
| 82 | + } |
|
| 81 | 83 | echo ' |
| 82 | 84 | </select> '; |
| 83 | 85 | } |
@@ -92,14 +94,15 @@ discard block |
||
| 92 | 94 | </dd>'; |
| 93 | 95 | |
| 94 | 96 | // If this is a new smiley set they have the option to import smileys already in the directory. |
| 95 | - if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) |
|
| 96 | - echo ' |
|
| 97 | + if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) { |
|
| 98 | + echo ' |
|
| 97 | 99 | <dt> |
| 98 | 100 | <strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong> |
| 99 | 101 | </dt> |
| 100 | 102 | <dd> |
| 101 | 103 | <input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1"> |
| 102 | 104 | </dd>'; |
| 105 | + } |
|
| 103 | 106 | |
| 104 | 107 | echo ' |
| 105 | 108 | </dl> |
@@ -131,9 +134,10 @@ discard block |
||
| 131 | 134 | <dd> |
| 132 | 135 | <img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'] . $context['user']['smiley_set_default_ext'], '" id="preview" alt=""> ', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();">'; |
| 133 | 136 | |
| 134 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 135 | - echo ' |
|
| 137 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 138 | + echo ' |
|
| 136 | 139 | <option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>'; |
| 140 | + } |
|
| 137 | 141 | |
| 138 | 142 | echo ' |
| 139 | 143 | </select> |
@@ -149,17 +153,18 @@ discard block |
||
| 149 | 153 | </dt> |
| 150 | 154 | <dd>'; |
| 151 | 155 | |
| 152 | - if (empty($context['filenames'])) |
|
| 153 | - echo ' |
|
| 156 | + if (empty($context['filenames'])) { |
|
| 157 | + echo ' |
|
| 154 | 158 | <input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">'; |
| 155 | - else |
|
| 159 | + } else |
|
| 156 | 160 | { |
| 157 | 161 | echo ' |
| 158 | 162 | <select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">'; |
| 159 | 163 | |
| 160 | - foreach ($context['filenames'] as $filename) |
|
| 161 | - echo ' |
|
| 164 | + foreach ($context['filenames'] as $filename) { |
|
| 165 | + echo ' |
|
| 162 | 166 | <option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>'; |
| 167 | + } |
|
| 163 | 168 | echo ' |
| 164 | 169 | </select>'; |
| 165 | 170 | } |
@@ -226,9 +231,10 @@ discard block |
||
| 226 | 231 | <dd> |
| 227 | 232 | ', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();selectMethod(\'existing\');">'; |
| 228 | 233 | |
| 229 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 230 | - echo ' |
|
| 234 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 235 | + echo ' |
|
| 231 | 236 | <option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>'; |
| 237 | + } |
|
| 232 | 238 | |
| 233 | 239 | echo ' |
| 234 | 240 | </select> |
@@ -238,17 +244,18 @@ discard block |
||
| 238 | 244 | </dt> |
| 239 | 245 | <dd>'; |
| 240 | 246 | |
| 241 | - if (empty($context['filenames'])) |
|
| 242 | - echo ' |
|
| 247 | + if (empty($context['filenames'])) { |
|
| 248 | + echo ' |
|
| 243 | 249 | <input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">'; |
| 244 | - else |
|
| 250 | + } else |
|
| 245 | 251 | { |
| 246 | 252 | echo ' |
| 247 | 253 | <select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">'; |
| 248 | 254 | |
| 249 | - foreach ($context['filenames'] as $filename) |
|
| 250 | - echo ' |
|
| 255 | + foreach ($context['filenames'] as $filename) { |
|
| 256 | + echo ' |
|
| 251 | 257 | <option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>'; |
| 258 | + } |
|
| 252 | 259 | echo ' |
| 253 | 260 | </select>'; |
| 254 | 261 | } |
@@ -261,14 +268,15 @@ discard block |
||
| 261 | 268 | |
| 262 | 269 | <dl id="uploadMore" class="settings">'; |
| 263 | 270 | |
| 264 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 265 | - echo ' |
|
| 271 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 272 | + echo ' |
|
| 266 | 273 | <dt> |
| 267 | 274 | ', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ': |
| 268 | 275 | </dt> |
| 269 | 276 | <dd> |
| 270 | 277 | <input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');"> |
| 271 | 278 | </dd>'; |
| 279 | + } |
|
| 272 | 280 | |
| 273 | 281 | echo ' |
| 274 | 282 | </dl> |
@@ -336,27 +344,30 @@ discard block |
||
| 336 | 344 | |
| 337 | 345 | foreach ($location['rows'] as $row) |
| 338 | 346 | { |
| 339 | - if (!empty($context['move_smiley'])) |
|
| 340 | - echo ' |
|
| 347 | + if (!empty($context['move_smiley'])) { |
|
| 348 | + echo ' |
|
| 341 | 349 | <a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>'; |
| 350 | + } |
|
| 342 | 351 | |
| 343 | 352 | foreach ($row as $smiley) |
| 344 | 353 | { |
| 345 | - if (empty($context['move_smiley'])) |
|
| 346 | - echo ' |
|
| 354 | + if (empty($context['move_smiley'])) { |
|
| 355 | + echo ' |
|
| 347 | 356 | <a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '"></a>'; |
| 348 | - else |
|
| 349 | - echo ' |
|
| 357 | + } else { |
|
| 358 | + echo ' |
|
| 350 | 359 | <img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" ', $smiley['selected'] ? 'class="selected_item"' : '', '> |
| 351 | 360 | <a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>'; |
| 361 | + } |
|
| 352 | 362 | } |
| 353 | 363 | |
| 354 | 364 | echo ' |
| 355 | 365 | <br>'; |
| 356 | 366 | } |
| 357 | - if (!empty($context['move_smiley'])) |
|
| 358 | - echo ' |
|
| 367 | + if (!empty($context['move_smiley'])) { |
|
| 368 | + echo ' |
|
| 359 | 369 | <a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>'; |
| 370 | + } |
|
| 360 | 371 | echo ' |
| 361 | 372 | </div><!-- .windowbg --> |
| 362 | 373 | <input type="hidden" name="reorder" value="1"> |
@@ -389,14 +400,15 @@ discard block |
||
| 389 | 400 | <div class="windowbg"> |
| 390 | 401 | <dl class="settings">'; |
| 391 | 402 | |
| 392 | - if (!$context['new_icon']) |
|
| 393 | - echo ' |
|
| 403 | + if (!$context['new_icon']) { |
|
| 404 | + echo ' |
|
| 394 | 405 | <dt> |
| 395 | 406 | <strong>', $txt['smiley_preview'], ': </strong> |
| 396 | 407 | </dt> |
| 397 | 408 | <dd> |
| 398 | 409 | <img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '"> |
| 399 | 410 | </dd>'; |
| 411 | + } |
|
| 400 | 412 | |
| 401 | 413 | echo ' |
| 402 | 414 | <dt> |
@@ -423,9 +435,10 @@ discard block |
||
| 423 | 435 | echo ' |
| 424 | 436 | <optgroup label="', $category['name'], '">'; |
| 425 | 437 | |
| 426 | - foreach ($category['boards'] as $board) |
|
| 427 | - echo ' |
|
| 438 | + foreach ($category['boards'] as $board) { |
|
| 439 | + echo ' |
|
| 428 | 440 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 441 | + } |
|
| 429 | 442 | |
| 430 | 443 | echo ' |
| 431 | 444 | </optgroup>'; |
@@ -442,19 +455,21 @@ discard block |
||
| 442 | 455 | <option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>'; |
| 443 | 456 | |
| 444 | 457 | // Print the list of all the icons it can be put after... |
| 445 | - foreach ($context['icons'] as $id => $data) |
|
| 446 | - if (empty($context['icon']['id']) || $id != $context['icon']['id']) |
|
| 458 | + foreach ($context['icons'] as $id => $data) { |
|
| 459 | + if (empty($context['icon']['id']) || $id != $context['icon']['id']) |
|
| 447 | 460 | echo ' |
| 448 | 461 | <option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>'; |
| 462 | + } |
|
| 449 | 463 | |
| 450 | 464 | echo ' |
| 451 | 465 | </select> |
| 452 | 466 | </dd> |
| 453 | 467 | </dl>'; |
| 454 | 468 | |
| 455 | - if (!$context['new_icon']) |
|
| 456 | - echo ' |
|
| 469 | + if (!$context['new_icon']) { |
|
| 470 | + echo ' |
|
| 457 | 471 | <input type="hidden" name="icon" value="', $context['icon']['id'], '">'; |
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | echo ' |
| 460 | 475 | <input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button"> |
@@ -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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $txt, $context, $scripturl, $user_info; |
| 30 | 31 | |
| 31 | 32 | // You are already logged in, go take a tour of the boards |
| 32 | - if (!empty($user_info['id'])) |
|
| 33 | - redirectexit(); |
|
| 33 | + if (!empty($user_info['id'])) { |
|
| 34 | + redirectexit(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // We need to load the Login template/language file. |
| 36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
| 57 | 59 | ); |
| 58 | 60 | |
| 59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
| 60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
| 61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
| 63 | - unset($_SESSION['login_url']); |
|
| 62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
| 63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
| 65 | + unset($_SESSION['login_url']); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | // Create a one time token. |
| 66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
| 84 | 87 | |
| 85 | 88 | // Check to ensure we're forcing SSL for authentication |
| 86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 87 | - fatal_lang_error('login_ssl_required'); |
|
| 89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 90 | + fatal_lang_error('login_ssl_required'); |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | // Load cookie authentication stuff. |
| 90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -98,23 +102,26 @@ discard block |
||
| 98 | 102 | if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest']) |
| 99 | 103 | { |
| 100 | 104 | // First check for 2.1 json-format cookie in $_COOKIE |
| 101 | - if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) |
|
| 102 | - list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
| 105 | + if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) { |
|
| 106 | + list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // Try checking for 2.1 json-format cookie in $_SESSION |
| 105 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) |
|
| 106 | - list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
| 110 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) { |
|
| 111 | + list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
| 112 | + } |
|
| 107 | 113 | |
| 108 | 114 | // Next, try checking for 2.0 serialized string cookie in $_COOKIE |
| 109 | - elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) |
|
| 110 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 115 | + elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) { |
|
| 116 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 117 | + } |
|
| 111 | 118 | |
| 112 | 119 | // Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION |
| 113 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) |
|
| 114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 115 | - |
|
| 116 | - else |
|
| 117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 120 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) { |
|
| 121 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 122 | + } else { |
|
| 123 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 124 | + } |
|
| 118 | 125 | |
| 119 | 126 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
| 120 | 127 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -134,24 +141,23 @@ discard block |
||
| 134 | 141 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
| 135 | 142 | { |
| 136 | 143 | // Strike! You're outta there! |
| 137 | - if ($_GET['member'] != $user_info['id']) |
|
| 138 | - fatal_lang_error('login_cookie_error', false); |
|
| 144 | + if ($_GET['member'] != $user_info['id']) { |
|
| 145 | + fatal_lang_error('login_cookie_error', false); |
|
| 146 | + } |
|
| 139 | 147 | |
| 140 | 148 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
| 141 | 149 | |
| 142 | 150 | // Some whitelisting for login_url... |
| 143 | - if (empty($_SESSION['login_url'])) |
|
| 144 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 145 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 151 | + if (empty($_SESSION['login_url'])) { |
|
| 152 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 153 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 146 | 154 | { |
| 147 | 155 | unset ($_SESSION['login_url']); |
| 148 | 156 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
| 149 | - } |
|
| 150 | - elseif (!empty($user_settings['tfa_secret'])) |
|
| 157 | + } elseif (!empty($user_settings['tfa_secret'])) |
|
| 151 | 158 | { |
| 152 | 159 | redirectexit('action=logintfa'); |
| 153 | - } |
|
| 154 | - else |
|
| 160 | + } else |
|
| 155 | 161 | { |
| 156 | 162 | // Best not to clutter the session data too much... |
| 157 | 163 | $temp = $_SESSION['login_url']; |
@@ -162,8 +168,9 @@ discard block |
||
| 162 | 168 | } |
| 163 | 169 | |
| 164 | 170 | // Beyond this point you are assumed to be a guest trying to login. |
| 165 | - if (!$user_info['is_guest']) |
|
| 166 | - redirectexit(); |
|
| 171 | + if (!$user_info['is_guest']) { |
|
| 172 | + redirectexit(); |
|
| 173 | + } |
|
| 167 | 174 | |
| 168 | 175 | // Are you guessing with a script? |
| 169 | 176 | checkSession(); |
@@ -171,18 +178,21 @@ discard block |
||
| 171 | 178 | spamProtection('login'); |
| 172 | 179 | |
| 173 | 180 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
| 174 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
| 175 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 181 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
| 182 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 183 | + } |
|
| 176 | 184 | |
| 177 | 185 | // Been guessing a lot, haven't we? |
| 178 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
| 179 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
| 186 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
| 187 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
| 188 | + } |
|
| 180 | 189 | |
| 181 | 190 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
| 182 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
| 183 | - $modSettings['cookieTime'] = 3153600; |
|
| 184 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) |
|
| 185 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 191 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
| 192 | + $modSettings['cookieTime'] = 3153600; |
|
| 193 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) { |
|
| 194 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 195 | + } |
|
| 186 | 196 | |
| 187 | 197 | loadLanguage('Login'); |
| 188 | 198 | // Load the template stuff. |
@@ -302,8 +312,9 @@ discard block |
||
| 302 | 312 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
| 303 | 313 | |
| 304 | 314 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
| 305 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
| 306 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 315 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
| 316 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 317 | + } |
|
| 307 | 318 | |
| 308 | 319 | // phpBB3 users new hashing. We now support it as well ;). |
| 309 | 320 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -323,27 +334,29 @@ discard block |
||
| 323 | 334 | // Some common md5 ones. |
| 324 | 335 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
| 325 | 336 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
| 326 | - } |
|
| 327 | - elseif (strlen($user_settings['passwd']) == 40) |
|
| 337 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
| 328 | 338 | { |
| 329 | 339 | // Maybe they are using a hash from before the password fix. |
| 330 | 340 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
| 331 | 341 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
| 332 | 342 | |
| 333 | 343 | // BurningBoard3 style of hashing. |
| 334 | - if (!empty($modSettings['enable_password_conversion'])) |
|
| 335 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 344 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
| 345 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 346 | + } |
|
| 336 | 347 | |
| 337 | 348 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
| 338 | 349 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
| 339 | 350 | { |
| 340 | 351 | // Try iconv first, for no particular reason. |
| 341 | - if (function_exists('iconv')) |
|
| 342 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 352 | + if (function_exists('iconv')) { |
|
| 353 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 354 | + } |
|
| 343 | 355 | |
| 344 | 356 | // Say it aint so, iconv failed! |
| 345 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
| 346 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 357 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
| 358 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 359 | + } |
|
| 347 | 360 | } |
| 348 | 361 | } |
| 349 | 362 | |
@@ -373,8 +386,9 @@ discard block |
||
| 373 | 386 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
| 374 | 387 | |
| 375 | 388 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
| 376 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
| 377 | - redirectexit('action=reminder'); |
|
| 389 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
| 390 | + redirectexit('action=reminder'); |
|
| 391 | + } |
|
| 378 | 392 | // We'll give you another chance... |
| 379 | 393 | else |
| 380 | 394 | { |
@@ -385,8 +399,7 @@ discard block |
||
| 385 | 399 | return; |
| 386 | 400 | } |
| 387 | 401 | } |
| 388 | - } |
|
| 389 | - elseif (!empty($user_settings['passwd_flood'])) |
|
| 402 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
| 390 | 403 | { |
| 391 | 404 | // Let's be sure they weren't a little hacker. |
| 392 | 405 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -403,8 +416,9 @@ discard block |
||
| 403 | 416 | } |
| 404 | 417 | |
| 405 | 418 | // Check their activation status. |
| 406 | - if (!checkActivation()) |
|
| 407 | - return; |
|
| 419 | + if (!checkActivation()) { |
|
| 420 | + return; |
|
| 421 | + } |
|
| 408 | 422 | |
| 409 | 423 | DoLogin(); |
| 410 | 424 | } |
@@ -416,8 +430,9 @@ discard block |
||
| 416 | 430 | { |
| 417 | 431 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
| 418 | 432 | |
| 419 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
| 420 | - fatal_lang_error('no_access', false); |
|
| 433 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
| 434 | + fatal_lang_error('no_access', false); |
|
| 435 | + } |
|
| 421 | 436 | |
| 422 | 437 | loadLanguage('Profile'); |
| 423 | 438 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -425,8 +440,9 @@ discard block |
||
| 425 | 440 | $member = $context['tfa_member']; |
| 426 | 441 | |
| 427 | 442 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
| 428 | - if (time() - $member['last_login'] < 120) |
|
| 429 | - fatal_lang_error('tfa_wait', false); |
|
| 443 | + if (time() - $member['last_login'] < 120) { |
|
| 444 | + fatal_lang_error('tfa_wait', false); |
|
| 445 | + } |
|
| 430 | 446 | |
| 431 | 447 | $totp = new \TOTP\Auth($member['tfa_secret']); |
| 432 | 448 | $totp->setRange(1); |
@@ -440,8 +456,9 @@ discard block |
||
| 440 | 456 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
| 441 | 457 | { |
| 442 | 458 | // Check to ensure we're forcing SSL for authentication |
| 443 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 444 | - fatal_lang_error('login_ssl_required'); |
|
| 459 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 460 | + fatal_lang_error('login_ssl_required'); |
|
| 461 | + } |
|
| 445 | 462 | |
| 446 | 463 | $code = $_POST['tfa_code']; |
| 447 | 464 | |
@@ -451,20 +468,19 @@ discard block |
||
| 451 | 468 | |
| 452 | 469 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
| 453 | 470 | redirectexit(); |
| 454 | - } |
|
| 455 | - else |
|
| 471 | + } else |
|
| 456 | 472 | { |
| 457 | 473 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
| 458 | 474 | |
| 459 | 475 | $context['tfa_error'] = true; |
| 460 | 476 | $context['tfa_value'] = $_POST['tfa_code']; |
| 461 | 477 | } |
| 462 | - } |
|
| 463 | - elseif (!empty($_POST['tfa_backup'])) |
|
| 478 | + } elseif (!empty($_POST['tfa_backup'])) |
|
| 464 | 479 | { |
| 465 | 480 | // Check to ensure we're forcing SSL for authentication |
| 466 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 467 | - fatal_lang_error('login_ssl_required'); |
|
| 481 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 482 | + fatal_lang_error('login_ssl_required'); |
|
| 483 | + } |
|
| 468 | 484 | |
| 469 | 485 | $backup = $_POST['tfa_backup']; |
| 470 | 486 | |
@@ -478,8 +494,7 @@ discard block |
||
| 478 | 494 | )); |
| 479 | 495 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
| 480 | 496 | redirectexit('action=profile;area=tfasetup;backup'); |
| 481 | - } |
|
| 482 | - else |
|
| 497 | + } else |
|
| 483 | 498 | { |
| 484 | 499 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
| 485 | 500 | |
@@ -502,8 +517,9 @@ discard block |
||
| 502 | 517 | { |
| 503 | 518 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
| 504 | 519 | |
| 505 | - if (!isset($context['login_errors'])) |
|
| 506 | - $context['login_errors'] = array(); |
|
| 520 | + if (!isset($context['login_errors'])) { |
|
| 521 | + $context['login_errors'] = array(); |
|
| 522 | + } |
|
| 507 | 523 | |
| 508 | 524 | // What is the true activation status of this account? |
| 509 | 525 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -515,8 +531,9 @@ discard block |
||
| 515 | 531 | return false; |
| 516 | 532 | } |
| 517 | 533 | // Awaiting approval still? |
| 518 | - elseif ($activation_status == 3) |
|
| 519 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 534 | + elseif ($activation_status == 3) { |
|
| 535 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 536 | + } |
|
| 520 | 537 | // Awaiting deletion, changed their mind? |
| 521 | 538 | elseif ($activation_status == 4) |
| 522 | 539 | { |
@@ -524,8 +541,7 @@ discard block |
||
| 524 | 541 | { |
| 525 | 542 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
| 526 | 543 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
| 527 | - } |
|
| 528 | - else |
|
| 544 | + } else |
|
| 529 | 545 | { |
| 530 | 546 | $context['disable_login_hashing'] = true; |
| 531 | 547 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -565,8 +581,9 @@ discard block |
||
| 565 | 581 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
| 566 | 582 | |
| 567 | 583 | // Reset the login threshold. |
| 568 | - if (isset($_SESSION['failed_login'])) |
|
| 569 | - unset($_SESSION['failed_login']); |
|
| 584 | + if (isset($_SESSION['failed_login'])) { |
|
| 585 | + unset($_SESSION['failed_login']); |
|
| 586 | + } |
|
| 570 | 587 | |
| 571 | 588 | $user_info['is_guest'] = false; |
| 572 | 589 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -588,16 +605,18 @@ discard block |
||
| 588 | 605 | 'id_member' => $user_info['id'], |
| 589 | 606 | ) |
| 590 | 607 | ); |
| 591 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 592 | - $_SESSION['first_login'] = true; |
|
| 593 | - else |
|
| 594 | - unset($_SESSION['first_login']); |
|
| 608 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 609 | + $_SESSION['first_login'] = true; |
|
| 610 | + } else { |
|
| 611 | + unset($_SESSION['first_login']); |
|
| 612 | + } |
|
| 595 | 613 | $smcFunc['db_free_result']($request); |
| 596 | 614 | |
| 597 | 615 | // You've logged in, haven't you? |
| 598 | 616 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
| 599 | - if (empty($user_settings['tfa_secret'])) |
|
| 600 | - $update['last_login'] = time(); |
|
| 617 | + if (empty($user_settings['tfa_secret'])) { |
|
| 618 | + $update['last_login'] = time(); |
|
| 619 | + } |
|
| 601 | 620 | updateMemberData($user_info['id'], $update); |
| 602 | 621 | |
| 603 | 622 | // Get rid of the online entry for that old guest.... |
@@ -611,8 +630,8 @@ discard block |
||
| 611 | 630 | $_SESSION['log_time'] = 0; |
| 612 | 631 | |
| 613 | 632 | // Log this entry, only if we have it enabled. |
| 614 | - if (!empty($modSettings['loginHistoryDays'])) |
|
| 615 | - $smcFunc['db_insert']('insert', |
|
| 633 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
| 634 | + $smcFunc['db_insert']('insert', |
|
| 616 | 635 | '{db_prefix}member_logins', |
| 617 | 636 | array( |
| 618 | 637 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -624,13 +643,15 @@ discard block |
||
| 624 | 643 | 'id_member', 'time' |
| 625 | 644 | ) |
| 626 | 645 | ); |
| 646 | + } |
|
| 627 | 647 | |
| 628 | 648 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
| 629 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
| 630 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 631 | - else |
|
| 632 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 633 | -} |
|
| 649 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
| 650 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 651 | + } else { |
|
| 652 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 653 | + } |
|
| 654 | + } |
|
| 634 | 655 | |
| 635 | 656 | /** |
| 636 | 657 | * Logs the current user out of their account. |
@@ -646,13 +667,15 @@ discard block |
||
| 646 | 667 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
| 647 | 668 | |
| 648 | 669 | // Make sure they aren't being auto-logged out. |
| 649 | - if (!$internal) |
|
| 650 | - checkSession('get'); |
|
| 670 | + if (!$internal) { |
|
| 671 | + checkSession('get'); |
|
| 672 | + } |
|
| 651 | 673 | |
| 652 | 674 | require_once($sourcedir . '/Subs-Auth.php'); |
| 653 | 675 | |
| 654 | - if (isset($_SESSION['pack_ftp'])) |
|
| 655 | - $_SESSION['pack_ftp'] = null; |
|
| 676 | + if (isset($_SESSION['pack_ftp'])) { |
|
| 677 | + $_SESSION['pack_ftp'] = null; |
|
| 678 | + } |
|
| 656 | 679 | |
| 657 | 680 | // It won't be first login anymore. |
| 658 | 681 | unset($_SESSION['first_login']); |
@@ -680,8 +703,9 @@ discard block |
||
| 680 | 703 | |
| 681 | 704 | // And some other housekeeping while we're at it. |
| 682 | 705 | $salt = substr(md5(mt_rand()), 0, 4); |
| 683 | - if (!empty($user_info['id'])) |
|
| 684 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 706 | + if (!empty($user_info['id'])) { |
|
| 707 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 708 | + } |
|
| 685 | 709 | |
| 686 | 710 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
| 687 | 711 | { |
@@ -694,14 +718,13 @@ discard block |
||
| 694 | 718 | // Off to the merry board index we go! |
| 695 | 719 | if ($redirect) |
| 696 | 720 | { |
| 697 | - if (empty($_SESSION['logout_url'])) |
|
| 698 | - redirectexit('', $context['server']['needs_login_fix']); |
|
| 699 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 721 | + if (empty($_SESSION['logout_url'])) { |
|
| 722 | + redirectexit('', $context['server']['needs_login_fix']); |
|
| 723 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 700 | 724 | { |
| 701 | 725 | unset ($_SESSION['logout_url']); |
| 702 | 726 | redirectexit(); |
| 703 | - } |
|
| 704 | - else |
|
| 727 | + } else |
|
| 705 | 728 | { |
| 706 | 729 | $temp = $_SESSION['logout_url']; |
| 707 | 730 | unset($_SESSION['logout_url']); |
@@ -734,8 +757,9 @@ discard block |
||
| 734 | 757 | function phpBB3_password_check($passwd, $passwd_hash) |
| 735 | 758 | { |
| 736 | 759 | // Too long or too short? |
| 737 | - if (strlen($passwd_hash) != 34) |
|
| 738 | - return; |
|
| 760 | + if (strlen($passwd_hash) != 34) { |
|
| 761 | + return; |
|
| 762 | + } |
|
| 739 | 763 | |
| 740 | 764 | // Range of characters allowed. |
| 741 | 765 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -746,8 +770,9 @@ discard block |
||
| 746 | 770 | $salt = substr($passwd_hash, 4, 8); |
| 747 | 771 | |
| 748 | 772 | $hash = md5($salt . $passwd, true); |
| 749 | - for (; $count != 0; --$count) |
|
| 750 | - $hash = md5($hash . $passwd, true); |
|
| 773 | + for (; $count != 0; --$count) { |
|
| 774 | + $hash = md5($hash . $passwd, true); |
|
| 775 | + } |
|
| 751 | 776 | |
| 752 | 777 | $output = substr($passwd_hash, 0, 12); |
| 753 | 778 | $i = 0; |
@@ -756,21 +781,25 @@ discard block |
||
| 756 | 781 | $value = ord($hash[$i++]); |
| 757 | 782 | $output .= $range[$value & 0x3f]; |
| 758 | 783 | |
| 759 | - if ($i < 16) |
|
| 760 | - $value |= ord($hash[$i]) << 8; |
|
| 784 | + if ($i < 16) { |
|
| 785 | + $value |= ord($hash[$i]) << 8; |
|
| 786 | + } |
|
| 761 | 787 | |
| 762 | 788 | $output .= $range[($value >> 6) & 0x3f]; |
| 763 | 789 | |
| 764 | - if ($i++ >= 16) |
|
| 765 | - break; |
|
| 790 | + if ($i++ >= 16) { |
|
| 791 | + break; |
|
| 792 | + } |
|
| 766 | 793 | |
| 767 | - if ($i < 16) |
|
| 768 | - $value |= ord($hash[$i]) << 16; |
|
| 794 | + if ($i < 16) { |
|
| 795 | + $value |= ord($hash[$i]) << 16; |
|
| 796 | + } |
|
| 769 | 797 | |
| 770 | 798 | $output .= $range[($value >> 12) & 0x3f]; |
| 771 | 799 | |
| 772 | - if ($i++ >= 16) |
|
| 773 | - break; |
|
| 800 | + if ($i++ >= 16) { |
|
| 801 | + break; |
|
| 802 | + } |
|
| 774 | 803 | |
| 775 | 804 | $output .= $range[($value >> 18) & 0x3f]; |
| 776 | 805 | } |
@@ -802,8 +831,9 @@ discard block |
||
| 802 | 831 | require_once($sourcedir . '/Subs-Auth.php'); |
| 803 | 832 | setLoginCookie(-3600, 0); |
| 804 | 833 | |
| 805 | - if (isset($_SESSION['login_' . $cookiename])) |
|
| 806 | - unset($_SESSION['login_' . $cookiename]); |
|
| 834 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
| 835 | + unset($_SESSION['login_' . $cookiename]); |
|
| 836 | + } |
|
| 807 | 837 | } |
| 808 | 838 | |
| 809 | 839 | // We need a member! |
@@ -817,8 +847,9 @@ discard block |
||
| 817 | 847 | } |
| 818 | 848 | |
| 819 | 849 | // Right, have we got a flood value? |
| 820 | - if ($password_flood_value !== false) |
|
| 821 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 850 | + if ($password_flood_value !== false) { |
|
| 851 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 852 | + } |
|
| 822 | 853 | |
| 823 | 854 | // Timestamp or number of tries invalid? |
| 824 | 855 | if (empty($number_tries) || empty($time_stamp)) |
@@ -834,15 +865,17 @@ discard block |
||
| 834 | 865 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
| 835 | 866 | |
| 836 | 867 | // They are trying too fast, make them wait longer |
| 837 | - if ($time_stamp < time() - 10) |
|
| 838 | - $time_stamp = time(); |
|
| 868 | + if ($time_stamp < time() - 10) { |
|
| 869 | + $time_stamp = time(); |
|
| 870 | + } |
|
| 839 | 871 | } |
| 840 | 872 | |
| 841 | 873 | $number_tries++; |
| 842 | 874 | |
| 843 | 875 | // Broken the law? |
| 844 | - if ($number_tries > 5) |
|
| 845 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
| 876 | + if ($number_tries > 5) { |
|
| 877 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
| 878 | + } |
|
| 846 | 879 | |
| 847 | 880 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
| 848 | 881 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
| 230 | 239 | // Now just redirect to a blank.png... |
| 231 | 240 | $secure = false; |
| 232 | 241 | |
| 233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 234 | - $secure = true; |
|
| 235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 236 | - $secure = true; |
|
| 242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 243 | + $secure = true; |
|
| 244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 245 | + $secure = true; |
|
| 246 | + } |
|
| 237 | 247 | |
| 238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
| 239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
| 244 | 254 | { |
| 245 | 255 | // Get PHP's default timezone, if set |
| 246 | 256 | $ini_tz = ini_get('date.timezone'); |
| 247 | - if (!empty($ini_tz)) |
|
| 248 | - $timezone_id = $ini_tz; |
|
| 249 | - else |
|
| 250 | - $timezone_id = ''; |
|
| 257 | + if (!empty($ini_tz)) { |
|
| 258 | + $timezone_id = $ini_tz; |
|
| 259 | + } else { |
|
| 260 | + $timezone_id = ''; |
|
| 261 | + } |
|
| 251 | 262 | |
| 252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
| 277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 278 | 289 | while ($entry = $dir->read()) |
| 279 | 290 | { |
| 280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 293 | + } |
|
| 282 | 294 | } |
| 283 | 295 | $dir->close(); |
| 284 | 296 | } |
@@ -325,10 +337,11 @@ discard block |
||
| 325 | 337 | } |
| 326 | 338 | |
| 327 | 339 | // Override the language file? |
| 328 | - if (isset($_GET['lang_file'])) |
|
| 329 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 330 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 331 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 340 | + if (isset($_GET['lang_file'])) { |
|
| 341 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 342 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 343 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 344 | + } |
|
| 332 | 345 | |
| 333 | 346 | // Make sure it exists, if it doesn't reset it. |
| 334 | 347 | 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'])) |
@@ -337,8 +350,9 @@ discard block |
||
| 337 | 350 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 338 | 351 | |
| 339 | 352 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 340 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 341 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 353 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 354 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 355 | + } |
|
| 342 | 356 | } |
| 343 | 357 | |
| 344 | 358 | // And now include the actual language file itself. |
@@ -355,15 +369,18 @@ discard block |
||
| 355 | 369 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings, $db_port; |
| 356 | 370 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist, $db_mb4; |
| 357 | 371 | |
| 358 | - if (empty($sourcedir)) |
|
| 359 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 372 | + if (empty($sourcedir)) { |
|
| 373 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 374 | + } |
|
| 360 | 375 | |
| 361 | 376 | // Need this to check whether we need the database password. |
| 362 | 377 | require(dirname(__FILE__) . '/Settings.php'); |
| 363 | - if (!defined('SMF')) |
|
| 364 | - define('SMF', 1); |
|
| 365 | - if (empty($smcFunc)) |
|
| 366 | - $smcFunc = array(); |
|
| 378 | + if (!defined('SMF')) { |
|
| 379 | + define('SMF', 1); |
|
| 380 | + } |
|
| 381 | + if (empty($smcFunc)) { |
|
| 382 | + $smcFunc = array(); |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | $modSettings['disableQueryCheck'] = true; |
| 369 | 386 | |
@@ -374,14 +391,17 @@ discard block |
||
| 374 | 391 | |
| 375 | 392 | $options = array('persist' => $db_persist); |
| 376 | 393 | |
| 377 | - if (!empty($db_port)) |
|
| 378 | - $options['port'] = $db_port; |
|
| 394 | + if (!empty($db_port)) { |
|
| 395 | + $options['port'] = $db_port; |
|
| 396 | + } |
|
| 379 | 397 | |
| 380 | - if (!empty($db_mb4)) |
|
| 381 | - $options['db_mb4'] = $db_mb4; |
|
| 398 | + if (!empty($db_mb4)) { |
|
| 399 | + $options['db_mb4'] = $db_mb4; |
|
| 400 | + } |
|
| 382 | 401 | |
| 383 | - if (!$db_connection) |
|
| 384 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
|
| 402 | + if (!$db_connection) { |
|
| 403 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
|
| 404 | + } |
|
| 385 | 405 | } |
| 386 | 406 | } |
| 387 | 407 | |
@@ -409,8 +429,9 @@ discard block |
||
| 409 | 429 | // @todo REMOVE THIS!! |
| 410 | 430 | else |
| 411 | 431 | { |
| 412 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 413 | - call_user_func('doStep' . $_GET['step']); |
|
| 432 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 433 | + call_user_func('doStep' . $_GET['step']); |
|
| 434 | + } |
|
| 414 | 435 | } |
| 415 | 436 | // Show the footer. |
| 416 | 437 | template_install_below(); |
@@ -428,8 +449,9 @@ discard block |
||
| 428 | 449 | $incontext['sub_template'] = 'welcome_message'; |
| 429 | 450 | |
| 430 | 451 | // Done the submission? |
| 431 | - if (isset($_POST['contbutt'])) |
|
| 432 | - return true; |
|
| 452 | + if (isset($_POST['contbutt'])) { |
|
| 453 | + return true; |
|
| 454 | + } |
|
| 433 | 455 | |
| 434 | 456 | // See if we think they have already installed it? |
| 435 | 457 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -437,14 +459,17 @@ discard block |
||
| 437 | 459 | $probably_installed = 0; |
| 438 | 460 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 439 | 461 | { |
| 440 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 441 | - $probably_installed++; |
|
| 442 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 443 | - $probably_installed++; |
|
| 462 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 463 | + $probably_installed++; |
|
| 464 | + } |
|
| 465 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 466 | + $probably_installed++; |
|
| 467 | + } |
|
| 444 | 468 | } |
| 445 | 469 | |
| 446 | - if ($probably_installed == 2) |
|
| 447 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 470 | + if ($probably_installed == 2) { |
|
| 471 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 472 | + } |
|
| 448 | 473 | } |
| 449 | 474 | |
| 450 | 475 | // Is some database support even compiled in? |
@@ -459,45 +484,54 @@ discard block |
||
| 459 | 484 | $databases[$key]['supported'] = false; |
| 460 | 485 | $notFoundSQLFile = true; |
| 461 | 486 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 487 | + } else { |
|
| 488 | + $incontext['supported_databases'][] = $db; |
|
| 462 | 489 | } |
| 463 | - else |
|
| 464 | - $incontext['supported_databases'][] = $db; |
|
| 465 | 490 | } |
| 466 | 491 | } |
| 467 | 492 | |
| 468 | 493 | // Check the PHP version. |
| 469 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 470 | - $error = 'error_php_too_low'; |
|
| 494 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 495 | + $error = 'error_php_too_low'; |
|
| 496 | + } |
|
| 471 | 497 | // Make sure we have a supported database |
| 472 | - elseif (empty($incontext['supported_databases'])) |
|
| 473 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 498 | + elseif (empty($incontext['supported_databases'])) { |
|
| 499 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 500 | + } |
|
| 474 | 501 | // How about session support? Some crazy sysadmin remove it? |
| 475 | - elseif (!function_exists('session_start')) |
|
| 476 | - $error = 'error_session_missing'; |
|
| 502 | + elseif (!function_exists('session_start')) { |
|
| 503 | + $error = 'error_session_missing'; |
|
| 504 | + } |
|
| 477 | 505 | // Make sure they uploaded all the files. |
| 478 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 479 | - $error = 'error_missing_files'; |
|
| 506 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 507 | + $error = 'error_missing_files'; |
|
| 508 | + } |
|
| 480 | 509 | // Very simple check on the session.save_path for Windows. |
| 481 | 510 | // @todo Move this down later if they don't use database-driven sessions? |
| 482 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 483 | - $error = 'error_session_save_path'; |
|
| 511 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 512 | + $error = 'error_session_save_path'; |
|
| 513 | + } |
|
| 484 | 514 | |
| 485 | 515 | // Since each of the three messages would look the same, anyway... |
| 486 | - if (isset($error)) |
|
| 487 | - $incontext['error'] = $txt[$error]; |
|
| 516 | + if (isset($error)) { |
|
| 517 | + $incontext['error'] = $txt[$error]; |
|
| 518 | + } |
|
| 488 | 519 | |
| 489 | 520 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 490 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 491 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 521 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 522 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | // Confirm mbstring is loaded... |
| 494 | - if (!extension_loaded('mbstring')) |
|
| 495 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 526 | + if (!extension_loaded('mbstring')) { |
|
| 527 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 528 | + } |
|
| 496 | 529 | |
| 497 | 530 | // Check for https stream support. |
| 498 | 531 | $supported_streams = stream_get_wrappers(); |
| 499 | - if (!in_array('https', $supported_streams)) |
|
| 500 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 532 | + if (!in_array('https', $supported_streams)) { |
|
| 533 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 534 | + } |
|
| 501 | 535 | |
| 502 | 536 | return false; |
| 503 | 537 | } |
@@ -522,12 +556,14 @@ discard block |
||
| 522 | 556 | 'Settings_bak.php', |
| 523 | 557 | ); |
| 524 | 558 | |
| 525 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 526 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 559 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 560 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 561 | + } |
|
| 527 | 562 | |
| 528 | 563 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 529 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 530 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 564 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 565 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 566 | + } |
|
| 531 | 567 | |
| 532 | 568 | $failed_files = array(); |
| 533 | 569 | |
@@ -539,20 +575,23 @@ discard block |
||
| 539 | 575 | foreach ($writable_files as $file) |
| 540 | 576 | { |
| 541 | 577 | // Some files won't exist, try to address up front |
| 542 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 543 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 578 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 579 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 580 | + } |
|
| 544 | 581 | // NOW do the writable check... |
| 545 | 582 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 546 | 583 | { |
| 547 | 584 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 548 | 585 | |
| 549 | 586 | // Well, 755 hopefully worked... if not, try 777. |
| 550 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 551 | - $failed_files[] = $file; |
|
| 587 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 588 | + $failed_files[] = $file; |
|
| 589 | + } |
|
| 552 | 590 | } |
| 553 | 591 | } |
| 554 | - foreach ($extra_files as $file) |
|
| 555 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 592 | + foreach ($extra_files as $file) { |
|
| 593 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 594 | + } |
|
| 556 | 595 | } |
| 557 | 596 | // Windows is trickier. Let's try opening for r+... |
| 558 | 597 | else |
@@ -562,30 +601,35 @@ discard block |
||
| 562 | 601 | foreach ($writable_files as $file) |
| 563 | 602 | { |
| 564 | 603 | // Folders can't be opened for write... but the index.php in them can ;) |
| 565 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 566 | - $file .= '/index.php'; |
|
| 604 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 605 | + $file .= '/index.php'; |
|
| 606 | + } |
|
| 567 | 607 | |
| 568 | 608 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 569 | 609 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 570 | 610 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 571 | 611 | |
| 572 | 612 | // Hmm, okay, try just for write in that case... |
| 573 | - if (!is_resource($fp)) |
|
| 574 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 613 | + if (!is_resource($fp)) { |
|
| 614 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 615 | + } |
|
| 575 | 616 | |
| 576 | - if (!is_resource($fp)) |
|
| 577 | - $failed_files[] = $file; |
|
| 617 | + if (!is_resource($fp)) { |
|
| 618 | + $failed_files[] = $file; |
|
| 619 | + } |
|
| 578 | 620 | |
| 579 | 621 | @fclose($fp); |
| 580 | 622 | } |
| 581 | - foreach ($extra_files as $file) |
|
| 582 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 623 | + foreach ($extra_files as $file) { |
|
| 624 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 625 | + } |
|
| 583 | 626 | } |
| 584 | 627 | |
| 585 | 628 | $failure = count($failed_files) >= 1; |
| 586 | 629 | |
| 587 | - if (!isset($_SERVER)) |
|
| 588 | - return !$failure; |
|
| 630 | + if (!isset($_SERVER)) { |
|
| 631 | + return !$failure; |
|
| 632 | + } |
|
| 589 | 633 | |
| 590 | 634 | // Put the list into context. |
| 591 | 635 | $incontext['failed_files'] = $failed_files; |
@@ -633,19 +677,23 @@ discard block |
||
| 633 | 677 | |
| 634 | 678 | if (!isset($ftp) || $ftp->error !== false) |
| 635 | 679 | { |
| 636 | - if (!isset($ftp)) |
|
| 637 | - $ftp = new ftp_connection(null); |
|
| 680 | + if (!isset($ftp)) { |
|
| 681 | + $ftp = new ftp_connection(null); |
|
| 682 | + } |
|
| 638 | 683 | // Save the error so we can mess with listing... |
| 639 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 640 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 684 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 685 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 686 | + } |
|
| 641 | 687 | |
| 642 | 688 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 643 | 689 | |
| 644 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 645 | - $_POST['ftp_path'] = $detect_path; |
|
| 690 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 691 | + $_POST['ftp_path'] = $detect_path; |
|
| 692 | + } |
|
| 646 | 693 | |
| 647 | - if (!isset($_POST['ftp_username'])) |
|
| 648 | - $_POST['ftp_username'] = $username; |
|
| 694 | + if (!isset($_POST['ftp_username'])) { |
|
| 695 | + $_POST['ftp_username'] = $username; |
|
| 696 | + } |
|
| 649 | 697 | |
| 650 | 698 | // Set the username etc, into context. |
| 651 | 699 | $incontext['ftp'] = array( |
@@ -657,8 +705,7 @@ discard block |
||
| 657 | 705 | ); |
| 658 | 706 | |
| 659 | 707 | return false; |
| 660 | - } |
|
| 661 | - else |
|
| 708 | + } else |
|
| 662 | 709 | { |
| 663 | 710 | $_SESSION['installer_temp_ftp'] = array( |
| 664 | 711 | 'server' => $_POST['ftp_server'], |
@@ -672,10 +719,12 @@ discard block |
||
| 672 | 719 | |
| 673 | 720 | foreach ($failed_files as $file) |
| 674 | 721 | { |
| 675 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 676 | - $ftp->chmod($file, 0755); |
|
| 677 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 678 | - $ftp->chmod($file, 0777); |
|
| 722 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 723 | + $ftp->chmod($file, 0755); |
|
| 724 | + } |
|
| 725 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 726 | + $ftp->chmod($file, 0777); |
|
| 727 | + } |
|
| 679 | 728 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 680 | 729 | { |
| 681 | 730 | $failed_files_updated[] = $file; |
@@ -731,15 +780,17 @@ discard block |
||
| 731 | 780 | |
| 732 | 781 | if (!$foundOne) |
| 733 | 782 | { |
| 734 | - if (isset($db['default_host'])) |
|
| 735 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 783 | + if (isset($db['default_host'])) { |
|
| 784 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 785 | + } |
|
| 736 | 786 | if (isset($db['default_user'])) |
| 737 | 787 | { |
| 738 | 788 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 739 | 789 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 740 | 790 | } |
| 741 | - if (isset($db['default_password'])) |
|
| 742 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 791 | + if (isset($db['default_password'])) { |
|
| 792 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 793 | + } |
|
| 743 | 794 | |
| 744 | 795 | // For simplicity and less confusion, leave the port blank by default |
| 745 | 796 | $incontext['db']['port'] = ''; |
@@ -758,10 +809,10 @@ discard block |
||
| 758 | 809 | $incontext['db']['server'] = $_POST['db_server']; |
| 759 | 810 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 760 | 811 | |
| 761 | - if (!empty($_POST['db_port'])) |
|
| 762 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 763 | - } |
|
| 764 | - else |
|
| 812 | + if (!empty($_POST['db_port'])) { |
|
| 813 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 814 | + } |
|
| 815 | + } else |
|
| 765 | 816 | { |
| 766 | 817 | $incontext['db']['prefix'] = 'smf_'; |
| 767 | 818 | } |
@@ -797,10 +848,11 @@ discard block |
||
| 797 | 848 | if (!empty($_POST['db_port'])) |
| 798 | 849 | { |
| 799 | 850 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 800 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 801 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 802 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 803 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 851 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 852 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 853 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 854 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 855 | + } |
|
| 804 | 856 | } |
| 805 | 857 | |
| 806 | 858 | // God I hope it saved! |
@@ -813,8 +865,9 @@ discard block |
||
| 813 | 865 | // Make sure it works. |
| 814 | 866 | require(dirname(__FILE__) . '/Settings.php'); |
| 815 | 867 | |
| 816 | - if (empty($sourcedir)) |
|
| 817 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 868 | + if (empty($sourcedir)) { |
|
| 869 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 870 | + } |
|
| 818 | 871 | |
| 819 | 872 | // Better find the database file! |
| 820 | 873 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -824,12 +877,14 @@ discard block |
||
| 824 | 877 | } |
| 825 | 878 | |
| 826 | 879 | // Now include it for database functions! |
| 827 | - if (!defined('SMF')) |
|
| 828 | - define('SMF', 1); |
|
| 880 | + if (!defined('SMF')) { |
|
| 881 | + define('SMF', 1); |
|
| 882 | + } |
|
| 829 | 883 | |
| 830 | 884 | $modSettings['disableQueryCheck'] = true; |
| 831 | - if (empty($smcFunc)) |
|
| 832 | - $smcFunc = array(); |
|
| 885 | + if (empty($smcFunc)) { |
|
| 886 | + $smcFunc = array(); |
|
| 887 | + } |
|
| 833 | 888 | |
| 834 | 889 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 835 | 890 | |
@@ -838,11 +893,13 @@ discard block |
||
| 838 | 893 | |
| 839 | 894 | $options = array('non_fatal' => true, 'dont_select_db' => !$needsDB); |
| 840 | 895 | // Add in the port if needed |
| 841 | - if (!empty($db_port)) |
|
| 842 | - $options['port'] = $db_port; |
|
| 896 | + if (!empty($db_port)) { |
|
| 897 | + $options['port'] = $db_port; |
|
| 898 | + } |
|
| 843 | 899 | |
| 844 | - if (!empty($db_mb4)) |
|
| 845 | - $options['db_mb4'] = $db_mb4; |
|
| 900 | + if (!empty($db_mb4)) { |
|
| 901 | + $options['db_mb4'] = $db_mb4; |
|
| 902 | + } |
|
| 846 | 903 | |
| 847 | 904 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
| 848 | 905 | |
@@ -928,12 +985,14 @@ discard block |
||
| 928 | 985 | $incontext['page_title'] = $txt['install_settings']; |
| 929 | 986 | |
| 930 | 987 | // Let's see if we got the database type correct. |
| 931 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 932 | - $db_type = $_POST['db_type']; |
|
| 988 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 989 | + $db_type = $_POST['db_type']; |
|
| 990 | + } |
|
| 933 | 991 | |
| 934 | 992 | // Else we'd better be able to get the connection. |
| 935 | - else |
|
| 936 | - load_database(); |
|
| 993 | + else { |
|
| 994 | + load_database(); |
|
| 995 | + } |
|
| 937 | 996 | |
| 938 | 997 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 939 | 998 | |
@@ -942,10 +1001,11 @@ discard block |
||
| 942 | 1001 | |
| 943 | 1002 | $secure = false; |
| 944 | 1003 | |
| 945 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 946 | - $secure = true; |
|
| 947 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 948 | - $secure = true; |
|
| 1004 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 1005 | + $secure = true; |
|
| 1006 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 1007 | + $secure = true; |
|
| 1008 | + } |
|
| 949 | 1009 | |
| 950 | 1010 | // Now, to put what we've learned together... and add a path. |
| 951 | 1011 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -977,18 +1037,21 @@ discard block |
||
| 977 | 1037 | // Submitting? |
| 978 | 1038 | if (isset($_POST['boardurl'])) |
| 979 | 1039 | { |
| 980 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 981 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 982 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 983 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 984 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 985 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1040 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1041 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1042 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1043 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1044 | + } |
|
| 1045 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1046 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1047 | + } |
|
| 986 | 1048 | |
| 987 | 1049 | //Make sure boardurl is aligned with ssl setting |
| 988 | - if (empty($_POST['force_ssl'])) |
|
| 989 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 990 | - else |
|
| 991 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1050 | + if (empty($_POST['force_ssl'])) { |
|
| 1051 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1052 | + } else { |
|
| 1053 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1054 | + } |
|
| 992 | 1055 | |
| 993 | 1056 | // Save these variables. |
| 994 | 1057 | $vars = array( |
@@ -1027,10 +1090,10 @@ discard block |
||
| 1027 | 1090 | { |
| 1028 | 1091 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1029 | 1092 | return false; |
| 1030 | - } |
|
| 1031 | - else |
|
| 1032 | - // Set the character set here. |
|
| 1093 | + } else { |
|
| 1094 | + // Set the character set here. |
|
| 1033 | 1095 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1096 | + } |
|
| 1034 | 1097 | } |
| 1035 | 1098 | |
| 1036 | 1099 | // Good, skip on. |
@@ -1050,8 +1113,9 @@ discard block |
||
| 1050 | 1113 | $incontext['continue'] = 1; |
| 1051 | 1114 | |
| 1052 | 1115 | // Already done? |
| 1053 | - if (isset($_POST['pop_done'])) |
|
| 1054 | - return true; |
|
| 1116 | + if (isset($_POST['pop_done'])) { |
|
| 1117 | + return true; |
|
| 1118 | + } |
|
| 1055 | 1119 | |
| 1056 | 1120 | // Reload settings. |
| 1057 | 1121 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1069,8 +1133,9 @@ discard block |
||
| 1069 | 1133 | $modSettings = array(); |
| 1070 | 1134 | if ($result !== false) |
| 1071 | 1135 | { |
| 1072 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1073 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1136 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1137 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1138 | + } |
|
| 1074 | 1139 | $smcFunc['db_free_result']($result); |
| 1075 | 1140 | |
| 1076 | 1141 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1083,20 +1148,22 @@ discard block |
||
| 1083 | 1148 | $modSettings['disableQueryCheck'] = true; |
| 1084 | 1149 | |
| 1085 | 1150 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1086 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1087 | - $smcFunc['db_query']('', ' |
|
| 1151 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1152 | + $smcFunc['db_query']('', ' |
|
| 1088 | 1153 | SET NAMES {string:utf8}', |
| 1089 | 1154 | array( |
| 1090 | 1155 | 'db_error_skip' => true, |
| 1091 | 1156 | 'utf8' => 'utf8', |
| 1092 | 1157 | ) |
| 1093 | 1158 | ); |
| 1159 | + } |
|
| 1094 | 1160 | |
| 1095 | 1161 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1096 | - if (substr(__DIR__, -1) == '\\') |
|
| 1097 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1098 | - else |
|
| 1099 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1162 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1163 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1164 | + } else { |
|
| 1165 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1166 | + } |
|
| 1100 | 1167 | |
| 1101 | 1168 | $replaces = array( |
| 1102 | 1169 | '{$db_prefix}' => $db_prefix, |
@@ -1113,8 +1180,9 @@ discard block |
||
| 1113 | 1180 | |
| 1114 | 1181 | foreach ($txt as $key => $value) |
| 1115 | 1182 | { |
| 1116 | - if (substr($key, 0, 8) == 'default_') |
|
| 1117 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1183 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1184 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1185 | + } |
|
| 1118 | 1186 | } |
| 1119 | 1187 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1120 | 1188 | |
@@ -1129,8 +1197,9 @@ discard block |
||
| 1129 | 1197 | |
| 1130 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1131 | 1199 | { |
| 1132 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1133 | - $engines[] = $row['Engine']; |
|
| 1200 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1201 | + $engines[] = $row['Engine']; |
|
| 1202 | + } |
|
| 1134 | 1203 | } |
| 1135 | 1204 | |
| 1136 | 1205 | // Done with this now |
@@ -1154,8 +1223,7 @@ discard block |
||
| 1154 | 1223 | $replaces['START TRANSACTION;'] = ''; |
| 1155 | 1224 | $replaces['COMMIT;'] = ''; |
| 1156 | 1225 | } |
| 1157 | - } |
|
| 1158 | - else |
|
| 1226 | + } else |
|
| 1159 | 1227 | { |
| 1160 | 1228 | $has_innodb = false; |
| 1161 | 1229 | } |
@@ -1177,21 +1245,24 @@ discard block |
||
| 1177 | 1245 | foreach ($sql_lines as $count => $line) |
| 1178 | 1246 | { |
| 1179 | 1247 | // No comments allowed! |
| 1180 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1181 | - $current_statement .= "\n" . rtrim($line); |
|
| 1248 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1249 | + $current_statement .= "\n" . rtrim($line); |
|
| 1250 | + } |
|
| 1182 | 1251 | |
| 1183 | 1252 | // Is this the end of the query string? |
| 1184 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1185 | - continue; |
|
| 1253 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1254 | + continue; |
|
| 1255 | + } |
|
| 1186 | 1256 | |
| 1187 | 1257 | // Does this table already exist? If so, don't insert more data into it! |
| 1188 | 1258 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1189 | 1259 | { |
| 1190 | 1260 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1191 | - if (!empty($matches[0])) |
|
| 1192 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1193 | - else |
|
| 1194 | - $incontext['sql_results']['insert_dups']++; |
|
| 1261 | + if (!empty($matches[0])) { |
|
| 1262 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1263 | + } else { |
|
| 1264 | + $incontext['sql_results']['insert_dups']++; |
|
| 1265 | + } |
|
| 1195 | 1266 | |
| 1196 | 1267 | $current_statement = ''; |
| 1197 | 1268 | continue; |
@@ -1200,8 +1271,9 @@ discard block |
||
| 1200 | 1271 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1201 | 1272 | { |
| 1202 | 1273 | // Use the appropriate function based on the DB type |
| 1203 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1204 | - $db_errorno = $db_type . '_errno'; |
|
| 1274 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1275 | + $db_errorno = $db_type . '_errno'; |
|
| 1276 | + } |
|
| 1205 | 1277 | |
| 1206 | 1278 | // Error 1050: Table already exists! |
| 1207 | 1279 | // @todo Needs to be made better! |
@@ -1216,18 +1288,18 @@ discard block |
||
| 1216 | 1288 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1217 | 1289 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1218 | 1290 | } |
| 1219 | - } |
|
| 1220 | - else |
|
| 1291 | + } else |
|
| 1221 | 1292 | { |
| 1222 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1223 | - $incontext['sql_results']['tables']++; |
|
| 1224 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1293 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1294 | + $incontext['sql_results']['tables']++; |
|
| 1295 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1225 | 1296 | { |
| 1226 | 1297 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1227 | - if (!empty($matches[0])) |
|
| 1228 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1229 | - else |
|
| 1230 | - $incontext['sql_results']['inserts']++; |
|
| 1298 | + if (!empty($matches[0])) { |
|
| 1299 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1300 | + } else { |
|
| 1301 | + $incontext['sql_results']['inserts']++; |
|
| 1302 | + } |
|
| 1231 | 1303 | } |
| 1232 | 1304 | } |
| 1233 | 1305 | |
@@ -1240,15 +1312,17 @@ discard block |
||
| 1240 | 1312 | // Sort out the context for the SQL. |
| 1241 | 1313 | foreach ($incontext['sql_results'] as $key => $number) |
| 1242 | 1314 | { |
| 1243 | - if ($number == 0) |
|
| 1244 | - unset($incontext['sql_results'][$key]); |
|
| 1245 | - else |
|
| 1246 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1315 | + if ($number == 0) { |
|
| 1316 | + unset($incontext['sql_results'][$key]); |
|
| 1317 | + } else { |
|
| 1318 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1319 | + } |
|
| 1247 | 1320 | } |
| 1248 | 1321 | |
| 1249 | 1322 | // Make sure UTF will be used globally. |
| 1250 | - 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']))) |
|
| 1251 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1323 | + 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']))) { |
|
| 1324 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1325 | + } |
|
| 1252 | 1326 | |
| 1253 | 1327 | // Auto-detect local & global cookie settings |
| 1254 | 1328 | $url_parts = parse_url($boardurl); |
@@ -1277,15 +1351,19 @@ discard block |
||
| 1277 | 1351 | |
| 1278 | 1352 | // Look for subfolder, if found, set localCookie |
| 1279 | 1353 | // Checking for len > 1 ensures you don't have just a slash... |
| 1280 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
| 1281 | - $localCookies = '1'; |
|
| 1354 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
| 1355 | + $localCookies = '1'; |
|
| 1356 | + } |
|
| 1282 | 1357 | |
| 1283 | - if (isset($globalCookies)) |
|
| 1284 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1285 | - if (isset($globalCookiesDomain)) |
|
| 1286 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1287 | - if (isset($localCookies)) |
|
| 1288 | - $newSettings[] = array('localCookies', $localCookies); |
|
| 1358 | + if (isset($globalCookies)) { |
|
| 1359 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1360 | + } |
|
| 1361 | + if (isset($globalCookiesDomain)) { |
|
| 1362 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1363 | + } |
|
| 1364 | + if (isset($localCookies)) { |
|
| 1365 | + $newSettings[] = array('localCookies', $localCookies); |
|
| 1366 | + } |
|
| 1289 | 1367 | } |
| 1290 | 1368 | |
| 1291 | 1369 | // Are we allowing stat collection? |
@@ -1303,16 +1381,17 @@ discard block |
||
| 1303 | 1381 | fwrite($fp, $out); |
| 1304 | 1382 | |
| 1305 | 1383 | $return_data = ''; |
| 1306 | - while (!feof($fp)) |
|
| 1307 | - $return_data .= fgets($fp, 128); |
|
| 1384 | + while (!feof($fp)) { |
|
| 1385 | + $return_data .= fgets($fp, 128); |
|
| 1386 | + } |
|
| 1308 | 1387 | |
| 1309 | 1388 | fclose($fp); |
| 1310 | 1389 | |
| 1311 | 1390 | // Get the unique site ID. |
| 1312 | 1391 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1313 | 1392 | |
| 1314 | - if (!empty($ID[1])) |
|
| 1315 | - $smcFunc['db_insert']('replace', |
|
| 1393 | + if (!empty($ID[1])) { |
|
| 1394 | + $smcFunc['db_insert']('replace', |
|
| 1316 | 1395 | $db_prefix . 'settings', |
| 1317 | 1396 | array('variable' => 'string', 'value' => 'string'), |
| 1318 | 1397 | array( |
@@ -1321,11 +1400,12 @@ discard block |
||
| 1321 | 1400 | ), |
| 1322 | 1401 | array('variable') |
| 1323 | 1402 | ); |
| 1403 | + } |
|
| 1324 | 1404 | } |
| 1325 | 1405 | } |
| 1326 | 1406 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1327 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1328 | - $smcFunc['db_query']('', ' |
|
| 1407 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1408 | + $smcFunc['db_query']('', ' |
|
| 1329 | 1409 | DELETE FROM {db_prefix}settings |
| 1330 | 1410 | WHERE variable = {string:enable_sm_stats}', |
| 1331 | 1411 | array( |
@@ -1333,20 +1413,23 @@ discard block |
||
| 1333 | 1413 | 'db_error_skip' => true, |
| 1334 | 1414 | ) |
| 1335 | 1415 | ); |
| 1416 | + } |
|
| 1336 | 1417 | |
| 1337 | 1418 | // Are we enabling SSL? |
| 1338 | - if (!empty($_POST['force_ssl'])) |
|
| 1339 | - $newSettings[] = array('force_ssl', 1); |
|
| 1419 | + if (!empty($_POST['force_ssl'])) { |
|
| 1420 | + $newSettings[] = array('force_ssl', 1); |
|
| 1421 | + } |
|
| 1340 | 1422 | |
| 1341 | 1423 | // Setting a timezone is required. |
| 1342 | 1424 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1343 | 1425 | { |
| 1344 | 1426 | // Get PHP's default timezone, if set |
| 1345 | 1427 | $ini_tz = ini_get('date.timezone'); |
| 1346 | - if (!empty($ini_tz)) |
|
| 1347 | - $timezone_id = $ini_tz; |
|
| 1348 | - else |
|
| 1349 | - $timezone_id = ''; |
|
| 1428 | + if (!empty($ini_tz)) { |
|
| 1429 | + $timezone_id = $ini_tz; |
|
| 1430 | + } else { |
|
| 1431 | + $timezone_id = ''; |
|
| 1432 | + } |
|
| 1350 | 1433 | |
| 1351 | 1434 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1352 | 1435 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1355,8 +1438,9 @@ discard block |
||
| 1355 | 1438 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1356 | 1439 | } |
| 1357 | 1440 | |
| 1358 | - if (date_default_timezone_set($timezone_id)) |
|
| 1359 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1441 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1442 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1443 | + } |
|
| 1360 | 1444 | } |
| 1361 | 1445 | |
| 1362 | 1446 | if (!empty($newSettings)) |
@@ -1387,16 +1471,18 @@ discard block |
||
| 1387 | 1471 | } |
| 1388 | 1472 | |
| 1389 | 1473 | // MySQL specific stuff |
| 1390 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1391 | - return false; |
|
| 1474 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1475 | + return false; |
|
| 1476 | + } |
|
| 1392 | 1477 | |
| 1393 | 1478 | // Find database user privileges. |
| 1394 | 1479 | $privs = array(); |
| 1395 | 1480 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1396 | 1481 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1397 | 1482 | { |
| 1398 | - if ($row['Privilege'] == 'Alter') |
|
| 1399 | - $privs[] = $row['Privilege']; |
|
| 1483 | + if ($row['Privilege'] == 'Alter') { |
|
| 1484 | + $privs[] = $row['Privilege']; |
|
| 1485 | + } |
|
| 1400 | 1486 | } |
| 1401 | 1487 | $smcFunc['db_free_result']($get_privs); |
| 1402 | 1488 | |
@@ -1426,8 +1512,9 @@ discard block |
||
| 1426 | 1512 | $incontext['continue'] = 1; |
| 1427 | 1513 | |
| 1428 | 1514 | // Skipping? |
| 1429 | - if (!empty($_POST['skip'])) |
|
| 1430 | - return true; |
|
| 1515 | + if (!empty($_POST['skip'])) { |
|
| 1516 | + return true; |
|
| 1517 | + } |
|
| 1431 | 1518 | |
| 1432 | 1519 | // Need this to check whether we need the database password. |
| 1433 | 1520 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1444,18 +1531,22 @@ discard block |
||
| 1444 | 1531 | // We need this to properly hash the password for Admin |
| 1445 | 1532 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1446 | 1533 | global $sourcedir; |
| 1447 | - if (function_exists('mb_strtolower')) |
|
| 1448 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1534 | + if (function_exists('mb_strtolower')) { |
|
| 1535 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1536 | + } |
|
| 1449 | 1537 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1450 | 1538 | return utf8_strtolower($string); |
| 1451 | 1539 | }; |
| 1452 | 1540 | |
| 1453 | - if (!isset($_POST['username'])) |
|
| 1454 | - $_POST['username'] = ''; |
|
| 1455 | - if (!isset($_POST['email'])) |
|
| 1456 | - $_POST['email'] = ''; |
|
| 1457 | - if (!isset($_POST['server_email'])) |
|
| 1458 | - $_POST['server_email'] = ''; |
|
| 1541 | + if (!isset($_POST['username'])) { |
|
| 1542 | + $_POST['username'] = ''; |
|
| 1543 | + } |
|
| 1544 | + if (!isset($_POST['email'])) { |
|
| 1545 | + $_POST['email'] = ''; |
|
| 1546 | + } |
|
| 1547 | + if (!isset($_POST['server_email'])) { |
|
| 1548 | + $_POST['server_email'] = ''; |
|
| 1549 | + } |
|
| 1459 | 1550 | |
| 1460 | 1551 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1461 | 1552 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1474,8 +1565,9 @@ discard block |
||
| 1474 | 1565 | 'admin_group' => 1, |
| 1475 | 1566 | ) |
| 1476 | 1567 | ); |
| 1477 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1478 | - $incontext['skip'] = 1; |
|
| 1568 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1569 | + $incontext['skip'] = 1; |
|
| 1570 | + } |
|
| 1479 | 1571 | $smcFunc['db_free_result']($request); |
| 1480 | 1572 | |
| 1481 | 1573 | // Trying to create an account? |
@@ -1506,8 +1598,9 @@ discard block |
||
| 1506 | 1598 | } |
| 1507 | 1599 | |
| 1508 | 1600 | // Update the webmaster's email? |
| 1509 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1510 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1601 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1602 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1603 | + } |
|
| 1511 | 1604 | |
| 1512 | 1605 | // Work out whether we're going to have dodgy characters and remove them. |
| 1513 | 1606 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1530,32 +1623,27 @@ discard block |
||
| 1530 | 1623 | $smcFunc['db_free_result']($result); |
| 1531 | 1624 | |
| 1532 | 1625 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1533 | - } |
|
| 1534 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1626 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1535 | 1627 | { |
| 1536 | 1628 | // Try the previous step again. |
| 1537 | 1629 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1538 | 1630 | return false; |
| 1539 | - } |
|
| 1540 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1631 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1541 | 1632 | { |
| 1542 | 1633 | // Try the previous step again. |
| 1543 | 1634 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1544 | 1635 | return false; |
| 1545 | - } |
|
| 1546 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1636 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1547 | 1637 | { |
| 1548 | 1638 | // One step back, this time fill out a proper admin email address. |
| 1549 | 1639 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1550 | 1640 | return false; |
| 1551 | - } |
|
| 1552 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1641 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1553 | 1642 | { |
| 1554 | 1643 | // One step back, this time fill out a proper admin email address. |
| 1555 | 1644 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1556 | 1645 | return false; |
| 1557 | - } |
|
| 1558 | - elseif ($_POST['username'] != '') |
|
| 1646 | + } elseif ($_POST['username'] != '') |
|
| 1559 | 1647 | { |
| 1560 | 1648 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1561 | 1649 | |
@@ -1623,17 +1711,19 @@ discard block |
||
| 1623 | 1711 | reloadSettings(); |
| 1624 | 1712 | |
| 1625 | 1713 | // Bring a warning over. |
| 1626 | - if (!empty($incontext['account_existed'])) |
|
| 1627 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1714 | + if (!empty($incontext['account_existed'])) { |
|
| 1715 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1716 | + } |
|
| 1628 | 1717 | |
| 1629 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1630 | - $smcFunc['db_query']('', ' |
|
| 1718 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1719 | + $smcFunc['db_query']('', ' |
|
| 1631 | 1720 | SET NAMES {string:db_character_set}', |
| 1632 | 1721 | array( |
| 1633 | 1722 | 'db_character_set' => $db_character_set, |
| 1634 | 1723 | 'db_error_skip' => true, |
| 1635 | 1724 | ) |
| 1636 | 1725 | ); |
| 1726 | + } |
|
| 1637 | 1727 | |
| 1638 | 1728 | // As track stats is by default enabled let's add some activity. |
| 1639 | 1729 | $smcFunc['db_insert']('ignore', |
@@ -1654,14 +1744,16 @@ discard block |
||
| 1654 | 1744 | // Only proceed if we can load the data. |
| 1655 | 1745 | if ($request) |
| 1656 | 1746 | { |
| 1657 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1658 | - $modSettings[$row[0]] = $row[1]; |
|
| 1747 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1748 | + $modSettings[$row[0]] = $row[1]; |
|
| 1749 | + } |
|
| 1659 | 1750 | $smcFunc['db_free_result']($request); |
| 1660 | 1751 | } |
| 1661 | 1752 | |
| 1662 | 1753 | // Automatically log them in ;) |
| 1663 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1664 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1754 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1755 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1756 | + } |
|
| 1665 | 1757 | |
| 1666 | 1758 | $result = $smcFunc['db_query']('', ' |
| 1667 | 1759 | SELECT value |
@@ -1672,13 +1764,14 @@ discard block |
||
| 1672 | 1764 | 'db_error_skip' => true, |
| 1673 | 1765 | ) |
| 1674 | 1766 | ); |
| 1675 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1676 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1767 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1768 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1769 | + } |
|
| 1677 | 1770 | $smcFunc['db_free_result']($result); |
| 1678 | 1771 | |
| 1679 | - if (empty($db_sessions)) |
|
| 1680 | - $_SESSION['admin_time'] = time(); |
|
| 1681 | - else |
|
| 1772 | + if (empty($db_sessions)) { |
|
| 1773 | + $_SESSION['admin_time'] = time(); |
|
| 1774 | + } else |
|
| 1682 | 1775 | { |
| 1683 | 1776 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1684 | 1777 | |
@@ -1702,8 +1795,9 @@ discard block |
||
| 1702 | 1795 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1703 | 1796 | function($string){ |
| 1704 | 1797 | global $sourcedir; |
| 1705 | - if (function_exists('mb_strtolower')) |
|
| 1706 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1798 | + if (function_exists('mb_strtolower')) { |
|
| 1799 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1800 | + } |
|
| 1707 | 1801 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1708 | 1802 | return utf8_strtolower($string); |
| 1709 | 1803 | }; |
@@ -1719,8 +1813,9 @@ discard block |
||
| 1719 | 1813 | ) |
| 1720 | 1814 | ); |
| 1721 | 1815 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1722 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1723 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1816 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1817 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1818 | + } |
|
| 1724 | 1819 | $smcFunc['db_free_result']($request); |
| 1725 | 1820 | |
| 1726 | 1821 | // Now is the perfect time to fetch the SM files. |
@@ -1739,8 +1834,9 @@ discard block |
||
| 1739 | 1834 | |
| 1740 | 1835 | // Check if we need some stupid MySQL fix. |
| 1741 | 1836 | $server_version = $smcFunc['db_server_info'](); |
| 1742 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1743 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1837 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1838 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1839 | + } |
|
| 1744 | 1840 | |
| 1745 | 1841 | // Some final context for the template. |
| 1746 | 1842 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1760,8 +1856,9 @@ discard block |
||
| 1760 | 1856 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1761 | 1857 | |
| 1762 | 1858 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1763 | - if (count($settingsArray) == 1) |
|
| 1764 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1859 | + if (count($settingsArray) == 1) { |
|
| 1860 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1861 | + } |
|
| 1765 | 1862 | |
| 1766 | 1863 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1767 | 1864 | { |
@@ -1769,25 +1866,29 @@ discard block |
||
| 1769 | 1866 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
| 1770 | 1867 | { |
| 1771 | 1868 | // Set the ten lines to nothing. |
| 1772 | - for ($j=0; $j < 10; $j++) |
|
| 1773 | - $settingsArray[$i++] = ''; |
|
| 1869 | + for ($j=0; $j < 10; $j++) { |
|
| 1870 | + $settingsArray[$i++] = ''; |
|
| 1871 | + } |
|
| 1774 | 1872 | |
| 1775 | 1873 | continue; |
| 1776 | 1874 | } |
| 1777 | 1875 | |
| 1778 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1779 | - $settingsArray[$i] = ''; |
|
| 1876 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1877 | + $settingsArray[$i] = ''; |
|
| 1878 | + } |
|
| 1780 | 1879 | |
| 1781 | 1880 | // Don't trim or bother with it if it's not a variable. |
| 1782 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1783 | - continue; |
|
| 1881 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1882 | + continue; |
|
| 1883 | + } |
|
| 1784 | 1884 | |
| 1785 | 1885 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1786 | 1886 | |
| 1787 | - foreach ($vars as $var => $val) |
|
| 1788 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1887 | + foreach ($vars as $var => $val) { |
|
| 1888 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1789 | 1889 | { |
| 1790 | 1890 | $comment = strstr($settingsArray[$i], '#'); |
| 1891 | + } |
|
| 1791 | 1892 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1792 | 1893 | unset($vars[$var]); |
| 1793 | 1894 | } |
@@ -1797,36 +1898,41 @@ discard block |
||
| 1797 | 1898 | if (!empty($vars)) |
| 1798 | 1899 | { |
| 1799 | 1900 | $settingsArray[$i++] = ''; |
| 1800 | - foreach ($vars as $var => $val) |
|
| 1801 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1901 | + foreach ($vars as $var => $val) { |
|
| 1902 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1903 | + } |
|
| 1802 | 1904 | } |
| 1803 | 1905 | |
| 1804 | 1906 | // Blank out the file - done to fix a oddity with some servers. |
| 1805 | 1907 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1806 | - if (!$fp) |
|
| 1807 | - return false; |
|
| 1908 | + if (!$fp) { |
|
| 1909 | + return false; |
|
| 1910 | + } |
|
| 1808 | 1911 | fclose($fp); |
| 1809 | 1912 | |
| 1810 | 1913 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1811 | 1914 | |
| 1812 | 1915 | // Gotta have one of these ;) |
| 1813 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1814 | - fwrite($fp, "<?php\n"); |
|
| 1916 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1917 | + fwrite($fp, "<?php\n"); |
|
| 1918 | + } |
|
| 1815 | 1919 | |
| 1816 | 1920 | $lines = count($settingsArray); |
| 1817 | 1921 | for ($i = 0; $i < $lines - 1; $i++) |
| 1818 | 1922 | { |
| 1819 | 1923 | // Don't just write a bunch of blank lines. |
| 1820 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1821 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1924 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1925 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1926 | + } |
|
| 1822 | 1927 | } |
| 1823 | 1928 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1824 | 1929 | fclose($fp); |
| 1825 | 1930 | |
| 1826 | 1931 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1827 | 1932 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1828 | - if (function_exists('opcache_invalidate')) |
|
| 1829 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1933 | + if (function_exists('opcache_invalidate')) { |
|
| 1934 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1935 | + } |
|
| 1830 | 1936 | |
| 1831 | 1937 | return true; |
| 1832 | 1938 | } |
@@ -1836,10 +1942,11 @@ discard block |
||
| 1836 | 1942 | global $cachedir; |
| 1837 | 1943 | |
| 1838 | 1944 | // Write out the db_last_error file with the error timestamp |
| 1839 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
| 1840 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1841 | - else |
|
| 1842 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1945 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
| 1946 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1947 | + } else { |
|
| 1948 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1949 | + } |
|
| 1843 | 1950 | |
| 1844 | 1951 | return true; |
| 1845 | 1952 | } |
@@ -1856,9 +1963,9 @@ discard block |
||
| 1856 | 1963 | SecFilterScanPOST Off |
| 1857 | 1964 | </IfModule>'; |
| 1858 | 1965 | |
| 1859 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1860 | - return true; |
|
| 1861 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1966 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1967 | + return true; |
|
| 1968 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1862 | 1969 | { |
| 1863 | 1970 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1864 | 1971 | |
@@ -1870,29 +1977,28 @@ discard block |
||
| 1870 | 1977 | fwrite($ht_handle, $htaccess_addition); |
| 1871 | 1978 | fclose($ht_handle); |
| 1872 | 1979 | return true; |
| 1980 | + } else { |
|
| 1981 | + return false; |
|
| 1873 | 1982 | } |
| 1874 | - else |
|
| 1875 | - return false; |
|
| 1983 | + } else { |
|
| 1984 | + return true; |
|
| 1876 | 1985 | } |
| 1877 | - else |
|
| 1878 | - return true; |
|
| 1879 | - } |
|
| 1880 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1881 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1882 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1986 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1987 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1988 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1883 | 1989 | { |
| 1884 | 1990 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1885 | 1991 | { |
| 1886 | 1992 | fwrite($ht_handle, $htaccess_addition); |
| 1887 | 1993 | fclose($ht_handle); |
| 1888 | 1994 | return true; |
| 1995 | + } else { |
|
| 1996 | + return false; |
|
| 1889 | 1997 | } |
| 1890 | - else |
|
| 1998 | + } else { |
|
| 1891 | 1999 | return false; |
| 1892 | 2000 | } |
| 1893 | - else |
|
| 1894 | - return false; |
|
| 1895 | -} |
|
| 2001 | + } |
|
| 1896 | 2002 | |
| 1897 | 2003 | function template_install_above() |
| 1898 | 2004 | { |
@@ -1931,9 +2037,10 @@ discard block |
||
| 1931 | 2037 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1932 | 2038 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1933 | 2039 | |
| 1934 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1935 | - echo ' |
|
| 2040 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 2041 | + echo ' |
|
| 1936 | 2042 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2043 | + } |
|
| 1937 | 2044 | |
| 1938 | 2045 | echo ' |
| 1939 | 2046 | </select> |
@@ -1953,9 +2060,10 @@ discard block |
||
| 1953 | 2060 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1954 | 2061 | <ul>'; |
| 1955 | 2062 | |
| 1956 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1957 | - echo ' |
|
| 2063 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2064 | + echo ' |
|
| 1958 | 2065 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2066 | + } |
|
| 1959 | 2067 | |
| 1960 | 2068 | echo ' |
| 1961 | 2069 | </ul> |
@@ -1981,20 +2089,23 @@ discard block |
||
| 1981 | 2089 | echo ' |
| 1982 | 2090 | <div class="floatright">'; |
| 1983 | 2091 | |
| 1984 | - if (!empty($incontext['continue'])) |
|
| 1985 | - echo ' |
|
| 2092 | + if (!empty($incontext['continue'])) { |
|
| 2093 | + echo ' |
|
| 1986 | 2094 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">'; |
| 1987 | - if (!empty($incontext['skip'])) |
|
| 1988 | - echo ' |
|
| 2095 | + } |
|
| 2096 | + if (!empty($incontext['skip'])) { |
|
| 2097 | + echo ' |
|
| 1989 | 2098 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">'; |
| 2099 | + } |
|
| 1990 | 2100 | echo ' |
| 1991 | 2101 | </div>'; |
| 1992 | 2102 | } |
| 1993 | 2103 | |
| 1994 | 2104 | // Show the closing form tag and other data only if not in the last step |
| 1995 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1996 | - echo ' |
|
| 2105 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2106 | + echo ' |
|
| 1997 | 2107 | </form>'; |
| 2108 | + } |
|
| 1998 | 2109 | |
| 1999 | 2110 | echo ' |
| 2000 | 2111 | </div><!-- .panel --> |
@@ -2027,13 +2138,15 @@ discard block |
||
| 2027 | 2138 | </div>'; |
| 2028 | 2139 | |
| 2029 | 2140 | // Show the warnings, or not. |
| 2030 | - if (template_warning_divs()) |
|
| 2031 | - echo ' |
|
| 2141 | + if (template_warning_divs()) { |
|
| 2142 | + echo ' |
|
| 2032 | 2143 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2144 | + } |
|
| 2033 | 2145 | |
| 2034 | 2146 | // Say we want the continue button! |
| 2035 | - if (empty($incontext['error'])) |
|
| 2036 | - $incontext['continue'] = 1; |
|
| 2147 | + if (empty($incontext['error'])) { |
|
| 2148 | + $incontext['continue'] = 1; |
|
| 2149 | + } |
|
| 2037 | 2150 | |
| 2038 | 2151 | // For the latest version stuff. |
| 2039 | 2152 | echo ' |
@@ -2067,19 +2180,21 @@ discard block |
||
| 2067 | 2180 | global $txt, $incontext; |
| 2068 | 2181 | |
| 2069 | 2182 | // Errors are very serious.. |
| 2070 | - if (!empty($incontext['error'])) |
|
| 2071 | - echo ' |
|
| 2183 | + if (!empty($incontext['error'])) { |
|
| 2184 | + echo ' |
|
| 2072 | 2185 | <div class="errorbox"> |
| 2073 | 2186 | <h3>', $txt['upgrade_critical_error'], '</h3> |
| 2074 | 2187 | ', $incontext['error'], ' |
| 2075 | 2188 | </div>'; |
| 2189 | + } |
|
| 2076 | 2190 | // A warning message? |
| 2077 | - elseif (!empty($incontext['warning'])) |
|
| 2078 | - echo ' |
|
| 2191 | + elseif (!empty($incontext['warning'])) { |
|
| 2192 | + echo ' |
|
| 2079 | 2193 | <div class="errorbox"> |
| 2080 | 2194 | <h3>', $txt['upgrade_warning'], '</h3> |
| 2081 | 2195 | ', $incontext['warning'], ' |
| 2082 | 2196 | </div>'; |
| 2197 | + } |
|
| 2083 | 2198 | |
| 2084 | 2199 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2085 | 2200 | } |
@@ -2095,26 +2210,29 @@ discard block |
||
| 2095 | 2210 | <li>', $incontext['failed_files']), '</li> |
| 2096 | 2211 | </ul>'; |
| 2097 | 2212 | |
| 2098 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2099 | - echo ' |
|
| 2213 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2214 | + echo ' |
|
| 2100 | 2215 | <hr> |
| 2101 | 2216 | <p>', $txt['chmod_linux_info'], '</p> |
| 2102 | 2217 | <samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>'; |
| 2218 | + } |
|
| 2103 | 2219 | |
| 2104 | 2220 | // This is serious! |
| 2105 | - if (!template_warning_divs()) |
|
| 2106 | - return; |
|
| 2221 | + if (!template_warning_divs()) { |
|
| 2222 | + return; |
|
| 2223 | + } |
|
| 2107 | 2224 | |
| 2108 | 2225 | echo ' |
| 2109 | 2226 | <hr> |
| 2110 | 2227 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2111 | 2228 | |
| 2112 | - if (!empty($incontext['ftp_errors'])) |
|
| 2113 | - echo ' |
|
| 2229 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2230 | + echo ' |
|
| 2114 | 2231 | <div class="error_message"> |
| 2115 | 2232 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2116 | 2233 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2117 | 2234 | </div>'; |
| 2235 | + } |
|
| 2118 | 2236 | |
| 2119 | 2237 | echo ' |
| 2120 | 2238 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2183,16 +2301,16 @@ discard block |
||
| 2183 | 2301 | <dd> |
| 2184 | 2302 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2185 | 2303 | |
| 2186 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2187 | - echo ' |
|
| 2304 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2305 | + echo ' |
|
| 2188 | 2306 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2307 | + } |
|
| 2189 | 2308 | |
| 2190 | 2309 | echo ' |
| 2191 | 2310 | </select> |
| 2192 | 2311 | <div class="smalltext">', $txt['db_settings_type_info'], '</div> |
| 2193 | 2312 | </dd>'; |
| 2194 | - } |
|
| 2195 | - else |
|
| 2313 | + } else |
|
| 2196 | 2314 | { |
| 2197 | 2315 | echo ' |
| 2198 | 2316 | <dd> |
@@ -2360,9 +2478,10 @@ discard block |
||
| 2360 | 2478 | <div class="red">', $txt['error_db_queries'], '</div> |
| 2361 | 2479 | <ul>'; |
| 2362 | 2480 | |
| 2363 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2364 | - echo ' |
|
| 2481 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2482 | + echo ' |
|
| 2365 | 2483 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2484 | + } |
|
| 2366 | 2485 | |
| 2367 | 2486 | echo ' |
| 2368 | 2487 | </ul>'; |
@@ -2427,15 +2546,16 @@ discard block |
||
| 2427 | 2546 | </dd> |
| 2428 | 2547 | </dl>'; |
| 2429 | 2548 | |
| 2430 | - if ($incontext['require_db_confirm']) |
|
| 2431 | - echo ' |
|
| 2549 | + if ($incontext['require_db_confirm']) { |
|
| 2550 | + echo ' |
|
| 2432 | 2551 | <h2>', $txt['user_settings_database'], '</h2> |
| 2433 | 2552 | <p>', $txt['user_settings_database_info'], '</p> |
| 2434 | 2553 | |
| 2435 | 2554 | <div class="lefttext"> |
| 2436 | 2555 | <input type="password" name="password3" size="30"> |
| 2437 | 2556 | </div>'; |
| 2438 | -} |
|
| 2557 | + } |
|
| 2558 | + } |
|
| 2439 | 2559 | |
| 2440 | 2560 | // Tell them it's done, and to delete. |
| 2441 | 2561 | function template_delete_install() |
@@ -2448,13 +2568,14 @@ discard block |
||
| 2448 | 2568 | template_warning_divs(); |
| 2449 | 2569 | |
| 2450 | 2570 | // Install directory still writable? |
| 2451 | - if ($incontext['dir_still_writable']) |
|
| 2452 | - echo ' |
|
| 2571 | + if ($incontext['dir_still_writable']) { |
|
| 2572 | + echo ' |
|
| 2453 | 2573 | <p><em>', $txt['still_writable'], '</em></p>'; |
| 2574 | + } |
|
| 2454 | 2575 | |
| 2455 | 2576 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2456 | - if ($incontext['probably_delete_install']) |
|
| 2457 | - echo ' |
|
| 2577 | + if ($incontext['probably_delete_install']) { |
|
| 2578 | + echo ' |
|
| 2458 | 2579 | <label> |
| 2459 | 2580 | <input type="checkbox" id="delete_self" onclick="doTheDelete();"> |
| 2460 | 2581 | <strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong> |
@@ -2470,6 +2591,7 @@ discard block |
||
| 2470 | 2591 | theCheck.disabled = true; |
| 2471 | 2592 | } |
| 2472 | 2593 | </script>'; |
| 2594 | + } |
|
| 2473 | 2595 | |
| 2474 | 2596 | echo ' |
| 2475 | 2597 | <p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p> |
@@ -23,11 +23,13 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $editor_context = &$context['controls']['richedit'][$editor_id]; |
| 25 | 25 | |
| 26 | - if ($smileyContainer === null) |
|
| 27 | - $editor_context['sce_options']['emoticonsEnabled'] = false; |
|
| 26 | + if ($smileyContainer === null) { |
|
| 27 | + $editor_context['sce_options']['emoticonsEnabled'] = false; |
|
| 28 | + } |
|
| 28 | 29 | |
| 29 | - if ($bbcContainer === null) |
|
| 30 | - $editor_context['sce_options']['toolbar'] = ''; |
|
| 30 | + if ($bbcContainer === null) { |
|
| 31 | + $editor_context['sce_options']['toolbar'] = ''; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | echo ' |
| 33 | 35 | <textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea> |
@@ -40,18 +42,21 @@ discard block |
||
| 40 | 42 | var textarea = $("#', $editor_id, '").get(0); |
| 41 | 43 | sceditor.create(textarea, ', $smcFunc['json_encode']($editor_context['sce_options'], JSON_PRETTY_PRINT), ');'; |
| 42 | 44 | |
| 43 | - if ($editor_context['sce_options']['emoticonsEnabled']) |
|
| 44 | - echo ' |
|
| 45 | + if ($editor_context['sce_options']['emoticonsEnabled']) { |
|
| 46 | + echo ' |
|
| 45 | 47 | sceditor.instance(textarea).createPermanentDropDown();'; |
| 48 | + } |
|
| 46 | 49 | |
| 47 | - if (empty($editor_context['rich_active'])) |
|
| 48 | - echo ' |
|
| 50 | + if (empty($editor_context['rich_active'])) { |
|
| 51 | + echo ' |
|
| 49 | 52 | sceditor.instance(textarea).toggleSourceMode();'; |
| 53 | + } |
|
| 50 | 54 | |
| 51 | - if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) |
|
| 52 | - echo ' |
|
| 55 | + if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) { |
|
| 56 | + echo ' |
|
| 53 | 57 | $(".sceditor-container").find("textarea").each(function() {$(this).css({border: "1px solid red"})}); |
| 54 | 58 | $(".sceditor-container").find("iframe").each(function() {$(this).css({border: "1px solid red"})});'; |
| 59 | + } |
|
| 55 | 60 | |
| 56 | 61 | echo ' |
| 57 | 62 | });'; |
@@ -88,42 +93,47 @@ discard block |
||
| 88 | 93 | |
| 89 | 94 | $tempTab = $context['tabindex']; |
| 90 | 95 | |
| 91 | - if (!empty($context['drafts_pm_save'])) |
|
| 92 | - $tempTab++; |
|
| 93 | - elseif (!empty($context['drafts_save'])) |
|
| 94 | - $tempTab++; |
|
| 95 | - elseif ($editor_context['preview_type']) |
|
| 96 | - $tempTab++; |
|
| 97 | - elseif ($context['show_spellchecking']) |
|
| 98 | - $tempTab++; |
|
| 96 | + if (!empty($context['drafts_pm_save'])) { |
|
| 97 | + $tempTab++; |
|
| 98 | + } elseif (!empty($context['drafts_save'])) { |
|
| 99 | + $tempTab++; |
|
| 100 | + } elseif ($editor_context['preview_type']) { |
|
| 101 | + $tempTab++; |
|
| 102 | + } elseif ($context['show_spellchecking']) { |
|
| 103 | + $tempTab++; |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $tempTab++; |
| 101 | 107 | $context['tabindex'] = $tempTab; |
| 102 | 108 | |
| 103 | - if (!empty($context['drafts_pm_save'])) |
|
| 104 | - echo ' |
|
| 109 | + if (!empty($context['drafts_pm_save'])) { |
|
| 110 | + echo ' |
|
| 105 | 111 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
| 106 | 112 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
| 113 | + } |
|
| 107 | 114 | |
| 108 | - if (!empty($context['drafts_save'])) |
|
| 109 | - echo ' |
|
| 115 | + if (!empty($context['drafts_save'])) { |
|
| 116 | + echo ' |
|
| 110 | 117 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button"> |
| 111 | 118 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
| 119 | + } |
|
| 112 | 120 | |
| 113 | - if ($context['show_spellchecking']) |
|
| 114 | - echo ' |
|
| 121 | + if ($context['show_spellchecking']) { |
|
| 122 | + echo ' |
|
| 115 | 123 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
| 124 | + } |
|
| 116 | 125 | |
| 117 | - if ($editor_context['preview_type']) |
|
| 118 | - echo ' |
|
| 126 | + if ($editor_context['preview_type']) { |
|
| 127 | + echo ' |
|
| 119 | 128 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? '' : 'return submitThisOnce(this);', '" accesskey="p" class="button">'; |
| 129 | + } |
|
| 120 | 130 | |
| 121 | 131 | echo ' |
| 122 | 132 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">'; |
| 123 | 133 | |
| 124 | 134 | // Load in the PM autosaver if it's enabled |
| 125 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
| 126 | - echo ' |
|
| 135 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
| 136 | + echo ' |
|
| 127 | 137 | <span class="righttext padding" style="display: block"> |
| 128 | 138 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
| 129 | 139 | <span id="draft_lastautosave" ></span> |
@@ -141,10 +151,11 @@ discard block |
||
| 141 | 151 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
| 142 | 152 | }); |
| 143 | 153 | </script>'; |
| 154 | + } |
|
| 144 | 155 | |
| 145 | 156 | // Start an instance of the auto saver if its enabled |
| 146 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
| 147 | - echo ' |
|
| 157 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
| 158 | + echo ' |
|
| 148 | 159 | <span class="righttext padding" style="display: block"> |
| 149 | 160 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
| 150 | 161 | <span id="draft_lastautosave" ></span> |
@@ -161,7 +172,8 @@ discard block |
||
| 161 | 172 | iFreq: ', $context['drafts_autosave_frequency'], ' |
| 162 | 173 | }); |
| 163 | 174 | </script>'; |
| 164 | -} |
|
| 175 | + } |
|
| 176 | + } |
|
| 165 | 177 | |
| 166 | 178 | /** |
| 167 | 179 | * This template displays a verification form |
@@ -178,51 +190,57 @@ discard block |
||
| 178 | 190 | $verify_context = &$context['controls']['verification'][$verify_id]; |
| 179 | 191 | |
| 180 | 192 | // Keep track of where we are. |
| 181 | - if (empty($verify_context['tracking']) || $reset) |
|
| 182 | - $verify_context['tracking'] = 0; |
|
| 193 | + if (empty($verify_context['tracking']) || $reset) { |
|
| 194 | + $verify_context['tracking'] = 0; |
|
| 195 | + } |
|
| 183 | 196 | |
| 184 | 197 | // How many items are there to display in total. |
| 185 | 198 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
| 186 | 199 | |
| 187 | 200 | // If we've gone too far, stop. |
| 188 | - if ($verify_context['tracking'] > $total_items) |
|
| 189 | - return false; |
|
| 201 | + if ($verify_context['tracking'] > $total_items) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 190 | 204 | |
| 191 | 205 | // Loop through each item to show them. |
| 192 | 206 | for ($i = 0; $i < $total_items; $i++) |
| 193 | 207 | { |
| 194 | 208 | // If we're after a single item only show it if we're in the right place. |
| 195 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
| 196 | - continue; |
|
| 209 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 197 | 212 | |
| 198 | - if ($display_type != 'single') |
|
| 199 | - echo ' |
|
| 213 | + if ($display_type != 'single') { |
|
| 214 | + echo ' |
|
| 200 | 215 | <div id="verification_control_', $i, '" class="verification_control">'; |
| 216 | + } |
|
| 201 | 217 | |
| 202 | 218 | // Display empty field, but only if we have one, and it's the first time. |
| 203 | - if ($verify_context['empty_field'] && empty($i)) |
|
| 204 | - echo ' |
|
| 219 | + if ($verify_context['empty_field'] && empty($i)) { |
|
| 220 | + echo ' |
|
| 205 | 221 | <div class="smalltext vv_special"> |
| 206 | 222 | ', $txt['visual_verification_hidden'], ': |
| 207 | 223 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
| 208 | 224 | </div>'; |
| 225 | + } |
|
| 209 | 226 | |
| 210 | 227 | // Do the actual stuff |
| 211 | 228 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
| 212 | 229 | { |
| 213 | 230 | if ($verify_context['show_visual']) |
| 214 | 231 | { |
| 215 | - if ($context['use_graphic_library']) |
|
| 216 | - echo ' |
|
| 232 | + if ($context['use_graphic_library']) { |
|
| 233 | + echo ' |
|
| 217 | 234 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
| 218 | - else |
|
| 219 | - echo ' |
|
| 235 | + } else { |
|
| 236 | + echo ' |
|
| 220 | 237 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
| 221 | 238 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
| 222 | 239 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
| 223 | 240 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
| 224 | 241 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
| 225 | 242 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
| 243 | + } |
|
| 226 | 244 | |
| 227 | 245 | echo ' |
| 228 | 246 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -240,8 +258,7 @@ discard block |
||
| 240 | 258 | <br> |
| 241 | 259 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>'; |
| 242 | 260 | } |
| 243 | - } |
|
| 244 | - else |
|
| 261 | + } else |
|
| 245 | 262 | { |
| 246 | 263 | // Where in the question array is this question? |
| 247 | 264 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -253,21 +270,24 @@ discard block |
||
| 253 | 270 | </div>'; |
| 254 | 271 | } |
| 255 | 272 | |
| 256 | - if ($display_type != 'single') |
|
| 257 | - echo ' |
|
| 273 | + if ($display_type != 'single') { |
|
| 274 | + echo ' |
|
| 258 | 275 | </div><!-- #verification_control_[i] -->'; |
| 276 | + } |
|
| 259 | 277 | |
| 260 | 278 | // If we were displaying just one and we did it, break. |
| 261 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
| 262 | - break; |
|
| 279 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
| 280 | + break; |
|
| 281 | + } |
|
| 263 | 282 | } |
| 264 | 283 | |
| 265 | 284 | // Assume we found something, always. |
| 266 | 285 | $verify_context['tracking']++; |
| 267 | 286 | |
| 268 | 287 | // Tell something displaying piecemeal to keep going. |
| 269 | - if ($display_type == 'single') |
|
| 270 | - return true; |
|
| 271 | -} |
|
| 288 | + if ($display_type == 'single') { |
|
| 289 | + return true; |
|
| 290 | + } |
|
| 291 | + } |
|
| 272 | 292 | |
| 273 | 293 | ?> |
| 274 | 294 | \ No newline at end of file |
@@ -22,24 +22,26 @@ discard block |
||
| 22 | 22 | <script>'; |
| 23 | 23 | |
| 24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
| 25 | - if (isBrowser('is_firefox')) |
|
| 26 | - echo ' |
|
| 25 | + if (isBrowser('is_firefox')) { |
|
| 26 | + echo ' |
|
| 27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | // Start with message icons - and any missing from this theme. |
| 30 | 31 | echo ' |
| 31 | 32 | var icon_urls = {'; |
| 32 | 33 | |
| 33 | - foreach ($context['icons'] as $icon) |
|
| 34 | - echo ' |
|
| 34 | + foreach ($context['icons'] as $icon) { |
|
| 35 | + echo ' |
|
| 35 | 36 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | echo ' |
| 38 | 40 | };'; |
| 39 | 41 | |
| 40 | 42 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
| 41 | - if ($context['make_poll']) |
|
| 42 | - echo ' |
|
| 43 | + if ($context['make_poll']) { |
|
| 44 | + echo ' |
|
| 43 | 45 | var pollOptionNum = 0, pollTabIndex; |
| 44 | 46 | var pollOptionId = ', $context['last_choice_id'], '; |
| 45 | 47 | function addPollOption() |
@@ -58,11 +60,13 @@ discard block |
||
| 58 | 60 | |
| 59 | 61 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), '); |
| 60 | 62 | }'; |
| 63 | + } |
|
| 61 | 64 | |
| 62 | 65 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
| 63 | - if ($context['make_event']) |
|
| 64 | - echo ' |
|
| 66 | + if ($context['make_event']) { |
|
| 67 | + echo ' |
|
| 65 | 68 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | // End of the javascript, start the form and display the link tree. |
| 68 | 72 | echo ' |
@@ -83,9 +87,10 @@ discard block |
||
| 83 | 87 | </div> |
| 84 | 88 | <br>'; |
| 85 | 89 | |
| 86 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
| 87 | - echo ' |
|
| 90 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
| 91 | + echo ' |
|
| 88 | 92 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
| 93 | + } |
|
| 89 | 94 | |
| 90 | 95 | // Start the main table. |
| 91 | 96 | echo ' |
@@ -110,26 +115,29 @@ discard block |
||
| 110 | 115 | </div>'; |
| 111 | 116 | |
| 112 | 117 | // If this won't be approved let them know! |
| 113 | - if (!$context['becomes_approved']) |
|
| 114 | - echo ' |
|
| 118 | + if (!$context['becomes_approved']) { |
|
| 119 | + echo ' |
|
| 115 | 120 | <div class="noticebox"> |
| 116 | 121 | <em>', $txt['wait_for_approval'], '</em> |
| 117 | 122 | <input type="hidden" name="not_approved" value="1"> |
| 118 | 123 | </div>'; |
| 124 | + } |
|
| 119 | 125 | |
| 120 | 126 | // If it's locked, show a message to warn the replier. |
| 121 | - if (!empty($context['locked'])) |
|
| 122 | - echo ' |
|
| 127 | + if (!empty($context['locked'])) { |
|
| 128 | + echo ' |
|
| 123 | 129 | <div class="errorbox"> |
| 124 | 130 | ', $txt['topic_locked_no_reply'], ' |
| 125 | 131 | </div>'; |
| 132 | + } |
|
| 126 | 133 | |
| 127 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 128 | - echo ' |
|
| 134 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 135 | + echo ' |
|
| 129 | 136 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
| 130 | 137 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
| 131 | 138 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
| 132 | 139 | </div>'; |
| 140 | + } |
|
| 133 | 141 | |
| 134 | 142 | // The post header... important stuff |
| 135 | 143 | template_post_header(); |
@@ -162,9 +170,10 @@ discard block |
||
| 162 | 170 | echo ' |
| 163 | 171 | <optgroup label="', $category['name'], '">'; |
| 164 | 172 | |
| 165 | - foreach ($category['boards'] as $board) |
|
| 166 | - echo ' |
|
| 173 | + foreach ($category['boards'] as $board) { |
|
| 174 | + echo ' |
|
| 167 | 175 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 176 | + } |
|
| 168 | 177 | echo ' |
| 169 | 178 | </optgroup>'; |
| 170 | 179 | } |
@@ -200,9 +209,10 @@ discard block |
||
| 200 | 209 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 201 | 210 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 202 | 211 | |
| 203 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 204 | - echo ' |
|
| 212 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 213 | + echo ' |
|
| 205 | 214 | <option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 215 | + } |
|
| 206 | 216 | |
| 207 | 217 | echo ' |
| 208 | 218 | </select> |
@@ -231,14 +241,15 @@ discard block |
||
| 231 | 241 | </dd>'; |
| 232 | 242 | |
| 233 | 243 | // Loop through all the choices and print them out. |
| 234 | - foreach ($context['choices'] as $choice) |
|
| 235 | - echo ' |
|
| 244 | + foreach ($context['choices'] as $choice) { |
|
| 245 | + echo ' |
|
| 236 | 246 | <dt> |
| 237 | 247 | <label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>: |
| 238 | 248 | </dt> |
| 239 | 249 | <dd> |
| 240 | 250 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255"> |
| 241 | 251 | </dd>'; |
| 252 | + } |
|
| 242 | 253 | |
| 243 | 254 | echo ' |
| 244 | 255 | <p id="pollMoreOptions"></p> |
@@ -268,14 +279,15 @@ discard block |
||
| 268 | 279 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
| 269 | 280 | </dd>'; |
| 270 | 281 | |
| 271 | - if ($context['poll_options']['guest_vote_enabled']) |
|
| 272 | - echo ' |
|
| 282 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
| 283 | + echo ' |
|
| 273 | 284 | <dt> |
| 274 | 285 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
| 275 | 286 | </dt> |
| 276 | 287 | <dd> |
| 277 | 288 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '> |
| 278 | 289 | </dd>'; |
| 290 | + } |
|
| 279 | 291 | |
| 280 | 292 | echo ' |
| 281 | 293 | <dt> |
@@ -296,8 +308,8 @@ discard block |
||
| 296 | 308 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
| 297 | 309 | |
| 298 | 310 | // If we're editing and displaying edit details, show a box where they can say why |
| 299 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
| 300 | - echo ' |
|
| 311 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
| 312 | + echo ' |
|
| 301 | 313 | <dl> |
| 302 | 314 | <dt class="clear"> |
| 303 | 315 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -306,20 +318,23 @@ discard block |
||
| 306 | 318 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"> |
| 307 | 319 | </dd> |
| 308 | 320 | </dl>'; |
| 321 | + } |
|
| 309 | 322 | |
| 310 | 323 | // If this message has been edited in the past - display when it was. |
| 311 | - if (isset($context['last_modified'])) |
|
| 312 | - echo ' |
|
| 324 | + if (isset($context['last_modified'])) { |
|
| 325 | + echo ' |
|
| 313 | 326 | <div class="padding smalltext"> |
| 314 | 327 | ', $context['last_modified_text'], ' |
| 315 | 328 | </div>'; |
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
| 318 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
| 319 | - echo ' |
|
| 332 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
| 333 | + echo ' |
|
| 320 | 334 | <div id="postAdditionalOptionsHeader"> |
| 321 | 335 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
| 322 | 336 | </div>'; |
| 337 | + } |
|
| 323 | 338 | |
| 324 | 339 | echo ' |
| 325 | 340 | <div id="postAdditionalOptions">'; |
@@ -352,19 +367,21 @@ discard block |
||
| 352 | 367 | ', $txt['uncheck_unwatchd_attach'], ': |
| 353 | 368 | </dd>'; |
| 354 | 369 | |
| 355 | - foreach ($context['current_attachments'] as $attachment) |
|
| 356 | - echo ' |
|
| 370 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 371 | + echo ' |
|
| 357 | 372 | <dd class="smalltext"> |
| 358 | 373 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
| 359 | 374 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label> |
| 360 | 375 | </dd>'; |
| 376 | + } |
|
| 361 | 377 | |
| 362 | 378 | echo ' |
| 363 | 379 | </dl>'; |
| 364 | 380 | |
| 365 | - if (!empty($context['files_in_session_warning'])) |
|
| 366 | - echo ' |
|
| 381 | + if (!empty($context['files_in_session_warning'])) { |
|
| 382 | + echo ' |
|
| 367 | 383 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
| 384 | + } |
|
| 368 | 385 | } |
| 369 | 386 | |
| 370 | 387 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -429,13 +446,14 @@ discard block |
||
| 429 | 446 | <div class="fallback"> |
| 430 | 447 | <input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)'; |
| 431 | 448 | |
| 432 | - if (!empty($modSettings['attachmentSizeLimit'])) |
|
| 433 | - echo ' |
|
| 449 | + if (!empty($modSettings['attachmentSizeLimit'])) { |
|
| 450 | + echo ' |
|
| 434 | 451 | <input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">'; |
| 452 | + } |
|
| 435 | 453 | |
| 436 | 454 | // Show more boxes if they aren't approaching that limit. |
| 437 | - if ($context['num_allowed_attachments'] > 1) |
|
| 438 | - echo ' |
|
| 455 | + if ($context['num_allowed_attachments'] > 1) { |
|
| 456 | + echo ' |
|
| 439 | 457 | <script> |
| 440 | 458 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
| 441 | 459 | var current_attachment = 1; |
@@ -455,6 +473,7 @@ discard block |
||
| 455 | 473 | <a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a> |
| 456 | 474 | </div><!-- .fallback --> |
| 457 | 475 | </div><!-- #attachUpload -->'; |
| 476 | + } |
|
| 458 | 477 | |
| 459 | 478 | echo ' |
| 460 | 479 | </dd>'; |
@@ -466,21 +485,25 @@ discard block |
||
| 466 | 485 | <dd class="smalltext">'; |
| 467 | 486 | |
| 468 | 487 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
| 469 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
| 470 | - echo ' |
|
| 488 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
| 489 | + echo ' |
|
| 471 | 490 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
| 491 | + } |
|
| 472 | 492 | |
| 473 | - if (!empty($context['attachment_restrictions'])) |
|
| 474 | - echo ' |
|
| 493 | + if (!empty($context['attachment_restrictions'])) { |
|
| 494 | + echo ' |
|
| 475 | 495 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
| 496 | + } |
|
| 476 | 497 | |
| 477 | - if ($context['num_allowed_attachments'] == 0) |
|
| 478 | - echo ' |
|
| 498 | + if ($context['num_allowed_attachments'] == 0) { |
|
| 499 | + echo ' |
|
| 479 | 500 | ', $txt['attach_limit_nag'], '<br>'; |
| 501 | + } |
|
| 480 | 502 | |
| 481 | - if (!$context['can_post_attachment_unapproved']) |
|
| 482 | - echo ' |
|
| 503 | + if (!$context['can_post_attachment_unapproved']) { |
|
| 504 | + echo ' |
|
| 483 | 505 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
| 506 | + } |
|
| 484 | 507 | |
| 485 | 508 | echo ' |
| 486 | 509 | </dd> |
@@ -504,24 +527,26 @@ discard block |
||
| 504 | 527 | <dt><strong>', $txt['subject'], '</strong></dt> |
| 505 | 528 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
| 506 | 529 | |
| 507 | - foreach ($context['drafts'] as $draft) |
|
| 508 | - echo ' |
|
| 530 | + foreach ($context['drafts'] as $draft) { |
|
| 531 | + echo ' |
|
| 509 | 532 | <dt>', $draft['link'], '</dt> |
| 510 | 533 | <dd>', $draft['poster_time'], '</dd>'; |
| 534 | + } |
|
| 511 | 535 | echo ' |
| 512 | 536 | </dl> |
| 513 | 537 | </div>'; |
| 514 | 538 | } |
| 515 | 539 | |
| 516 | 540 | // Is visual verification enabled? |
| 517 | - if ($context['require_verification']) |
|
| 518 | - echo ' |
|
| 541 | + if ($context['require_verification']) { |
|
| 542 | + echo ' |
|
| 519 | 543 | <div class="post_verification"> |
| 520 | 544 | <span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '> |
| 521 | 545 | <strong>', $txt['verification'], ':</strong> |
| 522 | 546 | </span> |
| 523 | 547 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 524 | 548 | </div>'; |
| 549 | + } |
|
| 525 | 550 | |
| 526 | 551 | // Finally, the submit buttons. |
| 527 | 552 | echo ' |
@@ -530,9 +555,10 @@ discard block |
||
| 530 | 555 | ', template_control_richedit_buttons($context['post_box_name']); |
| 531 | 556 | |
| 532 | 557 | // Option to delete an event if user is editing one. |
| 533 | - if ($context['make_event'] && !$context['event']['new']) |
|
| 534 | - echo ' |
|
| 558 | + if ($context['make_event'] && !$context['event']['new']) { |
|
| 559 | + echo ' |
|
| 535 | 560 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">'; |
| 561 | + } |
|
| 536 | 562 | |
| 537 | 563 | echo ' |
| 538 | 564 | </span> |
@@ -541,9 +567,10 @@ discard block |
||
| 541 | 567 | <br class="clear">'; |
| 542 | 568 | |
| 543 | 569 | // Assuming this isn't a new topic pass across the last message id. |
| 544 | - if (isset($context['topic_last_message'])) |
|
| 545 | - echo ' |
|
| 570 | + if (isset($context['topic_last_message'])) { |
|
| 571 | + echo ' |
|
| 546 | 572 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
| 573 | + } |
|
| 547 | 574 | |
| 548 | 575 | echo ' |
| 549 | 576 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -564,13 +591,14 @@ discard block |
||
| 564 | 591 | </h5> |
| 565 | 592 | - %PostTime% » <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>'; |
| 566 | 593 | |
| 567 | - if ($context['can_quote']) |
|
| 568 | - $newPostsHTML .= ' |
|
| 594 | + if ($context['can_quote']) { |
|
| 595 | + $newPostsHTML .= ' |
|
| 569 | 596 | <ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;"> |
| 570 | 597 | <li id="post_modify"> |
| 571 | 598 | <a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a> |
| 572 | 599 | </li> |
| 573 | 600 | </ul>'; |
| 601 | + } |
|
| 574 | 602 | |
| 575 | 603 | $newPostsHTML .= ' |
| 576 | 604 | <br class="clear"> |
@@ -596,16 +624,17 @@ discard block |
||
| 596 | 624 | sSessionVar: ', JavaScriptEscape($context['session_var']), ', |
| 597 | 625 | newPostsTemplate:', JavaScriptEscape($newPostsHTML); |
| 598 | 626 | |
| 599 | - if (!empty($context['current_board'])) |
|
| 600 | - echo ', |
|
| 627 | + if (!empty($context['current_board'])) { |
|
| 628 | + echo ', |
|
| 601 | 629 | iCurrentBoard: ', $context['current_board'], ''; |
| 630 | + } |
|
| 602 | 631 | |
| 603 | 632 | echo ' |
| 604 | 633 | });'; |
| 605 | 634 | |
| 606 | 635 | // Code for showing and hiding additional options. |
| 607 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
| 608 | - echo ' |
|
| 636 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
| 637 | + echo ' |
|
| 609 | 638 | var oSwapAdditionalOptions = new smc_Toggle({ |
| 610 | 639 | bToggleEnabled: true, |
| 611 | 640 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -633,10 +662,11 @@ discard block |
||
| 633 | 662 | } |
| 634 | 663 | ] |
| 635 | 664 | });'; |
| 665 | + } |
|
| 636 | 666 | |
| 637 | 667 | // Code for showing and hiding drafts |
| 638 | - if (!empty($context['drafts'])) |
|
| 639 | - echo ' |
|
| 668 | + if (!empty($context['drafts'])) { |
|
| 669 | + echo ' |
|
| 640 | 670 | var oSwapDraftOptions = new smc_Toggle({ |
| 641 | 671 | bToggleEnabled: true, |
| 642 | 672 | bCurrentlyCollapsed: true, |
@@ -658,6 +688,7 @@ discard block |
||
| 658 | 688 | } |
| 659 | 689 | ] |
| 660 | 690 | });'; |
| 691 | + } |
|
| 661 | 692 | |
| 662 | 693 | echo ' |
| 663 | 694 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -678,8 +709,9 @@ discard block |
||
| 678 | 709 | foreach ($context['previous_posts'] as $post) |
| 679 | 710 | { |
| 680 | 711 | $ignoring = false; |
| 681 | - if (!empty($post['is_ignored'])) |
|
| 682 | - $ignored_posts[] = $ignoring = $post['id']; |
|
| 712 | + if (!empty($post['is_ignored'])) { |
|
| 713 | + $ignored_posts[] = $ignoring = $post['id']; |
|
| 714 | + } |
|
| 683 | 715 | |
| 684 | 716 | echo ' |
| 685 | 717 | <div class="windowbg"> |
@@ -689,22 +721,24 @@ discard block |
||
| 689 | 721 | </h5> |
| 690 | 722 | - ', $post['time']; |
| 691 | 723 | |
| 692 | - if ($context['can_quote']) |
|
| 693 | - echo ' |
|
| 724 | + if ($context['can_quote']) { |
|
| 725 | + echo ' |
|
| 694 | 726 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
| 695 | 727 | <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
| 696 | 728 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
| 697 | 729 | </ul>'; |
| 730 | + } |
|
| 698 | 731 | |
| 699 | 732 | echo ' |
| 700 | 733 | <br class="clear">'; |
| 701 | 734 | |
| 702 | - if ($ignoring) |
|
| 703 | - echo ' |
|
| 735 | + if ($ignoring) { |
|
| 736 | + echo ' |
|
| 704 | 737 | <div id="msg_', $post['id'], '_ignored_prompt" class="smalltext"> |
| 705 | 738 | ', $txt['ignoring_user'], ' |
| 706 | 739 | <a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 707 | 740 | </div>'; |
| 741 | + } |
|
| 708 | 742 | |
| 709 | 743 | echo ' |
| 710 | 744 | <div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div> |
@@ -859,10 +893,10 @@ discard block |
||
| 859 | 893 | <div id="temporary_posting_area" style="display: none;"></div> |
| 860 | 894 | <script>'; |
| 861 | 895 | |
| 862 | - if ($context['close_window']) |
|
| 863 | - echo ' |
|
| 896 | + if ($context['close_window']) { |
|
| 897 | + echo ' |
|
| 864 | 898 | window.close();'; |
| 865 | - else |
|
| 899 | + } else |
|
| 866 | 900 | { |
| 867 | 901 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;) |
| 868 | 902 | echo ' |
@@ -916,11 +950,12 @@ discard block |
||
| 916 | 950 | </p> |
| 917 | 951 | <ul>'; |
| 918 | 952 | |
| 919 | - foreach ($context['groups'] as $group) |
|
| 920 | - echo ' |
|
| 953 | + foreach ($context['groups'] as $group) { |
|
| 954 | + echo ' |
|
| 921 | 955 | <li> |
| 922 | 956 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
| 923 | 957 | </li>'; |
| 958 | + } |
|
| 924 | 959 | |
| 925 | 960 | echo ' |
| 926 | 961 | <li> |
@@ -1027,28 +1062,32 @@ discard block |
||
| 1027 | 1062 | foreach ($context['posting_fields'] as $pfid => $pf) |
| 1028 | 1063 | { |
| 1029 | 1064 | // We need both a label and an input |
| 1030 | - if (empty($pf['label']) || empty($pf['input'])) |
|
| 1031 | - continue; |
|
| 1065 | + if (empty($pf['label']) || empty($pf['input'])) { |
|
| 1066 | + continue; |
|
| 1067 | + } |
|
| 1032 | 1068 | |
| 1033 | 1069 | // The labels are pretty simple... |
| 1034 | 1070 | echo ' |
| 1035 | 1071 | <dt class="clear pf_', $pfid, '">'; |
| 1036 | 1072 | |
| 1037 | 1073 | // Any leading HTML before the label |
| 1038 | - if (!empty($pf['label']['before'])) |
|
| 1039 | - echo ' |
|
| 1074 | + if (!empty($pf['label']['before'])) { |
|
| 1075 | + echo ' |
|
| 1040 | 1076 | ', $pf['label']['before']; |
| 1077 | + } |
|
| 1041 | 1078 | |
| 1042 | - if (!empty($pf['label']['html'])) |
|
| 1043 | - echo $pf['label']['html']; |
|
| 1044 | - else |
|
| 1045 | - echo ' |
|
| 1079 | + if (!empty($pf['label']['html'])) { |
|
| 1080 | + echo $pf['label']['html']; |
|
| 1081 | + } else { |
|
| 1082 | + echo ' |
|
| 1046 | 1083 | <label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>'; |
| 1084 | + } |
|
| 1047 | 1085 | |
| 1048 | 1086 | // Any trailing HTML after the label |
| 1049 | - if (!empty($pf['label']['after'])) |
|
| 1050 | - echo ' |
|
| 1087 | + if (!empty($pf['label']['after'])) { |
|
| 1088 | + echo ' |
|
| 1051 | 1089 | ', $pf['label']['after']; |
| 1090 | + } |
|
| 1052 | 1091 | |
| 1053 | 1092 | echo ' |
| 1054 | 1093 | </dt>'; |
@@ -1058,9 +1097,10 @@ discard block |
||
| 1058 | 1097 | <dd class="pf_', $pfid, '">'; |
| 1059 | 1098 | |
| 1060 | 1099 | // Any leading HTML before the main input |
| 1061 | - if (!empty($pf['input']['before'])) |
|
| 1062 | - echo ' |
|
| 1100 | + if (!empty($pf['input']['before'])) { |
|
| 1101 | + echo ' |
|
| 1063 | 1102 | ', $pf['input']['before']; |
| 1103 | + } |
|
| 1064 | 1104 | |
| 1065 | 1105 | // If there is a literal HTML string already defined, just print it. |
| 1066 | 1106 | if (!empty($pf['input']['html'])) |
@@ -1073,17 +1113,19 @@ discard block |
||
| 1073 | 1113 | echo ' |
| 1074 | 1114 | <input type="', $pf['input']['type'], '"'; |
| 1075 | 1115 | |
| 1076 | - if (empty($pf['input']['attributes']['name'])) |
|
| 1077 | - echo ' name="', $pfid, '"'; |
|
| 1116 | + if (empty($pf['input']['attributes']['name'])) { |
|
| 1117 | + echo ' name="', $pfid, '"'; |
|
| 1118 | + } |
|
| 1078 | 1119 | |
| 1079 | 1120 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
| 1080 | 1121 | { |
| 1081 | 1122 | foreach ($pf['input']['attributes'] as $attribute => $value) |
| 1082 | 1123 | { |
| 1083 | - if (is_bool($value)) |
|
| 1084 | - echo $value ? ' ' . $attribute : ''; |
|
| 1085 | - else |
|
| 1086 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1124 | + if (is_bool($value)) { |
|
| 1125 | + echo $value ? ' ' . $attribute : ''; |
|
| 1126 | + } else { |
|
| 1127 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1128 | + } |
|
| 1087 | 1129 | } |
| 1088 | 1130 | } |
| 1089 | 1131 | |
@@ -1095,19 +1137,21 @@ discard block |
||
| 1095 | 1137 | echo ' |
| 1096 | 1138 | <textarea'; |
| 1097 | 1139 | |
| 1098 | - if (empty($pf['input']['attributes']['name'])) |
|
| 1099 | - echo ' name="', $pfid, '"'; |
|
| 1140 | + if (empty($pf['input']['attributes']['name'])) { |
|
| 1141 | + echo ' name="', $pfid, '"'; |
|
| 1142 | + } |
|
| 1100 | 1143 | |
| 1101 | 1144 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
| 1102 | 1145 | { |
| 1103 | 1146 | foreach ($pf['input']['attributes'] as $attribute => $value) |
| 1104 | 1147 | { |
| 1105 | - if ($attribute === 'value') |
|
| 1106 | - continue; |
|
| 1107 | - elseif (is_bool($value)) |
|
| 1108 | - echo $value ? ' ' . $attribute : ''; |
|
| 1109 | - else |
|
| 1110 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1148 | + if ($attribute === 'value') { |
|
| 1149 | + continue; |
|
| 1150 | + } elseif (is_bool($value)) { |
|
| 1151 | + echo $value ? ' ' . $attribute : ''; |
|
| 1152 | + } else { |
|
| 1153 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1154 | + } |
|
| 1111 | 1155 | } |
| 1112 | 1156 | } |
| 1113 | 1157 | |
@@ -1120,17 +1164,19 @@ discard block |
||
| 1120 | 1164 | echo ' |
| 1121 | 1165 | <select'; |
| 1122 | 1166 | |
| 1123 | - if (empty($pf['input']['attributes']['name'])) |
|
| 1124 | - echo ' name="', $pfid, '"'; |
|
| 1167 | + if (empty($pf['input']['attributes']['name'])) { |
|
| 1168 | + echo ' name="', $pfid, '"'; |
|
| 1169 | + } |
|
| 1125 | 1170 | |
| 1126 | 1171 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
| 1127 | 1172 | { |
| 1128 | 1173 | foreach ($pf['input']['attributes'] as $attribute => $value) |
| 1129 | 1174 | { |
| 1130 | - if (is_bool($value)) |
|
| 1131 | - echo $value ? ' ' . $attribute : ''; |
|
| 1132 | - else |
|
| 1133 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1175 | + if (is_bool($value)) { |
|
| 1176 | + echo $value ? ' ' . $attribute : ''; |
|
| 1177 | + } else { |
|
| 1178 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1179 | + } |
|
| 1134 | 1180 | } |
| 1135 | 1181 | } |
| 1136 | 1182 | |
@@ -1145,17 +1191,19 @@ discard block |
||
| 1145 | 1191 | echo ' |
| 1146 | 1192 | <optgroup'; |
| 1147 | 1193 | |
| 1148 | - if (empty($option['attributes']['label'])) |
|
| 1149 | - echo ' label="', $optlabel, '"'; |
|
| 1194 | + if (empty($option['attributes']['label'])) { |
|
| 1195 | + echo ' label="', $optlabel, '"'; |
|
| 1196 | + } |
|
| 1150 | 1197 | |
| 1151 | 1198 | if (!empty($option['attributes']) && is_array($option['attributes'])) |
| 1152 | 1199 | { |
| 1153 | 1200 | foreach ($option['attributes'] as $attribute => $value) |
| 1154 | 1201 | { |
| 1155 | - if (is_bool($value)) |
|
| 1156 | - echo $value ? ' ' . $attribute : ''; |
|
| 1157 | - else |
|
| 1158 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1202 | + if (is_bool($value)) { |
|
| 1203 | + echo $value ? ' ' . $attribute : ''; |
|
| 1204 | + } else { |
|
| 1205 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1206 | + } |
|
| 1159 | 1207 | } |
| 1160 | 1208 | } |
| 1161 | 1209 | |
@@ -1168,10 +1216,11 @@ discard block |
||
| 1168 | 1216 | |
| 1169 | 1217 | foreach ($grouped_option['attributes'] as $attribute => $value) |
| 1170 | 1218 | { |
| 1171 | - if (is_bool($value)) |
|
| 1172 | - echo $value ? ' ' . $attribute : ''; |
|
| 1173 | - else |
|
| 1174 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1219 | + if (is_bool($value)) { |
|
| 1220 | + echo $value ? ' ' . $attribute : ''; |
|
| 1221 | + } else { |
|
| 1222 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1223 | + } |
|
| 1175 | 1224 | } |
| 1176 | 1225 | |
| 1177 | 1226 | echo '>', $grouped_optlabel, '</option>'; |
@@ -1189,10 +1238,11 @@ discard block |
||
| 1189 | 1238 | |
| 1190 | 1239 | foreach ($option['attributes'] as $attribute => $value) |
| 1191 | 1240 | { |
| 1192 | - if (is_bool($value)) |
|
| 1193 | - echo $value ? ' ' . $attribute : ''; |
|
| 1194 | - else |
|
| 1195 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1241 | + if (is_bool($value)) { |
|
| 1242 | + echo $value ? ' ' . $attribute : ''; |
|
| 1243 | + } else { |
|
| 1244 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1245 | + } |
|
| 1196 | 1246 | } |
| 1197 | 1247 | |
| 1198 | 1248 | echo '>', $optlabel, '</option>'; |
@@ -1213,12 +1263,13 @@ discard block |
||
| 1213 | 1263 | { |
| 1214 | 1264 | foreach ($pf['input']['attributes'] as $attribute => $value) |
| 1215 | 1265 | { |
| 1216 | - if ($attribute === 'name') |
|
| 1217 | - continue; |
|
| 1218 | - elseif (is_bool($value)) |
|
| 1219 | - echo $value ? ' ' . $attribute : ''; |
|
| 1220 | - else |
|
| 1221 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1266 | + if ($attribute === 'name') { |
|
| 1267 | + continue; |
|
| 1268 | + } elseif (is_bool($value)) { |
|
| 1269 | + echo $value ? ' ' . $attribute : ''; |
|
| 1270 | + } else { |
|
| 1271 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1272 | + } |
|
| 1222 | 1273 | } |
| 1223 | 1274 | } |
| 1224 | 1275 | |
@@ -1231,10 +1282,11 @@ discard block |
||
| 1231 | 1282 | |
| 1232 | 1283 | foreach ($option['attributes'] as $attribute => $value) |
| 1233 | 1284 | { |
| 1234 | - if (is_bool($value)) |
|
| 1235 | - echo $value ? ' ' . $attribute : ''; |
|
| 1236 | - else |
|
| 1237 | - echo ' ', $attribute, '="', $value, '"'; |
|
| 1285 | + if (is_bool($value)) { |
|
| 1286 | + echo $value ? ' ' . $attribute : ''; |
|
| 1287 | + } else { |
|
| 1288 | + echo ' ', $attribute, '="', $value, '"'; |
|
| 1289 | + } |
|
| 1238 | 1290 | } |
| 1239 | 1291 | |
| 1240 | 1292 | echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>'; |
@@ -1245,9 +1297,10 @@ discard block |
||
| 1245 | 1297 | } |
| 1246 | 1298 | |
| 1247 | 1299 | // Any trailing HTML after the main input |
| 1248 | - if (!empty($pf['input']['after'])) |
|
| 1249 | - echo ' |
|
| 1300 | + if (!empty($pf['input']['after'])) { |
|
| 1301 | + echo ' |
|
| 1250 | 1302 | ', $pf['input']['after']; |
| 1303 | + } |
|
| 1251 | 1304 | |
| 1252 | 1305 | echo ' |
| 1253 | 1306 | </dd>'; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -109,12 +110,13 @@ discard block |
||
| 109 | 110 | $context['tabs'][$context['last_tab']]['is_last'] = true; |
| 110 | 111 | |
| 111 | 112 | // Find the active tab. |
| 112 | - if (isset($context['tabs'][$context['current_subaction']])) |
|
| 113 | - $context['tabs'][$context['current_subaction']]['is_selected'] = true; |
|
| 114 | - elseif (isset($context['current_subaction'])) |
|
| 115 | - foreach ($context['tabs'] as $id_tab => $tab_data) |
|
| 113 | + if (isset($context['tabs'][$context['current_subaction']])) { |
|
| 114 | + $context['tabs'][$context['current_subaction']]['is_selected'] = true; |
|
| 115 | + } elseif (isset($context['current_subaction'])) { |
|
| 116 | + foreach ($context['tabs'] as $id_tab => $tab_data) |
|
| 116 | 117 | if (!empty($tab_data['selected_actions']) && in_array($context['current_subaction'], $tab_data['selected_actions'])) |
| 117 | 118 | $context['tabs'][$id_tab]['is_selected'] = true; |
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | call_helper($subActions[$context['current_subaction']][0]); |
| 120 | 122 | } |
@@ -144,8 +146,9 @@ discard block |
||
| 144 | 146 | foreach ($_POST['delete'] as $key => $value) |
| 145 | 147 | { |
| 146 | 148 | // Don't delete yourself, idiot. |
| 147 | - if ($value != $user_info['id']) |
|
| 148 | - $delete[$key] = (int) $value; |
|
| 149 | + if ($value != $user_info['id']) { |
|
| 150 | + $delete[$key] = (int) $value; |
|
| 151 | + } |
|
| 149 | 152 | } |
| 150 | 153 | |
| 151 | 154 | if (!empty($delete)) |
@@ -181,17 +184,18 @@ discard block |
||
| 181 | 184 | ); |
| 182 | 185 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 183 | 186 | { |
| 184 | - if ($row['min_posts'] == -1) |
|
| 185 | - $context['membergroups'][] = array( |
|
| 187 | + if ($row['min_posts'] == -1) { |
|
| 188 | + $context['membergroups'][] = array( |
|
| 186 | 189 | 'id' => $row['id_group'], |
| 187 | 190 | 'name' => $row['group_name'], |
| 188 | 191 | 'can_be_additional' => true |
| 189 | 192 | ); |
| 190 | - else |
|
| 191 | - $context['postgroups'][] = array( |
|
| 193 | + } else { |
|
| 194 | + $context['postgroups'][] = array( |
|
| 192 | 195 | 'id' => $row['id_group'], |
| 193 | 196 | 'name' => $row['group_name'] |
| 194 | 197 | ); |
| 198 | + } |
|
| 195 | 199 | } |
| 196 | 200 | $smcFunc['db_free_result']($request); |
| 197 | 201 | |
@@ -263,14 +267,15 @@ discard block |
||
| 263 | 267 | call_integration_hook('integrate_view_members_params', array(&$params)); |
| 264 | 268 | |
| 265 | 269 | $search_params = array(); |
| 266 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
| 267 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
| 268 | - elseif (!empty($_POST)) |
|
| 270 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
| 271 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
| 272 | + } elseif (!empty($_POST)) |
|
| 269 | 273 | { |
| 270 | 274 | $search_params['types'] = $_POST['types']; |
| 271 | - foreach ($params as $param_name => $param_info) |
|
| 272 | - if (isset($_POST[$param_name])) |
|
| 275 | + foreach ($params as $param_name => $param_info) { |
|
| 276 | + if (isset($_POST[$param_name])) |
|
| 273 | 277 | $search_params[$param_name] = $_POST[$param_name]; |
| 278 | + } |
|
| 274 | 279 | } |
| 275 | 280 | |
| 276 | 281 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -283,34 +288,38 @@ discard block |
||
| 283 | 288 | foreach ($params as $param_name => $param_info) |
| 284 | 289 | { |
| 285 | 290 | // Not filled in? |
| 286 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
| 287 | - continue; |
|
| 291 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
| 292 | + continue; |
|
| 293 | + } |
|
| 288 | 294 | |
| 289 | 295 | // Make sure numeric values are really numeric. |
| 290 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
| 291 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
| 296 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
| 297 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
| 298 | + } |
|
| 292 | 299 | // Date values have to match the specified format. |
| 293 | 300 | elseif ($param_info['type'] == 'date') |
| 294 | 301 | { |
| 295 | 302 | // Check if this date format is valid. |
| 296 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
| 297 | - continue; |
|
| 303 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
| 304 | + continue; |
|
| 305 | + } |
|
| 298 | 306 | |
| 299 | 307 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
| 300 | - } |
|
| 301 | - elseif ($param_info['type'] == 'inet') |
|
| 308 | + } elseif ($param_info['type'] == 'inet') |
|
| 302 | 309 | { |
| 303 | 310 | $search_params[$param_name] = ip2range($search_params[$param_name]); |
| 304 | - if (empty($search_params[$param_name])) |
|
| 305 | - continue; |
|
| 311 | + if (empty($search_params[$param_name])) { |
|
| 312 | + continue; |
|
| 313 | + } |
|
| 306 | 314 | } |
| 307 | 315 | |
| 308 | 316 | // Those values that are in some kind of range (<, <=, =, >=, >). |
| 309 | 317 | if (!empty($param_info['range'])) |
| 310 | 318 | { |
| 311 | 319 | // Default to '=', just in case... |
| 312 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
| 313 | - $search_params['types'][$param_name] = '='; |
|
| 320 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
| 321 | + $search_params['types'][$param_name] = '='; |
|
| 322 | + } |
|
| 314 | 323 | |
| 315 | 324 | // Handle special case 'age'. |
| 316 | 325 | if ($param_info['type'] == 'age') |
@@ -338,16 +347,17 @@ discard block |
||
| 338 | 347 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
| 339 | 348 | { |
| 340 | 349 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
| 350 | + } else { |
|
| 351 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
| 341 | 352 | } |
| 342 | - else |
|
| 343 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
| 344 | 353 | } |
| 345 | 354 | // Checkboxes. |
| 346 | 355 | elseif ($param_info['type'] == 'checkbox') |
| 347 | 356 | { |
| 348 | 357 | // Each checkbox or no checkbox at all is checked -> ignore. |
| 349 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
| 350 | - continue; |
|
| 358 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
| 359 | + continue; |
|
| 360 | + } |
|
| 351 | 361 | |
| 352 | 362 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
| 353 | 363 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
@@ -359,24 +369,23 @@ discard block |
||
| 359 | 369 | { |
| 360 | 370 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
| 361 | 371 | $where_params[$param_name] = $search_params[$param_name][0]; |
| 362 | - } |
|
| 363 | - elseif (count($search_params[$param_name]) === 2) |
|
| 372 | + } elseif (count($search_params[$param_name]) === 2) |
|
| 364 | 373 | { |
| 365 | 374 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
| 366 | 375 | $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
| 367 | 376 | $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
| 368 | 377 | } |
| 369 | 378 | |
| 370 | - } |
|
| 371 | - elseif ($param_info['type'] != 'groups') |
|
| 379 | + } elseif ($param_info['type'] != 'groups') |
|
| 372 | 380 | { |
| 373 | 381 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
| 374 | 382 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
| 375 | 383 | |
| 376 | - if ($smcFunc['db_case_sensitive']) |
|
| 377 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
| 378 | - else |
|
| 379 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
| 384 | + if ($smcFunc['db_case_sensitive']) { |
|
| 385 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
| 386 | + } else { |
|
| 387 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
| 388 | + } |
|
| 380 | 389 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
| 381 | 390 | } |
| 382 | 391 | } |
@@ -392,16 +401,18 @@ discard block |
||
| 392 | 401 | } |
| 393 | 402 | |
| 394 | 403 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
| 395 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
| 396 | - foreach ($search_params['membergroups'][2] as $mg) |
|
| 404 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
| 405 | + foreach ($search_params['membergroups'][2] as $mg) |
|
| 397 | 406 | { |
| 398 | 407 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
| 408 | + } |
|
| 399 | 409 | $where_params['add_group_' . $mg] = $mg; |
| 400 | 410 | } |
| 401 | 411 | |
| 402 | 412 | // Combine the one or two membergroup parts into one query part linked with an OR. |
| 403 | - if (!empty($mg_query_parts)) |
|
| 404 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
| 413 | + if (!empty($mg_query_parts)) { |
|
| 414 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
| 415 | + } |
|
| 405 | 416 | |
| 406 | 417 | // Get all selected post count related membergroups. |
| 407 | 418 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -413,9 +424,9 @@ discard block |
||
| 413 | 424 | // Construct the where part of the query. |
| 414 | 425 | $where = empty($query_parts) ? '1=1' : implode(' |
| 415 | 426 | AND ', $query_parts); |
| 427 | + } else { |
|
| 428 | + $search_url_params = null; |
|
| 416 | 429 | } |
| 417 | - else |
|
| 418 | - $search_url_params = null; |
|
| 419 | 430 | |
| 420 | 431 | // Construct the additional URL part with the query info in it. |
| 421 | 432 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -538,28 +549,32 @@ discard block |
||
| 538 | 549 | 'function' => function($rowData) use ($txt) |
| 539 | 550 | { |
| 540 | 551 | // Calculate number of days since last online. |
| 541 | - if (empty($rowData['last_login'])) |
|
| 542 | - $difference = $txt['never']; |
|
| 543 | - else |
|
| 552 | + if (empty($rowData['last_login'])) { |
|
| 553 | + $difference = $txt['never']; |
|
| 554 | + } else |
|
| 544 | 555 | { |
| 545 | 556 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
| 546 | 557 | |
| 547 | 558 | // Today. |
| 548 | - if (empty($num_days_difference)) |
|
| 549 | - $difference = $txt['viewmembers_today']; |
|
| 559 | + if (empty($num_days_difference)) { |
|
| 560 | + $difference = $txt['viewmembers_today']; |
|
| 561 | + } |
|
| 550 | 562 | |
| 551 | 563 | // Yesterday. |
| 552 | - elseif ($num_days_difference == 1) |
|
| 553 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
| 564 | + elseif ($num_days_difference == 1) { |
|
| 565 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
| 566 | + } |
|
| 554 | 567 | |
| 555 | 568 | // X days ago. |
| 556 | - else |
|
| 557 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
| 569 | + else { |
|
| 570 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
| 571 | + } |
|
| 558 | 572 | } |
| 559 | 573 | |
| 560 | 574 | // Show it in italics if they're not activated... |
| 561 | - if ($rowData['is_activated'] % 10 != 1) |
|
| 562 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
| 575 | + if ($rowData['is_activated'] % 10 != 1) { |
|
| 576 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
| 577 | + } |
|
| 563 | 578 | |
| 564 | 579 | return $difference; |
| 565 | 580 | }, |
@@ -611,8 +626,9 @@ discard block |
||
| 611 | 626 | ); |
| 612 | 627 | |
| 613 | 628 | // Without enough permissions, don't show 'delete members' checkboxes. |
| 614 | - if (!allowedTo('profile_remove_any')) |
|
| 615 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
| 629 | + if (!allowedTo('profile_remove_any')) { |
|
| 630 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | require_once($sourcedir . '/Subs-List.php'); |
| 618 | 634 | createList($listOptions); |
@@ -655,17 +671,18 @@ discard block |
||
| 655 | 671 | ); |
| 656 | 672 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 657 | 673 | { |
| 658 | - if ($row['min_posts'] == -1) |
|
| 659 | - $context['membergroups'][] = array( |
|
| 674 | + if ($row['min_posts'] == -1) { |
|
| 675 | + $context['membergroups'][] = array( |
|
| 660 | 676 | 'id' => $row['id_group'], |
| 661 | 677 | 'name' => $row['group_name'], |
| 662 | 678 | 'can_be_additional' => true |
| 663 | 679 | ); |
| 664 | - else |
|
| 665 | - $context['postgroups'][] = array( |
|
| 680 | + } else { |
|
| 681 | + $context['postgroups'][] = array( |
|
| 666 | 682 | 'id' => $row['id_group'], |
| 667 | 683 | 'name' => $row['group_name'] |
| 668 | 684 | ); |
| 685 | + } |
|
| 669 | 686 | } |
| 670 | 687 | $smcFunc['db_free_result']($request); |
| 671 | 688 | |
@@ -692,8 +709,9 @@ discard block |
||
| 692 | 709 | $context['page_title'] = $txt['admin_members']; |
| 693 | 710 | $context['sub_template'] = 'admin_browse'; |
| 694 | 711 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
| 695 | - if (isset($context['tabs'][$context['browse_type']])) |
|
| 696 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
| 712 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
| 713 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
| 714 | + } |
|
| 697 | 715 | |
| 698 | 716 | // Allowed filters are those we can have, in theory. |
| 699 | 717 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -704,18 +722,20 @@ discard block |
||
| 704 | 722 | foreach ($context['activation_numbers'] as $type => $amount) |
| 705 | 723 | { |
| 706 | 724 | // We have some of these... |
| 707 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
| 708 | - $context['available_filters'][] = array( |
|
| 725 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
| 726 | + $context['available_filters'][] = array( |
|
| 709 | 727 | 'type' => $type, |
| 710 | 728 | 'amount' => $amount, |
| 711 | 729 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
| 712 | 730 | 'selected' => $type == $context['current_filter'] |
| 713 | 731 | ); |
| 732 | + } |
|
| 714 | 733 | } |
| 715 | 734 | |
| 716 | 735 | // If the filter was not sent, set it to whatever has people in it! |
| 717 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
| 718 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
| 736 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
| 737 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
| 738 | + } |
|
| 719 | 739 | |
| 720 | 740 | // This little variable is used to determine if we should flag where we are looking. |
| 721 | 741 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -730,44 +750,47 @@ discard block |
||
| 730 | 750 | ); |
| 731 | 751 | |
| 732 | 752 | // Are we showing duplicate information? |
| 733 | - if (isset($_GET['showdupes'])) |
|
| 734 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
| 753 | + if (isset($_GET['showdupes'])) { |
|
| 754 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
| 755 | + } |
|
| 735 | 756 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
| 736 | 757 | |
| 737 | 758 | // Determine which actions we should allow on this page. |
| 738 | 759 | if ($context['browse_type'] == 'approve') |
| 739 | 760 | { |
| 740 | 761 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
| 741 | - if ($context['current_filter'] == 4) |
|
| 742 | - $context['allowed_actions'] = array( |
|
| 762 | + if ($context['current_filter'] == 4) { |
|
| 763 | + $context['allowed_actions'] = array( |
|
| 743 | 764 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
| 744 | 765 | 'ok' => $txt['admin_browse_w_reject'], |
| 745 | 766 | ); |
| 746 | - else |
|
| 747 | - $context['allowed_actions'] = array( |
|
| 767 | + } else { |
|
| 768 | + $context['allowed_actions'] = array( |
|
| 748 | 769 | 'ok' => $txt['admin_browse_w_approve'], |
| 749 | 770 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
| 750 | 771 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
| 751 | 772 | 'reject' => $txt['admin_browse_w_reject'], |
| 752 | 773 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
| 753 | 774 | ); |
| 754 | - } |
|
| 755 | - elseif ($context['browse_type'] == 'activate') |
|
| 756 | - $context['allowed_actions'] = array( |
|
| 775 | + } |
|
| 776 | + } elseif ($context['browse_type'] == 'activate') { |
|
| 777 | + $context['allowed_actions'] = array( |
|
| 757 | 778 | 'ok' => $txt['admin_browse_w_activate'], |
| 758 | 779 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
| 759 | 780 | 'delete' => $txt['admin_browse_w_delete'], |
| 760 | 781 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
| 761 | 782 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
| 762 | 783 | ); |
| 784 | + } |
|
| 763 | 785 | |
| 764 | 786 | // Create an option list for actions allowed to be done with selected members. |
| 765 | 787 | $allowed_actions = ' |
| 766 | 788 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
| 767 | 789 | <option value="" disabled>-----------------------------</option>'; |
| 768 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
| 769 | - $allowed_actions .= ' |
|
| 790 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
| 791 | + $allowed_actions .= ' |
|
| 770 | 792 | <option value="' . $key . '">' . $desc . '</option>'; |
| 793 | + } |
|
| 771 | 794 | |
| 772 | 795 | // Setup the Javascript function for selecting an action for the list. |
| 773 | 796 | $javascript = ' |
@@ -779,15 +802,16 @@ discard block |
||
| 779 | 802 | var message = "";'; |
| 780 | 803 | |
| 781 | 804 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
| 782 | - if ($context['current_filter'] == 4) |
|
| 783 | - $javascript .= ' |
|
| 805 | + if ($context['current_filter'] == 4) { |
|
| 806 | + $javascript .= ' |
|
| 784 | 807 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
| 785 | 808 | message = "' . $txt['admin_browse_w_delete'] . '"; |
| 786 | 809 | else |
| 787 | 810 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
| 811 | + } |
|
| 788 | 812 | // Otherwise a nice standard message. |
| 789 | - else |
|
| 790 | - $javascript .= ' |
|
| 813 | + else { |
|
| 814 | + $javascript .= ' |
|
| 791 | 815 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
| 792 | 816 | message = "' . $txt['admin_browse_w_delete'] . '"; |
| 793 | 817 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -796,6 +820,7 @@ discard block |
||
| 796 | 820 | message = "' . $txt['admin_browse_w_remind'] . '"; |
| 797 | 821 | else |
| 798 | 822 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
| 823 | + } |
|
| 799 | 824 | $javascript .= ' |
| 800 | 825 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
| 801 | 826 | document.forms.postForm.submit(); |
@@ -928,10 +953,11 @@ discard block |
||
| 928 | 953 | $member_links = array(); |
| 929 | 954 | foreach ($rowData['duplicate_members'] as $member) |
| 930 | 955 | { |
| 931 | - if ($member['id']) |
|
| 932 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
| 933 | - else |
|
| 934 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
| 956 | + if ($member['id']) { |
|
| 957 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
| 958 | + } else { |
|
| 959 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
| 960 | + } |
|
| 935 | 961 | } |
| 936 | 962 | return implode(', ', $member_links); |
| 937 | 963 | }, |
@@ -980,14 +1006,16 @@ discard block |
||
| 980 | 1006 | ); |
| 981 | 1007 | |
| 982 | 1008 | // Pick what column to actually include if we're showing duplicates. |
| 983 | - if ($context['show_duplicates']) |
|
| 984 | - unset($listOptions['columns']['email']); |
|
| 985 | - else |
|
| 986 | - unset($listOptions['columns']['duplicates']); |
|
| 1009 | + if ($context['show_duplicates']) { |
|
| 1010 | + unset($listOptions['columns']['email']); |
|
| 1011 | + } else { |
|
| 1012 | + unset($listOptions['columns']['duplicates']); |
|
| 1013 | + } |
|
| 987 | 1014 | |
| 988 | 1015 | // Only show hostname on duplicates as it takes a lot of time. |
| 989 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
| 990 | - unset($listOptions['columns']['hostname']); |
|
| 1016 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
| 1017 | + unset($listOptions['columns']['hostname']); |
|
| 1018 | + } |
|
| 991 | 1019 | |
| 992 | 1020 | // Is there any need to show filters? |
| 993 | 1021 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -995,9 +1023,10 @@ discard block |
||
| 995 | 1023 | $filterOptions = ' |
| 996 | 1024 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
| 997 | 1025 | <select name="filter" onchange="this.form.submit();">'; |
| 998 | - foreach ($context['available_filters'] as $filter) |
|
| 999 | - $filterOptions .= ' |
|
| 1026 | + foreach ($context['available_filters'] as $filter) { |
|
| 1027 | + $filterOptions .= ' |
|
| 1000 | 1028 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
| 1029 | + } |
|
| 1001 | 1030 | $filterOptions .= ' |
| 1002 | 1031 | </select> |
| 1003 | 1032 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -1009,12 +1038,13 @@ discard block |
||
| 1009 | 1038 | } |
| 1010 | 1039 | |
| 1011 | 1040 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
| 1012 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
| 1013 | - $listOptions['additional_rows'][] = array( |
|
| 1041 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
| 1042 | + $listOptions['additional_rows'][] = array( |
|
| 1014 | 1043 | 'position' => 'above_column_headers', |
| 1015 | 1044 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
| 1016 | 1045 | 'class' => 'smalltext floatright', |
| 1017 | 1046 | ); |
| 1047 | + } |
|
| 1018 | 1048 | |
| 1019 | 1049 | // Now that we have all the options, create the list. |
| 1020 | 1050 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1044,12 +1074,14 @@ discard block |
||
| 1044 | 1074 | $current_filter = (int) $_REQUEST['orig_filter']; |
| 1045 | 1075 | |
| 1046 | 1076 | // If we are applying a filter do just that - then redirect. |
| 1047 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
| 1048 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
| 1077 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
| 1078 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
| 1079 | + } |
|
| 1049 | 1080 | |
| 1050 | 1081 | // Nothing to do? |
| 1051 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
| 1052 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1082 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
| 1083 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1084 | + } |
|
| 1053 | 1085 | |
| 1054 | 1086 | // Are we dealing with members who have been waiting for > set amount of time? |
| 1055 | 1087 | if (isset($_POST['time_passed'])) |
@@ -1062,8 +1094,9 @@ discard block |
||
| 1062 | 1094 | else |
| 1063 | 1095 | { |
| 1064 | 1096 | $members = array(); |
| 1065 | - foreach ($_POST['todoAction'] as $id) |
|
| 1066 | - $members[] = (int) $id; |
|
| 1097 | + foreach ($_POST['todoAction'] as $id) { |
|
| 1098 | + $members[] = (int) $id; |
|
| 1099 | + } |
|
| 1067 | 1100 | $condition = ' |
| 1068 | 1101 | AND id_member IN ({array_int:members})'; |
| 1069 | 1102 | } |
@@ -1084,8 +1117,9 @@ discard block |
||
| 1084 | 1117 | $member_count = $smcFunc['db_num_rows']($request); |
| 1085 | 1118 | |
| 1086 | 1119 | // If no results then just return! |
| 1087 | - if ($member_count == 0) |
|
| 1088 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1120 | + if ($member_count == 0) { |
|
| 1121 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1122 | + } |
|
| 1089 | 1123 | |
| 1090 | 1124 | $member_info = array(); |
| 1091 | 1125 | $members = array(); |
@@ -1124,8 +1158,9 @@ discard block |
||
| 1124 | 1158 | // Do we have to let the integration code know about the activations? |
| 1125 | 1159 | if (!empty($modSettings['integrate_activate'])) |
| 1126 | 1160 | { |
| 1127 | - foreach ($member_info as $member) |
|
| 1128 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
| 1161 | + foreach ($member_info as $member) { |
|
| 1162 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
| 1163 | + } |
|
| 1129 | 1164 | } |
| 1130 | 1165 | |
| 1131 | 1166 | // Check for email. |
@@ -1255,20 +1290,23 @@ discard block |
||
| 1255 | 1290 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
| 1256 | 1291 | |
| 1257 | 1292 | require_once($sourcedir . '/Logging.php'); |
| 1258 | - foreach ($member_info as $member) |
|
| 1259 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
| 1293 | + foreach ($member_info as $member) { |
|
| 1294 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
| 1295 | + } |
|
| 1260 | 1296 | } |
| 1261 | 1297 | |
| 1262 | 1298 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
| 1263 | - if (in_array($current_filter, array(3, 4, 5))) |
|
| 1264 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
| 1299 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
| 1300 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
| 1301 | + } |
|
| 1265 | 1302 | |
| 1266 | 1303 | // Update the member's stats. (but, we know the member didn't change their name.) |
| 1267 | 1304 | updateStats('member', false); |
| 1268 | 1305 | |
| 1269 | 1306 | // If they haven't been deleted, update the post group statistics on them... |
| 1270 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
| 1271 | - updateStats('postgroups', $members); |
|
| 1307 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
| 1308 | + updateStats('postgroups', $members); |
|
| 1309 | + } |
|
| 1272 | 1310 | |
| 1273 | 1311 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
| 1274 | 1312 | } |
@@ -1293,10 +1331,11 @@ discard block |
||
| 1293 | 1331 | $dis = time() - $old; |
| 1294 | 1332 | |
| 1295 | 1333 | // Before midnight? |
| 1296 | - if ($dis < $sinceMidnight) |
|
| 1297 | - return 0; |
|
| 1298 | - else |
|
| 1299 | - $dis -= $sinceMidnight; |
|
| 1334 | + if ($dis < $sinceMidnight) { |
|
| 1335 | + return 0; |
|
| 1336 | + } else { |
|
| 1337 | + $dis -= $sinceMidnight; |
|
| 1338 | + } |
|
| 1300 | 1339 | |
| 1301 | 1340 | // Divide out the seconds in a day to get the number of days. |
| 1302 | 1341 | return ceil($dis / (24 * 60 * 60)); |
@@ -1323,16 +1362,18 @@ discard block |
||
| 1323 | 1362 | $context['activation_numbers'] = array(); |
| 1324 | 1363 | $context['awaiting_activation'] = 0; |
| 1325 | 1364 | $context['awaiting_approval'] = 0; |
| 1326 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1327 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
| 1365 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1366 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
| 1367 | + } |
|
| 1328 | 1368 | $smcFunc['db_free_result']($request); |
| 1329 | 1369 | |
| 1330 | 1370 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
| 1331 | 1371 | { |
| 1332 | - if (in_array($activation_type, array(0, 2))) |
|
| 1333 | - $context['awaiting_activation'] += $total_members; |
|
| 1334 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
| 1335 | - $context['awaiting_approval'] += $total_members; |
|
| 1372 | + if (in_array($activation_type, array(0, 2))) { |
|
| 1373 | + $context['awaiting_activation'] += $total_members; |
|
| 1374 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
| 1375 | + $context['awaiting_approval'] += $total_members; |
|
| 1376 | + } |
|
| 1336 | 1377 | } |
| 1337 | 1378 | |
| 1338 | 1379 | } |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | * @version 2.1 Beta 4 |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | -if (!defined('SMF')) |
|
| 33 | +if (!defined('SMF')) { |
|
| 34 | 34 | die('No direct access...'); |
| 35 | +} |
|
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
| 103 | 104 | cache_put_data('minimized_css', null); |
| 104 | 105 | |
| 105 | 106 | // Follow the sa or just go to administration. |
| 106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
| 107 | - call_helper($subActions[$_GET['sa']]); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - call_helper($subActions['admin']); |
|
| 111 | -} |
|
| 107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
| 108 | + call_helper($subActions[$_GET['sa']]); |
|
| 109 | + } else { |
|
| 110 | + call_helper($subActions['admin']); |
|
| 111 | + } |
|
| 112 | + } |
|
| 112 | 113 | |
| 113 | 114 | /** |
| 114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
| 130 | 131 | checkSession(); |
| 131 | 132 | validateToken('admin-tm'); |
| 132 | 133 | |
| 133 | - if (isset($_POST['options']['known_themes'])) |
|
| 134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 134 | + if (isset($_POST['options']['known_themes'])) { |
|
| 135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
| 137 | + } else { |
|
| 138 | + fatal_lang_error('themes_none_selectable', false); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | - else |
|
| 138 | - fatal_lang_error('themes_none_selectable', false); |
|
| 139 | - |
|
| 140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
| 141 | - fatal_lang_error('themes_default_selectable', false); |
|
| 141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
| 142 | + fatal_lang_error('themes_default_selectable', false); |
|
| 143 | + } |
|
| 142 | 144 | |
| 143 | 145 | // Commit the new settings. |
| 144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
| 146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
| 147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
| 148 | 150 | )); |
| 149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
| 150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
| 152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
| 153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
| 167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
| 168 | 171 | $i = 1; |
| 169 | - while (file_exists($theme_dir . $i)) |
|
| 170 | - $i++; |
|
| 172 | + while (file_exists($theme_dir . $i)) { |
|
| 173 | + $i++; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
| 173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
| 189 | 193 | loadLanguage('Admin'); |
| 190 | 194 | isAllowedTo('admin_forum'); |
| 191 | 195 | |
| 192 | - if (isset($_REQUEST['th'])) |
|
| 193 | - return SetThemeSettings(); |
|
| 196 | + if (isset($_REQUEST['th'])) { |
|
| 197 | + return SetThemeSettings(); |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | if (isset($_POST['save'])) |
| 196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
| 274 | 279 | $context['themes'] = array(); |
| 275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 276 | 281 | { |
| 277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
| 278 | - $context['themes'][$row['id_theme']] = array( |
|
| 282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
| 283 | + $context['themes'][$row['id_theme']] = array( |
|
| 279 | 284 | 'id' => $row['id_theme'], |
| 280 | 285 | 'num_default_options' => 0, |
| 281 | 286 | 'num_members' => 0, |
| 282 | 287 | ); |
| 288 | + } |
|
| 283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 284 | 290 | } |
| 285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
| 293 | 299 | 'guest_member' => -1, |
| 294 | 300 | ) |
| 295 | 301 | ); |
| 296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 304 | + } |
|
| 298 | 305 | $smcFunc['db_free_result']($request); |
| 299 | 306 | |
| 300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
| 305 | 312 | ) |
| 306 | 313 | ); |
| 307 | 314 | $customFields = array(); |
| 308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 309 | - $customFields[] = $row['col_name']; |
|
| 315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 316 | + $customFields[] = $row['col_name']; |
|
| 317 | + } |
|
| 310 | 318 | $smcFunc['db_free_result']($request); |
| 311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
| 312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
| 321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
| 322 | 330 | ) |
| 323 | 331 | ); |
| 324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 334 | + } |
|
| 326 | 335 | $smcFunc['db_free_result']($request); |
| 327 | 336 | |
| 328 | 337 | // There has to be a Settings template! |
| 329 | - foreach ($context['themes'] as $k => $v) |
|
| 330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 338 | + foreach ($context['themes'] as $k => $v) { |
|
| 339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 331 | 340 | unset($context['themes'][$k]); |
| 341 | + } |
|
| 332 | 342 | |
| 333 | 343 | loadTemplate('Themes'); |
| 334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
| 343 | 353 | checkSession(); |
| 344 | 354 | validateToken('admin-sto'); |
| 345 | 355 | |
| 346 | - if (empty($_POST['options'])) |
|
| 347 | - $_POST['options'] = array(); |
|
| 348 | - if (empty($_POST['default_options'])) |
|
| 349 | - $_POST['default_options'] = array(); |
|
| 356 | + if (empty($_POST['options'])) { |
|
| 357 | + $_POST['options'] = array(); |
|
| 358 | + } |
|
| 359 | + if (empty($_POST['default_options'])) { |
|
| 360 | + $_POST['default_options'] = array(); |
|
| 361 | + } |
|
| 350 | 362 | |
| 351 | 363 | // Set up the sql query. |
| 352 | 364 | $setValues = array(); |
| 353 | 365 | |
| 354 | - foreach ($_POST['options'] as $opt => $val) |
|
| 355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 366 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | $old_settings = array(); |
| 358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
| 366 | 379 | if (!empty($setValues)) |
| 367 | 380 | { |
| 368 | 381 | // Are there options in non-default themes set that should be cleared? |
| 369 | - if (!empty($old_settings)) |
|
| 370 | - $smcFunc['db_query']('', ' |
|
| 382 | + if (!empty($old_settings)) { |
|
| 383 | + $smcFunc['db_query']('', ' |
|
| 371 | 384 | DELETE FROM {db_prefix}themes |
| 372 | 385 | WHERE id_theme != {int:default_theme} |
| 373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
| 378 | 391 | 'old_settings' => $old_settings, |
| 379 | 392 | ) |
| 380 | 393 | ); |
| 394 | + } |
|
| 381 | 395 | |
| 382 | 396 | $smcFunc['db_insert']('replace', |
| 383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
| 391 | 405 | cache_put_data('theme_settings-1', null, 90); |
| 392 | 406 | |
| 393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 394 | - } |
|
| 395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 396 | 409 | { |
| 397 | 410 | checkSession(); |
| 398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
| 405 | 418 | $old_settings = array(); |
| 406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
| 407 | 420 | { |
| 408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
| 409 | - continue; |
|
| 410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
| 422 | + continue; |
|
| 423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 411 | 424 | { |
| 412 | 425 | // Delete then insert for ease of database compatibility! |
| 413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
| 433 | 446 | ); |
| 434 | 447 | |
| 435 | 448 | $old_settings[] = $opt; |
| 436 | - } |
|
| 437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 438 | 450 | { |
| 439 | 451 | $smcFunc['db_query']('', ' |
| 440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
| 449 | 461 | } |
| 450 | 462 | |
| 451 | 463 | // Delete options from other themes. |
| 452 | - if (!empty($old_settings)) |
|
| 453 | - $smcFunc['db_query']('', ' |
|
| 464 | + if (!empty($old_settings)) { |
|
| 465 | + $smcFunc['db_query']('', ' |
|
| 454 | 466 | DELETE FROM {db_prefix}themes |
| 455 | 467 | WHERE id_theme != {int:default_theme} |
| 456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
| 461 | 473 | 'old_settings' => $old_settings, |
| 462 | 474 | ) |
| 463 | 475 | ); |
| 476 | + } |
|
| 464 | 477 | |
| 465 | 478 | foreach ($_POST['options'] as $opt => $val) |
| 466 | 479 | { |
| 467 | - if ($_POST['options_master'][$opt] == 0) |
|
| 468 | - continue; |
|
| 469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
| 480 | + if ($_POST['options_master'][$opt] == 0) { |
|
| 481 | + continue; |
|
| 482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
| 470 | 483 | { |
| 471 | 484 | // Delete then insert for ease of database compatibility - again! |
| 472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
| 491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
| 492 | 505 | ) |
| 493 | 506 | ); |
| 494 | - } |
|
| 495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
| 507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
| 496 | 508 | { |
| 497 | 509 | $smcFunc['db_query']('', ' |
| 498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
| 509 | 521 | } |
| 510 | 522 | |
| 511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 512 | - } |
|
| 513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 514 | 525 | { |
| 515 | 526 | checkSession('get'); |
| 516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
| 525 | 536 | ) |
| 526 | 537 | ); |
| 527 | 538 | $customFields = array(); |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - $customFields[] = $row['col_name']; |
|
| 539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 540 | + $customFields[] = $row['col_name']; |
|
| 541 | + } |
|
| 530 | 542 | $smcFunc['db_free_result']($request); |
| 531 | 543 | } |
| 532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -581,13 +593,13 @@ discard block |
||
| 581 | 593 | ) |
| 582 | 594 | ); |
| 583 | 595 | $context['theme_options'] = array(); |
| 584 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 585 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
| 596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 597 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
| 598 | + } |
|
| 586 | 599 | $smcFunc['db_free_result']($request); |
| 587 | 600 | |
| 588 | 601 | $context['theme_options_reset'] = false; |
| 589 | - } |
|
| 590 | - else |
|
| 602 | + } else |
|
| 591 | 603 | { |
| 592 | 604 | $context['theme_options'] = array(); |
| 593 | 605 | $context['theme_options_reset'] = true; |
@@ -596,8 +608,9 @@ discard block |
||
| 596 | 608 | foreach ($context['options'] as $i => $setting) |
| 597 | 609 | { |
| 598 | 610 | // Just skip separators |
| 599 | - if (!is_array($setting)) |
|
| 600 | - continue; |
|
| 611 | + if (!is_array($setting)) { |
|
| 612 | + continue; |
|
| 613 | + } |
|
| 601 | 614 | |
| 602 | 615 | // Is this disabled? |
| 603 | 616 | if (isset($setting['enabled']) && $setting['enabled'] === false) |
@@ -606,15 +619,17 @@ discard block |
||
| 606 | 619 | continue; |
| 607 | 620 | } |
| 608 | 621 | |
| 609 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 610 | - $context['options'][$i]['type'] = 'checkbox'; |
|
| 611 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 612 | - $context['options'][$i]['type'] = 'number'; |
|
| 613 | - elseif ($setting['type'] == 'string') |
|
| 614 | - $context['options'][$i]['type'] = 'text'; |
|
| 622 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 623 | + $context['options'][$i]['type'] = 'checkbox'; |
|
| 624 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 625 | + $context['options'][$i]['type'] = 'number'; |
|
| 626 | + } elseif ($setting['type'] == 'string') { |
|
| 627 | + $context['options'][$i]['type'] = 'text'; |
|
| 628 | + } |
|
| 615 | 629 | |
| 616 | - if (isset($setting['options'])) |
|
| 617 | - $context['options'][$i]['type'] = 'list'; |
|
| 630 | + if (isset($setting['options'])) { |
|
| 631 | + $context['options'][$i]['type'] = 'list'; |
|
| 632 | + } |
|
| 618 | 633 | |
| 619 | 634 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
| 620 | 635 | } |
@@ -639,8 +654,9 @@ discard block |
||
| 639 | 654 | { |
| 640 | 655 | global $txt, $context, $settings, $modSettings, $smcFunc; |
| 641 | 656 | |
| 642 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
| 643 | - return ThemeAdmin(); |
|
| 657 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
| 658 | + return ThemeAdmin(); |
|
| 659 | + } |
|
| 644 | 660 | |
| 645 | 661 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 646 | 662 | |
@@ -651,8 +667,9 @@ discard block |
||
| 651 | 667 | isAllowedTo('admin_forum'); |
| 652 | 668 | |
| 653 | 669 | // Validate inputs/user. |
| 654 | - if (empty($_GET['th'])) |
|
| 655 | - fatal_lang_error('no_theme', false); |
|
| 670 | + if (empty($_GET['th'])) { |
|
| 671 | + fatal_lang_error('no_theme', false); |
|
| 672 | + } |
|
| 656 | 673 | |
| 657 | 674 | // Fetch the smiley sets... |
| 658 | 675 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -660,8 +677,9 @@ discard block |
||
| 660 | 677 | $context['smiley_sets'] = array( |
| 661 | 678 | '' => $txt['smileys_no_default'] |
| 662 | 679 | ); |
| 663 | - foreach ($sets as $i => $set) |
|
| 664 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 680 | + foreach ($sets as $i => $set) { |
|
| 681 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 682 | + } |
|
| 665 | 683 | |
| 666 | 684 | $old_id = $settings['theme_id']; |
| 667 | 685 | $old_settings = $settings; |
@@ -686,8 +704,9 @@ discard block |
||
| 686 | 704 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
| 687 | 705 | { |
| 688 | 706 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
| 689 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
| 690 | - eval('global $settings;' . $matches[0]); |
|
| 707 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
| 708 | + eval('global $settings;' . $matches[0]); |
|
| 709 | + } |
|
| 691 | 710 | } |
| 692 | 711 | |
| 693 | 712 | // Let mods hook into the theme settings. |
@@ -699,37 +718,45 @@ discard block |
||
| 699 | 718 | checkSession(); |
| 700 | 719 | validateToken('admin-sts'); |
| 701 | 720 | |
| 702 | - if (empty($_POST['options'])) |
|
| 703 | - $_POST['options'] = array(); |
|
| 704 | - if (empty($_POST['default_options'])) |
|
| 705 | - $_POST['default_options'] = array(); |
|
| 721 | + if (empty($_POST['options'])) { |
|
| 722 | + $_POST['options'] = array(); |
|
| 723 | + } |
|
| 724 | + if (empty($_POST['default_options'])) { |
|
| 725 | + $_POST['default_options'] = array(); |
|
| 726 | + } |
|
| 706 | 727 | |
| 707 | 728 | // Make sure items are cast correctly. |
| 708 | 729 | foreach ($context['theme_settings'] as $item) |
| 709 | 730 | { |
| 710 | 731 | // Disregard this item if this is just a separator. |
| 711 | - if (!is_array($item)) |
|
| 712 | - continue; |
|
| 732 | + if (!is_array($item)) { |
|
| 733 | + continue; |
|
| 734 | + } |
|
| 713 | 735 | |
| 714 | 736 | foreach (array('options', 'default_options') as $option) |
| 715 | 737 | { |
| 716 | - if (!isset($_POST[$option][$item['id']])) |
|
| 717 | - continue; |
|
| 738 | + if (!isset($_POST[$option][$item['id']])) { |
|
| 739 | + continue; |
|
| 740 | + } |
|
| 718 | 741 | // Checkbox. |
| 719 | - elseif (empty($item['type'])) |
|
| 720 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 742 | + elseif (empty($item['type'])) { |
|
| 743 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 744 | + } |
|
| 721 | 745 | // Number |
| 722 | - elseif ($item['type'] == 'number') |
|
| 723 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 746 | + elseif ($item['type'] == 'number') { |
|
| 747 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 748 | + } |
|
| 724 | 749 | } |
| 725 | 750 | } |
| 726 | 751 | |
| 727 | 752 | // Set up the sql query. |
| 728 | 753 | $inserts = array(); |
| 729 | - foreach ($_POST['options'] as $opt => $val) |
|
| 730 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 731 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 732 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 754 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 755 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 756 | + } |
|
| 757 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
| 758 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 759 | + } |
|
| 733 | 760 | // If we're actually inserting something.. |
| 734 | 761 | if (!empty($inserts)) |
| 735 | 762 | { |
@@ -755,8 +782,9 @@ discard block |
||
| 755 | 782 | |
| 756 | 783 | foreach ($settings as $setting => $dummy) |
| 757 | 784 | { |
| 758 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
| 759 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 785 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
| 786 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 787 | + } |
|
| 760 | 788 | } |
| 761 | 789 | |
| 762 | 790 | $context['settings'] = $context['theme_settings']; |
@@ -765,18 +793,21 @@ discard block |
||
| 765 | 793 | foreach ($context['settings'] as $i => $setting) |
| 766 | 794 | { |
| 767 | 795 | // Separators are dummies, so leave them alone. |
| 768 | - if (!is_array($setting)) |
|
| 769 | - continue; |
|
| 796 | + if (!is_array($setting)) { |
|
| 797 | + continue; |
|
| 798 | + } |
|
| 770 | 799 | |
| 771 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 772 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
| 773 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 774 | - $context['settings'][$i]['type'] = 'number'; |
|
| 775 | - elseif ($setting['type'] == 'string') |
|
| 776 | - $context['settings'][$i]['type'] = 'text'; |
|
| 800 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 801 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
| 802 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 803 | + $context['settings'][$i]['type'] = 'number'; |
|
| 804 | + } elseif ($setting['type'] == 'string') { |
|
| 805 | + $context['settings'][$i]['type'] = 'text'; |
|
| 806 | + } |
|
| 777 | 807 | |
| 778 | - if (isset($setting['options'])) |
|
| 779 | - $context['settings'][$i]['type'] = 'list'; |
|
| 808 | + if (isset($setting['options'])) { |
|
| 809 | + $context['settings'][$i]['type'] = 'list'; |
|
| 810 | + } |
|
| 780 | 811 | |
| 781 | 812 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
| 782 | 813 | } |
@@ -829,8 +860,9 @@ discard block |
||
| 829 | 860 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 830 | 861 | |
| 831 | 862 | // You can't delete the default theme! |
| 832 | - if ($themeID == 1) |
|
| 833 | - fatal_lang_error('no_access', false); |
|
| 863 | + if ($themeID == 1) { |
|
| 864 | + fatal_lang_error('no_access', false); |
|
| 865 | + } |
|
| 834 | 866 | |
| 835 | 867 | $theme_info = get_single_theme($themeID); |
| 836 | 868 | |
@@ -838,8 +870,9 @@ discard block |
||
| 838 | 870 | remove_theme($themeID); |
| 839 | 871 | |
| 840 | 872 | // And remove all its files and folders too. |
| 841 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
| 842 | - remove_dir($theme_info['theme_dir']); |
|
| 873 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
| 874 | + remove_dir($theme_info['theme_dir']); |
|
| 875 | + } |
|
| 843 | 876 | |
| 844 | 877 | // Go back to the list page. |
| 845 | 878 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -864,12 +897,14 @@ discard block |
||
| 864 | 897 | $enableThemes = explode(',', $modSettings['enableThemes']); |
| 865 | 898 | |
| 866 | 899 | // Are we disabling it? |
| 867 | - if (isset($_GET['disabled'])) |
|
| 868 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 900 | + if (isset($_GET['disabled'])) { |
|
| 901 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 902 | + } |
|
| 869 | 903 | |
| 870 | 904 | // Nope? then enable it! |
| 871 | - else |
|
| 872 | - $enableThemes[] = (string) $themeID; |
|
| 905 | + else { |
|
| 906 | + $enableThemes[] = (string) $themeID; |
|
| 907 | + } |
|
| 873 | 908 | |
| 874 | 909 | // Update the setting. |
| 875 | 910 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -904,18 +939,21 @@ discard block |
||
| 904 | 939 | |
| 905 | 940 | $_SESSION['id_theme'] = 0; |
| 906 | 941 | |
| 907 | - if (isset($_GET['id'])) |
|
| 908 | - $_GET['th'] = $_GET['id']; |
|
| 942 | + if (isset($_GET['id'])) { |
|
| 943 | + $_GET['th'] = $_GET['id']; |
|
| 944 | + } |
|
| 909 | 945 | |
| 910 | 946 | // Saving a variant cause JS doesn't work - pretend it did ;) |
| 911 | 947 | if (isset($_POST['save'])) |
| 912 | 948 | { |
| 913 | 949 | // Which theme? |
| 914 | - foreach ($_POST['save'] as $k => $v) |
|
| 915 | - $_GET['th'] = (int) $k; |
|
| 950 | + foreach ($_POST['save'] as $k => $v) { |
|
| 951 | + $_GET['th'] = (int) $k; |
|
| 952 | + } |
|
| 916 | 953 | |
| 917 | - if (isset($_POST['vrt'][$k])) |
|
| 918 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 954 | + if (isset($_POST['vrt'][$k])) { |
|
| 955 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 956 | + } |
|
| 919 | 957 | } |
| 920 | 958 | |
| 921 | 959 | // Have we made a decision, or are we just browsing? |
@@ -1004,10 +1042,10 @@ discard block |
||
| 1004 | 1042 | ); |
| 1005 | 1043 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
| 1006 | 1044 | |
| 1007 | - if ($user_info['id'] == $_REQUEST['u']) |
|
| 1008 | - $_SESSION['id_variant'] = 0; |
|
| 1009 | - } |
|
| 1010 | - elseif ($_GET['th'] == 0) |
|
| 1045 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
| 1046 | + $_SESSION['id_variant'] = 0; |
|
| 1047 | + } |
|
| 1048 | + } elseif ($_GET['th'] == 0) |
|
| 1011 | 1049 | { |
| 1012 | 1050 | // Remove any custom variants. |
| 1013 | 1051 | $smcFunc['db_query']('', ' |
@@ -1088,12 +1126,13 @@ discard block |
||
| 1088 | 1126 | ); |
| 1089 | 1127 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1090 | 1128 | { |
| 1091 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
| 1092 | - $context['available_themes'][$row['id_theme']] = array( |
|
| 1129 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
| 1130 | + $context['available_themes'][$row['id_theme']] = array( |
|
| 1093 | 1131 | 'id' => $row['id_theme'], |
| 1094 | 1132 | 'selected' => $context['current_theme'] == $row['id_theme'], |
| 1095 | 1133 | 'num_users' => 0 |
| 1096 | 1134 | ); |
| 1135 | + } |
|
| 1097 | 1136 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 1098 | 1137 | } |
| 1099 | 1138 | $smcFunc['db_free_result']($request); |
@@ -1106,9 +1145,9 @@ discard block |
||
| 1106 | 1145 | 'num_users' => 0 |
| 1107 | 1146 | ); |
| 1108 | 1147 | $guest_theme = 0; |
| 1148 | + } else { |
|
| 1149 | + $guest_theme = $modSettings['theme_guests']; |
|
| 1109 | 1150 | } |
| 1110 | - else |
|
| 1111 | - $guest_theme = $modSettings['theme_guests']; |
|
| 1112 | 1151 | |
| 1113 | 1152 | $request = $smcFunc['db_query']('', ' |
| 1114 | 1153 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1121,15 +1160,17 @@ discard block |
||
| 1121 | 1160 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1122 | 1161 | { |
| 1123 | 1162 | // Figure out which theme it is they are REALLY using. |
| 1124 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
| 1125 | - $row['id_theme'] = $guest_theme; |
|
| 1126 | - elseif (empty($modSettings['theme_allow'])) |
|
| 1127 | - $row['id_theme'] = $guest_theme; |
|
| 1163 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
| 1164 | + $row['id_theme'] = $guest_theme; |
|
| 1165 | + } elseif (empty($modSettings['theme_allow'])) { |
|
| 1166 | + $row['id_theme'] = $guest_theme; |
|
| 1167 | + } |
|
| 1128 | 1168 | |
| 1129 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
| 1130 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1131 | - else |
|
| 1132 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1169 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
| 1170 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1171 | + } else { |
|
| 1172 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1173 | + } |
|
| 1133 | 1174 | } |
| 1134 | 1175 | $smcFunc['db_free_result']($request); |
| 1135 | 1176 | |
@@ -1148,8 +1189,9 @@ discard block |
||
| 1148 | 1189 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
| 1149 | 1190 | ) |
| 1150 | 1191 | ); |
| 1151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1152 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1192 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1193 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1194 | + } |
|
| 1153 | 1195 | $smcFunc['db_free_result']($request); |
| 1154 | 1196 | } |
| 1155 | 1197 | |
@@ -1160,17 +1202,18 @@ discard block |
||
| 1160 | 1202 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
| 1161 | 1203 | { |
| 1162 | 1204 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
| 1163 | - if ($id_theme == 0) |
|
| 1164 | - continue; |
|
| 1205 | + if ($id_theme == 0) { |
|
| 1206 | + continue; |
|
| 1207 | + } |
|
| 1165 | 1208 | |
| 1166 | 1209 | // The thumbnail needs the correct path. |
| 1167 | 1210 | $settings['images_url'] = &$theme_data['images_url']; |
| 1168 | 1211 | |
| 1169 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
| 1170 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1171 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
| 1172 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1173 | - else |
|
| 1212 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
| 1213 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1214 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
| 1215 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1216 | + } else |
|
| 1174 | 1217 | { |
| 1175 | 1218 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
| 1176 | 1219 | $txt['theme_description'] = ''; |
@@ -1195,15 +1238,17 @@ discard block |
||
| 1195 | 1238 | loadLanguage('Settings'); |
| 1196 | 1239 | |
| 1197 | 1240 | $context['available_themes'][$id_theme]['variants'] = array(); |
| 1198 | - foreach ($settings['theme_variants'] as $variant) |
|
| 1199 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1241 | + foreach ($settings['theme_variants'] as $variant) { |
|
| 1242 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1200 | 1243 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
| 1201 | 1244 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
| 1202 | 1245 | ); |
| 1246 | + } |
|
| 1203 | 1247 | |
| 1204 | 1248 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
| 1205 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
| 1206 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1249 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
| 1250 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1251 | + } |
|
| 1207 | 1252 | |
| 1208 | 1253 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
| 1209 | 1254 | // Allow themes to override the text. |
@@ -1219,8 +1264,9 @@ discard block |
||
| 1219 | 1264 | // As long as we're not doing the default theme... |
| 1220 | 1265 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
| 1221 | 1266 | { |
| 1222 | - if ($guest_theme != 0) |
|
| 1223 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1267 | + if ($guest_theme != 0) { |
|
| 1268 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1269 | + } |
|
| 1224 | 1270 | |
| 1225 | 1271 | $context['available_themes'][0]['id'] = 0; |
| 1226 | 1272 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1269,14 +1315,16 @@ discard block |
||
| 1269 | 1315 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
| 1270 | 1316 | |
| 1271 | 1317 | // Got any info from the specific form? |
| 1272 | - if (!isset($_POST['save_' . $action])) |
|
| 1273 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1318 | + if (!isset($_POST['save_' . $action])) { |
|
| 1319 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1320 | + } |
|
| 1274 | 1321 | |
| 1275 | 1322 | validateToken('admin-t-' . $action); |
| 1276 | 1323 | |
| 1277 | 1324 | // Hopefully the themes directory is writable, or we might have a problem. |
| 1278 | - if (!is_writable($themedir)) |
|
| 1279 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1325 | + if (!is_writable($themedir)) { |
|
| 1326 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1327 | + } |
|
| 1280 | 1328 | |
| 1281 | 1329 | // Call the function and handle the result. |
| 1282 | 1330 | $result = $subActions[$action](); |
@@ -1291,9 +1339,10 @@ discard block |
||
| 1291 | 1339 | } |
| 1292 | 1340 | |
| 1293 | 1341 | // Nope, show a nice error. |
| 1294 | - else |
|
| 1295 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1296 | -} |
|
| 1342 | + else { |
|
| 1343 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1344 | + } |
|
| 1345 | + } |
|
| 1297 | 1346 | |
| 1298 | 1347 | /** |
| 1299 | 1348 | * Installs a theme from a theme package. |
@@ -1309,8 +1358,9 @@ discard block |
||
| 1309 | 1358 | $dirtemp = $themedir . '/temp'; |
| 1310 | 1359 | |
| 1311 | 1360 | // Make sure the temp dir doesn't already exist |
| 1312 | - if (file_exists($dirtemp)) |
|
| 1313 | - remove_dir($dirtemp); |
|
| 1361 | + if (file_exists($dirtemp)) { |
|
| 1362 | + remove_dir($dirtemp); |
|
| 1363 | + } |
|
| 1314 | 1364 | |
| 1315 | 1365 | // Create the temp dir. |
| 1316 | 1366 | mkdir($dirtemp, 0777); |
@@ -1322,17 +1372,20 @@ discard block |
||
| 1322 | 1372 | smf_chmod($dirtemp, '0755'); |
| 1323 | 1373 | |
| 1324 | 1374 | // How about now? |
| 1325 | - if (!is_writable($dirtemp)) |
|
| 1326 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1375 | + if (!is_writable($dirtemp)) { |
|
| 1376 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1377 | + } |
|
| 1327 | 1378 | } |
| 1328 | 1379 | |
| 1329 | 1380 | // This happens when the admin session is gone and the user has to login again. |
| 1330 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
| 1331 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1381 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
| 1382 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1383 | + } |
|
| 1332 | 1384 | |
| 1333 | 1385 | // Another error check layer, something went wrong with the upload. |
| 1334 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
| 1335 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
| 1386 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
| 1387 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
| 1388 | + } |
|
| 1336 | 1389 | |
| 1337 | 1390 | // Get the theme's name. |
| 1338 | 1391 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1363,11 +1416,10 @@ discard block |
||
| 1363 | 1416 | |
| 1364 | 1417 | // return all the info. |
| 1365 | 1418 | return $context['to_install']; |
| 1419 | + } else { |
|
| 1420 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1421 | + } |
|
| 1366 | 1422 | } |
| 1367 | - |
|
| 1368 | - else |
|
| 1369 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1370 | -} |
|
| 1371 | 1423 | |
| 1372 | 1424 | /** |
| 1373 | 1425 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1381,15 +1433,17 @@ discard block |
||
| 1381 | 1433 | global $forum_version; |
| 1382 | 1434 | |
| 1383 | 1435 | // There's gotta be something to work with. |
| 1384 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
| 1385 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1436 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
| 1437 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1438 | + } |
|
| 1386 | 1439 | |
| 1387 | 1440 | // Get a cleaner version. |
| 1388 | 1441 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
| 1389 | 1442 | |
| 1390 | 1443 | // Is there a theme already named like this? |
| 1391 | - if (file_exists($themedir . '/' . $name)) |
|
| 1392 | - fatal_lang_error('theme_install_already_dir', false); |
|
| 1444 | + if (file_exists($themedir . '/' . $name)) { |
|
| 1445 | + fatal_lang_error('theme_install_already_dir', false); |
|
| 1446 | + } |
|
| 1393 | 1447 | |
| 1394 | 1448 | // This is a brand new theme so set all possible values. |
| 1395 | 1449 | $context['to_install'] = array( |
@@ -1409,8 +1463,9 @@ discard block |
||
| 1409 | 1463 | |
| 1410 | 1464 | // Buy some time. |
| 1411 | 1465 | @set_time_limit(600); |
| 1412 | - if (function_exists('apache_reset_timeout')) |
|
| 1413 | - @apache_reset_timeout(); |
|
| 1466 | + if (function_exists('apache_reset_timeout')) { |
|
| 1467 | + @apache_reset_timeout(); |
|
| 1468 | + } |
|
| 1414 | 1469 | |
| 1415 | 1470 | // Create subdirectories for css and javascript files. |
| 1416 | 1471 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1446,12 +1501,13 @@ discard block |
||
| 1446 | 1501 | |
| 1447 | 1502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1448 | 1503 | { |
| 1449 | - if ($row['variable'] == 'theme_templates') |
|
| 1450 | - $theme_templates = $row['value']; |
|
| 1451 | - elseif ($row['variable'] == 'theme_layers') |
|
| 1452 | - $theme_layers = $row['value']; |
|
| 1453 | - else |
|
| 1454 | - continue; |
|
| 1504 | + if ($row['variable'] == 'theme_templates') { |
|
| 1505 | + $theme_templates = $row['value']; |
|
| 1506 | + } elseif ($row['variable'] == 'theme_layers') { |
|
| 1507 | + $theme_layers = $row['value']; |
|
| 1508 | + } else { |
|
| 1509 | + continue; |
|
| 1510 | + } |
|
| 1455 | 1511 | } |
| 1456 | 1512 | |
| 1457 | 1513 | $smcFunc['db_free_result']($request); |
@@ -1510,12 +1566,14 @@ discard block |
||
| 1510 | 1566 | global $themedir, $themeurl, $context; |
| 1511 | 1567 | |
| 1512 | 1568 | // Cannot use the theme dir as a theme dir. |
| 1513 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
| 1514 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1569 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
| 1570 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1571 | + } |
|
| 1515 | 1572 | |
| 1516 | 1573 | // Check is there is "something" on the dir. |
| 1517 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
| 1518 | - fatal_lang_error('theme_install_error', false); |
|
| 1574 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
| 1575 | + fatal_lang_error('theme_install_error', false); |
|
| 1576 | + } |
|
| 1519 | 1577 | |
| 1520 | 1578 | $name = basename($_REQUEST['theme_dir']); |
| 1521 | 1579 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1559,24 +1617,27 @@ discard block |
||
| 1559 | 1617 | } |
| 1560 | 1618 | |
| 1561 | 1619 | // Any special layers? |
| 1562 | - if (isset($settings['catch_action']['layers'])) |
|
| 1563 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1620 | + if (isset($settings['catch_action']['layers'])) { |
|
| 1621 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1622 | + } |
|
| 1564 | 1623 | |
| 1565 | 1624 | // Any function to call? |
| 1566 | 1625 | if (isset($settings['catch_action']['function'])) |
| 1567 | 1626 | { |
| 1568 | 1627 | $hook = $settings['catch_action']['function']; |
| 1569 | 1628 | |
| 1570 | - if (!isset($settings['catch_action']['filename'])) |
|
| 1571 | - $settings['catch_action']['filename'] = ''; |
|
| 1629 | + if (!isset($settings['catch_action']['filename'])) { |
|
| 1630 | + $settings['catch_action']['filename'] = ''; |
|
| 1631 | + } |
|
| 1572 | 1632 | |
| 1573 | 1633 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
| 1574 | 1634 | call_integration_hook('integrate_wrap_action'); |
| 1575 | 1635 | } |
| 1576 | 1636 | // And finally, the main sub template ;). |
| 1577 | - if (isset($settings['catch_action']['sub_template'])) |
|
| 1578 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1579 | -} |
|
| 1637 | + if (isset($settings['catch_action']['sub_template'])) { |
|
| 1638 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1639 | + } |
|
| 1640 | + } |
|
| 1580 | 1641 | |
| 1581 | 1642 | /** |
| 1582 | 1643 | * Set an option via javascript. |
@@ -1595,12 +1656,14 @@ discard block |
||
| 1595 | 1656 | checkSession('get'); |
| 1596 | 1657 | |
| 1597 | 1658 | // This good-for-nothing pixel is being used to keep the session alive. |
| 1598 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
| 1599 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1659 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
| 1660 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1661 | + } |
|
| 1600 | 1662 | |
| 1601 | 1663 | // Sorry, guests can't go any further than this. |
| 1602 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
| 1603 | - obExit(false); |
|
| 1664 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
| 1665 | + obExit(false); |
|
| 1666 | + } |
|
| 1604 | 1667 | |
| 1605 | 1668 | $reservedVars = array( |
| 1606 | 1669 | 'actual_theme_url', |
@@ -1623,8 +1686,9 @@ discard block |
||
| 1623 | 1686 | ); |
| 1624 | 1687 | |
| 1625 | 1688 | // Can't change reserved vars. |
| 1626 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
| 1627 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1689 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
| 1690 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1691 | + } |
|
| 1628 | 1692 | |
| 1629 | 1693 | // Use a specific theme? |
| 1630 | 1694 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1640,8 +1704,9 @@ discard block |
||
| 1640 | 1704 | { |
| 1641 | 1705 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
| 1642 | 1706 | // New thingy... |
| 1643 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
| 1644 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1707 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
| 1708 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1709 | + } |
|
| 1645 | 1710 | |
| 1646 | 1711 | // Change the value to be something nice, |
| 1647 | 1712 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1671,8 +1736,9 @@ discard block |
||
| 1671 | 1736 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
| 1672 | 1737 | |
| 1673 | 1738 | // @todo Should this be removed? |
| 1674 | - if (isset($_REQUEST['preview'])) |
|
| 1675 | - die('die() with fire'); |
|
| 1739 | + if (isset($_REQUEST['preview'])) { |
|
| 1740 | + die('die() with fire'); |
|
| 1741 | + } |
|
| 1676 | 1742 | |
| 1677 | 1743 | isAllowedTo('admin_forum'); |
| 1678 | 1744 | loadTemplate('Themes'); |
@@ -1686,11 +1752,11 @@ discard block |
||
| 1686 | 1752 | foreach ($context['themes'] as $key => $theme) |
| 1687 | 1753 | { |
| 1688 | 1754 | // There has to be a Settings template! |
| 1689 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
| 1690 | - unset($context['themes'][$key]); |
|
| 1691 | - |
|
| 1692 | - else |
|
| 1693 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1755 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
| 1756 | + unset($context['themes'][$key]); |
|
| 1757 | + } else { |
|
| 1758 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1759 | + } |
|
| 1694 | 1760 | } |
| 1695 | 1761 | |
| 1696 | 1762 | $context['sub_template'] = 'edit_list'; |
@@ -1705,22 +1771,24 @@ discard block |
||
| 1705 | 1771 | $context['theme_id'] = $currentTheme['id']; |
| 1706 | 1772 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
| 1707 | 1773 | |
| 1708 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
| 1709 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1774 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
| 1775 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1776 | + } |
|
| 1710 | 1777 | |
| 1711 | 1778 | if (!isset($_REQUEST['filename'])) |
| 1712 | 1779 | { |
| 1713 | 1780 | if (isset($_GET['directory'])) |
| 1714 | 1781 | { |
| 1715 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
| 1716 | - $_GET['directory'] = ''; |
|
| 1717 | - else |
|
| 1782 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
| 1783 | + $_GET['directory'] = ''; |
|
| 1784 | + } else |
|
| 1718 | 1785 | { |
| 1719 | 1786 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
| 1720 | 1787 | |
| 1721 | 1788 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
| 1722 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1723 | - $_GET['directory'] = ''; |
|
| 1789 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1790 | + $_GET['directory'] = ''; |
|
| 1791 | + } |
|
| 1724 | 1792 | } |
| 1725 | 1793 | } |
| 1726 | 1794 | |
@@ -1739,44 +1807,47 @@ discard block |
||
| 1739 | 1807 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
| 1740 | 1808 | 'size' => '', |
| 1741 | 1809 | )); |
| 1810 | + } else { |
|
| 1811 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1742 | 1812 | } |
| 1743 | - else |
|
| 1744 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1745 | 1813 | |
| 1746 | 1814 | // Do not list minified_ files |
| 1747 | 1815 | foreach($context['theme_files'] as $key=>$file) |
| 1748 | 1816 | { |
| 1749 | - if(strpos($file['filename'], 'minified_') !== FALSE) |
|
| 1750 | - unset($context['theme_files'][$key]); |
|
| 1817 | + if(strpos($file['filename'], 'minified_') !== FALSE) { |
|
| 1818 | + unset($context['theme_files'][$key]); |
|
| 1819 | + } |
|
| 1751 | 1820 | } |
| 1752 | 1821 | |
| 1753 | 1822 | $context['sub_template'] = 'edit_browse'; |
| 1754 | 1823 | |
| 1755 | 1824 | return; |
| 1756 | - } |
|
| 1757 | - else |
|
| 1825 | + } else |
|
| 1758 | 1826 | { |
| 1759 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
| 1760 | - $_REQUEST['filename'] = ''; |
|
| 1761 | - else |
|
| 1827 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
| 1828 | + $_REQUEST['filename'] = ''; |
|
| 1829 | + } else |
|
| 1762 | 1830 | { |
| 1763 | 1831 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
| 1764 | 1832 | |
| 1765 | 1833 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
| 1766 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1767 | - $_REQUEST['filename'] = ''; |
|
| 1834 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1835 | + $_REQUEST['filename'] = ''; |
|
| 1836 | + } |
|
| 1768 | 1837 | } |
| 1769 | 1838 | |
| 1770 | - if (empty($_REQUEST['filename'])) |
|
| 1771 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1839 | + if (empty($_REQUEST['filename'])) { |
|
| 1840 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1841 | + } |
|
| 1772 | 1842 | } |
| 1773 | 1843 | |
| 1774 | 1844 | if (isset($_POST['save'])) |
| 1775 | 1845 | { |
| 1776 | 1846 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
| 1777 | 1847 | { |
| 1778 | - if (is_array($_POST['entire_file'])) |
|
| 1779 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1848 | + if (is_array($_POST['entire_file'])) { |
|
| 1849 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1850 | + } |
|
| 1780 | 1851 | |
| 1781 | 1852 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
| 1782 | 1853 | |
@@ -1788,10 +1859,11 @@ discard block |
||
| 1788 | 1859 | fclose($fp); |
| 1789 | 1860 | |
| 1790 | 1861 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
| 1791 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
| 1792 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1793 | - else |
|
| 1794 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1862 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
| 1863 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1864 | + } else { |
|
| 1865 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1866 | + } |
|
| 1795 | 1867 | } |
| 1796 | 1868 | |
| 1797 | 1869 | if (!isset($error_file)) |
@@ -1812,10 +1884,11 @@ discard block |
||
| 1812 | 1884 | $context['sub_template'] = 'edit_file'; |
| 1813 | 1885 | |
| 1814 | 1886 | // Recycle the submitted data. |
| 1815 | - if (is_array($_POST['entire_file'])) |
|
| 1816 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1817 | - else |
|
| 1818 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1887 | + if (is_array($_POST['entire_file'])) { |
|
| 1888 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1889 | + } else { |
|
| 1890 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1891 | + } |
|
| 1819 | 1892 | |
| 1820 | 1893 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
| 1821 | 1894 | |
@@ -1838,17 +1911,17 @@ discard block |
||
| 1838 | 1911 | $context['sub_template'] = 'edit_style'; |
| 1839 | 1912 | |
| 1840 | 1913 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
| 1841 | - } |
|
| 1842 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1914 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1843 | 1915 | { |
| 1844 | 1916 | $context['sub_template'] = 'edit_template'; |
| 1845 | 1917 | |
| 1846 | - if (!isset($error_file)) |
|
| 1847 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1848 | - else |
|
| 1918 | + if (!isset($error_file)) { |
|
| 1919 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1920 | + } else |
|
| 1849 | 1921 | { |
| 1850 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
| 1851 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1922 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
| 1923 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1924 | + } |
|
| 1852 | 1925 | $file_data = file($error_file); |
| 1853 | 1926 | unlink($error_file); |
| 1854 | 1927 | } |
@@ -1862,8 +1935,9 @@ discard block |
||
| 1862 | 1935 | // Try to format the functions a little nicer... |
| 1863 | 1936 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
| 1864 | 1937 | |
| 1865 | - if (empty($context['file_parts'][$j]['lines'])) |
|
| 1866 | - unset($context['file_parts'][$j]); |
|
| 1938 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
| 1939 | + unset($context['file_parts'][$j]); |
|
| 1940 | + } |
|
| 1867 | 1941 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
| 1868 | 1942 | } |
| 1869 | 1943 | |
@@ -1872,8 +1946,7 @@ discard block |
||
| 1872 | 1946 | } |
| 1873 | 1947 | |
| 1874 | 1948 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
| 1875 | - } |
|
| 1876 | - else |
|
| 1949 | + } else |
|
| 1877 | 1950 | { |
| 1878 | 1951 | $context['sub_template'] = 'edit_file'; |
| 1879 | 1952 | |
@@ -1899,8 +1972,9 @@ discard block |
||
| 1899 | 1972 | |
| 1900 | 1973 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 1901 | 1974 | |
| 1902 | - if (empty($_GET['th'])) |
|
| 1903 | - fatal_lang_error('theme_install_invalid_id'); |
|
| 1975 | + if (empty($_GET['th'])) { |
|
| 1976 | + fatal_lang_error('theme_install_invalid_id'); |
|
| 1977 | + } |
|
| 1904 | 1978 | |
| 1905 | 1979 | // Get the theme info. |
| 1906 | 1980 | $theme = get_single_theme($_GET['th']); |
@@ -1908,25 +1982,24 @@ discard block |
||
| 1908 | 1982 | |
| 1909 | 1983 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
| 1910 | 1984 | { |
| 1911 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
| 1912 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1913 | - |
|
| 1914 | - else |
|
| 1915 | - fatal_lang_error('no_access', false); |
|
| 1985 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
| 1986 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1987 | + } else { |
|
| 1988 | + fatal_lang_error('no_access', false); |
|
| 1989 | + } |
|
| 1916 | 1990 | |
| 1917 | 1991 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
| 1918 | 1992 | fwrite($fp, file_get_contents($filename)); |
| 1919 | 1993 | fclose($fp); |
| 1920 | 1994 | |
| 1921 | 1995 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
| 1922 | - } |
|
| 1923 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1996 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1924 | 1997 | { |
| 1925 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
| 1926 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1927 | - |
|
| 1928 | - else |
|
| 1929 | - fatal_lang_error('no_access', false); |
|
| 1998 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
| 1999 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 2000 | + } else { |
|
| 2001 | + fatal_lang_error('no_access', false); |
|
| 2002 | + } |
|
| 1930 | 2003 | |
| 1931 | 2004 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
| 1932 | 2005 | fwrite($fp, file_get_contents($filename)); |
@@ -1941,16 +2014,18 @@ discard block |
||
| 1941 | 2014 | $dir = dir($settings['default_theme_dir']); |
| 1942 | 2015 | while ($entry = $dir->read()) |
| 1943 | 2016 | { |
| 1944 | - if (substr($entry, -13) == '.template.php') |
|
| 1945 | - $templates[] = substr($entry, 0, -13); |
|
| 2017 | + if (substr($entry, -13) == '.template.php') { |
|
| 2018 | + $templates[] = substr($entry, 0, -13); |
|
| 2019 | + } |
|
| 1946 | 2020 | } |
| 1947 | 2021 | $dir->close(); |
| 1948 | 2022 | |
| 1949 | 2023 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
| 1950 | 2024 | while ($entry = $dir->read()) |
| 1951 | 2025 | { |
| 1952 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
| 1953 | - $lang_files[] = $matches[1]; |
|
| 2026 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
| 2027 | + $lang_files[] = $matches[1]; |
|
| 2028 | + } |
|
| 1954 | 2029 | } |
| 1955 | 2030 | $dir->close(); |
| 1956 | 2031 | |
@@ -1958,21 +2033,23 @@ discard block |
||
| 1958 | 2033 | natcasesort($lang_files); |
| 1959 | 2034 | |
| 1960 | 2035 | $context['available_templates'] = array(); |
| 1961 | - foreach ($templates as $template) |
|
| 1962 | - $context['available_templates'][$template] = array( |
|
| 2036 | + foreach ($templates as $template) { |
|
| 2037 | + $context['available_templates'][$template] = array( |
|
| 1963 | 2038 | 'filename' => $template . '.template.php', |
| 1964 | 2039 | 'value' => $template, |
| 1965 | 2040 | 'already_exists' => false, |
| 1966 | 2041 | 'can_copy' => is_writable($theme['theme_dir']), |
| 1967 | 2042 | ); |
| 2043 | + } |
|
| 1968 | 2044 | $context['available_language_files'] = array(); |
| 1969 | - foreach ($lang_files as $file) |
|
| 1970 | - $context['available_language_files'][$file] = array( |
|
| 2045 | + foreach ($lang_files as $file) { |
|
| 2046 | + $context['available_language_files'][$file] = array( |
|
| 1971 | 2047 | 'filename' => $file . '.php', |
| 1972 | 2048 | 'value' => $file, |
| 1973 | 2049 | 'already_exists' => false, |
| 1974 | 2050 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
| 1975 | 2051 | ); |
| 2052 | + } |
|
| 1976 | 2053 | |
| 1977 | 2054 | $dir = dir($theme['theme_dir']); |
| 1978 | 2055 | while ($entry = $dir->read()) |