@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 58 | - return; |
|
| 58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -117,21 +119,23 @@ discard block |
||
| 117 | 119 | |
| 118 | 120 | $subwords = text2words($word, $this->min_word_length, true); |
| 119 | 121 | |
| 120 | - if (empty($modSettings['search_force_index'])) |
|
| 121 | - $wordsSearch['words'][] = $word; |
|
| 122 | + if (empty($modSettings['search_force_index'])) { |
|
| 123 | + $wordsSearch['words'][] = $word; |
|
| 124 | + } |
|
| 122 | 125 | |
| 123 | 126 | // Excluded phrases don't benefit from being split into subwords. |
| 124 | - if (count($subwords) > 1 && $isExcluded) |
|
| 125 | - return; |
|
| 126 | - else |
|
| 127 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 128 | + return; |
|
| 129 | + } else |
|
| 127 | 130 | { |
| 128 | 131 | foreach ($subwords as $subword) |
| 129 | 132 | { |
| 130 | 133 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 131 | 134 | { |
| 132 | 135 | $wordsSearch['indexed_words'][] = $subword; |
| 133 | - if ($isExcluded) |
|
| 134 | - $wordsExclude[] = $subword; |
|
| 136 | + if ($isExcluded) { |
|
| 137 | + $wordsExclude[] = $subword; |
|
| 138 | + } |
|
| 135 | 139 | } |
| 136 | 140 | } |
| 137 | 141 | } |
@@ -152,8 +156,9 @@ discard block |
||
| 152 | 156 | $query_where = array(); |
| 153 | 157 | $query_params = $search_data['params']; |
| 154 | 158 | |
| 155 | - if ($query_params['id_search']) |
|
| 156 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 159 | + if ($query_params['id_search']) { |
|
| 160 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 161 | + } |
|
| 157 | 162 | |
| 158 | 163 | $count = 0; |
| 159 | 164 | foreach ($words['words'] as $regularWord) |
@@ -162,30 +167,37 @@ discard block |
||
| 162 | 167 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | - if ($query_params['user_query']) |
|
| 166 | - $query_where[] = '{raw:user_query}'; |
|
| 167 | - if ($query_params['board_query']) |
|
| 168 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 170 | + if ($query_params['user_query']) { |
|
| 171 | + $query_where[] = '{raw:user_query}'; |
|
| 172 | + } |
|
| 173 | + if ($query_params['board_query']) { |
|
| 174 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 175 | + } |
|
| 169 | 176 | |
| 170 | - if ($query_params['topic']) |
|
| 171 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 172 | - if ($query_params['min_msg_id']) |
|
| 173 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 174 | - if ($query_params['max_msg_id']) |
|
| 175 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 177 | + if ($query_params['topic']) { |
|
| 178 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 179 | + } |
|
| 180 | + if ($query_params['min_msg_id']) { |
|
| 181 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 182 | + } |
|
| 183 | + if ($query_params['max_msg_id']) { |
|
| 184 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 185 | + } |
|
| 176 | 186 | |
| 177 | 187 | $count = 0; |
| 178 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 179 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 188 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 189 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 180 | 190 | { |
| 181 | 191 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 192 | + } |
|
| 182 | 193 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 183 | 194 | } |
| 184 | 195 | $count = 0; |
| 185 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 186 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 196 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 197 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 187 | 198 | { |
| 188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 200 | + } |
|
| 189 | 201 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 190 | 202 | } |
| 191 | 203 | |
@@ -198,8 +210,7 @@ discard block |
||
| 198 | 210 | { |
| 199 | 211 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
| 200 | 212 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 201 | - } |
|
| 202 | - else |
|
| 213 | + } else |
|
| 203 | 214 | { |
| 204 | 215 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
| 205 | 216 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -235,16 +246,18 @@ discard block |
||
| 235 | 246 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
| 236 | 247 | |
| 237 | 248 | $inserts = array(); |
| 238 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 239 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 249 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 250 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 251 | + } |
|
| 240 | 252 | |
| 241 | - if (!empty($inserts)) |
|
| 242 | - $smcFunc['db_insert']('ignore', |
|
| 253 | + if (!empty($inserts)) { |
|
| 254 | + $smcFunc['db_insert']('ignore', |
|
| 243 | 255 | '{db_prefix}log_search_words', |
| 244 | 256 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 245 | 257 | $inserts, |
| 246 | 258 | array('id_word', 'id_msg') |
| 247 | 259 | ); |
| 260 | + } |
|
| 248 | 261 | } |
| 249 | 262 | |
| 250 | 263 | /** |
@@ -287,8 +300,9 @@ discard block |
||
| 287 | 300 | if (!empty($inserted_words)) |
| 288 | 301 | { |
| 289 | 302 | $inserts = array(); |
| 290 | - foreach ($inserted_words as $word) |
|
| 291 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 303 | + foreach ($inserted_words as $word) { |
|
| 304 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 305 | + } |
|
| 292 | 306 | $smcFunc['db_insert']('insert', |
| 293 | 307 | '{db_prefix}log_search_words', |
| 294 | 308 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -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 | loadLanguage('Drafts'); |
| 21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
| 34 | 35 | |
| 35 | 36 | // can you be, should you be ... here? |
| 36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
| 37 | - return false; |
|
| 37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | // read in what they sent us, if anything |
| 40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
| 46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 47 | 49 | |
| 48 | 50 | // since we were called from the autosave function, send something back |
| 49 | - if (!empty($id_draft)) |
|
| 50 | - XmlDraft($id_draft); |
|
| 51 | + if (!empty($id_draft)) { |
|
| 52 | + XmlDraft($id_draft); |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | return true; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - if (!isset($_POST['message'])) |
|
| 56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 58 | + if (!isset($_POST['message'])) { |
|
| 59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // prepare any data from the form |
| 59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
| 66 | 70 | |
| 67 | 71 | // message and subject still need a bit more work |
| 68 | 72 | preparsecode($draft['body']); |
| 69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 75 | + } |
|
| 71 | 76 | |
| 72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
| 73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
| 148 | 153 | { |
| 149 | 154 | $context['draft_saved'] = true; |
| 150 | 155 | $context['id_draft'] = $id_draft; |
| 156 | + } else { |
|
| 157 | + $post_errors[] = 'draft_not_saved'; |
|
| 151 | 158 | } |
| 152 | - else |
|
| 153 | - $post_errors[] = 'draft_not_saved'; |
|
| 154 | 159 | |
| 155 | 160 | // cleanup |
| 156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
| 180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
| 181 | 186 | |
| 182 | 187 | // PM survey says ... can you stay or must you go |
| 183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
| 184 | - return false; |
|
| 188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | // read in what you sent us |
| 187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
| 193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 194 | 200 | |
| 195 | 201 | // Send something back to the javascript caller |
| 196 | - if (!empty($id_draft)) |
|
| 197 | - XmlDraft($id_draft); |
|
| 202 | + if (!empty($id_draft)) { |
|
| 203 | + XmlDraft($id_draft); |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | return true; |
| 200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
| 204 | 211 | { |
| 205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
| 206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
| 214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
| 215 | + $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
| 207 | 216 | } |
| 208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
| 209 | - $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
| 210 | 217 | |
| 211 | 218 | // prepare the data we got from the form |
| 212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | |
| 216 | 223 | // message and subject always need a bit more work |
| 217 | 224 | preparsecode($draft['body']); |
| 218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | // Modifying an existing PM draft? |
| 222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
| 280 | 288 | { |
| 281 | 289 | $context['draft_saved'] = true; |
| 282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
| 291 | + } else { |
|
| 292 | + $post_errors[] = 'draft_not_saved'; |
|
| 283 | 293 | } |
| 284 | - else |
|
| 285 | - $post_errors[] = 'draft_not_saved'; |
|
| 286 | 294 | } |
| 287 | 295 | |
| 288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
| 315 | 323 | $type = (int) $type; |
| 316 | 324 | |
| 317 | 325 | // nothing to read, nothing to do |
| 318 | - if (empty($id_draft)) |
|
| 319 | - return false; |
|
| 326 | + if (empty($id_draft)) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 320 | 329 | |
| 321 | 330 | // load in this draft from the DB |
| 322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
| 337 | 346 | ); |
| 338 | 347 | |
| 339 | 348 | // no results? |
| 340 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 341 | - return false; |
|
| 349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 350 | + return false; |
|
| 351 | + } |
|
| 342 | 352 | |
| 343 | 353 | // load up the data |
| 344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
| 358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
| 359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
| 360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
| 361 | - } |
|
| 362 | - elseif ($type === 1) |
|
| 371 | + } elseif ($type === 1) |
|
| 363 | 372 | { |
| 364 | 373 | // one of those pm drafts? then set it up like we have an error |
| 365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
| 395 | 404 | global $user_info, $smcFunc; |
| 396 | 405 | |
| 397 | 406 | // Only a single draft. |
| 398 | - if (is_numeric($id_draft)) |
|
| 399 | - $id_draft = array($id_draft); |
|
| 407 | + if (is_numeric($id_draft)) { |
|
| 408 | + $id_draft = array($id_draft); |
|
| 409 | + } |
|
| 400 | 410 | |
| 401 | 411 | // can't delete nothing |
| 402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
| 403 | - return false; |
|
| 412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
| 413 | + return false; |
|
| 414 | + } |
|
| 404 | 415 | |
| 405 | 416 | $smcFunc['db_query']('', ' |
| 406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
| 429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
| 430 | 441 | |
| 431 | 442 | // Permissions |
| 432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
| 433 | - return false; |
|
| 443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 434 | 446 | |
| 435 | 447 | $context['drafts'] = array(); |
| 436 | 448 | |
| 437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
| 438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
| 439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
| 451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 452 | + } |
|
| 440 | 453 | |
| 441 | 454 | // load the drafts this user has available |
| 442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
| 459 | 472 | // add them to the draft array for display |
| 460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 461 | 474 | { |
| 462 | - if (empty($row['subject'])) |
|
| 463 | - $row['subject'] = $txt['no_subject']; |
|
| 475 | + if (empty($row['subject'])) { |
|
| 476 | + $row['subject'] = $txt['no_subject']; |
|
| 477 | + } |
|
| 464 | 478 | |
| 465 | 479 | // Post drafts |
| 466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | } |
| 546 | 560 | |
| 547 | 561 | // Default to 10. |
| 548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 549 | - $_REQUEST['viewscount'] = 10; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = 10; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
| 552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
| 611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 612 | 627 | { |
| 613 | 628 | // Censor.... |
| 614 | - if (empty($row['body'])) |
|
| 615 | - $row['body'] = ''; |
|
| 629 | + if (empty($row['body'])) { |
|
| 630 | + $row['body'] = ''; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 618 | - if (empty($row['subject'])) |
|
| 619 | - $row['subject'] = $txt['no_subject']; |
|
| 634 | + if (empty($row['subject'])) { |
|
| 635 | + $row['subject'] = $txt['no_subject']; |
|
| 636 | + } |
|
| 620 | 637 | |
| 621 | 638 | censorText($row['body']); |
| 622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
| 648 | 665 | $smcFunc['db_free_result']($request); |
| 649 | 666 | |
| 650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
| 651 | - if ($reverse) |
|
| 652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 668 | + if ($reverse) { |
|
| 669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 670 | + } |
|
| 653 | 671 | |
| 654 | 672 | // Menu tab |
| 655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
| 707 | 725 | } |
| 708 | 726 | |
| 709 | 727 | // Default to 10. |
| 710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 711 | - $_REQUEST['viewscount'] = 10; |
|
| 728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 729 | + $_REQUEST['viewscount'] = 10; |
|
| 730 | + } |
|
| 712 | 731 | |
| 713 | 732 | // Get the count of applicable drafts |
| 714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
| 767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 768 | 787 | { |
| 769 | 788 | // Censor.... |
| 770 | - if (empty($row['body'])) |
|
| 771 | - $row['body'] = ''; |
|
| 789 | + if (empty($row['body'])) { |
|
| 790 | + $row['body'] = ''; |
|
| 791 | + } |
|
| 772 | 792 | |
| 773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 774 | - if (empty($row['subject'])) |
|
| 775 | - $row['subject'] = $txt['no_subject']; |
|
| 794 | + if (empty($row['subject'])) { |
|
| 795 | + $row['subject'] = $txt['no_subject']; |
|
| 796 | + } |
|
| 776 | 797 | |
| 777 | 798 | censorText($row['body']); |
| 778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
| 827 | 848 | $smcFunc['db_free_result']($request); |
| 828 | 849 | |
| 829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
| 830 | - if ($reverse) |
|
| 831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 851 | + if ($reverse) { |
|
| 852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 853 | + } |
|
| 832 | 854 | |
| 833 | 855 | // off to the template we go |
| 834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // Start things rolling by getting SMF alive... |
| 18 | 18 | $ssi_guest_access = true; |
| 19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
| 19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
| 20 | 20 | die('Cannot find SSI.php'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
| 23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | // I assume we're even active? |
| 38 | -if (empty($modSettings['paid_enabled'])) |
|
| 39 | +if (empty($modSettings['paid_enabled'])) { |
|
| 39 | 40 | exit; |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // If we have some custom people who find out about problems load them here. |
| 42 | 44 | $notify_users = array(); |
| 43 | 45 | if (!empty($modSettings['paid_email_to'])) |
| 44 | 46 | { |
| 45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
| 46 | - $notify_users[] = array( |
|
| 47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
| 48 | + $notify_users[] = array( |
|
| 47 | 49 | 'email' => $email, |
| 48 | 50 | 'name' => $txt['who_member'], |
| 49 | 51 | 'id' => 0, |
| 50 | 52 | ); |
| 51 | -} |
|
| 53 | + } |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // We need to see whether we can find the correct payment gateway, |
| 54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | } |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | -if (empty($txnType)) |
|
| 71 | +if (empty($txnType)) { |
|
| 69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
| 73 | +} |
|
| 70 | 74 | |
| 71 | 75 | // Get the subscription and member ID amoungst others... |
| 72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
| 76 | 80 | $member_id = (int) $member_id; |
| 77 | 81 | |
| 78 | 82 | // This would be bad... |
| 79 | -if (empty($member_id)) |
|
| 83 | +if (empty($member_id)) { |
|
| 80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
| 85 | +} |
|
| 81 | 86 | |
| 82 | 87 | // Verify the member. |
| 83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
| 89 | 94 | ) |
| 90 | 95 | ); |
| 91 | 96 | // Didn't find them? |
| 92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
| 99 | +} |
|
| 94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
| 95 | 101 | $smcFunc['db_free_result']($request); |
| 96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
| 105 | 111 | ); |
| 106 | 112 | |
| 107 | 113 | // Didn't find it? |
| 108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
| 116 | +} |
|
| 110 | 117 | |
| 111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
| 112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
| 123 | 130 | 'current_member' => $member_id, |
| 124 | 131 | ) |
| 125 | 132 | ); |
| 126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
| 135 | +} |
|
| 128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
| 129 | 137 | $smcFunc['db_free_result']($request); |
| 130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
| 139 | 147 | removeSubscription($subscription_id, $member_id); |
| 140 | 148 | $subscription_act = time(); |
| 141 | 149 | $status = 0; |
| 142 | - } |
|
| 143 | - else |
|
| 150 | + } else |
|
| 144 | 151 | { |
| 145 | 152 | loadSubscriptions(); |
| 146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
| 188 | 195 | if (!$gatewayClass->isSubscription()) |
| 189 | 196 | { |
| 190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
| 191 | - if (empty($real_details)) |
|
| 192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 198 | + if (empty($real_details)) { |
|
| 199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 200 | + } |
|
| 193 | 201 | |
| 194 | 202 | // Now we just try to find anything pending. |
| 195 | 203 | // We don't really care which it is as security happens later. |
| 196 | 204 | foreach ($real_details as $id => $detail) |
| 197 | 205 | { |
| 198 | 206 | unset($real_details[$id]); |
| 199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
| 200 | - $subscription_info['payments_pending']--; |
|
| 207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
| 208 | + $subscription_info['payments_pending']--; |
|
| 209 | + } |
|
| 201 | 210 | break; |
| 202 | 211 | } |
| 203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
| 223 | 232 | // This is a little harder, can we find the right duration? |
| 224 | 233 | foreach ($cost as $duration => $value) |
| 225 | 234 | { |
| 226 | - if ($duration == 'fixed') |
|
| 227 | - continue; |
|
| 228 | - elseif ((float) $value == (float) $total_cost) |
|
| 229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 235 | + if ($duration == 'fixed') { |
|
| 236 | + continue; |
|
| 237 | + } elseif ((float) $value == (float) $total_cost) { |
|
| 238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 239 | + } |
|
| 230 | 240 | } |
| 231 | 241 | |
| 232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
| 235 | 245 | $notify = true; |
| 236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
| 237 | 247 | } |
| 238 | - } |
|
| 239 | - else |
|
| 248 | + } else |
|
| 240 | 249 | { |
| 241 | 250 | $actual_cost = $cost['fixed']; |
| 242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
| 268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
| 269 | 278 | elseif ($gatewayClass->isCancellation()) |
| 270 | 279 | { |
| 271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
| 272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 273 | -} |
|
| 274 | -else |
|
| 280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
| 281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 282 | + } |
|
| 283 | + } else |
|
| 275 | 284 | { |
| 276 | 285 | // Some other "valid" transaction such as: |
| 277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
| 308 | 317 | // Maybe we can try to give them the post data? |
| 309 | 318 | if (!empty($_POST)) |
| 310 | 319 | { |
| 311 | - foreach ($_POST as $key => $val) |
|
| 312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 320 | + foreach ($_POST as $key => $val) { |
|
| 321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 322 | + } |
|
| 313 | 323 | } |
| 314 | 324 | |
| 315 | 325 | // Then just log and die. |
@@ -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 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | 'is_approved' => 1, |
| 45 | 46 | ) |
| 46 | 47 | ); |
| 47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 48 | - return array(); |
|
| 48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 49 | + return array(); |
|
| 50 | + } |
|
| 49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
| 50 | 52 | $smcFunc['db_free_result']($request); |
| 51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | censorText($row['body']); |
| 55 | 57 | |
| 56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
| 57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | // Send the data. |
| 61 | 64 | return array( |
@@ -83,15 +86,17 @@ discard block |
||
| 83 | 86 | |
| 84 | 87 | $context['is_redirect'] = false; |
| 85 | 88 | |
| 86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
| 87 | - $_REQUEST['start'] = 95; |
|
| 89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
| 90 | + $_REQUEST['start'] = 95; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | $query_parameters = array(); |
| 90 | 94 | if (!empty($_REQUEST['c']) && empty($board)) |
| 91 | 95 | { |
| 92 | 96 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 93 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 94 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 97 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 98 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 99 | + } |
|
| 95 | 100 | |
| 96 | 101 | if (count($_REQUEST['c']) == 1) |
| 97 | 102 | { |
@@ -107,8 +112,9 @@ discard block |
||
| 107 | 112 | list ($name) = $smcFunc['db_fetch_row']($request); |
| 108 | 113 | $smcFunc['db_free_result']($request); |
| 109 | 114 | |
| 110 | - if (empty($name)) |
|
| 111 | - fatal_lang_error('no_access', false); |
|
| 115 | + if (empty($name)) { |
|
| 116 | + fatal_lang_error('no_access', false); |
|
| 117 | + } |
|
| 112 | 118 | |
| 113 | 119 | $context['linktree'][] = array( |
| 114 | 120 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -140,8 +146,9 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | $smcFunc['db_free_result']($request); |
| 142 | 148 | |
| 143 | - if (empty($boards)) |
|
| 144 | - fatal_lang_error('error_no_boards_selected'); |
|
| 149 | + if (empty($boards)) { |
|
| 150 | + fatal_lang_error('error_no_boards_selected'); |
|
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 147 | 154 | $query_parameters['boards'] = $boards; |
@@ -155,12 +162,12 @@ discard block |
||
| 155 | 162 | } |
| 156 | 163 | |
| 157 | 164 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
| 158 | - } |
|
| 159 | - elseif (!empty($_REQUEST['boards'])) |
|
| 165 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 160 | 166 | { |
| 161 | 167 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 162 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 163 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 168 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 169 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | 172 | $request = $smcFunc['db_query']('', ' |
| 166 | 173 | SELECT b.id_board, b.num_posts |
@@ -184,8 +191,9 @@ discard block |
||
| 184 | 191 | } |
| 185 | 192 | $smcFunc['db_free_result']($request); |
| 186 | 193 | |
| 187 | - if (empty($boards)) |
|
| 188 | - fatal_lang_error('error_no_boards_selected'); |
|
| 194 | + if (empty($boards)) { |
|
| 195 | + fatal_lang_error('error_no_boards_selected'); |
|
| 196 | + } |
|
| 189 | 197 | |
| 190 | 198 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 191 | 199 | $query_parameters['boards'] = $boards; |
@@ -199,8 +207,7 @@ discard block |
||
| 199 | 207 | } |
| 200 | 208 | |
| 201 | 209 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
| 202 | - } |
|
| 203 | - elseif (!empty($board)) |
|
| 210 | + } elseif (!empty($board)) |
|
| 204 | 211 | { |
| 205 | 212 | $request = $smcFunc['db_query']('', ' |
| 206 | 213 | SELECT num_posts, redirect |
@@ -233,8 +240,7 @@ discard block |
||
| 233 | 240 | } |
| 234 | 241 | |
| 235 | 242 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
| 236 | - } |
|
| 237 | - else |
|
| 243 | + } else |
|
| 238 | 244 | { |
| 239 | 245 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 240 | 246 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -269,8 +275,9 @@ discard block |
||
| 269 | 275 | ); |
| 270 | 276 | |
| 271 | 277 | // If you selected a redirection board, don't try getting posts for it... |
| 272 | - if ($context['is_redirect']) |
|
| 273 | - $messages = 0; |
|
| 278 | + if ($context['is_redirect']) { |
|
| 279 | + $messages = 0; |
|
| 280 | + } |
|
| 274 | 281 | |
| 275 | 282 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
| 276 | 283 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -301,16 +308,18 @@ discard block |
||
| 301 | 308 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
| 302 | 309 | $cache_results = true; |
| 303 | 310 | unset($query_parameters['max_id_msg']); |
| 311 | + } else { |
|
| 312 | + $done = true; |
|
| 304 | 313 | } |
| 305 | - else |
|
| 306 | - $done = true; |
|
| 307 | 314 | } |
| 308 | 315 | $messages = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $messages[] = $row['id_msg']; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $messages[] = $row['id_msg']; |
|
| 318 | + } |
|
| 311 | 319 | $smcFunc['db_free_result']($request); |
| 312 | - if (!empty($cache_results)) |
|
| 313 | - cache_put_data($key, $messages, 120); |
|
| 320 | + if (!empty($cache_results)) { |
|
| 321 | + cache_put_data($key, $messages, 120); |
|
| 322 | + } |
|
| 314 | 323 | } |
| 315 | 324 | |
| 316 | 325 | // Nothing here... Or at least, nothing you can see... |
@@ -397,8 +406,9 @@ discard block |
||
| 397 | 406 | 'css_class' => 'windowbg', |
| 398 | 407 | ); |
| 399 | 408 | |
| 400 | - if ($user_info['id'] == $row['id_first_member']) |
|
| 401 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 409 | + if ($user_info['id'] == $row['id_first_member']) { |
|
| 410 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 411 | + } |
|
| 402 | 412 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
| 403 | 413 | } |
| 404 | 414 | $smcFunc['db_free_result']($request); |
@@ -424,20 +434,23 @@ discard block |
||
| 424 | 434 | $boards = boardsAllowedTo($permission); |
| 425 | 435 | |
| 426 | 436 | // If 0 is the only thing in the array, they can do it everywhere! |
| 427 | - if (!empty($boards) && $boards[0] == 0) |
|
| 428 | - $boards = array_keys($board_ids[$type]); |
|
| 437 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 438 | + $boards = array_keys($board_ids[$type]); |
|
| 439 | + } |
|
| 429 | 440 | |
| 430 | 441 | // Go through the boards, and look for posts they can do this on. |
| 431 | 442 | foreach ($boards as $board_id) |
| 432 | 443 | { |
| 433 | 444 | // Hmm, they have permission, but there are no topics from that board on this page. |
| 434 | - if (!isset($board_ids[$type][$board_id])) |
|
| 435 | - continue; |
|
| 445 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 446 | + continue; |
|
| 447 | + } |
|
| 436 | 448 | |
| 437 | 449 | // Okay, looks like they can do it for these posts. |
| 438 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 439 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 450 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 451 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 440 | 452 | $context['posts'][$counter][$allowed] = true; |
| 453 | + } |
|
| 441 | 454 | } |
| 442 | 455 | } |
| 443 | 456 | } |
@@ -480,17 +493,19 @@ discard block |
||
| 480 | 493 | $context['showing_all_topics'] = isset($_GET['all']); |
| 481 | 494 | $context['start'] = (int) $_REQUEST['start']; |
| 482 | 495 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
| 483 | - if ($_REQUEST['action'] == 'unread') |
|
| 484 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 485 | - else |
|
| 486 | - $context['page_title'] = $txt['unread_replies']; |
|
| 496 | + if ($_REQUEST['action'] == 'unread') { |
|
| 497 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 498 | + } else { |
|
| 499 | + $context['page_title'] = $txt['unread_replies']; |
|
| 500 | + } |
|
| 487 | 501 | |
| 488 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
| 489 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 490 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
| 491 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 492 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
| 493 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
| 502 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
| 503 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 504 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
| 505 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 506 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
| 507 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
| 508 | + } |
|
| 494 | 509 | |
| 495 | 510 | // Parameters for the main query. |
| 496 | 511 | $query_parameters = array(); |
@@ -503,12 +518,14 @@ discard block |
||
| 503 | 518 | if (!empty($_REQUEST['boards'])) |
| 504 | 519 | { |
| 505 | 520 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 506 | - foreach ($_REQUEST['boards'] as $b) |
|
| 507 | - $boards[] = (int) $b; |
|
| 521 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 522 | + $boards[] = (int) $b; |
|
| 523 | + } |
|
| 508 | 524 | } |
| 509 | 525 | |
| 510 | - if (!empty($board)) |
|
| 511 | - $boards[] = (int) $board; |
|
| 526 | + if (!empty($board)) { |
|
| 527 | + $boards[] = (int) $board; |
|
| 528 | + } |
|
| 512 | 529 | |
| 513 | 530 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
| 514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -525,30 +542,31 @@ discard block |
||
| 525 | 542 | ) |
| 526 | 543 | ); |
| 527 | 544 | |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - if (in_array($row['id_parent'], $boards)) |
|
| 545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 546 | + if (in_array($row['id_parent'], $boards)) |
|
| 530 | 547 | $boards[] = $row['id_board']; |
| 548 | + } |
|
| 531 | 549 | |
| 532 | 550 | $smcFunc['db_free_result']($request); |
| 533 | 551 | |
| 534 | - if (empty($boards)) |
|
| 535 | - fatal_lang_error('error_no_boards_selected'); |
|
| 552 | + if (empty($boards)) { |
|
| 553 | + fatal_lang_error('error_no_boards_selected'); |
|
| 554 | + } |
|
| 536 | 555 | |
| 537 | 556 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 538 | 557 | $query_parameters['boards'] = $boards; |
| 539 | 558 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
| 540 | - } |
|
| 541 | - elseif (!empty($board)) |
|
| 559 | + } elseif (!empty($board)) |
|
| 542 | 560 | { |
| 543 | 561 | $query_this_board = 'id_board = {int:board}'; |
| 544 | 562 | $query_parameters['board'] = $board; |
| 545 | 563 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
| 546 | - } |
|
| 547 | - elseif (!empty($_REQUEST['boards'])) |
|
| 564 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 548 | 565 | { |
| 549 | 566 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 550 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 551 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 567 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 568 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 569 | + } |
|
| 552 | 570 | |
| 553 | 571 | $request = $smcFunc['db_query']('', ' |
| 554 | 572 | SELECT b.id_board |
@@ -560,22 +578,24 @@ discard block |
||
| 560 | 578 | ) |
| 561 | 579 | ); |
| 562 | 580 | $boards = array(); |
| 563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 564 | - $boards[] = $row['id_board']; |
|
| 581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 582 | + $boards[] = $row['id_board']; |
|
| 583 | + } |
|
| 565 | 584 | $smcFunc['db_free_result']($request); |
| 566 | 585 | |
| 567 | - if (empty($boards)) |
|
| 568 | - fatal_lang_error('error_no_boards_selected'); |
|
| 586 | + if (empty($boards)) { |
|
| 587 | + fatal_lang_error('error_no_boards_selected'); |
|
| 588 | + } |
|
| 569 | 589 | |
| 570 | 590 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 571 | 591 | $query_parameters['boards'] = $boards; |
| 572 | 592 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
| 573 | - } |
|
| 574 | - elseif (!empty($_REQUEST['c'])) |
|
| 593 | + } elseif (!empty($_REQUEST['c'])) |
|
| 575 | 594 | { |
| 576 | 595 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 577 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 578 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 596 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 597 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 598 | + } |
|
| 579 | 599 | |
| 580 | 600 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 581 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -588,18 +608,19 @@ discard block |
||
| 588 | 608 | ) |
| 589 | 609 | ); |
| 590 | 610 | $boards = array(); |
| 591 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 592 | - $boards[] = $row['id_board']; |
|
| 611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 612 | + $boards[] = $row['id_board']; |
|
| 613 | + } |
|
| 593 | 614 | $smcFunc['db_free_result']($request); |
| 594 | 615 | |
| 595 | - if (empty($boards)) |
|
| 596 | - fatal_lang_error('error_no_boards_selected'); |
|
| 616 | + if (empty($boards)) { |
|
| 617 | + fatal_lang_error('error_no_boards_selected'); |
|
| 618 | + } |
|
| 597 | 619 | |
| 598 | 620 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 599 | 621 | $query_parameters['boards'] = $boards; |
| 600 | 622 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
| 601 | - } |
|
| 602 | - else |
|
| 623 | + } else |
|
| 603 | 624 | { |
| 604 | 625 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 605 | 626 | // Don't bother to show deleted posts! |
@@ -613,12 +634,14 @@ discard block |
||
| 613 | 634 | ) |
| 614 | 635 | ); |
| 615 | 636 | $boards = array(); |
| 616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 617 | - $boards[] = $row['id_board']; |
|
| 637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 638 | + $boards[] = $row['id_board']; |
|
| 639 | + } |
|
| 618 | 640 | $smcFunc['db_free_result']($request); |
| 619 | 641 | |
| 620 | - if (empty($boards)) |
|
| 621 | - fatal_lang_error('error_no_boards_available', false); |
|
| 642 | + if (empty($boards)) { |
|
| 643 | + fatal_lang_error('error_no_boards_available', false); |
|
| 644 | + } |
|
| 622 | 645 | |
| 623 | 646 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 624 | 647 | $query_parameters['boards'] = $boards; |
@@ -680,13 +703,14 @@ discard block |
||
| 680 | 703 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
| 681 | 704 | ); |
| 682 | 705 | |
| 683 | - if ($context['showing_all_topics']) |
|
| 684 | - $context['linktree'][] = array( |
|
| 706 | + if ($context['showing_all_topics']) { |
|
| 707 | + $context['linktree'][] = array( |
|
| 685 | 708 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
| 686 | 709 | 'name' => $txt['unread_topics_all'] |
| 687 | 710 | ); |
| 688 | - else |
|
| 689 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 711 | + } else { |
|
| 712 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 713 | + } |
|
| 690 | 714 | |
| 691 | 715 | loadTemplate('Recent'); |
| 692 | 716 | loadTemplate('MessageIndex'); |
@@ -694,8 +718,9 @@ discard block |
||
| 694 | 718 | |
| 695 | 719 | // Setup the default topic icons... for checking they exist and the like ;) |
| 696 | 720 | $context['icon_sources'] = array(); |
| 697 | - foreach ($context['stable_icons'] as $icon) |
|
| 698 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 721 | + foreach ($context['stable_icons'] as $icon) { |
|
| 722 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 723 | + } |
|
| 699 | 724 | |
| 700 | 725 | $is_topics = $_REQUEST['action'] == 'unread'; |
| 701 | 726 | |
@@ -725,8 +750,7 @@ discard block |
||
| 725 | 750 | ); |
| 726 | 751 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
| 727 | 752 | $smcFunc['db_free_result']($request); |
| 728 | - } |
|
| 729 | - else |
|
| 753 | + } else |
|
| 730 | 754 | { |
| 731 | 755 | $request = $smcFunc['db_query']('', ' |
| 732 | 756 | SELECT MIN(lmr.id_msg) |
@@ -742,14 +766,14 @@ discard block |
||
| 742 | 766 | } |
| 743 | 767 | |
| 744 | 768 | // This is needed in case of topics marked unread. |
| 745 | - if (empty($earliest_msg)) |
|
| 746 | - $earliest_msg = 0; |
|
| 747 | - else |
|
| 769 | + if (empty($earliest_msg)) { |
|
| 770 | + $earliest_msg = 0; |
|
| 771 | + } else |
|
| 748 | 772 | { |
| 749 | 773 | // Using caching, when possible, to ignore the below slow query. |
| 750 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
| 751 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 752 | - else |
|
| 774 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
| 775 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 776 | + } else |
|
| 753 | 777 | { |
| 754 | 778 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
| 755 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -764,8 +788,9 @@ discard block |
||
| 764 | 788 | $smcFunc['db_free_result']($request); |
| 765 | 789 | |
| 766 | 790 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
| 767 | - if ($earliest_msg2 == 0) |
|
| 768 | - $earliest_msg2 = -1; |
|
| 791 | + if ($earliest_msg2 == 0) { |
|
| 792 | + $earliest_msg2 = -1; |
|
| 793 | + } |
|
| 769 | 794 | |
| 770 | 795 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
| 771 | 796 | } |
@@ -803,9 +828,9 @@ discard block |
||
| 803 | 828 | 'db_error_skip' => true, |
| 804 | 829 | )) |
| 805 | 830 | ) !== false; |
| 831 | + } else { |
|
| 832 | + $have_temp_table = false; |
|
| 806 | 833 | } |
| 807 | - else |
|
| 808 | - $have_temp_table = false; |
|
| 809 | 834 | |
| 810 | 835 | if ($context['showing_all_topics'] && $have_temp_table) |
| 811 | 836 | { |
@@ -851,14 +876,15 @@ discard block |
||
| 851 | 876 | |
| 852 | 877 | $context['topics'] = array(); |
| 853 | 878 | $context['no_topic_listing'] = true; |
| 854 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
| 855 | - $context['querystring_board_limits'] = ''; |
|
| 856 | - else |
|
| 857 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 879 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
| 880 | + $context['querystring_board_limits'] = ''; |
|
| 881 | + } else { |
|
| 882 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 883 | + } |
|
| 858 | 884 | return; |
| 885 | + } else { |
|
| 886 | + $min_message = (int) $min_message; |
|
| 859 | 887 | } |
| 860 | - else |
|
| 861 | - $min_message = (int) $min_message; |
|
| 862 | 888 | |
| 863 | 889 | $request = $smcFunc['db_query']('substring', ' |
| 864 | 890 | SELECT ' . $select_clause . ' |
@@ -887,8 +913,7 @@ discard block |
||
| 887 | 913 | 'limit' => $context['topics_per_page'], |
| 888 | 914 | )) |
| 889 | 915 | ); |
| 890 | - } |
|
| 891 | - elseif ($is_topics) |
|
| 916 | + } elseif ($is_topics) |
|
| 892 | 917 | { |
| 893 | 918 | $request = $smcFunc['db_query']('', ' |
| 894 | 919 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -939,14 +964,15 @@ discard block |
||
| 939 | 964 | |
| 940 | 965 | $context['topics'] = array(); |
| 941 | 966 | $context['no_topic_listing'] = true; |
| 942 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 943 | - $context['querystring_board_limits'] = ''; |
|
| 944 | - else |
|
| 945 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 967 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 968 | + $context['querystring_board_limits'] = ''; |
|
| 969 | + } else { |
|
| 970 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 971 | + } |
|
| 946 | 972 | return; |
| 973 | + } else { |
|
| 974 | + $min_message = (int) $min_message; |
|
| 947 | 975 | } |
| 948 | - else |
|
| 949 | - $min_message = (int) $min_message; |
|
| 950 | 976 | |
| 951 | 977 | $request = $smcFunc['db_query']('substring', ' |
| 952 | 978 | SELECT ' . $select_clause . ' |
@@ -976,8 +1002,7 @@ discard block |
||
| 976 | 1002 | 'limit' => $context['topics_per_page'], |
| 977 | 1003 | )) |
| 978 | 1004 | ); |
| 979 | - } |
|
| 980 | - else |
|
| 1005 | + } else |
|
| 981 | 1006 | { |
| 982 | 1007 | if ($modSettings['totalMessages'] > 100000) |
| 983 | 1008 | { |
@@ -1029,8 +1054,8 @@ discard block |
||
| 1029 | 1054 | ) !== false; |
| 1030 | 1055 | |
| 1031 | 1056 | // If that worked, create a sample of the log_topics table too. |
| 1032 | - if ($have_temp_table) |
|
| 1033 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1057 | + if ($have_temp_table) { |
|
| 1058 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1034 | 1059 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
| 1035 | 1060 | PRIMARY KEY (id_topic) |
| 1036 | 1061 | ) |
@@ -1043,6 +1068,7 @@ discard block |
||
| 1043 | 1068 | 'db_error_skip' => true, |
| 1044 | 1069 | ) |
| 1045 | 1070 | ) !== false; |
| 1071 | + } |
|
| 1046 | 1072 | } |
| 1047 | 1073 | |
| 1048 | 1074 | if (!empty($have_temp_table)) |
@@ -1058,8 +1084,7 @@ discard block |
||
| 1058 | 1084 | ); |
| 1059 | 1085 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
| 1060 | 1086 | $smcFunc['db_free_result']($request); |
| 1061 | - } |
|
| 1062 | - else |
|
| 1087 | + } else |
|
| 1063 | 1088 | { |
| 1064 | 1089 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
| 1065 | 1090 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1100,15 +1125,16 @@ discard block |
||
| 1100 | 1125 | { |
| 1101 | 1126 | $context['topics'] = array(); |
| 1102 | 1127 | $context['no_topic_listing'] = true; |
| 1103 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1104 | - $context['querystring_board_limits'] = ''; |
|
| 1105 | - else |
|
| 1106 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1128 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1129 | + $context['querystring_board_limits'] = ''; |
|
| 1130 | + } else { |
|
| 1131 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1132 | + } |
|
| 1107 | 1133 | return; |
| 1108 | 1134 | } |
| 1109 | 1135 | |
| 1110 | - if (!empty($have_temp_table)) |
|
| 1111 | - $request = $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($have_temp_table)) { |
|
| 1137 | + $request = $smcFunc['db_query']('', ' |
|
| 1112 | 1138 | SELECT t.id_topic |
| 1113 | 1139 | FROM {db_prefix}topics_posted_in AS t |
| 1114 | 1140 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1122,8 +1148,8 @@ discard block |
||
| 1122 | 1148 | 'limit' => $context['topics_per_page'], |
| 1123 | 1149 | )) |
| 1124 | 1150 | ); |
| 1125 | - else |
|
| 1126 | - $request = $smcFunc['db_query']('', ' |
|
| 1151 | + } else { |
|
| 1152 | + $request = $smcFunc['db_query']('', ' |
|
| 1127 | 1153 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
| 1128 | 1154 | FROM {db_prefix}topics AS t |
| 1129 | 1155 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1147,10 +1173,12 @@ discard block |
||
| 1147 | 1173 | 'sort' => $_REQUEST['sort'], |
| 1148 | 1174 | )) |
| 1149 | 1175 | ); |
| 1176 | + } |
|
| 1150 | 1177 | |
| 1151 | 1178 | $topics = array(); |
| 1152 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1153 | - $topics[] = $row['id_topic']; |
|
| 1179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1180 | + $topics[] = $row['id_topic']; |
|
| 1181 | + } |
|
| 1154 | 1182 | $smcFunc['db_free_result']($request); |
| 1155 | 1183 | |
| 1156 | 1184 | // Sanity... where have you gone? |
@@ -1158,10 +1186,11 @@ discard block |
||
| 1158 | 1186 | { |
| 1159 | 1187 | $context['topics'] = array(); |
| 1160 | 1188 | $context['no_topic_listing'] = true; |
| 1161 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1162 | - $context['querystring_board_limits'] = ''; |
|
| 1163 | - else |
|
| 1164 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1189 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1190 | + $context['querystring_board_limits'] = ''; |
|
| 1191 | + } else { |
|
| 1192 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1193 | + } |
|
| 1165 | 1194 | return; |
| 1166 | 1195 | } |
| 1167 | 1196 | |
@@ -1195,8 +1224,9 @@ discard block |
||
| 1195 | 1224 | |
| 1196 | 1225 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1197 | 1226 | { |
| 1198 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 1199 | - continue; |
|
| 1227 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 1228 | + continue; |
|
| 1229 | + } |
|
| 1200 | 1230 | |
| 1201 | 1231 | $topic_ids[] = $row['id_topic']; |
| 1202 | 1232 | |
@@ -1204,11 +1234,13 @@ discard block |
||
| 1204 | 1234 | { |
| 1205 | 1235 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
| 1206 | 1236 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 1207 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
| 1208 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1237 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
| 1238 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1239 | + } |
|
| 1209 | 1240 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 1210 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
| 1211 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1241 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
| 1242 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1243 | + } |
|
| 1212 | 1244 | |
| 1213 | 1245 | // Censor the subject and message preview. |
| 1214 | 1246 | censorText($row['first_subject']); |
@@ -1219,23 +1251,22 @@ discard block |
||
| 1219 | 1251 | { |
| 1220 | 1252 | $row['last_subject'] = $row['first_subject']; |
| 1221 | 1253 | $row['last_body'] = $row['first_body']; |
| 1222 | - } |
|
| 1223 | - else |
|
| 1254 | + } else |
|
| 1224 | 1255 | { |
| 1225 | 1256 | censorText($row['last_subject']); |
| 1226 | 1257 | censorText($row['last_body']); |
| 1227 | 1258 | } |
| 1228 | - } |
|
| 1229 | - else |
|
| 1259 | + } else |
|
| 1230 | 1260 | { |
| 1231 | 1261 | $row['first_body'] = ''; |
| 1232 | 1262 | $row['last_body'] = ''; |
| 1233 | 1263 | censorText($row['first_subject']); |
| 1234 | 1264 | |
| 1235 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 1236 | - $row['last_subject'] = $row['first_subject']; |
|
| 1237 | - else |
|
| 1238 | - censorText($row['last_subject']); |
|
| 1265 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 1266 | + $row['last_subject'] = $row['first_subject']; |
|
| 1267 | + } else { |
|
| 1268 | + censorText($row['last_subject']); |
|
| 1269 | + } |
|
| 1239 | 1270 | } |
| 1240 | 1271 | |
| 1241 | 1272 | // Decide how many pages the topic should have. |
@@ -1247,22 +1278,24 @@ discard block |
||
| 1247 | 1278 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
| 1248 | 1279 | |
| 1249 | 1280 | // If we can use all, show all. |
| 1250 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
| 1251 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1281 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
| 1282 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1283 | + } |
|
| 1284 | + } else { |
|
| 1285 | + $pages = ''; |
|
| 1252 | 1286 | } |
| 1253 | 1287 | |
| 1254 | - else |
|
| 1255 | - $pages = ''; |
|
| 1256 | - |
|
| 1257 | 1288 | // We need to check the topic icons exist... you can never be too sure! |
| 1258 | 1289 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1259 | 1290 | { |
| 1260 | 1291 | // First icon first... as you'd expect. |
| 1261 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 1262 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1292 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 1293 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1294 | + } |
|
| 1263 | 1295 | // Last icon... last... duh. |
| 1264 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 1265 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1296 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 1297 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1298 | + } |
|
| 1266 | 1299 | } |
| 1267 | 1300 | |
| 1268 | 1301 | // Force the recycling icon if appropriate |
@@ -1276,12 +1309,14 @@ discard block |
||
| 1276 | 1309 | $colorClass = 'windowbg'; |
| 1277 | 1310 | |
| 1278 | 1311 | // Sticky topics should get a different color, too. |
| 1279 | - if ($row['is_sticky']) |
|
| 1280 | - $colorClass .= ' sticky'; |
|
| 1312 | + if ($row['is_sticky']) { |
|
| 1313 | + $colorClass .= ' sticky'; |
|
| 1314 | + } |
|
| 1281 | 1315 | |
| 1282 | 1316 | // Locked topics get special treatment as well. |
| 1283 | - if ($row['locked']) |
|
| 1284 | - $colorClass .= ' locked'; |
|
| 1317 | + if ($row['locked']) { |
|
| 1318 | + $colorClass .= ' locked'; |
|
| 1319 | + } |
|
| 1285 | 1320 | |
| 1286 | 1321 | // And build the array. |
| 1287 | 1322 | $context['topics'][$row['id_topic']] = array( |
@@ -1378,8 +1413,9 @@ discard block |
||
| 1378 | 1413 | ); |
| 1379 | 1414 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1380 | 1415 | { |
| 1381 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
| 1382 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1416 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
| 1417 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1418 | + } |
|
| 1383 | 1419 | } |
| 1384 | 1420 | $smcFunc['db_free_result']($result); |
| 1385 | 1421 | } |
@@ -1394,28 +1430,30 @@ discard block |
||
| 1394 | 1430 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1395 | 1431 | ); |
| 1396 | 1432 | |
| 1397 | - if ($context['showCheckboxes']) |
|
| 1398 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1433 | + if ($context['showCheckboxes']) { |
|
| 1434 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1399 | 1435 | 'text' => 'quick_mod_markread', |
| 1400 | 1436 | 'image' => 'markselectedread.png', |
| 1401 | 1437 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1402 | 1438 | ); |
| 1439 | + } |
|
| 1403 | 1440 | |
| 1404 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
| 1405 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1406 | - } |
|
| 1407 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1441 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
| 1442 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1443 | + } |
|
| 1444 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1408 | 1445 | { |
| 1409 | 1446 | $context['recent_buttons'] = array( |
| 1410 | 1447 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1411 | 1448 | ); |
| 1412 | 1449 | |
| 1413 | - if ($context['showCheckboxes']) |
|
| 1414 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1450 | + if ($context['showCheckboxes']) { |
|
| 1451 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1415 | 1452 | 'text' => 'quick_mod_markread', |
| 1416 | 1453 | 'image' => 'markselectedread.png', |
| 1417 | 1454 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1418 | 1455 | ); |
| 1456 | + } |
|
| 1419 | 1457 | } |
| 1420 | 1458 | |
| 1421 | 1459 | // Allow mods to add additional buttons here |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcached'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -53,9 +55,9 @@ discard block |
||
| 53 | 55 | $currentServers = $this->memcached->getServerList(); |
| 54 | 56 | foreach ($servers as $server) |
| 55 | 57 | { |
| 56 | - if (strpos($server,'/') !== false) |
|
| 57 | - $tempServer = array($server, 0); |
|
| 58 | - else |
|
| 58 | + if (strpos($server,'/') !== false) { |
|
| 59 | + $tempServer = array($server, 0); |
|
| 60 | + } else |
|
| 59 | 61 | { |
| 60 | 62 | $server = explode(':', $server); |
| 61 | 63 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | // Found it? |
| 76 | - if (empty($foundServer)) |
|
| 77 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 78 | + if (empty($foundServer)) { |
|
| 79 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | // Best guess is this worked. |
@@ -91,8 +94,9 @@ discard block |
||
| 91 | 94 | $value = $this->memcached->get($key); |
| 92 | 95 | |
| 93 | 96 | // $value should return either data or false (from failure, key not found or empty array). |
| 94 | - if ($value === false) |
|
| 95 | - return null; |
|
| 97 | + if ($value === false) { |
|
| 98 | + return null; |
|
| 99 | + } |
|
| 96 | 100 | return $value; |
| 97 | 101 | } |
| 98 | 102 | |
@@ -135,8 +139,9 @@ discard block |
||
| 135 | 139 | $config_vars[] = $txt['cache_memcache_settings']; |
| 136 | 140 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 137 | 141 | |
| 138 | - if (!isset($context['settings_post_javascript'])) |
|
| 139 | - $context['settings_post_javascript'] = ''; |
|
| 142 | + if (!isset($context['settings_post_javascript'])) { |
|
| 143 | + $context['settings_post_javascript'] = ''; |
|
| 144 | + } |
|
| 140 | 145 | |
| 141 | 146 | $context['settings_post_javascript'] .= ' |
| 142 | 147 | $("#cache_accelerator").change(function (e) { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -32,16 +32,18 @@ discard block |
||
| 32 | 32 | ob_start(); |
| 33 | 33 | |
| 34 | 34 | // Do some cleaning, just in case. |
| 35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 36 | 36 | if (isset($GLOBALS[$variable])) |
| 37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 38 | +} |
|
| 38 | 39 | |
| 39 | 40 | // Load the settings... |
| 40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 41 | 42 | |
| 42 | 43 | // Make absolutely sure the cache directory is defined. |
| 43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 44 | 45 | $cachedir = $boarddir . '/cache'; |
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | // Without those we can't go anywhere |
| 47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | require_once($sourcedir . '/Load.php'); |
| 52 | 54 | |
| 53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 54 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 55 | 57 | display_maintenance_message(); |
| 58 | +} |
|
| 56 | 59 | |
| 57 | 60 | // Create a variable to store some SMF specific functions in. |
| 58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | cleanRequest(); |
| 68 | 71 | |
| 69 | 72 | // Seed the random generator. |
| 70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 71 | 74 | smf_seed_generator(); |
| 75 | +} |
|
| 72 | 76 | |
| 73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
| 88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 89 | 93 | { |
| 90 | 94 | // If zlib is being used, turn off output compression. |
| 91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 93 | - else |
|
| 95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 97 | + } else |
|
| 94 | 98 | { |
| 95 | 99 | ob_end_clean(); |
| 96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
| 182 | 186 | loadPermissions(); |
| 183 | 187 | |
| 184 | 188 | // Attachments don't require the entire theme to be loaded. |
| 185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 186 | - detectBrowser(); |
|
| 189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 190 | + detectBrowser(); |
|
| 191 | + } |
|
| 187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 188 | - else |
|
| 189 | - loadTheme(); |
|
| 193 | + else { |
|
| 194 | + loadTheme(); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | // Check if the user should be disallowed access. |
| 192 | 198 | is_not_banned(); |
| 193 | 199 | |
| 194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 196 | - fatal_lang_error('not_a_topic', false); |
|
| 201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 202 | + fatal_lang_error('not_a_topic', false); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | writeLog(); |
| 205 | 212 | |
| 206 | 213 | // Track forum statistics and hits...? |
| 207 | - if (!empty($modSettings['hitStats'])) |
|
| 208 | - trackStats(array('hits' => '+')); |
|
| 214 | + if (!empty($modSettings['hitStats'])) { |
|
| 215 | + trackStats(array('hits' => '+')); |
|
| 216 | + } |
|
| 209 | 217 | } |
| 210 | 218 | unset($no_stat_actions); |
| 211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
| 219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 220 | 228 | } |
| 221 | 229 | // Don't even try it, sonny. |
| 222 | - else |
|
| 223 | - return 'InMaintenance'; |
|
| 230 | + else { |
|
| 231 | + return 'InMaintenance'; |
|
| 232 | + } |
|
| 224 | 233 | } |
| 225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
| 226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 227 | - return 'KickGuest'; |
|
| 228 | - elseif (empty($_REQUEST['action'])) |
|
| 235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 236 | + return 'KickGuest'; |
|
| 237 | + } elseif (empty($_REQUEST['action'])) |
|
| 229 | 238 | { |
| 230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
| 239 | 248 | |
| 240 | 249 | $call = call_helper($defaultAction, true); |
| 241 | 250 | |
| 242 | - if (!empty($call)) |
|
| 243 | - return $call; |
|
| 251 | + if (!empty($call)) { |
|
| 252 | + return $call; |
|
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | |
| 371 | 381 | $call = call_helper($fallbackAction, true); |
| 372 | 382 | |
| 373 | - if (!empty($call)) |
|
| 374 | - return $call; |
|
| 383 | + if (!empty($call)) { |
|
| 384 | + return $call; |
|
| 385 | + } |
|
| 375 | 386 | } |
| 376 | 387 | |
| 377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // Otherwise, it was set - so let's go to that action. |
| 385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
| 386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
| 397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 398 | + } |
|
| 387 | 399 | |
| 388 | 400 | // Do the right thing. |
| 389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -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 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
| 64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
| 65 | 66 | |
| 66 | 67 | // Allow extend *any* menu with a single hook |
| 67 | - if (!empty($menu_context['current_action'])) |
|
| 68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
| 68 | + if (!empty($menu_context['current_action'])) { |
|
| 69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
| 70 | + } |
|
| 69 | 71 | |
| 70 | 72 | // What is the current area selected? |
| 71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
| 72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
| 73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
| 74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
| 75 | + } |
|
| 73 | 76 | |
| 74 | 77 | // Build a list of additional parameters that should go in the URL. |
| 75 | 78 | $menu_context['extra_parameters'] = ''; |
| 76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
| 77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
| 79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
| 80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
| 78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
| 81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
| 82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
| 86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | $include_data = array(); |
| 85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
| 87 | 92 | foreach ($menuData as $section_id => $section) |
| 88 | 93 | { |
| 89 | 94 | // Is this enabled - or has as permission check - which fails? |
| 90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
| 91 | - continue; |
|
| 95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | 99 | // Now we cycle through the sections to pick the right area. |
| 94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,59 +116,57 @@ discard block |
||
| 110 | 116 | if (empty($area['hidden'])) |
| 111 | 117 | { |
| 112 | 118 | // First time this section? |
| 113 | - if (!isset($menu_context['sections'][$section_id])) |
|
| 114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
| 119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
| 120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
| 121 | + } |
|
| 115 | 122 | |
| 116 | 123 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
| 117 | 124 | // We'll need the ID as well... |
| 118 | 125 | $menu_context['sections'][$section_id]['id'] = $section_id; |
| 119 | 126 | // Does it have a custom URL? |
| 120 | - if (isset($area['custom_url'])) |
|
| 121 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
| 127 | + if (isset($area['custom_url'])) { |
|
| 128 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
| 129 | + } |
|
| 122 | 130 | |
| 123 | 131 | // Does this area have its own icon? |
| 124 | 132 | if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
| 125 | 133 | { |
| 126 | 134 | $menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
| 127 | - } |
|
| 128 | - elseif (isset($area['icon'])) |
|
| 135 | + } elseif (isset($area['icon'])) |
|
| 129 | 136 | { |
| 130 | 137 | if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
| 131 | 138 | { |
| 132 | 139 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
| 133 | - } |
|
| 134 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
| 140 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
| 135 | 141 | { |
| 136 | 142 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
| 143 | + } else { |
|
| 144 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
| 137 | 145 | } |
| 138 | - else |
|
| 139 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
| 146 | + } else { |
|
| 147 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
| 140 | 148 | } |
| 141 | - else |
|
| 142 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
| 143 | 149 | |
| 144 | 150 | if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
| 145 | 151 | { |
| 146 | 152 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
| 147 | - } |
|
| 148 | - elseif (isset($area['icon'])) |
|
| 153 | + } elseif (isset($area['icon'])) |
|
| 149 | 154 | { |
| 150 | 155 | if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') |
| 151 | 156 | { |
| 152 | 157 | if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
| 153 | 158 | { |
| 154 | 159 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
| 155 | - } |
|
| 156 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
| 160 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
| 157 | 161 | { |
| 158 | 162 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
| 159 | 163 | } |
| 160 | 164 | } |
| 161 | 165 | |
| 162 | 166 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
| 167 | + } else { |
|
| 168 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
| 163 | 169 | } |
| 164 | - else |
|
| 165 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
| 166 | 170 | |
| 167 | 171 | // This is a shortcut for Font-Icon users so they don't have to re-do whole CSS. |
| 168 | 172 | $menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : ''; |
@@ -179,35 +183,41 @@ discard block |
||
| 179 | 183 | { |
| 180 | 184 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
| 181 | 185 | { |
| 182 | - if ($first_sa == null) |
|
| 183 | - $first_sa = $sa; |
|
| 186 | + if ($first_sa == null) { |
|
| 187 | + $first_sa = $sa; |
|
| 188 | + } |
|
| 184 | 189 | |
| 185 | 190 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
| 186 | 191 | // Custom URL? |
| 187 | - if (isset($sub['url'])) |
|
| 188 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
| 192 | + if (isset($sub['url'])) { |
|
| 193 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
| 194 | + } |
|
| 189 | 195 | |
| 190 | 196 | // A bit complicated - but is this set? |
| 191 | 197 | if ($menu_context['current_area'] == $area_id) |
| 192 | 198 | { |
| 193 | 199 | // Save which is the first... |
| 194 | - if (empty($first_sa)) |
|
| 195 | - $first_sa = $sa; |
|
| 200 | + if (empty($first_sa)) { |
|
| 201 | + $first_sa = $sa; |
|
| 202 | + } |
|
| 196 | 203 | |
| 197 | 204 | // Is this the current subsection? |
| 198 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
| 199 | - $menu_context['current_subsection'] = $sa; |
|
| 205 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
| 206 | + $menu_context['current_subsection'] = $sa; |
|
| 207 | + } |
|
| 200 | 208 | // Otherwise is it the default? |
| 201 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
| 202 | - $menu_context['current_subsection'] = $sa; |
|
| 209 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
| 210 | + $menu_context['current_subsection'] = $sa; |
|
| 211 | + } |
|
| 203 | 212 | } |
| 204 | 213 | |
| 205 | 214 | // Let's assume this is the last, for now. |
| 206 | 215 | $last_sa = $sa; |
| 207 | 216 | } |
| 208 | 217 | // Mark it as disabled... |
| 209 | - else |
|
| 210 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
| 218 | + else { |
|
| 219 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
| 220 | + } |
|
| 211 | 221 | } |
| 212 | 222 | |
| 213 | 223 | // Set which one is first, last and selected in the group. |
@@ -216,8 +226,9 @@ discard block |
||
| 216 | 226 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
| 217 | 227 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
| 218 | 228 | |
| 219 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
| 220 | - $menu_context['current_subsection'] = $first_sa; |
|
| 229 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
| 230 | + $menu_context['current_subsection'] = $first_sa; |
|
| 231 | + } |
|
| 221 | 232 | } |
| 222 | 233 | } |
| 223 | 234 | } |
@@ -251,23 +262,26 @@ discard block |
||
| 251 | 262 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
| 252 | 263 | |
| 253 | 264 | // If we didn't find the area we were looking for go to a default one. |
| 254 | - if (isset($backup_area) && empty($found_section)) |
|
| 255 | - $menu_context['current_area'] = $backup_area; |
|
| 265 | + if (isset($backup_area) && empty($found_section)) { |
|
| 266 | + $menu_context['current_area'] = $backup_area; |
|
| 267 | + } |
|
| 256 | 268 | |
| 257 | 269 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
| 258 | 270 | if (!empty($menu_context['current_section'])) |
| 259 | 271 | { |
| 260 | 272 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
| 261 | 273 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
| 262 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
| 263 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
| 274 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
| 275 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
| 276 | + } |
|
| 264 | 277 | |
| 265 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
| 266 | - foreach ($section['areas'] as $area_id => $area) |
|
| 278 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
| 279 | + foreach ($section['areas'] as $area_id => $area) |
|
| 267 | 280 | { |
| 268 | 281 | if (!isset($menu_context['sections'][$section_id]['url'])) |
| 269 | 282 | { |
| 270 | 283 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
| 284 | + } |
|
| 271 | 285 | break; |
| 272 | 286 | } |
| 273 | 287 | } |
@@ -278,8 +292,9 @@ discard block |
||
| 278 | 292 | { |
| 279 | 293 | // Never happened! |
| 280 | 294 | $context['max_menu_id']--; |
| 281 | - if ($context['max_menu_id'] == 0) |
|
| 282 | - unset($context['max_menu_id']); |
|
| 295 | + if ($context['max_menu_id'] == 0) { |
|
| 296 | + unset($context['max_menu_id']); |
|
| 297 | + } |
|
| 283 | 298 | |
| 284 | 299 | return false; |
| 285 | 300 | } |
@@ -290,8 +305,9 @@ discard block |
||
| 290 | 305 | $context['template_layers'][] = $menu_context['layer_name']; |
| 291 | 306 | |
| 292 | 307 | // Check we had something - for sanity sake. |
| 293 | - if (empty($include_data)) |
|
| 294 | - return false; |
|
| 308 | + if (empty($include_data)) { |
|
| 309 | + return false; |
|
| 310 | + } |
|
| 295 | 311 | |
| 296 | 312 | // Finally - return information on the selected item. |
| 297 | 313 | $include_data += array( |
@@ -314,12 +330,14 @@ discard block |
||
| 314 | 330 | global $context; |
| 315 | 331 | |
| 316 | 332 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
| 317 | - if (!isset($context[$menu_name])) |
|
| 318 | - return false; |
|
| 333 | + if (!isset($context[$menu_name])) { |
|
| 334 | + return false; |
|
| 335 | + } |
|
| 319 | 336 | |
| 320 | 337 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
| 321 | - if ($layer_index !== false) |
|
| 322 | - unset($context['template_layers'][$layer_index]); |
|
| 338 | + if ($layer_index !== false) { |
|
| 339 | + unset($context['template_layers'][$layer_index]); |
|
| 340 | + } |
|
| 323 | 341 | |
| 324 | 342 | unset($context[$menu_name]); |
| 325 | 343 | } |