@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 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 = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
| 118 | 120 | |
| 119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
| 120 | 122 | |
| 121 | - if (empty($modSettings['search_force_index'])) |
|
| 122 | - $wordsSearch['words'][] = $word; |
|
| 123 | + if (empty($modSettings['search_force_index'])) { |
|
| 124 | + $wordsSearch['words'][] = $word; |
|
| 125 | + } |
|
| 123 | 126 | |
| 124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
| 125 | - if (count($subwords) > 1 && $isExcluded) |
|
| 126 | - return; |
|
| 127 | - else |
|
| 128 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 129 | + return; |
|
| 130 | + } else |
|
| 128 | 131 | { |
| 129 | 132 | foreach ($subwords as $subword) |
| 130 | 133 | { |
| 131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 132 | 135 | { |
| 133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
| 134 | - if ($isExcluded) |
|
| 135 | - $wordsExclude[] = $subword; |
|
| 137 | + if ($isExcluded) { |
|
| 138 | + $wordsExclude[] = $subword; |
|
| 139 | + } |
|
| 136 | 140 | } |
| 137 | 141 | } |
| 138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
| 153 | 157 | $query_where = array(); |
| 154 | 158 | $query_params = $search_data['params']; |
| 155 | 159 | |
| 156 | - if ($query_params['id_search']) |
|
| 157 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 160 | + if ($query_params['id_search']) { |
|
| 161 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 162 | + } |
|
| 158 | 163 | |
| 159 | 164 | $count = 0; |
| 160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
| 163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 164 | 169 | } |
| 165 | 170 | |
| 166 | - if ($query_params['user_query']) |
|
| 167 | - $query_where[] = '{raw:user_query}'; |
|
| 168 | - if ($query_params['board_query']) |
|
| 169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 171 | + if ($query_params['user_query']) { |
|
| 172 | + $query_where[] = '{raw:user_query}'; |
|
| 173 | + } |
|
| 174 | + if ($query_params['board_query']) { |
|
| 175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 176 | + } |
|
| 170 | 177 | |
| 171 | - if ($query_params['topic']) |
|
| 172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 173 | - if ($query_params['min_msg_id']) |
|
| 174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 175 | - if ($query_params['max_msg_id']) |
|
| 176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 178 | + if ($query_params['topic']) { |
|
| 179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 180 | + } |
|
| 181 | + if ($query_params['min_msg_id']) { |
|
| 182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 183 | + } |
|
| 184 | + if ($query_params['max_msg_id']) { |
|
| 185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 186 | + } |
|
| 177 | 187 | |
| 178 | 188 | $count = 0; |
| 179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 181 | 191 | { |
| 182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 193 | + } |
|
| 183 | 194 | $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), '\\\'') . '[[:>:]]'; |
| 184 | 195 | } |
| 185 | 196 | $count = 0; |
| 186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 188 | 199 | { |
| 189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 201 | + } |
|
| 190 | 202 | $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), '\\\'') . '[[:>:]]'; |
| 191 | 203 | } |
| 192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
| 199 | 211 | { |
| 200 | 212 | $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)'; |
| 201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 202 | - } |
|
| 203 | - else |
|
| 214 | + } else |
|
| 204 | 215 | { |
| 205 | 216 | $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)'; |
| 206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
| 236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 237 | 248 | |
| 238 | 249 | $inserts = array(); |
| 239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 240 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 251 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 252 | + } |
|
| 241 | 253 | |
| 242 | - if (!empty($inserts)) |
|
| 243 | - $smcFunc['db_insert']('ignore', |
|
| 254 | + if (!empty($inserts)) { |
|
| 255 | + $smcFunc['db_insert']('ignore', |
|
| 244 | 256 | '{db_prefix}log_search_words', |
| 245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 246 | 258 | $inserts, |
| 247 | 259 | array('id_word', 'id_msg') |
| 248 | 260 | ); |
| 261 | + } |
|
| 249 | 262 | } |
| 250 | 263 | |
| 251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
| 288 | 301 | if (!empty($inserted_words)) |
| 289 | 302 | { |
| 290 | 303 | $inserts = array(); |
| 291 | - foreach ($inserted_words as $word) |
|
| 292 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 304 | + foreach ($inserted_words as $word) { |
|
| 305 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 306 | + } |
|
| 293 | 307 | $smcFunc['db_insert']('insert', |
| 294 | 308 | '{db_prefix}log_search_words', |
| 295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Show the database queries for debugging |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug; |
| 31 | 32 | |
| 32 | 33 | // We should have debug mode enabled, as well as something to display! |
| 33 | - if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) |
|
| 34 | - fatal_lang_error('no_access', false); |
|
| 34 | + if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) { |
|
| 35 | + fatal_lang_error('no_access', false); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Don't allow except for administrators. |
| 37 | 39 | isAllowedTo('admin_forum'); |
@@ -41,10 +43,11 @@ discard block |
||
| 41 | 43 | { |
| 42 | 44 | $_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1; |
| 43 | 45 | |
| 44 | - if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) |
|
| 45 | - redirectexit(); |
|
| 46 | - else |
|
| 47 | - redirectexit($_SESSION['old_url']); |
|
| 46 | + if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) { |
|
| 47 | + redirectexit(); |
|
| 48 | + } else { |
|
| 49 | + redirectexit($_SESSION['old_url']); |
|
| 50 | + } |
|
| 48 | 51 | } |
| 49 | 52 | |
| 50 | 53 | call_integration_hook('integrate_egg_nog'); |
@@ -83,26 +86,28 @@ discard block |
||
| 83 | 86 | foreach ($query as $line) |
| 84 | 87 | { |
| 85 | 88 | preg_match('/^(\t*)/', $line, $temp); |
| 86 | - if (strlen($temp[0]) < $min_indent || $min_indent == 0) |
|
| 87 | - $min_indent = strlen($temp[0]); |
|
| 89 | + if (strlen($temp[0]) < $min_indent || $min_indent == 0) { |
|
| 90 | + $min_indent = strlen($temp[0]); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + foreach ($query as $l => $dummy) { |
|
| 94 | + $query[$l] = substr($dummy, $min_indent); |
|
| 88 | 95 | } |
| 89 | - foreach ($query as $l => $dummy) |
|
| 90 | - $query[$l] = substr($dummy, $min_indent); |
|
| 91 | 96 | $query_data['q'] = implode("\n", $query); |
| 92 | 97 | |
| 93 | 98 | // Make the filenames look a bit better. |
| 94 | - if (isset($query_data['f'])) |
|
| 95 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 99 | + if (isset($query_data['f'])) { |
|
| 100 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 101 | + } |
|
| 96 | 102 | |
| 97 | 103 | $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT'; |
| 98 | - if ($is_select_query) |
|
| 99 | - $select = $query_data['q']; |
|
| 100 | - elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 104 | + if ($is_select_query) { |
|
| 105 | + $select = $query_data['q']; |
|
| 106 | + } elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 101 | 107 | { |
| 102 | 108 | $is_select_query = true; |
| 103 | 109 | $select = $matches[1]; |
| 104 | - } |
|
| 105 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 110 | + } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 106 | 111 | { |
| 107 | 112 | $is_select_query = true; |
| 108 | 113 | $select = $matches[1]; |
@@ -110,10 +115,11 @@ discard block |
||
| 110 | 115 | // Temporary tables created in earlier queries are not explainable. |
| 111 | 116 | if ($is_select_query) |
| 112 | 117 | { |
| 113 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 114 | - if (strpos($select, $tmp) !== false) |
|
| 118 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 119 | + if (strpos($select, $tmp) !== false) |
|
| 115 | 120 | { |
| 116 | 121 | $is_select_query = false; |
| 122 | + } |
|
| 117 | 123 | break; |
| 118 | 124 | } |
| 119 | 125 | } |
@@ -124,13 +130,15 @@ discard block |
||
| 124 | 130 | ', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars']($query_data['q']))), ' |
| 125 | 131 | </a><br>'; |
| 126 | 132 | |
| 127 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
| 128 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 133 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
| 134 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 135 | + } |
|
| 129 | 136 | |
| 130 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 131 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
| 132 | - else |
|
| 133 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
| 137 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 138 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
| 139 | + } else { |
|
| 140 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
| 141 | + } |
|
| 134 | 142 | |
| 135 | 143 | echo ' |
| 136 | 144 | </div>'; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $board_info, $smcFunc, $modSettings; |
| 33 | 34 | |
| 34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
| 35 | - if (empty($topic)) |
|
| 36 | - redirectexit(); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + redirectexit(); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
| 39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | ) |
| 60 | 62 | ); |
| 61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
| 62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 63 | - redirectexit(); |
|
| 64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 65 | + redirectexit(); |
|
| 66 | + } |
|
| 64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
| 65 | 68 | $smcFunc['db_free_result']($request); |
| 66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
| 134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
| 135 | 138 | { |
| 136 | 139 | $guestvoted = explode(',', $guestvoted); |
| 137 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 138 | - break; |
|
| 140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 139 | 143 | } |
| 140 | 144 | // Has the poll been reset since guest voted? |
| 141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 142 | 146 | { |
| 143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
| 144 | 148 | unset($guestinfo[$i]); |
| 145 | - if (!empty($guestinfo)) |
|
| 146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 147 | - else |
|
| 148 | - unset($_COOKIE['guest_poll_vote']); |
|
| 149 | - } |
|
| 150 | - else |
|
| 149 | + if (!empty($guestinfo)) { |
|
| 150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 151 | + } else { |
|
| 152 | + unset($_COOKIE['guest_poll_vote']); |
|
| 153 | + } |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | // What did they vote for? |
| 153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
| 233 | 237 | $context['poster_name'] = $row['poster_name']; |
| 234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
| 235 | 239 | $context['parent_boards'] = array(); |
| 236 | - foreach ($board_info['parent_boards'] as $parent) |
|
| 237 | - $context['parent_boards'][] = $parent['name']; |
|
| 240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
| 241 | + $context['parent_boards'][] = $parent['name']; |
|
| 242 | + } |
|
| 238 | 243 | |
| 239 | 244 | // Split the topics up so we can print them. |
| 240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
| 266 | 271 | 'id_msg' => $row['id_msg'], |
| 267 | 272 | ); |
| 268 | 273 | |
| 269 | - if (!isset($context['topic_subject'])) |
|
| 270 | - $context['topic_subject'] = $row['subject']; |
|
| 274 | + if (!isset($context['topic_subject'])) { |
|
| 275 | + $context['topic_subject'] = $row['subject']; |
|
| 276 | + } |
|
| 271 | 277 | } |
| 272 | 278 | $smcFunc['db_free_result']($request); |
| 273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
| 275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
| 276 | 282 | { |
| 277 | 283 | $messages = array(); |
| 278 | - foreach ($context['posts'] as $temp) |
|
| 279 | - $messages[] = $temp['id_msg']; |
|
| 284 | + foreach ($context['posts'] as $temp) { |
|
| 285 | + $messages[] = $temp['id_msg']; |
|
| 286 | + } |
|
| 280 | 287 | |
| 281 | 288 | // build the request |
| 282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 296 | 303 | { |
| 297 | 304 | $temp[$row['id_attach']] = $row; |
| 298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
| 299 | - $context['printattach'][$row['id_msg']] = array(); |
|
| 305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
| 306 | + $context['printattach'][$row['id_msg']] = array(); |
|
| 307 | + } |
|
| 300 | 308 | } |
| 301 | 309 | $smcFunc['db_free_result']($request); |
| 302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
| 313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
| 314 | 322 | $row['width'] = $modSettings['max_image_width']; |
| 315 | 323 | } |
| 316 | - } |
|
| 317 | - elseif (!empty($modSettings['max_image_width'])) |
|
| 324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
| 318 | 325 | { |
| 319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
| 320 | 327 | { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 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) { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_engine'](); |
@@ -74,24 +74,31 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | - if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') |
|
| 78 | - get_memcached_server(); |
|
| 77 | + if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { |
|
| 78 | + get_memcached_server(); |
|
| 79 | + } |
|
| 79 | 80 | |
| 80 | 81 | // Check to see if we have any accelerators installed... |
| 81 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 82 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 83 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 84 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 85 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 86 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
| 87 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 88 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 82 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 83 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | + } |
|
| 85 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 86 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 87 | + } |
|
| 88 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 89 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
| 90 | + } |
|
| 91 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 92 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | - if (in_array('php', $checkFor)) |
|
| 91 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 95 | + if (in_array('php', $checkFor)) { |
|
| 96 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | - if (in_array('server', $checkFor)) |
|
| 94 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 99 | + if (in_array('server', $checkFor)) { |
|
| 100 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | return $versions; |
| 97 | 104 | } |
@@ -131,11 +138,13 @@ discard block |
||
| 131 | 138 | fclose($fp); |
| 132 | 139 | |
| 133 | 140 | // The comment looks rougly like... that. |
| 134 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 135 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 141 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 142 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 143 | + } |
|
| 136 | 144 | // Not found! This is bad. |
| 137 | - else |
|
| 138 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 145 | + else { |
|
| 146 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 147 | + } |
|
| 139 | 148 | } |
| 140 | 149 | |
| 141 | 150 | // Do the paid subscriptions handler? |
@@ -146,11 +155,13 @@ discard block |
||
| 146 | 155 | fclose($fp); |
| 147 | 156 | |
| 148 | 157 | // Found it? |
| 149 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 150 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 158 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 159 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 160 | + } |
|
| 151 | 161 | // If we haven't how do we all get paid? |
| 152 | - else |
|
| 153 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 162 | + else { |
|
| 163 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 164 | + } |
|
| 154 | 165 | } |
| 155 | 166 | |
| 156 | 167 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -165,11 +176,13 @@ discard block |
||
| 165 | 176 | fclose($fp); |
| 166 | 177 | |
| 167 | 178 | // Look for the version comment in the file header. |
| 168 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 169 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 179 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 180 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 181 | + } |
|
| 170 | 182 | // It wasn't found, but the file was... show a '??'. |
| 171 | - else |
|
| 172 | - $version_info['file_versions'][$entry] = '??'; |
|
| 183 | + else { |
|
| 184 | + $version_info['file_versions'][$entry] = '??'; |
|
| 185 | + } |
|
| 173 | 186 | } |
| 174 | 187 | } |
| 175 | 188 | $sources_dir->close(); |
@@ -188,11 +201,13 @@ discard block |
||
| 188 | 201 | fclose($fp); |
| 189 | 202 | |
| 190 | 203 | // Look for the version comment in the file header. |
| 191 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 192 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 204 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 205 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 206 | + } |
|
| 193 | 207 | // It wasn't found, but the file was... show a '??'. |
| 194 | - else |
|
| 195 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 208 | + else { |
|
| 209 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 210 | + } |
|
| 196 | 211 | } |
| 197 | 212 | } |
| 198 | 213 | $tasks_dir->close(); |
@@ -200,8 +215,9 @@ discard block |
||
| 200 | 215 | |
| 201 | 216 | // Load all the files in the default template directory - and the current theme if applicable. |
| 202 | 217 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 203 | - if ($settings['theme_id'] != 1) |
|
| 204 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 218 | + if ($settings['theme_id'] != 1) { |
|
| 219 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 220 | + } |
|
| 205 | 221 | |
| 206 | 222 | foreach ($directories as $type => $dirname) |
| 207 | 223 | { |
@@ -216,11 +232,13 @@ discard block |
||
| 216 | 232 | fclose($fp); |
| 217 | 233 | |
| 218 | 234 | // Look for the version comment in the file header. |
| 219 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 220 | - $version_info[$type][$entry] = $match[1]; |
|
| 235 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 236 | + $version_info[$type][$entry] = $match[1]; |
|
| 237 | + } |
|
| 221 | 238 | // It wasn't found, but the file was... show a '??'. |
| 222 | - else |
|
| 223 | - $version_info[$type][$entry] = '??'; |
|
| 239 | + else { |
|
| 240 | + $version_info[$type][$entry] = '??'; |
|
| 241 | + } |
|
| 224 | 242 | } |
| 225 | 243 | } |
| 226 | 244 | $this_dir->close(); |
@@ -241,11 +259,13 @@ discard block |
||
| 241 | 259 | list ($name, $language) = explode('.', $entry); |
| 242 | 260 | |
| 243 | 261 | // Look for the version comment in the file header. |
| 244 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 245 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 262 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 263 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 264 | + } |
|
| 246 | 265 | // It wasn't found, but the file was... show a '??'. |
| 247 | - else |
|
| 248 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 266 | + else { |
|
| 267 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 268 | + } |
|
| 249 | 269 | } |
| 250 | 270 | } |
| 251 | 271 | $this_dir->close(); |
@@ -260,8 +280,9 @@ discard block |
||
| 260 | 280 | ksort($version_info['tasks_versions']); |
| 261 | 281 | |
| 262 | 282 | // For languages sort each language too. |
| 263 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 264 | - ksort($version_info['default_language_versions'][$language]); |
|
| 283 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 284 | + ksort($version_info['default_language_versions'][$language]); |
|
| 285 | + } |
|
| 265 | 286 | } |
| 266 | 287 | return $version_info; |
| 267 | 288 | } |
@@ -303,27 +324,31 @@ discard block |
||
| 303 | 324 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 304 | 325 | |
| 305 | 326 | // Break it up based on \r or \n, and then clean out extra characters. |
| 306 | - if (strpos($settingsArray, "\n") !== false) |
|
| 307 | - $settingsArray = explode("\n", $settingsArray); |
|
| 308 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 309 | - $settingsArray = explode("\r", $settingsArray); |
|
| 310 | - else |
|
| 311 | - return; |
|
| 327 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 328 | + $settingsArray = explode("\n", $settingsArray); |
|
| 329 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 330 | + $settingsArray = explode("\r", $settingsArray); |
|
| 331 | + } else { |
|
| 332 | + return; |
|
| 333 | + } |
|
| 312 | 334 | |
| 313 | 335 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 314 | - if (count($settingsArray) < 10) |
|
| 315 | - return; |
|
| 336 | + if (count($settingsArray) < 10) { |
|
| 337 | + return; |
|
| 338 | + } |
|
| 316 | 339 | |
| 317 | 340 | // remove any /r's that made there way in here |
| 318 | - foreach ($settingsArray as $k => $dummy) |
|
| 319 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 341 | + foreach ($settingsArray as $k => $dummy) { |
|
| 342 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 343 | + } |
|
| 320 | 344 | |
| 321 | 345 | // go line by line and see whats changing |
| 322 | 346 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 323 | 347 | { |
| 324 | 348 | // Don't trim or bother with it if it's not a variable. |
| 325 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 326 | - continue; |
|
| 349 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 350 | + continue; |
|
| 351 | + } |
|
| 327 | 352 | |
| 328 | 353 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 329 | 354 | |
@@ -335,8 +360,7 @@ discard block |
||
| 335 | 360 | { |
| 336 | 361 | updateDbLastError($val); |
| 337 | 362 | unset($config_vars[$var]); |
| 338 | - } |
|
| 339 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 363 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 340 | 364 | { |
| 341 | 365 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 342 | 366 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -347,34 +371,39 @@ discard block |
||
| 347 | 371 | } |
| 348 | 372 | |
| 349 | 373 | // End of the file ... maybe |
| 350 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 351 | - $end = $i; |
|
| 374 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 375 | + $end = $i; |
|
| 376 | + } |
|
| 352 | 377 | } |
| 353 | 378 | |
| 354 | 379 | // This should never happen, but apparently it is happening. |
| 355 | - if (empty($end) || $end < 10) |
|
| 356 | - $end = count($settingsArray) - 1; |
|
| 380 | + if (empty($end) || $end < 10) { |
|
| 381 | + $end = count($settingsArray) - 1; |
|
| 382 | + } |
|
| 357 | 383 | |
| 358 | 384 | // Still more variables to go? Then lets add them at the end. |
| 359 | 385 | if (!empty($config_vars)) |
| 360 | 386 | { |
| 361 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 362 | - $settingsArray[$end++] = ''; |
|
| 363 | - else |
|
| 364 | - $end++; |
|
| 387 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 388 | + $settingsArray[$end++] = ''; |
|
| 389 | + } else { |
|
| 390 | + $end++; |
|
| 391 | + } |
|
| 365 | 392 | |
| 366 | 393 | // Add in any newly defined vars that were passed |
| 367 | - foreach ($config_vars as $var => $val) |
|
| 368 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 394 | + foreach ($config_vars as $var => $val) { |
|
| 395 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 396 | + } |
|
| 369 | 397 | |
| 370 | 398 | $settingsArray[$end] = '?' . '>'; |
| 399 | + } else { |
|
| 400 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 371 | 401 | } |
| 372 | - else |
|
| 373 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 374 | 402 | |
| 375 | 403 | // Sanity error checking: the file needs to be at least 12 lines. |
| 376 | - if (count($settingsArray) < 12) |
|
| 377 | - return; |
|
| 404 | + if (count($settingsArray) < 12) { |
|
| 405 | + return; |
|
| 406 | + } |
|
| 378 | 407 | |
| 379 | 408 | // Try to avoid a few pitfalls: |
| 380 | 409 | // - like a possible race condition, |
@@ -382,8 +411,9 @@ discard block |
||
| 382 | 411 | // |
| 383 | 412 | // Check before you act: if cache is enabled, we can do a simple write test |
| 384 | 413 | // to validate that we even write things on this filesystem. |
| 385 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 386 | - $cachedir = $boarddir . '/cache'; |
|
| 414 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 415 | + $cachedir = $boarddir . '/cache'; |
|
| 416 | + } |
|
| 387 | 417 | |
| 388 | 418 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 389 | 419 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
| 419 | 449 | // Well this is not good at all, lets see if we can save this |
| 420 | 450 | $context['settings_message'] = 'settings_error'; |
| 421 | 451 | |
| 422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 454 | + } |
|
| 424 | 455 | } |
| 425 | 456 | } |
| 426 | 457 | |
| 427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 429 | - if (function_exists('opcache_invalidate')) |
|
| 430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 431 | -} |
|
| 460 | + if (function_exists('opcache_invalidate')) { |
|
| 461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 462 | + } |
|
| 463 | + } |
|
| 432 | 464 | |
| 433 | 465 | /** |
| 434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
| 454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
| 455 | 487 | |
| 456 | 488 | // This must exist! |
| 457 | - if (!isset($context['admin_preferences'])) |
|
| 458 | - return false; |
|
| 489 | + if (!isset($context['admin_preferences'])) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 459 | 492 | |
| 460 | 493 | // This is what we'll be saving. |
| 461 | 494 | $options['admin_preferences'] = json_encode($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
| 519 | 552 | $emails_sent = array(); |
| 520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 521 | 554 | { |
| 522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 523 | - continue; |
|
| 555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 524 | 558 | |
| 525 | 559 | // Stick their particulars in the replacement data. |
| 526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
| 539 | 573 | $smcFunc['db_free_result']($request); |
| 540 | 574 | |
| 541 | 575 | // Any additional users we must email this to? |
| 542 | - if (!empty($additional_recipients)) |
|
| 543 | - foreach ($additional_recipients as $recipient) |
|
| 576 | + if (!empty($additional_recipients)) { |
|
| 577 | + foreach ($additional_recipients as $recipient) |
|
| 544 | 578 | { |
| 545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
| 546 | 580 | continue; |
| 581 | + } |
|
| 547 | 582 | |
| 548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
| 549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Locks a topic... either by way of a moderator or the topic starter. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $topic, $user_info, $sourcedir, $board, $smcFunc; |
| 33 | 34 | |
| 34 | 35 | // Just quit if there's no topic to lock. |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('not_a_topic', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('not_a_topic', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | checkSession('get'); |
| 39 | 41 | |
@@ -55,23 +57,28 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | // Can you lock topics here, mister? |
| 57 | 59 | $user_lock = !allowedTo('lock_any'); |
| 58 | - if ($user_lock && $starter == $user_info['id']) |
|
| 59 | - isAllowedTo('lock_own'); |
|
| 60 | - else |
|
| 61 | - isAllowedTo('lock_any'); |
|
| 60 | + if ($user_lock && $starter == $user_info['id']) { |
|
| 61 | + isAllowedTo('lock_own'); |
|
| 62 | + } else { |
|
| 63 | + isAllowedTo('lock_any'); |
|
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | // Locking with high privileges. |
| 64 | - if ($locked == '0' && !$user_lock) |
|
| 65 | - $locked = '1'; |
|
| 67 | + if ($locked == '0' && !$user_lock) { |
|
| 68 | + $locked = '1'; |
|
| 69 | + } |
|
| 66 | 70 | // Locking with low privileges. |
| 67 | - elseif ($locked == '0') |
|
| 68 | - $locked = '2'; |
|
| 71 | + elseif ($locked == '0') { |
|
| 72 | + $locked = '2'; |
|
| 73 | + } |
|
| 69 | 74 | // Unlocking - make sure you don't unlock what you can't. |
| 70 | - elseif ($locked == '2' || ($locked == '1' && !$user_lock)) |
|
| 71 | - $locked = '0'; |
|
| 75 | + elseif ($locked == '2' || ($locked == '1' && !$user_lock)) { |
|
| 76 | + $locked = '0'; |
|
| 77 | + } |
|
| 72 | 78 | // You cannot unlock this! |
| 73 | - else |
|
| 74 | - fatal_lang_error('locked_by_admin', 'user'); |
|
| 79 | + else { |
|
| 80 | + fatal_lang_error('locked_by_admin', 'user'); |
|
| 81 | + } |
|
| 75 | 82 | |
| 76 | 83 | // Actually lock the topic in the database with the new value. |
| 77 | 84 | $smcFunc['db_query']('', ' |
@@ -85,8 +92,9 @@ discard block |
||
| 85 | 92 | ); |
| 86 | 93 | |
| 87 | 94 | // If they are allowed a "moderator" permission, log it in the moderator log. |
| 88 | - if (!$user_lock) |
|
| 89 | - logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
| 95 | + if (!$user_lock) { |
|
| 96 | + logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
| 97 | + } |
|
| 90 | 98 | // Notify people that this topic has been locked? |
| 91 | 99 | sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); |
| 92 | 100 | |
@@ -112,8 +120,9 @@ discard block |
||
| 112 | 120 | isAllowedTo('make_sticky'); |
| 113 | 121 | |
| 114 | 122 | // You can't sticky a board or something! |
| 115 | - if (empty($topic)) |
|
| 116 | - fatal_lang_error('not_a_topic', false); |
|
| 123 | + if (empty($topic)) { |
|
| 124 | + fatal_lang_error('not_a_topic', false); |
|
| 125 | + } |
|
| 117 | 126 | |
| 118 | 127 | checkSession('get'); |
| 119 | 128 | |
@@ -147,8 +156,9 @@ discard block |
||
| 147 | 156 | // Log this sticky action - always a moderator thing. |
| 148 | 157 | logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); |
| 149 | 158 | // Notify people that this topic has been stickied? |
| 150 | - if (empty($is_sticky)) |
|
| 151 | - sendNotifications($topic, 'sticky'); |
|
| 159 | + if (empty($is_sticky)) { |
|
| 160 | + sendNotifications($topic, 'sticky'); |
|
| 161 | + } |
|
| 152 | 162 | |
| 153 | 163 | // Take them back to the now stickied topic. |
| 154 | 164 | redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); |
@@ -132,8 +132,9 @@ discard block |
||
| 132 | 132 | 'GROUPNAME' => $user['group_name'], |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - if (!empty($custom_reason)) |
|
| 136 | - $replacements['REASON'] = $custom_reason; |
|
| 135 | + if (!empty($custom_reason)) { |
|
| 136 | + $replacements['REASON'] = $custom_reason; |
|
| 137 | + } |
|
| 137 | 138 | |
| 138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
| 139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
| 142 | 143 | } |
| 143 | 144 | |
| 144 | 145 | // Insert the alerts if any |
| 145 | - if (!empty($alert_rows)) |
|
| 146 | - $smcFunc['db_insert']('', |
|
| 146 | + if (!empty($alert_rows)) { |
|
| 147 | + $smcFunc['db_insert']('', |
|
| 147 | 148 | '{db_prefix}user_alerts', |
| 148 | 149 | array( |
| 149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
| 152 | 153 | $alert_rows, |
| 153 | 154 | array() |
| 154 | 155 | ); |
| 156 | + } |
|
| 155 | 157 | } |
| 156 | 158 | |
| 157 | 159 | return true; |
@@ -32,8 +32,9 @@ discard block |
||
| 32 | 32 | $members = membersAllowedTo('calendar_view'); |
| 33 | 33 | |
| 34 | 34 | // Don't alert the event creator |
| 35 | - if (!empty($this->_details['sender_id'])) |
|
| 36 | - $members = array_diff($members, array($this->_details['sender_id'])); |
|
| 35 | + if (!empty($this->_details['sender_id'])) { |
|
| 36 | + $members = array_diff($members, array($this->_details['sender_id'])); |
|
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | // Having successfully figured this out, now let's get the preferences of everyone. |
| 39 | 40 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -44,10 +45,11 @@ discard block |
||
| 44 | 45 | if (!empty($this->_details['sender_id']) && empty($this->_details['sender_name'])) |
| 45 | 46 | { |
| 46 | 47 | loadMemberData($this->_details['sender_id'], 'minimal'); |
| 47 | - if (!empty($user_profile[$this->_details['sender_id']])) |
|
| 48 | - $this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name']; |
|
| 49 | - else |
|
| 50 | - $this->_details['sender_id'] = 0; |
|
| 48 | + if (!empty($user_profile[$this->_details['sender_id']])) { |
|
| 49 | + $this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name']; |
|
| 50 | + } else { |
|
| 51 | + $this->_details['sender_id'] = 0; |
|
| 52 | + } |
|
| 51 | 53 | } |
| 52 | 54 | |
| 53 | 55 | // So now we find out who wants what. |
@@ -59,9 +61,10 @@ discard block |
||
| 59 | 61 | |
| 60 | 62 | foreach ($prefs as $member => $pref_option) |
| 61 | 63 | { |
| 62 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 63 | - if ($pref_option['event_new'] & $bitvalue) |
|
| 64 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 65 | + if ($pref_option['event_new'] & $bitvalue) |
|
| 64 | 66 | $notifies[$type][] = $member; |
| 67 | + } |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | // Firstly, anyone who wants alerts. |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | 'last_comment' => $this->_details['comment_id'], |
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 44 | - $possible_members[] = $row[0]; |
|
| 43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 44 | + $possible_members[] = $row[0]; |
|
| 45 | + } |
|
| 45 | 46 | $smcFunc['db_free_result']($request); |
| 46 | 47 | |
| 47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
| 51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
| 52 | 53 | } |
| 53 | - if (empty($possible_members)) |
|
| 54 | - return true; |
|
| 54 | + if (empty($possible_members)) { |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
| 57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -67,8 +69,9 @@ discard block |
||
| 67 | 69 | 'current_board' => $this->_details['board_id'], |
| 68 | 70 | ) |
| 69 | 71 | ); |
| 70 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 71 | - $members[] = $row['id_member']; |
|
| 72 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 73 | + $members[] = $row['id_member']; |
|
| 74 | + } |
|
| 72 | 75 | $smcFunc['db_free_result']($request); |
| 73 | 76 | |
| 74 | 77 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -85,8 +88,9 @@ discard block |
||
| 85 | 88 | ) |
| 86 | 89 | ); |
| 87 | 90 | |
| 88 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 89 | - $members[] = $row['id_member']; |
|
| 91 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 92 | + $members[] = $row['id_member']; |
|
| 93 | + } |
|
| 90 | 94 | $smcFunc['db_free_result']($request); |
| 91 | 95 | |
| 92 | 96 | // So now we have two lists: the people who replied to a report in the past, |
@@ -108,8 +112,9 @@ discard block |
||
| 108 | 112 | { |
| 109 | 113 | foreach ($alert_bits as $type => $bitvalue) |
| 110 | 114 | { |
| 111 | - if ($pref_option['msg_report_reply'] & $bitvalue) |
|
| 112 | - $notifies[$type][] = $member; |
|
| 115 | + if ($pref_option['msg_report_reply'] & $bitvalue) { |
|
| 116 | + $notifies[$type][] = $member; |
|
| 117 | + } |
|
| 113 | 118 | } |
| 114 | 119 | } |
| 115 | 120 | |
@@ -170,8 +175,9 @@ discard block |
||
| 170 | 175 | ); |
| 171 | 176 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 172 | 177 | { |
| 173 | - if (empty($row['lngfile'])) |
|
| 174 | - $row['lngfile'] = $language; |
|
| 178 | + if (empty($row['lngfile'])) { |
|
| 179 | + $row['lngfile'] = $language; |
|
| 180 | + } |
|
| 175 | 181 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 176 | 182 | } |
| 177 | 183 | $smcFunc['db_free_result']($request); |
@@ -203,8 +209,9 @@ discard block |
||
| 203 | 209 | $emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 204 | 210 | |
| 205 | 211 | // And do the actual sending... |
| 206 | - foreach ($recipients as $id_member => $email_address) |
|
| 207 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 212 | + foreach ($recipients as $id_member => $email_address) { |
|
| 213 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 214 | + } |
|
| 208 | 215 | } |
| 209 | 216 | } |
| 210 | 217 | |