@@ -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 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => true, |
32 | 33 | ); |
33 | -} |
|
34 | + } |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /** |
36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
54 | 56 | { |
55 | 57 | global $smcFunc; |
56 | 58 | |
57 | - if ($size == 'small') |
|
58 | - $size = 'smallint(5)'; |
|
59 | - elseif ($size == 'medium') |
|
60 | - $size = 'mediumint(8)'; |
|
61 | - else |
|
62 | - $size = 'int(10)'; |
|
59 | + if ($size == 'small') { |
|
60 | + $size = 'smallint(5)'; |
|
61 | + } elseif ($size == 'medium') { |
|
62 | + $size = 'mediumint(8)'; |
|
63 | + } else { |
|
64 | + $size = 'int(10)'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | $smcFunc['db_query']('', ' |
65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -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 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | is_not_guest(); |
35 | 36 | |
36 | 37 | // You have to specify a board to turn notifications on! |
37 | - if (empty($board)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($board)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // No subaction: find out what to do. |
41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
50 | 52 | |
51 | - if ($mode > 1) |
|
52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | + if ($mode > 1) { |
|
54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | 55 | $smcFunc['db_insert']('ignore', |
54 | 56 | '{db_prefix}log_notify', |
55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
56 | 58 | array($user_info['id'], $board), |
57 | 59 | array('id_member', 'id_board') |
58 | 60 | ); |
59 | - else |
|
60 | - $smcFunc['db_query']('', ' |
|
61 | + } else { |
|
62 | + $smcFunc['db_query']('', ' |
|
61 | 63 | DELETE FROM {db_prefix}log_notify |
62 | 64 | WHERE id_member = {int:current_member} |
63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
66 | 68 | 'current_member' => $user_info['id'], |
67 | 69 | ) |
68 | 70 | ); |
71 | + } |
|
69 | 72 | |
70 | 73 | } |
71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
81 | 84 | ), |
82 | 85 | ); |
83 | 86 | $context['sub_template'] = 'generic_xml'; |
87 | + } else { |
|
88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
89 | + } |
|
84 | 90 | } |
85 | - else |
|
86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
87 | -} |
|
88 | 91 | |
89 | 92 | /** |
90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
108 | 111 | $mode = (int) $_GET['mode']; |
109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
110 | 113 | |
111 | - if (empty($mode)) |
|
112 | - $mode = 1; |
|
114 | + if (empty($mode)) { |
|
115 | + $mode = 1; |
|
116 | + } |
|
113 | 117 | |
114 | 118 | $request = $smcFunc['db_query']('', ' |
115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
132 | 136 | 'id_msg' => 0, |
133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
134 | 138 | ); |
135 | - } |
|
136 | - else |
|
139 | + } else |
|
137 | 140 | { |
138 | 141 | $insert = false; |
139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
160 | 163 | array($user_info['id'], $log['id_topic']), |
161 | 164 | array('id_member', 'id_board') |
162 | 165 | ); |
163 | - } |
|
164 | - else |
|
165 | - $smcFunc['db_query']('', ' |
|
166 | + } else { |
|
167 | + $smcFunc['db_query']('', ' |
|
166 | 168 | DELETE FROM {db_prefix}log_notify |
167 | 169 | WHERE id_topic = {int:topic} |
168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | 'topic' => $log['id_topic'], |
171 | 173 | 'member' => $user_info['id'], |
172 | 174 | )); |
175 | + } |
|
173 | 176 | |
174 | 177 | } |
175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
186 | 189 | ), |
187 | 190 | ); |
188 | 191 | $context['sub_template'] = 'generic_xml'; |
192 | + } else { |
|
193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
194 | + } |
|
189 | 195 | } |
190 | - else |
|
191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
192 | -} |
|
193 | 196 | |
194 | 197 | ?> |
195 | 198 | \ No newline at end of file |
@@ -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 |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -42,10 +44,11 @@ discard block |
||
42 | 44 | $key = $this->prefix . strtr($key, ':/', '-_'); |
43 | 45 | |
44 | 46 | // Zend's pricey stuff. |
45 | - if (function_exists('zend_shm_cache_fetch')) |
|
46 | - return zend_shm_cache_fetch('SMF::' . $key); |
|
47 | - elseif (function_exists('output_cache_get')) |
|
48 | - return output_cache_get($key, $ttl); |
|
47 | + if (function_exists('zend_shm_cache_fetch')) { |
|
48 | + return zend_shm_cache_fetch('SMF::' . $key); |
|
49 | + } elseif (function_exists('output_cache_get')) { |
|
50 | + return output_cache_get($key, $ttl); |
|
51 | + } |
|
49 | 52 | } |
50 | 53 | |
51 | 54 | /** |
@@ -55,10 +58,11 @@ discard block |
||
55 | 58 | { |
56 | 59 | $key = $this->prefix . strtr($key, ':/', '-_'); |
57 | 60 | |
58 | - if (function_exists('zend_shm_cache_store')) |
|
59 | - return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
60 | - elseif (function_exists('output_cache_put')) |
|
61 | - return output_cache_put($key, $value); |
|
61 | + if (function_exists('zend_shm_cache_store')) { |
|
62 | + return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
63 | + } elseif (function_exists('output_cache_put')) { |
|
64 | + return output_cache_put($key, $value); |
|
65 | + } |
|
62 | 66 | } |
63 | 67 | |
64 | 68 | /** |
@@ -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'); |