@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $query_where = array(); |
167 | 167 | $query_params = $search_data['params']; |
168 | 168 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
170 | 170 | $modSettings['search_simple_fulltext'] = true; |
171 | 171 | |
172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
211 | 211 | { |
212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
213 | 213 | { |
214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // remove any indexed words that are used in the complex body search terms |
228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
229 | 229 | |
230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
231 | 231 | $row = 0; |
232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | // if we have bool terms to search, add them in |
245 | 245 | if ($query_params['boolean_match']) { |
246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
247 | 247 | { |
248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
170 | - $modSettings['search_simple_fulltext'] = true; |
|
171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
172 | + $modSettings['search_simple_fulltext'] = true; |
|
173 | + } |
|
171 | 174 | |
172 | - if ($query_params['id_search']) |
|
173 | - $query_select['id_search'] = '{int:id_search}'; |
|
175 | + if ($query_params['id_search']) { |
|
176 | + $query_select['id_search'] = '{int:id_search}'; |
|
177 | + } |
|
174 | 178 | |
175 | 179 | $count = 0; |
176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
177 | - foreach ($words['words'] as $regularWord) |
|
180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
181 | + foreach ($words['words'] as $regularWord) |
|
178 | 182 | { |
179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
184 | + } |
|
180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
181 | 186 | } |
182 | 187 | |
183 | - if ($query_params['user_query']) |
|
184 | - $query_where[] = '{raw:user_query}'; |
|
185 | - if ($query_params['board_query']) |
|
186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
188 | + if ($query_params['user_query']) { |
|
189 | + $query_where[] = '{raw:user_query}'; |
|
190 | + } |
|
191 | + if ($query_params['board_query']) { |
|
192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
193 | + } |
|
187 | 194 | |
188 | - if ($query_params['topic']) |
|
189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
190 | - if ($query_params['min_msg_id']) |
|
191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
192 | - if ($query_params['max_msg_id']) |
|
193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
195 | + if ($query_params['topic']) { |
|
196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
197 | + } |
|
198 | + if ($query_params['min_msg_id']) { |
|
199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
200 | + } |
|
201 | + if ($query_params['max_msg_id']) { |
|
202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | $count = 0; |
196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
198 | 208 | { |
199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
210 | + } |
|
200 | 211 | $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), '\\\'') . '[[:>:]]'; |
201 | 212 | } |
202 | 213 | $count = 0; |
203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
205 | 216 | { |
206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
218 | + } |
|
207 | 219 | $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), '\\\'') . '[[:>:]]'; |
208 | 220 | } |
209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
215 | 227 | |
216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
217 | 229 | $query_params['language_ftx'] = $language_ftx; |
230 | + } else { |
|
231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 232 | } |
219 | - else |
|
220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
222 | - } |
|
223 | - else |
|
234 | + } else |
|
224 | 235 | { |
225 | 236 | $query_params['boolean_match'] = ''; |
226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
235 | 246 | $row++; |
236 | 247 | } |
237 | - } |
|
238 | - else |
|
239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
248 | + } else { |
|
249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
251 | + } |
|
241 | 252 | |
242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
249 | 260 | |
250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
251 | 262 | $query_params['language_ftx'] = $language_ftx; |
263 | + } else { |
|
264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 265 | } |
253 | - else |
|
254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
255 | 266 | } |
256 | 267 | |
257 | 268 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
257 | 257 | |
258 | 258 | $js_time_string = str_replace( |
259 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
259 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
261 | 261 | $time_string |
262 | 262 | ); |
263 | 263 | |
@@ -1305,14 +1305,14 @@ discard block |
||
1305 | 1305 | if (isset($context['name']) && isset($context['email'])) |
1306 | 1306 | { |
1307 | 1307 | $context['posting_fields']['guestname'] = array( |
1308 | - 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1308 | + 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1309 | 1309 | 'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>', |
1310 | 1310 | ); |
1311 | 1311 | |
1312 | 1312 | if (empty($modSettings['guest_post_no_email'])) |
1313 | 1313 | { |
1314 | 1314 | $context['posting_fields']['email'] = array( |
1315 | - 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1315 | + 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1316 | 1316 | 'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>', |
1317 | 1317 | ); |
1318 | 1318 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
55 | 58 | |
56 | 59 | // You must be posting to *some* board. |
57 | - if (empty($board) && !$context['make_event']) |
|
58 | - fatal_lang_error('no_board', false); |
|
60 | + if (empty($board) && !$context['make_event']) { |
|
61 | + fatal_lang_error('no_board', false); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
78 | 82 | array( |
79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
80 | 84 | )); |
81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
83 | - else |
|
84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
87 | + } else { |
|
88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
89 | + } |
|
85 | 90 | $smcFunc['db_free_result']($request); |
86 | 91 | } |
87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | 115 | // If this topic already has a poll, they sure can't add another. |
111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
112 | - unset($_REQUEST['poll']); |
|
116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
117 | + unset($_REQUEST['poll']); |
|
118 | + } |
|
113 | 119 | |
114 | 120 | if (empty($_REQUEST['msg'])) |
115 | 121 | { |
116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
117 | - is_not_guest(); |
|
122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
123 | + is_not_guest(); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | // By default the reply will be approved... |
120 | 127 | $context['becomes_approved'] = true; |
121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
122 | 129 | { |
123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
124 | - $context['becomes_approved'] = false; |
|
125 | - else |
|
126 | - isAllowedTo('post_reply_any'); |
|
127 | - } |
|
128 | - elseif (!allowedTo('post_reply_any')) |
|
130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
131 | + $context['becomes_approved'] = false; |
|
132 | + } else { |
|
133 | + isAllowedTo('post_reply_any'); |
|
134 | + } |
|
135 | + } elseif (!allowedTo('post_reply_any')) |
|
129 | 136 | { |
130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
131 | - $context['becomes_approved'] = false; |
|
132 | - else |
|
133 | - isAllowedTo('post_reply_own'); |
|
137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
138 | + $context['becomes_approved'] = false; |
|
139 | + } else { |
|
140 | + isAllowedTo('post_reply_own'); |
|
141 | + } |
|
134 | 142 | } |
143 | + } else { |
|
144 | + $context['becomes_approved'] = true; |
|
135 | 145 | } |
136 | - else |
|
137 | - $context['becomes_approved'] = true; |
|
138 | 146 | |
139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
147 | 155 | |
148 | 156 | // Check whether this is a really old post being bumped... |
149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
151 | - } |
|
152 | - else |
|
157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
159 | + } |
|
160 | + } else |
|
153 | 161 | { |
154 | 162 | $context['becomes_approved'] = true; |
155 | 163 | if ((!$context['make_event'] || !empty($board))) |
156 | 164 | { |
157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
158 | - $context['becomes_approved'] = false; |
|
159 | - else |
|
160 | - isAllowedTo('post_new'); |
|
165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
166 | + $context['becomes_approved'] = false; |
|
167 | + } else { |
|
168 | + isAllowedTo('post_new'); |
|
169 | + } |
|
161 | 170 | } |
162 | 171 | |
163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
193 | 202 | } |
194 | 203 | |
195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
196 | - if ($locked && !allowedTo('moderate_board')) |
|
197 | - fatal_lang_error('topic_locked', false); |
|
205 | + if ($locked && !allowedTo('moderate_board')) { |
|
206 | + fatal_lang_error('topic_locked', false); |
|
207 | + } |
|
198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
200 | 210 | { |
201 | 211 | // New topic, new poll. |
202 | - if (empty($topic)) |
|
203 | - isAllowedTo('poll_post'); |
|
212 | + if (empty($topic)) { |
|
213 | + isAllowedTo('poll_post'); |
|
214 | + } |
|
204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
206 | - isAllowedTo('poll_add_own'); |
|
216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
217 | + isAllowedTo('poll_add_own'); |
|
218 | + } |
|
207 | 219 | // If you're not the owner, can you add to any poll? |
208 | - else |
|
209 | - isAllowedTo('poll_add_any'); |
|
220 | + else { |
|
221 | + isAllowedTo('poll_add_any'); |
|
222 | + } |
|
210 | 223 | |
211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
235 | 248 | if ($context['make_event']) |
236 | 249 | { |
237 | 250 | // They might want to pick a board. |
238 | - if (!isset($context['current_board'])) |
|
239 | - $context['current_board'] = 0; |
|
251 | + if (!isset($context['current_board'])) { |
|
252 | + $context['current_board'] = 0; |
|
253 | + } |
|
240 | 254 | |
241 | 255 | // Start loading up the event info. |
242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
250 | 264 | isAllowedTo('calendar_post'); |
251 | 265 | |
252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
254 | - $time_string = '%k:%M'; |
|
255 | - else |
|
256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
268 | + $time_string = '%k:%M'; |
|
269 | + } else { |
|
270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
271 | + } |
|
257 | 272 | |
258 | 273 | $js_time_string = str_replace( |
259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
278 | - } |
|
279 | - else |
|
293 | + } else |
|
280 | 294 | { |
281 | 295 | // Get the current event information. |
282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
285 | 299 | |
286 | 300 | // Make sure the year and month are in the valid range. |
287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
288 | - fatal_lang_error('invalid_month', false); |
|
289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
290 | - fatal_lang_error('invalid_year', false); |
|
301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
302 | + fatal_lang_error('invalid_month', false); |
|
303 | + } |
|
304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
305 | + fatal_lang_error('invalid_year', false); |
|
306 | + } |
|
291 | 307 | |
292 | 308 | // Get a list of boards they can post in. |
293 | 309 | $boards = boardsAllowedTo('post_new'); |
294 | - if (empty($boards)) |
|
295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
310 | + if (empty($boards)) { |
|
311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
312 | + } |
|
296 | 313 | |
297 | 314 | // Load a list of boards for this event in the context. |
298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
411 | 428 | |
412 | 429 | if (!empty($context['new_replies'])) |
413 | 430 | { |
414 | - if ($context['new_replies'] == 1) |
|
415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
416 | - else |
|
417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
431 | + if ($context['new_replies'] == 1) { |
|
432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
433 | + } else { |
|
434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | $post_errors[] = 'new_replies'; |
420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
428 | 446 | { |
429 | - if ($language === $user_info['language']) |
|
430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
431 | - else |
|
447 | + if ($language === $user_info['language']) { |
|
448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
449 | + } else |
|
432 | 450 | { |
433 | 451 | loadLanguage('index', $language, false); |
434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
441 | 459 | // Do we have a body, but an error happened. |
442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
443 | 461 | { |
444 | - if (isset($_REQUEST['quickReply'])) |
|
445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
462 | + if (isset($_REQUEST['quickReply'])) { |
|
463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
464 | + } |
|
446 | 465 | |
447 | 466 | // Validate inputs. |
448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
450 | 469 | // This means they didn't click Post and get an error. |
451 | 470 | $really_previewing = true; |
452 | 471 | |
453 | - } |
|
454 | - else |
|
472 | + } else |
|
455 | 473 | { |
456 | - if (!isset($_REQUEST['subject'])) |
|
457 | - $_REQUEST['subject'] = ''; |
|
458 | - if (!isset($_REQUEST['message'])) |
|
459 | - $_REQUEST['message'] = ''; |
|
460 | - if (!isset($_REQUEST['icon'])) |
|
461 | - $_REQUEST['icon'] = 'xx'; |
|
474 | + if (!isset($_REQUEST['subject'])) { |
|
475 | + $_REQUEST['subject'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['message'])) { |
|
478 | + $_REQUEST['message'] = ''; |
|
479 | + } |
|
480 | + if (!isset($_REQUEST['icon'])) { |
|
481 | + $_REQUEST['icon'] = 'xx'; |
|
482 | + } |
|
462 | 483 | |
463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
475 | 496 | |
476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if (isset($_REQUEST['poll'])) |
481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
488 | 510 | foreach ($_POST['options'] as $option) |
489 | 511 | { |
490 | - if (trim($option) == '') |
|
491 | - continue; |
|
512 | + if (trim($option) == '') { |
|
513 | + continue; |
|
514 | + } |
|
492 | 515 | |
493 | 516 | $context['choices'][] = array( |
494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
550 | 573 | $context['preview_subject'] = $form_subject; |
551 | 574 | |
552 | 575 | censorText($context['preview_subject']); |
576 | + } else { |
|
577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 578 | } |
554 | - else |
|
555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
556 | 579 | |
557 | 580 | // Protect any CDATA blocks. |
558 | - if (isset($_REQUEST['xml'])) |
|
559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
581 | + if (isset($_REQUEST['xml'])) { |
|
582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
599 | - fatal_lang_error('no_board', false); |
|
622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
623 | + fatal_lang_error('no_board', false); |
|
624 | + } |
|
600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
601 | 626 | |
602 | 627 | $attachment_stuff = array($row); |
603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
604 | - $attachment_stuff[] = $row2; |
|
628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
629 | + $attachment_stuff[] = $row2; |
|
630 | + } |
|
605 | 631 | $smcFunc['db_free_result']($request); |
606 | 632 | |
607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
608 | 634 | { |
609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
611 | - fatal_lang_error('modify_post_time_passed', false); |
|
612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
613 | - isAllowedTo('modify_replies'); |
|
614 | - else |
|
615 | - isAllowedTo('modify_own'); |
|
636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
637 | + fatal_lang_error('modify_post_time_passed', false); |
|
638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
639 | + isAllowedTo('modify_replies'); |
|
640 | + } else { |
|
641 | + isAllowedTo('modify_own'); |
|
642 | + } |
|
643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
644 | + isAllowedTo('modify_replies'); |
|
645 | + } else { |
|
646 | + isAllowedTo('modify_any'); |
|
616 | 647 | } |
617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
618 | - isAllowedTo('modify_replies'); |
|
619 | - else |
|
620 | - isAllowedTo('modify_any'); |
|
621 | 648 | |
622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
641 | 668 | |
642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
643 | 670 | { |
644 | - if ($row['filesize'] <= 0) |
|
645 | - continue; |
|
671 | + if ($row['filesize'] <= 0) { |
|
672 | + continue; |
|
673 | + } |
|
646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
712 | 740 | ) |
713 | 741 | ); |
714 | 742 | // The message they were trying to edit was most likely deleted. |
715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
716 | - fatal_lang_error('no_message', false); |
|
743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
744 | + fatal_lang_error('no_message', false); |
|
745 | + } |
|
717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
718 | 747 | |
719 | 748 | $attachment_stuff = array($row); |
720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
721 | - $attachment_stuff[] = $row2; |
|
749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
750 | + $attachment_stuff[] = $row2; |
|
751 | + } |
|
722 | 752 | $smcFunc['db_free_result']($request); |
723 | 753 | |
724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
725 | 755 | { |
726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
728 | - fatal_lang_error('modify_post_time_passed', false); |
|
729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
730 | - isAllowedTo('modify_replies'); |
|
731 | - else |
|
732 | - isAllowedTo('modify_own'); |
|
757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
758 | + fatal_lang_error('modify_post_time_passed', false); |
|
759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
760 | + isAllowedTo('modify_replies'); |
|
761 | + } else { |
|
762 | + isAllowedTo('modify_own'); |
|
763 | + } |
|
764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
765 | + isAllowedTo('modify_replies'); |
|
766 | + } else { |
|
767 | + isAllowedTo('modify_any'); |
|
733 | 768 | } |
734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
735 | - isAllowedTo('modify_replies'); |
|
736 | - else |
|
737 | - isAllowedTo('modify_any'); |
|
738 | 769 | |
739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
761 | 792 | $context['icon'] = $row['icon']; |
762 | 793 | |
763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
764 | - if (!$row['approved'] && !$context['show_approval']) |
|
765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
797 | + } |
|
766 | 798 | |
767 | 799 | // Sort the attachments so they are in the order saved |
768 | 800 | $temp = array(); |
769 | 801 | foreach ($attachment_stuff as $attachment) |
770 | 802 | { |
771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
772 | - $temp[$attachment['id_attach']] = $attachment; |
|
803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
804 | + $temp[$attachment['id_attach']] = $attachment; |
|
805 | + } |
|
773 | 806 | |
774 | 807 | } |
775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
831 | 864 | 'is_approved' => 1, |
832 | 865 | ) |
833 | 866 | ); |
834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
835 | - fatal_lang_error('quoted_post_deleted', false); |
|
867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
868 | + fatal_lang_error('quoted_post_deleted', false); |
|
869 | + } |
|
836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
837 | 871 | $smcFunc['db_free_result']($request); |
838 | 872 | |
839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
876 | + } |
|
842 | 877 | |
843 | 878 | // Censor the message and subject. |
844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
852 | 887 | { |
853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
854 | - if ($i % 4 == 0) |
|
855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
889 | + if ($i % 4 == 0) { |
|
890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
856 | 891 | { |
857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
893 | + } |
|
858 | 894 | }, $parts[$i]); |
859 | 895 | } |
860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
864 | 900 | |
865 | 901 | // Remove any nested quotes, if necessary. |
866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
904 | + } |
|
868 | 905 | |
869 | 906 | // Add a quote string on the front and end. |
870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
876 | 913 | $form_subject = $first_subject; |
877 | 914 | |
878 | 915 | // Add 'Re: ' to the front of the subject. |
879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
918 | + } |
|
881 | 919 | |
882 | 920 | // Censor the subject. |
883 | 921 | censorText($form_subject); |
884 | 922 | |
885 | 923 | $form_message = ''; |
886 | - } |
|
887 | - else |
|
924 | + } else |
|
888 | 925 | { |
889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
902 | 939 | if (isset($_REQUEST['msg'])) |
903 | 940 | { |
904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
905 | - foreach ($context['current_attachments'] as $attachment) |
|
906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
942 | + foreach ($context['current_attachments'] as $attachment) { |
|
943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
944 | + } |
|
907 | 945 | } |
908 | 946 | |
909 | 947 | // A bit of house keeping first. |
910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
911 | - unset($_SESSION['temp_attachments']); |
|
948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
949 | + unset($_SESSION['temp_attachments']); |
|
950 | + } |
|
912 | 951 | |
913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
917 | 956 | { |
918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
919 | 958 | { |
920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
921 | - if (file_exists($attachment['tmp_name'])) |
|
959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
960 | + if (file_exists($attachment['tmp_name'])) |
|
922 | 961 | unlink($attachment['tmp_name']); |
962 | + } |
|
923 | 963 | } |
924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
935 | 975 | { |
936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
937 | - continue; |
|
976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
977 | + continue; |
|
978 | + } |
|
938 | 979 | |
939 | 980 | if (file_exists($attachment['tmp_name'])) |
940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
944 | 985 | break; |
945 | 986 | } |
946 | 987 | } |
947 | - } |
|
948 | - else |
|
988 | + } else |
|
949 | 989 | { |
950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
951 | - if (!empty($topic)) |
|
952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
953 | - else |
|
954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
991 | + if (!empty($topic)) { |
|
992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
993 | + } else { |
|
994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
995 | + } |
|
955 | 996 | |
956 | 997 | // Compile a list of the files to show the user. |
957 | 998 | $file_list = array(); |
958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
960 | 1001 | $file_list[] = $attachment['name']; |
1002 | + } |
|
961 | 1003 | |
962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
969 | 1011 | |
970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
971 | 1013 | $context['ignore_temp_attachments'] = true; |
972 | - } |
|
973 | - else |
|
1014 | + } else |
|
974 | 1015 | { |
975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
978 | 1019 | } |
979 | 1020 | } |
980 | 1021 | |
981 | - if (!empty($context['we_are_history'])) |
|
982 | - $post_errors[] = $context['we_are_history']; |
|
1022 | + if (!empty($context['we_are_history'])) { |
|
1023 | + $post_errors[] = $context['we_are_history']; |
|
1024 | + } |
|
983 | 1025 | |
984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
985 | 1027 | { |
986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
987 | - break; |
|
1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1029 | + break; |
|
1030 | + } |
|
988 | 1031 | |
989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
990 | - continue; |
|
1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1033 | + continue; |
|
1034 | + } |
|
991 | 1035 | |
992 | 1036 | if ($attachID == 'initial_error') |
993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
1002 | 1046 | { |
1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1005 | - foreach ($attachment['errors'] as $error) |
|
1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1049 | + foreach ($attachment['errors'] as $error) { |
|
1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1051 | + } |
|
1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
1008 | 1053 | $post_errors[] = 'attach_errors'; |
1009 | 1054 | |
1010 | 1055 | // Take out the trash. |
1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
1012 | - if (file_exists($attachment['tmp_name'])) |
|
1013 | - unlink($attachment['tmp_name']); |
|
1057 | + if (file_exists($attachment['tmp_name'])) { |
|
1058 | + unlink($attachment['tmp_name']); |
|
1059 | + } |
|
1014 | 1060 | continue; |
1015 | 1061 | } |
1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
1023 | 1069 | |
1024 | 1070 | $context['attachments']['quantity']++; |
1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
1026 | - if (!isset($context['files_in_session_warning'])) |
|
1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1072 | + if (!isset($context['files_in_session_warning'])) { |
|
1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1074 | + } |
|
1028 | 1075 | |
1029 | 1076 | $context['current_attachments'][$attachID] = array( |
1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
1052 | 1099 | } |
1053 | 1100 | |
1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1056 | - $post_errors[] = 'need_qr_verification'; |
|
1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1103 | + $post_errors[] = 'need_qr_verification'; |
|
1104 | + } |
|
1057 | 1105 | |
1058 | 1106 | /* |
1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
1070 | 1118 | { |
1071 | 1119 | loadLanguage('Errors'); |
1072 | 1120 | $context['error_type'] = 'minor'; |
1073 | - foreach ($post_errors as $post_error) |
|
1074 | - if (is_array($post_error)) |
|
1121 | + foreach ($post_errors as $post_error) { |
|
1122 | + if (is_array($post_error)) |
|
1075 | 1123 | { |
1076 | 1124 | $post_error_id = $post_error[0]; |
1125 | + } |
|
1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1078 | 1127 | |
1079 | 1128 | // If it's not a minor error flag it as such. |
1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
1081 | - $context['error_type'] = 'serious'; |
|
1082 | - } |
|
1083 | - else |
|
1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1130 | + $context['error_type'] = 'serious'; |
|
1131 | + } |
|
1132 | + } else |
|
1084 | 1133 | { |
1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1086 | 1135 | |
1087 | 1136 | // If it's not a minor error flag it as such. |
1088 | - if (!in_array($post_error, $minor_errors)) |
|
1089 | - $context['error_type'] = 'serious'; |
|
1137 | + if (!in_array($post_error, $minor_errors)) { |
|
1138 | + $context['error_type'] = 'serious'; |
|
1139 | + } |
|
1090 | 1140 | } |
1091 | 1141 | } |
1092 | 1142 | |
1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1094 | - if (isset($_REQUEST['poll'])) |
|
1095 | - $context['page_title'] = $txt['new_poll']; |
|
1096 | - elseif ($context['make_event']) |
|
1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1098 | - elseif (isset($_REQUEST['msg'])) |
|
1099 | - $context['page_title'] = $txt['modify_msg']; |
|
1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1102 | - elseif (empty($topic)) |
|
1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
1104 | - else |
|
1105 | - $context['page_title'] = $txt['post_reply']; |
|
1144 | + if (isset($_REQUEST['poll'])) { |
|
1145 | + $context['page_title'] = $txt['new_poll']; |
|
1146 | + } elseif ($context['make_event']) { |
|
1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
1149 | + $context['page_title'] = $txt['modify_msg']; |
|
1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1152 | + } elseif (empty($topic)) { |
|
1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
1154 | + } else { |
|
1155 | + $context['page_title'] = $txt['post_reply']; |
|
1156 | + } |
|
1106 | 1157 | |
1107 | 1158 | // Build the link tree. |
1108 | - if (empty($topic)) |
|
1109 | - $context['linktree'][] = array( |
|
1159 | + if (empty($topic)) { |
|
1160 | + $context['linktree'][] = array( |
|
1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1111 | 1162 | ); |
1112 | - else |
|
1113 | - $context['linktree'][] = array( |
|
1163 | + } else { |
|
1164 | + $context['linktree'][] = array( |
|
1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1115 | 1166 | 'name' => $form_subject, |
1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1118 | 1169 | ); |
1170 | + } |
|
1119 | 1171 | |
1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
1159 | 1211 | // Message icons - customized icons are off? |
1160 | 1212 | $context['icons'] = getMessageIcons($board); |
1161 | 1213 | |
1162 | - if (!empty($context['icons'])) |
|
1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1214 | + if (!empty($context['icons'])) { |
|
1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1216 | + } |
|
1164 | 1217 | |
1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1181 | 1234 | { |
1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1183 | - if ($context['icons'][$i]['selected']) |
|
1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1236 | + if ($context['icons'][$i]['selected']) { |
|
1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1238 | + } |
|
1185 | 1239 | } |
1186 | 1240 | if (empty($context['icon_url'])) |
1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
1195 | 1249 | )); |
1196 | 1250 | } |
1197 | 1251 | |
1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1199 | - getTopic(); |
|
1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1253 | + getTopic(); |
|
1254 | + } |
|
1200 | 1255 | |
1201 | 1256 | // If the user can post attachments prepare the warning labels. |
1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
1207 | 1262 | $context['attachment_restrictions'] = array(); |
1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
1211 | - if (!empty($modSettings[$type])) |
|
1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1266 | + if (!empty($modSettings[$type])) |
|
1212 | 1267 | { |
1213 | 1268 | // Show the max number of attachments if not 0. |
1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1271 | + } |
|
1216 | 1272 | } |
1217 | 1273 | } |
1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
1246 | 1302 | |
1247 | 1303 | if (!empty($context['current_attachments'])) |
1248 | 1304 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1306 | + addInlineJavaScript(' |
|
1251 | 1307 | current_attachments.push({ |
1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1314 | });', true); |
1315 | + } |
|
1259 | 1316 | } |
1260 | 1317 | |
1261 | 1318 | // File Upload. |
@@ -1340,8 +1397,9 @@ discard block |
||
1340 | 1397 | |
1341 | 1398 | |
1342 | 1399 | // Finally, load the template. |
1343 | - if (!isset($_REQUEST['xml'])) |
|
1344 | - loadTemplate('Post'); |
|
1400 | + if (!isset($_REQUEST['xml'])) { |
|
1401 | + loadTemplate('Post'); |
|
1402 | + } |
|
1345 | 1403 | |
1346 | 1404 | call_integration_hook('integrate_post_end'); |
1347 | 1405 | } |
@@ -1362,13 +1420,14 @@ discard block |
||
1362 | 1420 | // Sneaking off, are we? |
1363 | 1421 | if (empty($_POST) && empty($topic)) |
1364 | 1422 | { |
1365 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1366 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1367 | - else |
|
1368 | - fatal_lang_error('post_upload_error', false); |
|
1423 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1424 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1425 | + } else { |
|
1426 | + fatal_lang_error('post_upload_error', false); |
|
1427 | + } |
|
1428 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1429 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1369 | 1430 | } |
1370 | - elseif (empty($_POST) && !empty($topic)) |
|
1371 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1372 | 1431 | |
1373 | 1432 | // No need! |
1374 | 1433 | $context['robot_no_index'] = true; |
@@ -1380,8 +1439,9 @@ discard block |
||
1380 | 1439 | $post_errors = array(); |
1381 | 1440 | |
1382 | 1441 | // If the session has timed out, let the user re-submit their form. |
1383 | - if (checkSession('post', '', false) != '') |
|
1384 | - $post_errors[] = 'session_timeout'; |
|
1442 | + if (checkSession('post', '', false) != '') { |
|
1443 | + $post_errors[] = 'session_timeout'; |
|
1444 | + } |
|
1385 | 1445 | |
1386 | 1446 | // Wrong verification code? |
1387 | 1447 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1391,33 +1451,38 @@ discard block |
||
1391 | 1451 | 'id' => 'post', |
1392 | 1452 | ); |
1393 | 1453 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1394 | - if (is_array($context['require_verification'])) |
|
1395 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1454 | + if (is_array($context['require_verification'])) { |
|
1455 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1456 | + } |
|
1396 | 1457 | } |
1397 | 1458 | |
1398 | 1459 | require_once($sourcedir . '/Subs-Post.php'); |
1399 | 1460 | loadLanguage('Post'); |
1400 | 1461 | |
1401 | 1462 | // Drafts enabled and needed? |
1402 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1403 | - require_once($sourcedir . '/Drafts.php'); |
|
1463 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1464 | + require_once($sourcedir . '/Drafts.php'); |
|
1465 | + } |
|
1404 | 1466 | |
1405 | 1467 | // First check to see if they are trying to delete any current attachments. |
1406 | 1468 | if (isset($_POST['attach_del'])) |
1407 | 1469 | { |
1408 | 1470 | $keep_temp = array(); |
1409 | 1471 | $keep_ids = array(); |
1410 | - foreach ($_POST['attach_del'] as $dummy) |
|
1411 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1472 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1473 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1412 | 1474 | $keep_temp[] = $dummy; |
1413 | - else |
|
1414 | - $keep_ids[] = (int) $dummy; |
|
1475 | + } |
|
1476 | + else { |
|
1477 | + $keep_ids[] = (int) $dummy; |
|
1478 | + } |
|
1415 | 1479 | |
1416 | - if (isset($_SESSION['temp_attachments'])) |
|
1417 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1480 | + if (isset($_SESSION['temp_attachments'])) { |
|
1481 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1418 | 1482 | { |
1419 | 1483 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1420 | 1484 | continue; |
1485 | + } |
|
1421 | 1486 | |
1422 | 1487 | unset($_SESSION['temp_attachments'][$attachID]); |
1423 | 1488 | unlink($attachment['tmp_name']); |
@@ -1459,12 +1524,14 @@ discard block |
||
1459 | 1524 | $smcFunc['db_free_result']($request); |
1460 | 1525 | |
1461 | 1526 | // Though the topic should be there, it might have vanished. |
1462 | - if (!is_array($topic_info)) |
|
1463 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1527 | + if (!is_array($topic_info)) { |
|
1528 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1529 | + } |
|
1464 | 1530 | |
1465 | 1531 | // Did this topic suddenly move? Just checking... |
1466 | - if ($topic_info['id_board'] != $board) |
|
1467 | - fatal_lang_error('not_a_topic'); |
|
1532 | + if ($topic_info['id_board'] != $board) { |
|
1533 | + fatal_lang_error('not_a_topic'); |
|
1534 | + } |
|
1468 | 1535 | |
1469 | 1536 | // Do the permissions and approval stuff... |
1470 | 1537 | $becomesApproved = true; |
@@ -1487,49 +1554,50 @@ discard block |
||
1487 | 1554 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1488 | 1555 | { |
1489 | 1556 | // Don't allow a post if it's locked. |
1490 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1491 | - fatal_lang_error('topic_locked', false); |
|
1557 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1558 | + fatal_lang_error('topic_locked', false); |
|
1559 | + } |
|
1492 | 1560 | |
1493 | 1561 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1494 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1495 | - unset($_REQUEST['poll']); |
|
1496 | - |
|
1497 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1498 | - { |
|
1499 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1500 | - $becomesApproved = false; |
|
1501 | - |
|
1502 | - else |
|
1503 | - isAllowedTo('post_reply_any'); |
|
1504 | - } |
|
1505 | - elseif (!allowedTo('post_reply_any')) |
|
1562 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1563 | + unset($_REQUEST['poll']); |
|
1564 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1565 | + { |
|
1566 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1567 | + $becomesApproved = false; |
|
1568 | + } else { |
|
1569 | + isAllowedTo('post_reply_any'); |
|
1570 | + } |
|
1571 | + } elseif (!allowedTo('post_reply_any')) |
|
1506 | 1572 | { |
1507 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1508 | - $becomesApproved = false; |
|
1509 | - |
|
1510 | - else |
|
1511 | - isAllowedTo('post_reply_own'); |
|
1573 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1574 | + $becomesApproved = false; |
|
1575 | + } else { |
|
1576 | + isAllowedTo('post_reply_own'); |
|
1577 | + } |
|
1512 | 1578 | } |
1513 | 1579 | |
1514 | 1580 | if (isset($_POST['lock'])) |
1515 | 1581 | { |
1516 | 1582 | // Nothing is changed to the lock. |
1517 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1518 | - unset($_POST['lock']); |
|
1583 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1584 | + unset($_POST['lock']); |
|
1585 | + } |
|
1519 | 1586 | |
1520 | 1587 | // You're have no permission to lock this topic. |
1521 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1522 | - unset($_POST['lock']); |
|
1588 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1589 | + unset($_POST['lock']); |
|
1590 | + } |
|
1523 | 1591 | |
1524 | 1592 | // You are allowed to (un)lock your own topic only. |
1525 | 1593 | elseif (!allowedTo('lock_any')) |
1526 | 1594 | { |
1527 | 1595 | // You cannot override a moderator lock. |
1528 | - if ($topic_info['locked'] == 1) |
|
1529 | - unset($_POST['lock']); |
|
1530 | - |
|
1531 | - else |
|
1532 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1596 | + if ($topic_info['locked'] == 1) { |
|
1597 | + unset($_POST['lock']); |
|
1598 | + } else { |
|
1599 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1600 | + } |
|
1533 | 1601 | } |
1534 | 1602 | // Hail mighty moderator, (un)lock this topic immediately. |
1535 | 1603 | else |
@@ -1537,19 +1605,21 @@ discard block |
||
1537 | 1605 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1538 | 1606 | |
1539 | 1607 | // Did someone (un)lock this while you were posting? |
1540 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1541 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1608 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1609 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1610 | + } |
|
1542 | 1611 | } |
1543 | 1612 | } |
1544 | 1613 | |
1545 | 1614 | // So you wanna (un)sticky this...let's see. |
1546 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1547 | - unset($_POST['sticky']); |
|
1548 | - elseif (isset($_POST['sticky'])) |
|
1615 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1616 | + unset($_POST['sticky']); |
|
1617 | + } elseif (isset($_POST['sticky'])) |
|
1549 | 1618 | { |
1550 | 1619 | // Did someone (un)sticky this while you were posting? |
1551 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1552 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1620 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1621 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1622 | + } |
|
1553 | 1623 | } |
1554 | 1624 | |
1555 | 1625 | // If drafts are enabled, then pass this off |
@@ -1576,26 +1646,31 @@ discard block |
||
1576 | 1646 | |
1577 | 1647 | // Do like, the permissions, for safety and stuff... |
1578 | 1648 | $becomesApproved = true; |
1579 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1580 | - $becomesApproved = false; |
|
1581 | - else |
|
1582 | - isAllowedTo('post_new'); |
|
1649 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1650 | + $becomesApproved = false; |
|
1651 | + } else { |
|
1652 | + isAllowedTo('post_new'); |
|
1653 | + } |
|
1583 | 1654 | |
1584 | 1655 | if (isset($_POST['lock'])) |
1585 | 1656 | { |
1586 | 1657 | // New topics are by default not locked. |
1587 | - if (empty($_POST['lock'])) |
|
1588 | - unset($_POST['lock']); |
|
1658 | + if (empty($_POST['lock'])) { |
|
1659 | + unset($_POST['lock']); |
|
1660 | + } |
|
1589 | 1661 | // Besides, you need permission. |
1590 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1591 | - unset($_POST['lock']); |
|
1662 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1663 | + unset($_POST['lock']); |
|
1664 | + } |
|
1592 | 1665 | // A moderator-lock (1) can override a user-lock (2). |
1593 | - else |
|
1594 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1666 | + else { |
|
1667 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1668 | + } |
|
1595 | 1669 | } |
1596 | 1670 | |
1597 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1598 | - unset($_POST['sticky']); |
|
1671 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1672 | + unset($_POST['sticky']); |
|
1673 | + } |
|
1599 | 1674 | |
1600 | 1675 | // Saving your new topic as a draft first? |
1601 | 1676 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1620,31 +1695,37 @@ discard block |
||
1620 | 1695 | 'id_msg' => $_REQUEST['msg'], |
1621 | 1696 | ) |
1622 | 1697 | ); |
1623 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1624 | - fatal_lang_error('cant_find_messages', false); |
|
1698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1699 | + fatal_lang_error('cant_find_messages', false); |
|
1700 | + } |
|
1625 | 1701 | $row = $smcFunc['db_fetch_assoc']($request); |
1626 | 1702 | $smcFunc['db_free_result']($request); |
1627 | 1703 | |
1628 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1629 | - fatal_lang_error('topic_locked', false); |
|
1704 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1705 | + fatal_lang_error('topic_locked', false); |
|
1706 | + } |
|
1630 | 1707 | |
1631 | 1708 | if (isset($_POST['lock'])) |
1632 | 1709 | { |
1633 | 1710 | // Nothing changes to the lock status. |
1634 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1635 | - unset($_POST['lock']); |
|
1711 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1712 | + unset($_POST['lock']); |
|
1713 | + } |
|
1636 | 1714 | // You're simply not allowed to (un)lock this. |
1637 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1638 | - unset($_POST['lock']); |
|
1715 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1716 | + unset($_POST['lock']); |
|
1717 | + } |
|
1639 | 1718 | // You're only allowed to lock your own topics. |
1640 | 1719 | elseif (!allowedTo('lock_any')) |
1641 | 1720 | { |
1642 | 1721 | // You're not allowed to break a moderator's lock. |
1643 | - if ($topic_info['locked'] == 1) |
|
1644 | - unset($_POST['lock']); |
|
1722 | + if ($topic_info['locked'] == 1) { |
|
1723 | + unset($_POST['lock']); |
|
1724 | + } |
|
1645 | 1725 | // Lock it with a soft lock or unlock it. |
1646 | - else |
|
1647 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1726 | + else { |
|
1727 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1728 | + } |
|
1648 | 1729 | } |
1649 | 1730 | // You must be the moderator. |
1650 | 1731 | else |
@@ -1652,44 +1733,46 @@ discard block |
||
1652 | 1733 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1653 | 1734 | |
1654 | 1735 | // Did someone (un)lock this while you were posting? |
1655 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1656 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1736 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1737 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1738 | + } |
|
1657 | 1739 | } |
1658 | 1740 | } |
1659 | 1741 | |
1660 | 1742 | // Change the sticky status of this topic? |
1661 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1662 | - unset($_POST['sticky']); |
|
1663 | - elseif (isset($_POST['sticky'])) |
|
1743 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1744 | + unset($_POST['sticky']); |
|
1745 | + } elseif (isset($_POST['sticky'])) |
|
1664 | 1746 | { |
1665 | 1747 | // Did someone (un)sticky this while you were posting? |
1666 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1667 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1748 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1749 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1750 | + } |
|
1668 | 1751 | } |
1669 | 1752 | |
1670 | 1753 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1671 | 1754 | { |
1672 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1673 | - fatal_lang_error('modify_post_time_passed', false); |
|
1674 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1675 | - isAllowedTo('modify_replies'); |
|
1676 | - else |
|
1677 | - isAllowedTo('modify_own'); |
|
1678 | - } |
|
1679 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1755 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1756 | + fatal_lang_error('modify_post_time_passed', false); |
|
1757 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1758 | + isAllowedTo('modify_replies'); |
|
1759 | + } else { |
|
1760 | + isAllowedTo('modify_own'); |
|
1761 | + } |
|
1762 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1680 | 1763 | { |
1681 | 1764 | isAllowedTo('modify_replies'); |
1682 | 1765 | |
1683 | 1766 | // If you're modifying a reply, I say it better be logged... |
1684 | 1767 | $moderationAction = true; |
1685 | - } |
|
1686 | - else |
|
1768 | + } else |
|
1687 | 1769 | { |
1688 | 1770 | isAllowedTo('modify_any'); |
1689 | 1771 | |
1690 | 1772 | // Log it, assuming you're not modifying your own post. |
1691 | - if ($row['id_member'] != $user_info['id']) |
|
1692 | - $moderationAction = true; |
|
1773 | + if ($row['id_member'] != $user_info['id']) { |
|
1774 | + $moderationAction = true; |
|
1775 | + } |
|
1693 | 1776 | } |
1694 | 1777 | |
1695 | 1778 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1729 | 1812 | |
1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1731 | - $post_errors[] = 'no_name'; |
|
1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1733 | - $post_errors[] = 'long_name'; |
|
1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1814 | + $post_errors[] = 'no_name'; |
|
1815 | + } |
|
1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1817 | + $post_errors[] = 'long_name'; |
|
1818 | + } |
|
1734 | 1819 | |
1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
1736 | 1821 | { |
1737 | 1822 | // Only check if they changed it! |
1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1739 | 1824 | { |
1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1741 | - $post_errors[] = 'no_email'; |
|
1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1743 | - $post_errors[] = 'bad_email'; |
|
1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1826 | + $post_errors[] = 'no_email'; |
|
1827 | + } |
|
1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1829 | + $post_errors[] = 'bad_email'; |
|
1830 | + } |
|
1744 | 1831 | } |
1745 | 1832 | |
1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
1756 | 1843 | } |
1757 | 1844 | |
1758 | 1845 | // Coming from the quickReply? |
1759 | - if (isset($_POST['quickReply'])) |
|
1760 | - $_POST['message'] = $_POST['quickReply']; |
|
1846 | + if (isset($_POST['quickReply'])) { |
|
1847 | + $_POST['message'] = $_POST['quickReply']; |
|
1848 | + } |
|
1761 | 1849 | |
1762 | 1850 | // Check the subject and message. |
1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1764 | - $post_errors[] = 'no_subject'; |
|
1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1766 | - $post_errors[] = 'no_message'; |
|
1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1769 | - else |
|
1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1852 | + $post_errors[] = 'no_subject'; |
|
1853 | + } |
|
1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1855 | + $post_errors[] = 'no_message'; |
|
1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1858 | + } else |
|
1770 | 1859 | { |
1771 | 1860 | // Prepare the message a bit for some additional testing. |
1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1773 | 1862 | |
1774 | 1863 | // Preparse code. (Zef) |
1775 | - if ($user_info['is_guest']) |
|
1776 | - $user_info['name'] = $_POST['guestname']; |
|
1864 | + if ($user_info['is_guest']) { |
|
1865 | + $user_info['name'] = $_POST['guestname']; |
|
1866 | + } |
|
1777 | 1867 | preparsecode($_POST['message']); |
1778 | 1868 | |
1779 | 1869 | // Let's see if there's still some content left without the tags. |
1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1781 | - $post_errors[] = 'no_message'; |
|
1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1871 | + $post_errors[] = 'no_message'; |
|
1872 | + } |
|
1873 | + } |
|
1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1875 | + $post_errors[] = 'no_event'; |
|
1782 | 1876 | } |
1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1784 | - $post_errors[] = 'no_event'; |
|
1785 | 1877 | // You are not! |
1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1880 | + } |
|
1788 | 1881 | |
1789 | 1882 | // Validate the poll... |
1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1791 | 1884 | { |
1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1793 | - fatal_lang_error('no_access', false); |
|
1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1886 | + fatal_lang_error('no_access', false); |
|
1887 | + } |
|
1794 | 1888 | |
1795 | 1889 | // This is a new topic... so it's a new poll. |
1796 | - if (empty($topic)) |
|
1797 | - isAllowedTo('poll_post'); |
|
1890 | + if (empty($topic)) { |
|
1891 | + isAllowedTo('poll_post'); |
|
1892 | + } |
|
1798 | 1893 | // Can you add to your own topics? |
1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1800 | - isAllowedTo('poll_add_own'); |
|
1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1895 | + isAllowedTo('poll_add_own'); |
|
1896 | + } |
|
1801 | 1897 | // Can you add polls to any topic, then? |
1802 | - else |
|
1803 | - isAllowedTo('poll_add_any'); |
|
1898 | + else { |
|
1899 | + isAllowedTo('poll_add_any'); |
|
1900 | + } |
|
1804 | 1901 | |
1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1806 | - $post_errors[] = 'no_question'; |
|
1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1903 | + $post_errors[] = 'no_question'; |
|
1904 | + } |
|
1807 | 1905 | |
1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1809 | 1907 | |
1810 | 1908 | // Get rid of empty ones. |
1811 | - foreach ($_POST['options'] as $k => $option) |
|
1812 | - if ($option == '') |
|
1909 | + foreach ($_POST['options'] as $k => $option) { |
|
1910 | + if ($option == '') |
|
1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1912 | + } |
|
1814 | 1913 | |
1815 | 1914 | // What are you going to vote between with one choice?!? |
1816 | - if (count($_POST['options']) < 2) |
|
1817 | - $post_errors[] = 'poll_few'; |
|
1818 | - elseif (count($_POST['options']) > 256) |
|
1819 | - $post_errors[] = 'poll_many'; |
|
1915 | + if (count($_POST['options']) < 2) { |
|
1916 | + $post_errors[] = 'poll_few'; |
|
1917 | + } elseif (count($_POST['options']) > 256) { |
|
1918 | + $post_errors[] = 'poll_many'; |
|
1919 | + } |
|
1820 | 1920 | } |
1821 | 1921 | |
1822 | 1922 | if ($posterIsGuest) |
1823 | 1923 | { |
1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1827 | - $post_errors[] = 'bad_name'; |
|
1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1927 | + $post_errors[] = 'bad_name'; |
|
1928 | + } |
|
1828 | 1929 | } |
1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
1855 | 1956 | } |
1856 | 1957 | |
1857 | 1958 | // Make sure the user isn't spamming the board. |
1858 | - if (!isset($_REQUEST['msg'])) |
|
1859 | - spamProtection('post'); |
|
1959 | + if (!isset($_REQUEST['msg'])) { |
|
1960 | + spamProtection('post'); |
|
1961 | + } |
|
1860 | 1962 | |
1861 | 1963 | // At about this point, we're posting and that's that. |
1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1870 | 1972 | |
1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1976 | + } |
|
1874 | 1977 | |
1875 | 1978 | // Same with the "why did you edit this" text. |
1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1981 | + } |
|
1878 | 1982 | |
1879 | 1983 | // Make the poll... |
1880 | 1984 | if (isset($_REQUEST['poll'])) |
1881 | 1985 | { |
1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1884 | - $_POST['poll_max_votes'] = 1; |
|
1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1887 | - else |
|
1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1988 | + $_POST['poll_max_votes'] = 1; |
|
1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1991 | + } else { |
|
1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1993 | + } |
|
1889 | 1994 | |
1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1892 | 1997 | |
1893 | 1998 | // Just set it to zero if it's not there.. |
1894 | - if (!isset($_POST['poll_hide'])) |
|
1895 | - $_POST['poll_hide'] = 0; |
|
1896 | - else |
|
1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1999 | + if (!isset($_POST['poll_hide'])) { |
|
2000 | + $_POST['poll_hide'] = 0; |
|
2001 | + } else { |
|
2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2003 | + } |
|
1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1899 | 2005 | |
1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
1903 | 2009 | { |
1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1907 | - $_POST['poll_guest_vote'] = 0; |
|
2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2013 | + $_POST['poll_guest_vote'] = 0; |
|
2014 | + } |
|
1908 | 2015 | } |
1909 | 2016 | |
1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1912 | - fatal_lang_error('poll_range_error', false); |
|
2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2019 | + fatal_lang_error('poll_range_error', false); |
|
2020 | + } |
|
1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1915 | - $_POST['poll_hide'] = 1; |
|
2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2023 | + $_POST['poll_hide'] = 1; |
|
2024 | + } |
|
1916 | 2025 | |
1917 | 2026 | // Clean up the question and answers. |
1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
1926 | 2035 | { |
1927 | 2036 | $attachIDs = array(); |
1928 | 2037 | $attach_errors = array(); |
1929 | - if (!empty($context['we_are_history'])) |
|
1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2038 | + if (!empty($context['we_are_history'])) { |
|
2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2040 | + } |
|
1931 | 2041 | |
1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1933 | 2043 | { |
1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1935 | - continue; |
|
2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2045 | + continue; |
|
2046 | + } |
|
1936 | 2047 | |
1937 | 2048 | // If there was an initial error just show that message. |
1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
1961 | 2072 | if (createAttachment($attachmentOptions)) |
1962 | 2073 | { |
1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
1964 | - if (!empty($attachmentOptions['thumb'])) |
|
1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2077 | + } |
|
1966 | 2078 | } |
2079 | + } else { |
|
2080 | + $attach_errors[] = '<dt> </dt>'; |
|
1967 | 2081 | } |
1968 | - else |
|
1969 | - $attach_errors[] = '<dt> </dt>'; |
|
1970 | 2082 | |
1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
1978 | 2090 | if (!is_array($error)) |
1979 | 2091 | { |
1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1981 | - if (in_array($error, $log_these)) |
|
1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2093 | + if (in_array($error, $log_these)) { |
|
2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2095 | + } |
|
2096 | + } else { |
|
2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1983 | 2098 | } |
1984 | - else |
|
1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1986 | 2099 | } |
1987 | - if (file_exists($attachment['tmp_name'])) |
|
1988 | - unlink($attachment['tmp_name']); |
|
2100 | + if (file_exists($attachment['tmp_name'])) { |
|
2101 | + unlink($attachment['tmp_name']); |
|
2102 | + } |
|
1989 | 2103 | } |
1990 | 2104 | } |
1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
2026 | 2140 | ); |
2027 | 2141 | |
2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2143 | + } else { |
|
2144 | + $id_poll = 0; |
|
2029 | 2145 | } |
2030 | - else |
|
2031 | - $id_poll = 0; |
|
2032 | 2146 | |
2033 | 2147 | // Creating a new topic? |
2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2035 | 2149 | |
2036 | 2150 | // Check the icon. |
2037 | - if (!isset($_POST['icon'])) |
|
2038 | - $_POST['icon'] = 'xx'; |
|
2039 | - |
|
2040 | - else |
|
2151 | + if (!isset($_POST['icon'])) { |
|
2152 | + $_POST['icon'] = 'xx'; |
|
2153 | + } else |
|
2041 | 2154 | { |
2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2043 | 2156 | |
2044 | 2157 | // Need to figure it out if this is a valid icon name. |
2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2046 | - $_POST['icon'] = 'xx'; |
|
2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2159 | + $_POST['icon'] = 'xx'; |
|
2160 | + } |
|
2047 | 2161 | } |
2048 | 2162 | |
2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
2084 | 2198 | } |
2085 | 2199 | |
2086 | 2200 | // This will save some time... |
2087 | - if (empty($approve_has_changed)) |
|
2088 | - unset($msgOptions['approved']); |
|
2201 | + if (empty($approve_has_changed)) { |
|
2202 | + unset($msgOptions['approved']); |
|
2203 | + } |
|
2089 | 2204 | |
2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
2094 | 2209 | { |
2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
2096 | 2211 | |
2097 | - if (isset($topicOptions['id'])) |
|
2098 | - $topic = $topicOptions['id']; |
|
2212 | + if (isset($topicOptions['id'])) { |
|
2213 | + $topic = $topicOptions['id']; |
|
2214 | + } |
|
2099 | 2215 | } |
2100 | 2216 | |
2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
2107 | 2223 | } |
2108 | 2224 | |
2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2111 | - DeleteDraft($_POST['id_draft']); |
|
2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2227 | + DeleteDraft($_POST['id_draft']); |
|
2228 | + } |
|
2112 | 2229 | |
2113 | 2230 | // Editing or posting an event? |
2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
2127 | 2244 | 'member' => $user_info['id'], |
2128 | 2245 | ); |
2129 | 2246 | insertEvent($eventOptions); |
2130 | - } |
|
2131 | - elseif (isset($_POST['calendar'])) |
|
2247 | + } elseif (isset($_POST['calendar'])) |
|
2132 | 2248 | { |
2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
2156 | 2272 | } |
2157 | 2273 | |
2158 | 2274 | // Delete it? |
2159 | - if (isset($_REQUEST['deleteevent'])) |
|
2160 | - $smcFunc['db_query']('', ' |
|
2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
2276 | + $smcFunc['db_query']('', ' |
|
2161 | 2277 | DELETE FROM {db_prefix}calendar |
2162 | 2278 | WHERE id_event = {int:id_event}', |
2163 | 2279 | array( |
2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
2165 | 2281 | ) |
2166 | 2282 | ); |
2283 | + } |
|
2167 | 2284 | // ... or just update it? |
2168 | 2285 | else |
2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
2205 | 2322 | array($user_info['id'], $topic, 0), |
2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
2207 | 2324 | ); |
2208 | - } |
|
2209 | - elseif (!$newTopic) |
|
2210 | - $smcFunc['db_query']('', ' |
|
2325 | + } elseif (!$newTopic) { |
|
2326 | + $smcFunc['db_query']('', ' |
|
2211 | 2327 | DELETE FROM {db_prefix}log_notify |
2212 | 2328 | WHERE id_member = {int:current_member} |
2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
2216 | 2332 | 'current_topic' => $topic, |
2217 | 2333 | ) |
2218 | 2334 | ); |
2335 | + } |
|
2219 | 2336 | |
2220 | 2337 | // Log an act of moderation - modifying. |
2221 | - if (!empty($moderationAction)) |
|
2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2338 | + if (!empty($moderationAction)) { |
|
2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2340 | + } |
|
2223 | 2341 | |
2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2344 | + } |
|
2226 | 2345 | |
2227 | - if (isset($_POST['sticky'])) |
|
2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2346 | + if (isset($_POST['sticky'])) { |
|
2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2348 | + } |
|
2229 | 2349 | |
2230 | 2350 | // Returning to the topic? |
2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
2244 | 2364 | ); |
2245 | 2365 | } |
2246 | 2366 | |
2247 | - if ($board_info['num_topics'] == 0) |
|
2248 | - cache_put_data('board-' . $board, null, 120); |
|
2367 | + if ($board_info['num_topics'] == 0) { |
|
2368 | + cache_put_data('board-' . $board, null, 120); |
|
2369 | + } |
|
2249 | 2370 | |
2250 | 2371 | call_integration_hook('integrate_post2_end'); |
2251 | 2372 | |
2252 | - if (!empty($_POST['announce_topic'])) |
|
2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2373 | + if (!empty($_POST['announce_topic'])) { |
|
2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2375 | + } |
|
2254 | 2376 | |
2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2379 | + } |
|
2257 | 2380 | |
2258 | 2381 | // Return to post if the mod is on. |
2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2261 | - elseif (!empty($_REQUEST['goback'])) |
|
2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2386 | + } |
|
2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2264 | - else |
|
2265 | - redirectexit('board=' . $board . '.0'); |
|
2266 | -} |
|
2388 | + else { |
|
2389 | + redirectexit('board=' . $board . '.0'); |
|
2390 | + } |
|
2391 | + } |
|
2267 | 2392 | |
2268 | 2393 | /** |
2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
2281 | 2406 | |
2282 | 2407 | validateSession(); |
2283 | 2408 | |
2284 | - if (empty($topic)) |
|
2285 | - fatal_lang_error('topic_gone', false); |
|
2409 | + if (empty($topic)) { |
|
2410 | + fatal_lang_error('topic_gone', false); |
|
2411 | + } |
|
2286 | 2412 | |
2287 | 2413 | loadLanguage('Post'); |
2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
2309 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
2310 | 2436 | |
2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
2312 | - foreach ($groups as $id => $group) |
|
2313 | - $groups[$id] = (int) $group; |
|
2438 | + foreach ($groups as $id => $group) { |
|
2439 | + $groups[$id] = (int) $group; |
|
2440 | + } |
|
2314 | 2441 | |
2315 | 2442 | $context['groups'] = array(); |
2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
2353 | 2480 | 'group_list' => $groups, |
2354 | 2481 | ) |
2355 | 2482 | ); |
2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2485 | + } |
|
2358 | 2486 | $smcFunc['db_free_result']($request); |
2359 | 2487 | |
2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
2398 | 2526 | |
2399 | - if (isset($_POST['membergroups'])) |
|
2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2527 | + if (isset($_POST['membergroups'])) { |
|
2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2529 | + } |
|
2401 | 2530 | |
2402 | 2531 | // Check whether at least one membergroup was selected. |
2403 | - if (empty($_POST['who'])) |
|
2404 | - fatal_lang_error('no_membergroup_selected'); |
|
2532 | + if (empty($_POST['who'])) { |
|
2533 | + fatal_lang_error('no_membergroup_selected'); |
|
2534 | + } |
|
2405 | 2535 | |
2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
2407 | - foreach ($_POST['who'] as $id => $mg) |
|
2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2539 | + } |
|
2409 | 2540 | |
2410 | 2541 | // Get the topic subject and censor it. |
2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
2452 | 2583 | { |
2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2456 | - elseif (!empty($_REQUEST['goback'])) |
|
2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2458 | - else |
|
2459 | - redirectexit('board=' . $board . '.0'); |
|
2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2589 | + } else { |
|
2590 | + redirectexit('board=' . $board . '.0'); |
|
2591 | + } |
|
2460 | 2592 | } |
2461 | 2593 | |
2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
2475 | 2607 | foreach ($rows as $row) |
2476 | 2608 | { |
2477 | 2609 | // Force them to have it? |
2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2479 | - continue; |
|
2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2611 | + continue; |
|
2612 | + } |
|
2480 | 2613 | |
2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
2504 | 2637 | } |
2505 | 2638 | |
2506 | 2639 | // For each language send a different mail - low priority... |
2507 | - foreach ($announcements as $lang => $mail) |
|
2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2640 | + foreach ($announcements as $lang => $mail) { |
|
2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2642 | + } |
|
2509 | 2643 | |
2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
2516 | 2650 | |
2517 | 2651 | // Go back to the correct language for the user ;). |
2518 | - if (!empty($modSettings['userLanguage'])) |
|
2519 | - loadLanguage('Post'); |
|
2520 | -} |
|
2652 | + if (!empty($modSettings['userLanguage'])) { |
|
2653 | + loadLanguage('Post'); |
|
2654 | + } |
|
2655 | + } |
|
2521 | 2656 | |
2522 | 2657 | /** |
2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
2530 | 2665 | { |
2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2532 | 2667 | |
2533 | - if (isset($_REQUEST['xml'])) |
|
2534 | - $limit = ' |
|
2668 | + if (isset($_REQUEST['xml'])) { |
|
2669 | + $limit = ' |
|
2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2536 | - else |
|
2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2671 | + } else { |
|
2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2674 | + } |
|
2539 | 2675 | |
2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2574 | 2710 | ); |
2575 | 2711 | |
2576 | - if (!empty($context['new_replies'])) |
|
2577 | - $context['new_replies']--; |
|
2712 | + if (!empty($context['new_replies'])) { |
|
2713 | + $context['new_replies']--; |
|
2714 | + } |
|
2578 | 2715 | } |
2579 | 2716 | $smcFunc['db_free_result']($request); |
2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
2591 | 2728 | global $sourcedir, $smcFunc; |
2592 | 2729 | |
2593 | 2730 | loadLanguage('Post'); |
2594 | - if (!isset($_REQUEST['xml'])) |
|
2595 | - loadTemplate('Post'); |
|
2731 | + if (!isset($_REQUEST['xml'])) { |
|
2732 | + loadTemplate('Post'); |
|
2733 | + } |
|
2596 | 2734 | |
2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
2623 | 2761 | $smcFunc['db_free_result']($request); |
2624 | 2762 | |
2625 | 2763 | $context['sub_template'] = 'quotefast'; |
2626 | - if (!empty($row)) |
|
2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2764 | + if (!empty($row)) { |
|
2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2766 | + } |
|
2628 | 2767 | |
2629 | 2768 | if (!empty($can_view_post)) |
2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
2657 | 2796 | } |
2658 | 2797 | |
2659 | 2798 | // Remove any nested quotes. |
2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2801 | + } |
|
2662 | 2802 | |
2663 | 2803 | $lb = "\n"; |
2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
2684 | 2824 | 'time' => '', |
2685 | 2825 | ), |
2686 | 2826 | ); |
2687 | - } |
|
2688 | - else |
|
2689 | - $context['quote'] = array( |
|
2827 | + } else { |
|
2828 | + $context['quote'] = array( |
|
2690 | 2829 | 'xml' => '', |
2691 | 2830 | 'mozilla' => '', |
2692 | 2831 | 'text' => '', |
2693 | 2832 | ); |
2694 | -} |
|
2833 | + } |
|
2834 | + } |
|
2695 | 2835 | |
2696 | 2836 | /** |
2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
2704 | 2844 | |
2705 | 2845 | // We have to have a topic! |
2706 | - if (empty($topic)) |
|
2707 | - obExit(false); |
|
2846 | + if (empty($topic)) { |
|
2847 | + obExit(false); |
|
2848 | + } |
|
2708 | 2849 | |
2709 | 2850 | checkSession('get'); |
2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
2730 | 2871 | 'guest_id' => 0, |
2731 | 2872 | ) |
2732 | 2873 | ); |
2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2734 | - fatal_lang_error('no_board', false); |
|
2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2875 | + fatal_lang_error('no_board', false); |
|
2876 | + } |
|
2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
2736 | 2878 | $smcFunc['db_free_result']($request); |
2737 | 2879 | |
2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2740 | 2882 | { |
2741 | - if (!empty($row['locked'])) |
|
2742 | - isAllowedTo('moderate_board'); |
|
2883 | + if (!empty($row['locked'])) { |
|
2884 | + isAllowedTo('moderate_board'); |
|
2885 | + } |
|
2743 | 2886 | |
2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2745 | 2888 | { |
2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2749 | - isAllowedTo('modify_replies'); |
|
2750 | - else |
|
2751 | - isAllowedTo('modify_own'); |
|
2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2892 | + isAllowedTo('modify_replies'); |
|
2893 | + } else { |
|
2894 | + isAllowedTo('modify_own'); |
|
2895 | + } |
|
2752 | 2896 | } |
2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2755 | - isAllowedTo('modify_replies'); |
|
2756 | - else |
|
2757 | - isAllowedTo('modify_any'); |
|
2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2899 | + isAllowedTo('modify_replies'); |
|
2900 | + } else { |
|
2901 | + isAllowedTo('modify_any'); |
|
2902 | + } |
|
2758 | 2903 | |
2759 | 2904 | // Only log this action if it wasn't your message. |
2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2767 | 2912 | |
2768 | 2913 | // Maximum number of characters. |
2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2771 | - } |
|
2772 | - elseif (isset($_POST['subject'])) |
|
2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2916 | + } |
|
2917 | + } elseif (isset($_POST['subject'])) |
|
2773 | 2918 | { |
2774 | 2919 | $post_errors[] = 'no_subject'; |
2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
2781 | 2926 | { |
2782 | 2927 | $post_errors[] = 'no_message'; |
2783 | 2928 | unset($_POST['message']); |
2784 | - } |
|
2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2786 | 2930 | { |
2787 | 2931 | $post_errors[] = 'long_message'; |
2788 | 2932 | unset($_POST['message']); |
2789 | - } |
|
2790 | - else |
|
2933 | + } else |
|
2791 | 2934 | { |
2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
2803 | 2946 | |
2804 | 2947 | if (isset($_POST['lock'])) |
2805 | 2948 | { |
2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2807 | - unset($_POST['lock']); |
|
2808 | - elseif (!allowedTo('lock_any')) |
|
2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2950 | + unset($_POST['lock']); |
|
2951 | + } elseif (!allowedTo('lock_any')) |
|
2809 | 2952 | { |
2810 | - if ($row['locked'] == 1) |
|
2811 | - unset($_POST['lock']); |
|
2812 | - else |
|
2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2953 | + if ($row['locked'] == 1) { |
|
2954 | + unset($_POST['lock']); |
|
2955 | + } else { |
|
2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2957 | + } |
|
2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2959 | + unset($_POST['lock']); |
|
2960 | + } else { |
|
2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2814 | 2962 | } |
2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2816 | - unset($_POST['lock']); |
|
2817 | - else |
|
2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2819 | 2963 | } |
2820 | 2964 | |
2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2822 | - unset($_POST['sticky']); |
|
2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2966 | + unset($_POST['sticky']); |
|
2967 | + } |
|
2823 | 2968 | |
2824 | 2969 | if (isset($_POST['modify_reason'])) |
2825 | 2970 | { |
2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2827 | 2972 | |
2828 | 2973 | // Maximum number of characters. |
2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2976 | + } |
|
2831 | 2977 | } |
2832 | 2978 | |
2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
2864 | 3010 | } |
2865 | 3011 | } |
2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
2867 | - else |
|
2868 | - $moderationAction = false; |
|
3013 | + else { |
|
3014 | + $moderationAction = false; |
|
3015 | + } |
|
2869 | 3016 | |
2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
2883 | 3030 | // Get the proper (default language) response prefix first. |
2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2885 | 3032 | { |
2886 | - if ($language === $user_info['language']) |
|
2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2888 | - else |
|
3033 | + if ($language === $user_info['language']) { |
|
3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3035 | + } else |
|
2889 | 3036 | { |
2890 | 3037 | loadLanguage('index', $language, false); |
2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
2907 | 3054 | ); |
2908 | 3055 | } |
2909 | 3056 | |
2910 | - if (!empty($moderationAction)) |
|
2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3057 | + if (!empty($moderationAction)) { |
|
3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3059 | + } |
|
2912 | 3060 | } |
2913 | 3061 | |
2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
2949 | 3097 | ); |
2950 | 3098 | |
2951 | 3099 | censorText($context['message']['subject']); |
2952 | - } |
|
2953 | - else |
|
3100 | + } else |
|
2954 | 3101 | { |
2955 | 3102 | $context['message'] = array( |
2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
2962 | 3109 | loadLanguage('Errors'); |
2963 | 3110 | foreach ($post_errors as $post_error) |
2964 | 3111 | { |
2965 | - if ($post_error == 'long_message') |
|
2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2967 | - else |
|
2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3112 | + if ($post_error == 'long_message') { |
|
3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3114 | + } else { |
|
3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3116 | + } |
|
2969 | 3117 | } |
2970 | 3118 | } |
3119 | + } else { |
|
3120 | + obExit(false); |
|
3121 | + } |
|
2971 | 3122 | } |
2972 | - else |
|
2973 | - obExit(false); |
|
2974 | -} |
|
2975 | 3123 | |
2976 | 3124 | ?> |
2977 | 3125 | \ No newline at end of file |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'class' => 'centercol', |
257 | 257 | ), |
258 | 258 | 'data' => array( |
259 | - 'function' => function ($entry) |
|
259 | + 'function' => function($entry) |
|
260 | 260 | { |
261 | 261 | return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if (empty($entries[$k]['action_text'])) |
639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | - function ($matches) use ($entries, $k) |
|
641 | + function($matches) use ($entries, $k) |
|
642 | 642 | { |
643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
644 | 644 | }, $entries[$k]['action_text']); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
301 | 305 | $context['default_list'] = 'moderation_log_list'; |
302 | 306 | |
303 | 307 | // If a hook has changed this, respect it. |
304 | - if (!empty($moderation_menu_name)) |
|
305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
306 | - elseif (isset($context['moderation_menu_name'])) |
|
307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | + if (!empty($moderation_menu_name)) { |
|
309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
311 | 315 | ); |
312 | -} |
|
316 | + } |
|
317 | + } |
|
313 | 318 | |
314 | 319 | /** |
315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
413 | 418 | // Add on some of the column stuff info |
414 | 419 | if (!empty($row['id_board'])) |
415 | 420 | { |
416 | - if ($row['action'] == 'move') |
|
417 | - $row['extra']['board_to'] = $row['id_board']; |
|
418 | - else |
|
419 | - $row['extra']['board'] = $row['id_board']; |
|
421 | + if ($row['action'] == 'move') { |
|
422 | + $row['extra']['board_to'] = $row['id_board']; |
|
423 | + } else { |
|
424 | + $row['extra']['board'] = $row['id_board']; |
|
425 | + } |
|
420 | 426 | } |
421 | 427 | |
422 | - if (!empty($row['id_topic'])) |
|
423 | - $row['extra']['topic'] = $row['id_topic']; |
|
424 | - if (!empty($row['id_msg'])) |
|
425 | - $row['extra']['message'] = $row['id_msg']; |
|
428 | + if (!empty($row['id_topic'])) { |
|
429 | + $row['extra']['topic'] = $row['id_topic']; |
|
430 | + } |
|
431 | + if (!empty($row['id_msg'])) { |
|
432 | + $row['extra']['message'] = $row['id_msg']; |
|
433 | + } |
|
426 | 434 | |
427 | 435 | // Is this associated with a topic? |
428 | - if (isset($row['extra']['topic'])) |
|
429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
430 | - if (isset($row['extra']['new_topic'])) |
|
431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
436 | + if (isset($row['extra']['topic'])) { |
|
437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
438 | + } |
|
439 | + if (isset($row['extra']['new_topic'])) { |
|
440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
441 | + } |
|
432 | 442 | |
433 | 443 | // How about a member? |
434 | 444 | if (isset($row['extra']['member'])) |
435 | 445 | { |
436 | 446 | // Guests don't have names! |
437 | - if (empty($row['extra']['member'])) |
|
438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
439 | - else |
|
447 | + if (empty($row['extra']['member'])) { |
|
448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
449 | + } else |
|
440 | 450 | { |
441 | 451 | // Try to find it... |
442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
444 | 454 | } |
445 | 455 | |
446 | 456 | // Associated with a board? |
447 | - if (isset($row['extra']['board_to'])) |
|
448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
449 | - if (isset($row['extra']['board_from'])) |
|
450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
451 | - if (isset($row['extra']['board'])) |
|
452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
457 | + if (isset($row['extra']['board_to'])) { |
|
458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
459 | + } |
|
460 | + if (isset($row['extra']['board_from'])) { |
|
461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
462 | + } |
|
463 | + if (isset($row['extra']['board'])) { |
|
464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
465 | + } |
|
453 | 466 | |
454 | 467 | // A message? |
455 | - if (isset($row['extra']['message'])) |
|
456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
468 | + if (isset($row['extra']['message'])) { |
|
469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
470 | + } |
|
457 | 471 | |
458 | 472 | // IP Info? |
459 | - if (isset($row['extra']['ip_range'])) |
|
460 | - if ($seeIP) |
|
473 | + if (isset($row['extra']['ip_range'])) { |
|
474 | + if ($seeIP) |
|
461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
462 | - else |
|
463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
476 | + } else { |
|
477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
478 | + } |
|
464 | 479 | |
465 | 480 | // Email? |
466 | - if (isset($row['extra']['email'])) |
|
467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
481 | + if (isset($row['extra']['email'])) { |
|
482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
483 | + } |
|
468 | 484 | |
469 | 485 | // Bans are complex. |
470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
471 | 487 | { |
472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
474 | - if (isset($row['extra'][$type])) |
|
489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
490 | + if (isset($row['extra'][$type])) |
|
475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
492 | + } |
|
476 | 493 | } |
477 | 494 | |
478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
508 | 525 | foreach ($boards[$row['id_board']] as $action) |
509 | 526 | { |
510 | 527 | // Make the board number into a link - dealing with moving too. |
511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | } |
519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
547 | 565 | ); |
548 | 566 | |
549 | 567 | // Make the topic number into a link - dealing with splitting too. |
550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
572 | + } |
|
554 | 573 | } |
555 | 574 | } |
556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
583 | 602 | ); |
584 | 603 | |
585 | 604 | // Make the message number into a link. |
586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
607 | + } |
|
588 | 608 | } |
589 | 609 | } |
590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
624 | 644 | foreach ($entries as $k => $entry) |
625 | 645 | { |
626 | 646 | // Make any message info links so its easier to go find that message. |
627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
649 | + } |
|
629 | 650 | |
630 | 651 | // Mark up any deleted members, topics and boards. |
631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
655 | + } |
|
634 | 656 | |
635 | 657 | if (isset($entry['extra']['report'])) |
636 | 658 | { |
637 | 659 | // Member profile reports go in a different area |
638 | - if (stristr($entry['action'], 'user_report')) |
|
639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
640 | - else |
|
641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
660 | + if (stristr($entry['action'], 'user_report')) { |
|
661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
662 | + } else { |
|
663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
664 | + } |
|
642 | 665 | } |
643 | 666 | |
644 | - if (empty($entries[$k]['action_text'])) |
|
645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
667 | + if (empty($entries[$k]['action_text'])) { |
|
668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
669 | + } |
|
646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
647 | 671 | function ($matches) use ($entries, $k) |
648 | 672 | { |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -62,16 +63,18 @@ discard block |
||
62 | 63 | $context['activation_numbers'] = array(); |
63 | 64 | $context['awaiting_activation'] = 0; |
64 | 65 | $context['awaiting_approval'] = 0; |
65 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
66 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
66 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
67 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
68 | + } |
|
67 | 69 | $smcFunc['db_free_result']($request); |
68 | 70 | |
69 | 71 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
70 | 72 | { |
71 | - if (in_array($activation_type, array(0, 2))) |
|
72 | - $context['awaiting_activation'] += $total_members; |
|
73 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
74 | - $context['awaiting_approval'] += $total_members; |
|
73 | + if (in_array($activation_type, array(0, 2))) { |
|
74 | + $context['awaiting_activation'] += $total_members; |
|
75 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
76 | + $context['awaiting_approval'] += $total_members; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | // For the page header... do we show activation? |
@@ -124,8 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) |
126 | 129 | { |
127 | - if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) |
|
128 | - $context['tabs']['search']['is_last'] = true; |
|
130 | + if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) { |
|
131 | + $context['tabs']['search']['is_last'] = true; |
|
132 | + } |
|
129 | 133 | unset($context['tabs']['approve']); |
130 | 134 | } |
131 | 135 | |
@@ -157,8 +161,9 @@ discard block |
||
157 | 161 | foreach ($_POST['delete'] as $key => $value) |
158 | 162 | { |
159 | 163 | // Don't delete yourself, idiot. |
160 | - if ($value != $user_info['id']) |
|
161 | - $delete[$key] = (int) $value; |
|
164 | + if ($value != $user_info['id']) { |
|
165 | + $delete[$key] = (int) $value; |
|
166 | + } |
|
162 | 167 | } |
163 | 168 | |
164 | 169 | if (!empty($delete)) |
@@ -194,17 +199,18 @@ discard block |
||
194 | 199 | ); |
195 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
196 | 201 | { |
197 | - if ($row['min_posts'] == -1) |
|
198 | - $context['membergroups'][] = array( |
|
202 | + if ($row['min_posts'] == -1) { |
|
203 | + $context['membergroups'][] = array( |
|
199 | 204 | 'id' => $row['id_group'], |
200 | 205 | 'name' => $row['group_name'], |
201 | 206 | 'can_be_additional' => true |
202 | 207 | ); |
203 | - else |
|
204 | - $context['postgroups'][] = array( |
|
208 | + } else { |
|
209 | + $context['postgroups'][] = array( |
|
205 | 210 | 'id' => $row['id_group'], |
206 | 211 | 'name' => $row['group_name'] |
207 | 212 | ); |
213 | + } |
|
208 | 214 | } |
209 | 215 | $smcFunc['db_free_result']($request); |
210 | 216 | |
@@ -268,14 +274,15 @@ discard block |
||
268 | 274 | call_integration_hook('integrate_view_members_params', array(&$params)); |
269 | 275 | |
270 | 276 | $search_params = array(); |
271 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
272 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
273 | - elseif (!empty($_POST)) |
|
277 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
278 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
279 | + } elseif (!empty($_POST)) |
|
274 | 280 | { |
275 | 281 | $search_params['types'] = $_POST['types']; |
276 | - foreach ($params as $param_name => $param_info) |
|
277 | - if (isset($_POST[$param_name])) |
|
282 | + foreach ($params as $param_name => $param_info) { |
|
283 | + if (isset($_POST[$param_name])) |
|
278 | 284 | $search_params[$param_name] = $_POST[$param_name]; |
285 | + } |
|
279 | 286 | } |
280 | 287 | |
281 | 288 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -288,18 +295,21 @@ discard block |
||
288 | 295 | foreach ($params as $param_name => $param_info) |
289 | 296 | { |
290 | 297 | // Not filled in? |
291 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
292 | - continue; |
|
298 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
299 | + continue; |
|
300 | + } |
|
293 | 301 | |
294 | 302 | // Make sure numeric values are really numeric. |
295 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
296 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
303 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
304 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
305 | + } |
|
297 | 306 | // Date values have to match the specified format. |
298 | 307 | elseif ($param_info['type'] == 'date') |
299 | 308 | { |
300 | 309 | // Check if this date format is valid. |
301 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
302 | - continue; |
|
310 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
311 | + continue; |
|
312 | + } |
|
303 | 313 | |
304 | 314 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
305 | 315 | } |
@@ -308,8 +318,9 @@ discard block |
||
308 | 318 | if (!empty($param_info['range'])) |
309 | 319 | { |
310 | 320 | // Default to '=', just in case... |
311 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
312 | - $search_params['types'][$param_name] = '='; |
|
321 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
322 | + $search_params['types'][$param_name] = '='; |
|
323 | + } |
|
313 | 324 | |
314 | 325 | // Handle special case 'age'. |
315 | 326 | if ($param_info['type'] == 'age') |
@@ -337,29 +348,30 @@ discard block |
||
337 | 348 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
338 | 349 | { |
339 | 350 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
351 | + } else { |
|
352 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
340 | 353 | } |
341 | - else |
|
342 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
343 | 354 | } |
344 | 355 | // Checkboxes. |
345 | 356 | elseif ($param_info['type'] == 'checkbox') |
346 | 357 | { |
347 | 358 | // Each checkbox or no checkbox at all is checked -> ignore. |
348 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
349 | - continue; |
|
359 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
360 | + continue; |
|
361 | + } |
|
350 | 362 | |
351 | 363 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
352 | 364 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
353 | - } |
|
354 | - else |
|
365 | + } else |
|
355 | 366 | { |
356 | 367 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
357 | 368 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
358 | 369 | |
359 | - if ($smcFunc['db_case_sensitive']) |
|
360 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
361 | - else |
|
362 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
370 | + if ($smcFunc['db_case_sensitive']) { |
|
371 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
372 | + } else { |
|
373 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
374 | + } |
|
363 | 375 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
364 | 376 | } |
365 | 377 | } |
@@ -375,16 +387,18 @@ discard block |
||
375 | 387 | } |
376 | 388 | |
377 | 389 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
378 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
379 | - foreach ($search_params['membergroups'][2] as $mg) |
|
390 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
391 | + foreach ($search_params['membergroups'][2] as $mg) |
|
380 | 392 | { |
381 | 393 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
394 | + } |
|
382 | 395 | $where_params['add_group_' . $mg] = $mg; |
383 | 396 | } |
384 | 397 | |
385 | 398 | // Combine the one or two membergroup parts into one query part linked with an OR. |
386 | - if (!empty($mg_query_parts)) |
|
387 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
399 | + if (!empty($mg_query_parts)) { |
|
400 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
401 | + } |
|
388 | 402 | |
389 | 403 | // Get all selected post count related membergroups. |
390 | 404 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -396,9 +410,9 @@ discard block |
||
396 | 410 | // Construct the where part of the query. |
397 | 411 | $where = empty($query_parts) ? '1=1' : implode(' |
398 | 412 | AND ', $query_parts); |
413 | + } else { |
|
414 | + $search_url_params = null; |
|
399 | 415 | } |
400 | - else |
|
401 | - $search_url_params = null; |
|
402 | 416 | |
403 | 417 | // Construct the additional URL part with the query info in it. |
404 | 418 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -521,28 +535,32 @@ discard block |
||
521 | 535 | 'function' => function($rowData) use ($txt) |
522 | 536 | { |
523 | 537 | // Calculate number of days since last online. |
524 | - if (empty($rowData['last_login'])) |
|
525 | - $difference = $txt['never']; |
|
526 | - else |
|
538 | + if (empty($rowData['last_login'])) { |
|
539 | + $difference = $txt['never']; |
|
540 | + } else |
|
527 | 541 | { |
528 | 542 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
529 | 543 | |
530 | 544 | // Today. |
531 | - if (empty($num_days_difference)) |
|
532 | - $difference = $txt['viewmembers_today']; |
|
545 | + if (empty($num_days_difference)) { |
|
546 | + $difference = $txt['viewmembers_today']; |
|
547 | + } |
|
533 | 548 | |
534 | 549 | // Yesterday. |
535 | - elseif ($num_days_difference == 1) |
|
536 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
550 | + elseif ($num_days_difference == 1) { |
|
551 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
552 | + } |
|
537 | 553 | |
538 | 554 | // X days ago. |
539 | - else |
|
540 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
555 | + else { |
|
556 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
557 | + } |
|
541 | 558 | } |
542 | 559 | |
543 | 560 | // Show it in italics if they're not activated... |
544 | - if ($rowData['is_activated'] % 10 != 1) |
|
545 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
561 | + if ($rowData['is_activated'] % 10 != 1) { |
|
562 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
563 | + } |
|
546 | 564 | |
547 | 565 | return $difference; |
548 | 566 | }, |
@@ -594,8 +612,9 @@ discard block |
||
594 | 612 | ); |
595 | 613 | |
596 | 614 | // Without enough permissions, don't show 'delete members' checkboxes. |
597 | - if (!allowedTo('profile_remove_any')) |
|
598 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
615 | + if (!allowedTo('profile_remove_any')) { |
|
616 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
617 | + } |
|
599 | 618 | |
600 | 619 | require_once($sourcedir . '/Subs-List.php'); |
601 | 620 | createList($listOptions); |
@@ -638,17 +657,18 @@ discard block |
||
638 | 657 | ); |
639 | 658 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 659 | { |
641 | - if ($row['min_posts'] == -1) |
|
642 | - $context['membergroups'][] = array( |
|
660 | + if ($row['min_posts'] == -1) { |
|
661 | + $context['membergroups'][] = array( |
|
643 | 662 | 'id' => $row['id_group'], |
644 | 663 | 'name' => $row['group_name'], |
645 | 664 | 'can_be_additional' => true |
646 | 665 | ); |
647 | - else |
|
648 | - $context['postgroups'][] = array( |
|
666 | + } else { |
|
667 | + $context['postgroups'][] = array( |
|
649 | 668 | 'id' => $row['id_group'], |
650 | 669 | 'name' => $row['group_name'] |
651 | 670 | ); |
671 | + } |
|
652 | 672 | } |
653 | 673 | $smcFunc['db_free_result']($request); |
654 | 674 | |
@@ -675,8 +695,9 @@ discard block |
||
675 | 695 | $context['page_title'] = $txt['admin_members']; |
676 | 696 | $context['sub_template'] = 'admin_browse'; |
677 | 697 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
678 | - if (isset($context['tabs'][$context['browse_type']])) |
|
679 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
698 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
699 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
700 | + } |
|
680 | 701 | |
681 | 702 | // Allowed filters are those we can have, in theory. |
682 | 703 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -687,18 +708,20 @@ discard block |
||
687 | 708 | foreach ($context['activation_numbers'] as $type => $amount) |
688 | 709 | { |
689 | 710 | // We have some of these... |
690 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
691 | - $context['available_filters'][] = array( |
|
711 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
712 | + $context['available_filters'][] = array( |
|
692 | 713 | 'type' => $type, |
693 | 714 | 'amount' => $amount, |
694 | 715 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
695 | 716 | 'selected' => $type == $context['current_filter'] |
696 | 717 | ); |
718 | + } |
|
697 | 719 | } |
698 | 720 | |
699 | 721 | // If the filter was not sent, set it to whatever has people in it! |
700 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
701 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
722 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
723 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
724 | + } |
|
702 | 725 | |
703 | 726 | // This little variable is used to determine if we should flag where we are looking. |
704 | 727 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -713,44 +736,47 @@ discard block |
||
713 | 736 | ); |
714 | 737 | |
715 | 738 | // Are we showing duplicate information? |
716 | - if (isset($_GET['showdupes'])) |
|
717 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
739 | + if (isset($_GET['showdupes'])) { |
|
740 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
741 | + } |
|
718 | 742 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
719 | 743 | |
720 | 744 | // Determine which actions we should allow on this page. |
721 | 745 | if ($context['browse_type'] == 'approve') |
722 | 746 | { |
723 | 747 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
724 | - if ($context['current_filter'] == 4) |
|
725 | - $context['allowed_actions'] = array( |
|
748 | + if ($context['current_filter'] == 4) { |
|
749 | + $context['allowed_actions'] = array( |
|
726 | 750 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
727 | 751 | 'ok' => $txt['admin_browse_w_reject'], |
728 | 752 | ); |
729 | - else |
|
730 | - $context['allowed_actions'] = array( |
|
753 | + } else { |
|
754 | + $context['allowed_actions'] = array( |
|
731 | 755 | 'ok' => $txt['admin_browse_w_approve'], |
732 | 756 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
733 | 757 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
734 | 758 | 'reject' => $txt['admin_browse_w_reject'], |
735 | 759 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
736 | 760 | ); |
737 | - } |
|
738 | - elseif ($context['browse_type'] == 'activate') |
|
739 | - $context['allowed_actions'] = array( |
|
761 | + } |
|
762 | + } elseif ($context['browse_type'] == 'activate') { |
|
763 | + $context['allowed_actions'] = array( |
|
740 | 764 | 'ok' => $txt['admin_browse_w_activate'], |
741 | 765 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
742 | 766 | 'delete' => $txt['admin_browse_w_delete'], |
743 | 767 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
744 | 768 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
745 | 769 | ); |
770 | + } |
|
746 | 771 | |
747 | 772 | // Create an option list for actions allowed to be done with selected members. |
748 | 773 | $allowed_actions = ' |
749 | 774 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
750 | 775 | <option value="" disabled>-----------------------------</option>'; |
751 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
752 | - $allowed_actions .= ' |
|
776 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
777 | + $allowed_actions .= ' |
|
753 | 778 | <option value="' . $key . '">' . $desc . '</option>'; |
779 | + } |
|
754 | 780 | |
755 | 781 | // Setup the Javascript function for selecting an action for the list. |
756 | 782 | $javascript = ' |
@@ -762,15 +788,16 @@ discard block |
||
762 | 788 | var message = "";'; |
763 | 789 | |
764 | 790 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
765 | - if ($context['current_filter'] == 4) |
|
766 | - $javascript .= ' |
|
791 | + if ($context['current_filter'] == 4) { |
|
792 | + $javascript .= ' |
|
767 | 793 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
768 | 794 | message = "' . $txt['admin_browse_w_delete'] . '"; |
769 | 795 | else |
770 | 796 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
797 | + } |
|
771 | 798 | // Otherwise a nice standard message. |
772 | - else |
|
773 | - $javascript .= ' |
|
799 | + else { |
|
800 | + $javascript .= ' |
|
774 | 801 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
775 | 802 | message = "' . $txt['admin_browse_w_delete'] . '"; |
776 | 803 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -779,6 +806,7 @@ discard block |
||
779 | 806 | message = "' . $txt['admin_browse_w_remind'] . '"; |
780 | 807 | else |
781 | 808 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
809 | + } |
|
782 | 810 | $javascript .= ' |
783 | 811 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
784 | 812 | document.forms.postForm.submit(); |
@@ -911,10 +939,11 @@ discard block |
||
911 | 939 | $member_links = array(); |
912 | 940 | foreach ($rowData['duplicate_members'] as $member) |
913 | 941 | { |
914 | - if ($member['id']) |
|
915 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
916 | - else |
|
917 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
942 | + if ($member['id']) { |
|
943 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
944 | + } else { |
|
945 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
946 | + } |
|
918 | 947 | } |
919 | 948 | return implode(', ', $member_links); |
920 | 949 | }, |
@@ -963,14 +992,16 @@ discard block |
||
963 | 992 | ); |
964 | 993 | |
965 | 994 | // Pick what column to actually include if we're showing duplicates. |
966 | - if ($context['show_duplicates']) |
|
967 | - unset($listOptions['columns']['email']); |
|
968 | - else |
|
969 | - unset($listOptions['columns']['duplicates']); |
|
995 | + if ($context['show_duplicates']) { |
|
996 | + unset($listOptions['columns']['email']); |
|
997 | + } else { |
|
998 | + unset($listOptions['columns']['duplicates']); |
|
999 | + } |
|
970 | 1000 | |
971 | 1001 | // Only show hostname on duplicates as it takes a lot of time. |
972 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
973 | - unset($listOptions['columns']['hostname']); |
|
1002 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1003 | + unset($listOptions['columns']['hostname']); |
|
1004 | + } |
|
974 | 1005 | |
975 | 1006 | // Is there any need to show filters? |
976 | 1007 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -978,9 +1009,10 @@ discard block |
||
978 | 1009 | $filterOptions = ' |
979 | 1010 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
980 | 1011 | <select name="filter" onchange="this.form.submit();">'; |
981 | - foreach ($context['available_filters'] as $filter) |
|
982 | - $filterOptions .= ' |
|
1012 | + foreach ($context['available_filters'] as $filter) { |
|
1013 | + $filterOptions .= ' |
|
983 | 1014 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1015 | + } |
|
984 | 1016 | $filterOptions .= ' |
985 | 1017 | </select> |
986 | 1018 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -992,12 +1024,13 @@ discard block |
||
992 | 1024 | } |
993 | 1025 | |
994 | 1026 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
995 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
996 | - $listOptions['additional_rows'][] = array( |
|
1027 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1028 | + $listOptions['additional_rows'][] = array( |
|
997 | 1029 | 'position' => 'above_column_headers', |
998 | 1030 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
999 | 1031 | 'class' => 'smalltext floatright', |
1000 | 1032 | ); |
1033 | + } |
|
1001 | 1034 | |
1002 | 1035 | // Now that we have all the options, create the list. |
1003 | 1036 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1027,12 +1060,14 @@ discard block |
||
1027 | 1060 | $current_filter = (int) $_REQUEST['orig_filter']; |
1028 | 1061 | |
1029 | 1062 | // If we are applying a filter do just that - then redirect. |
1030 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1031 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1063 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1064 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1065 | + } |
|
1032 | 1066 | |
1033 | 1067 | // Nothing to do? |
1034 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1035 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1068 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1069 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1070 | + } |
|
1036 | 1071 | |
1037 | 1072 | // Are we dealing with members who have been waiting for > set amount of time? |
1038 | 1073 | if (isset($_POST['time_passed'])) |
@@ -1045,8 +1080,9 @@ discard block |
||
1045 | 1080 | else |
1046 | 1081 | { |
1047 | 1082 | $members = array(); |
1048 | - foreach ($_POST['todoAction'] as $id) |
|
1049 | - $members[] = (int) $id; |
|
1083 | + foreach ($_POST['todoAction'] as $id) { |
|
1084 | + $members[] = (int) $id; |
|
1085 | + } |
|
1050 | 1086 | $condition = ' |
1051 | 1087 | AND id_member IN ({array_int:members})'; |
1052 | 1088 | } |
@@ -1067,8 +1103,9 @@ discard block |
||
1067 | 1103 | $member_count = $smcFunc['db_num_rows']($request); |
1068 | 1104 | |
1069 | 1105 | // If no results then just return! |
1070 | - if ($member_count == 0) |
|
1071 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1106 | + if ($member_count == 0) { |
|
1107 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1108 | + } |
|
1072 | 1109 | |
1073 | 1110 | $member_info = array(); |
1074 | 1111 | $members = array(); |
@@ -1107,8 +1144,9 @@ discard block |
||
1107 | 1144 | // Do we have to let the integration code know about the activations? |
1108 | 1145 | if (!empty($modSettings['integrate_activate'])) |
1109 | 1146 | { |
1110 | - foreach ($member_info as $member) |
|
1111 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1147 | + foreach ($member_info as $member) { |
|
1148 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1149 | + } |
|
1112 | 1150 | } |
1113 | 1151 | |
1114 | 1152 | // Check for email. |
@@ -1238,20 +1276,23 @@ discard block |
||
1238 | 1276 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
1239 | 1277 | |
1240 | 1278 | require_once($sourcedir . '/Logging.php'); |
1241 | - foreach ($member_info as $member) |
|
1242 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1279 | + foreach ($member_info as $member) { |
|
1280 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1281 | + } |
|
1243 | 1282 | } |
1244 | 1283 | |
1245 | 1284 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1246 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1247 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1285 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1286 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1287 | + } |
|
1248 | 1288 | |
1249 | 1289 | // Update the member's stats. (but, we know the member didn't change their name.) |
1250 | 1290 | updateStats('member', false); |
1251 | 1291 | |
1252 | 1292 | // If they haven't been deleted, update the post group statistics on them... |
1253 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1254 | - updateStats('postgroups', $members); |
|
1293 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1294 | + updateStats('postgroups', $members); |
|
1295 | + } |
|
1255 | 1296 | |
1256 | 1297 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1257 | 1298 | } |
@@ -1276,10 +1317,11 @@ discard block |
||
1276 | 1317 | $dis = time() - $old; |
1277 | 1318 | |
1278 | 1319 | // Before midnight? |
1279 | - if ($dis < $sinceMidnight) |
|
1280 | - return 0; |
|
1281 | - else |
|
1282 | - $dis -= $sinceMidnight; |
|
1320 | + if ($dis < $sinceMidnight) { |
|
1321 | + return 0; |
|
1322 | + } else { |
|
1323 | + $dis -= $sinceMidnight; |
|
1324 | + } |
|
1283 | 1325 | |
1284 | 1326 | // Divide out the seconds in a day to get the number of days. |
1285 | 1327 | return ceil($dis / (24 * 60 * 60)); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
107 | 108 | |
108 | 109 | // We do not want to output debug information here. |
109 | - if ($this->_js) |
|
110 | - $db_show_debug = false; |
|
110 | + if ($this->_js) { |
|
111 | + $db_show_debug = false; |
|
112 | + } |
|
111 | 113 | } |
112 | 114 | |
113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
141 | 143 | $call = $this->_sa; |
142 | 144 | |
143 | 145 | // Guest can only view likes. |
144 | - if ($call != 'view') |
|
145 | - is_not_guest(); |
|
146 | + if ($call != 'view') { |
|
147 | + is_not_guest(); |
|
148 | + } |
|
146 | 149 | |
147 | 150 | checkSession('get'); |
148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
180 | 183 | global $smcFunc, $modSettings; |
181 | 184 | |
182 | 185 | // This feature is currently disable. |
183 | - if (empty($modSettings['enable_likes'])) |
|
184 | - return $this->_error = 'like_disable'; |
|
186 | + if (empty($modSettings['enable_likes'])) { |
|
187 | + return $this->_error = 'like_disable'; |
|
188 | + } |
|
185 | 189 | |
186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
189 | 193 | |
190 | - if ($this->_type == '' || $this->_content <= 0) |
|
191 | - return $this->_error = 'cannot_'; |
|
194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
195 | + return $this->_error = 'cannot_'; |
|
196 | + } |
|
192 | 197 | |
193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
207 | 212 | 'msg' => $this->_content, |
208 | 213 | ) |
209 | 214 | ); |
210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + } |
|
212 | 218 | |
213 | 219 | $smcFunc['db_free_result']($request); |
214 | - if (empty($this->_idTopic)) |
|
215 | - return $this->_error = 'cannot_'; |
|
220 | + if (empty($this->_idTopic)) { |
|
221 | + return $this->_error = 'cannot_'; |
|
222 | + } |
|
216 | 223 | |
217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
222 | 229 | |
223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
224 | - } |
|
225 | - |
|
226 | - else |
|
231 | + } else |
|
227 | 232 | { |
228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
241 | 246 | if ($result !== false) |
242 | 247 | { |
243 | 248 | // Match the type with what we already have. |
244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
245 | - return $this->_error = 'not_valid_like_type'; |
|
249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
250 | + return $this->_error = 'not_valid_like_type'; |
|
251 | + } |
|
246 | 252 | |
247 | 253 | // Fill out the rest. |
248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
253 | 259 | } |
254 | 260 | } |
255 | 261 | |
256 | - if (!$found) |
|
257 | - return $this->_error = 'cannot_'; |
|
262 | + if (!$found) { |
|
263 | + return $this->_error = 'cannot_'; |
|
264 | + } |
|
258 | 265 | } |
259 | 266 | |
260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
262 | - return $this->_error = $this->_validLikes['can_like']; |
|
268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
269 | + return $this->_error = $this->_validLikes['can_like']; |
|
270 | + } |
|
263 | 271 | } |
264 | 272 | |
265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
284 | 292 | ); |
285 | 293 | |
286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
287 | - if ($this->_sa == __FUNCTION__) |
|
288 | - $this->_data = __FUNCTION__; |
|
295 | + if ($this->_sa == __FUNCTION__) { |
|
296 | + $this->_data = __FUNCTION__; |
|
297 | + } |
|
289 | 298 | } |
290 | 299 | |
291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
315 | 324 | |
316 | 325 | // Add a background task to process sending alerts. |
317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
318 | - if ($this->_type == 'msg') |
|
319 | - $smcFunc['db_insert']('insert', |
|
327 | + if ($this->_type == 'msg') { |
|
328 | + $smcFunc['db_insert']('insert', |
|
320 | 329 | '{db_prefix}background_tasks', |
321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
328 | 337 | )), 0), |
329 | 338 | array('id_task') |
330 | 339 | ); |
340 | + } |
|
331 | 341 | |
332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
333 | - if ($this->_sa == __FUNCTION__) |
|
334 | - $this->_data = __FUNCTION__; |
|
343 | + if ($this->_sa == __FUNCTION__) { |
|
344 | + $this->_data = __FUNCTION__; |
|
345 | + } |
|
335 | 346 | } |
336 | 347 | |
337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
357 | 368 | $smcFunc['db_free_result']($request); |
358 | 369 | |
359 | 370 | // If you want to call this directly, fill out _data property too. |
360 | - if ($this->_sa == __FUNCTION__) |
|
361 | - $this->_data = $this->_numLikes; |
|
371 | + if ($this->_sa == __FUNCTION__) { |
|
372 | + $this->_data = $this->_numLikes; |
|
373 | + } |
|
362 | 374 | } |
363 | 375 | |
364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
371 | 383 | global $smcFunc; |
372 | 384 | |
373 | 385 | // Safety first! |
374 | - if (empty($this->_type) || empty($this->_content)) |
|
375 | - return $this->_error = 'cannot_'; |
|
386 | + if (empty($this->_type) || empty($this->_content)) { |
|
387 | + return $this->_error = 'cannot_'; |
|
388 | + } |
|
376 | 389 | |
377 | 390 | // Do we already like this? |
378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
391 | 404 | $smcFunc['db_free_result']($request); |
392 | 405 | |
393 | - if ($this->_alreadyLiked) |
|
394 | - $this->delete(); |
|
395 | - |
|
396 | - else |
|
397 | - $this->insert(); |
|
406 | + if ($this->_alreadyLiked) { |
|
407 | + $this->delete(); |
|
408 | + } else { |
|
409 | + $this->insert(); |
|
410 | + } |
|
398 | 411 | |
399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
400 | 413 | $this->_count(); |
401 | 414 | |
402 | 415 | // Update the likes count for messages. |
403 | - if ($this->_type == 'msg') |
|
404 | - $this->msgIssueLike(); |
|
416 | + if ($this->_type == 'msg') { |
|
417 | + $this->msgIssueLike(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Any callbacks? |
407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
408 | 422 | { |
409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
410 | 424 | |
411 | - if (!empty($call)) |
|
412 | - call_user_func_array($call, array($this)); |
|
425 | + if (!empty($call)) { |
|
426 | + call_user_func_array($call, array($this)); |
|
427 | + } |
|
413 | 428 | } |
414 | 429 | |
415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
438 | + } |
|
423 | 439 | |
424 | 440 | // All done, start building the data to pass as response. |
425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
442 | 458 | { |
443 | 459 | global $smcFunc; |
444 | 460 | |
445 | - if ($this->_type !== 'msg') |
|
446 | - return; |
|
461 | + if ($this->_type !== 'msg') { |
|
462 | + return; |
|
463 | + } |
|
447 | 464 | |
448 | 465 | $smcFunc['db_query']('', ' |
449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
484 | 501 | 'like_type' => $this->_type, |
485 | 502 | ) |
486 | 503 | ); |
487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
506 | + } |
|
489 | 507 | |
490 | 508 | // Now to get member data, including avatars and so on. |
491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
493 | 511 | if (count($loaded) != count($members)) |
494 | 512 | { |
495 | 513 | $members = array_diff($members, $loaded); |
496 | - foreach ($members as $not_loaded) |
|
497 | - unset ($context['likers'][$not_loaded]); |
|
514 | + foreach ($members as $not_loaded) { |
|
515 | + unset ($context['likers'][$not_loaded]); |
|
516 | + } |
|
498 | 517 | } |
499 | 518 | |
500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
536 | 555 | global $context, $txt; |
537 | 556 | |
538 | 557 | // Don't do anything if someone else has already take care of the response. |
539 | - if (!$this->_setResponse) |
|
540 | - return; |
|
558 | + if (!$this->_setResponse) { |
|
559 | + return; |
|
560 | + } |
|
541 | 561 | |
542 | 562 | // Want a json response huh? |
543 | - if ($this->_validLikes['json']) |
|
544 | - return $this->jsonResponse(); |
|
563 | + if ($this->_validLikes['json']) { |
|
564 | + return $this->jsonResponse(); |
|
565 | + } |
|
545 | 566 | |
546 | 567 | // Set everything up for display. |
547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
551 | 572 | if ($this->_error) |
552 | 573 | { |
553 | 574 | // If this is a generic error, set it up good. |
554 | - if ($this->_error == 'cannot_') |
|
555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
575 | + if ($this->_error == 'cannot_') { |
|
576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
577 | + } |
|
556 | 578 | |
557 | 579 | // Is this request coming from an ajax call? |
558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
562 | 584 | } |
563 | 585 | |
564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
565 | - else |
|
566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
587 | + else { |
|
588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
589 | + } |
|
567 | 590 | |
568 | 591 | return; |
569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
572 | 595 | else |
573 | 596 | { |
574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
575 | - if (!$this->_js) |
|
576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
598 | + if (!$this->_js) { |
|
599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
600 | + } |
|
577 | 601 | |
578 | 602 | // These fine gentlemen all share the same template. |
579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
606 | 630 | // If there is an error, send it. |
607 | 631 | if ($this->_error) |
608 | 632 | { |
609 | - if ($this->_error == 'cannot_') |
|
610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
633 | + if ($this->_error == 'cannot_') { |
|
634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
635 | + } |
|
611 | 636 | |
612 | 637 | $print['error'] = $this->_error; |
613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
645 | 670 | |
646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
647 | - $_GET['verse'] = '4:16'; |
|
671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
672 | + $_GET['verse'] = '4:16'; |
|
673 | + } |
|
648 | 674 | |
649 | - if ($_GET['verse'] == '2:18') |
|
650 | - echo ' |
|
675 | + if ($_GET['verse'] == '2:18') { |
|
676 | + echo ' |
|
651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
652 | - elseif ($_GET['verse'] == '4:16') |
|
653 | - echo ' |
|
678 | + } elseif ($_GET['verse'] == '4:16') { |
|
679 | + echo ' |
|
654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
655 | - elseif ($_GET['verse'] == '22:1-2') |
|
656 | - echo ' |
|
681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
682 | + echo ' |
|
657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
685 | + } |
|
659 | 686 | |
660 | 687 | echo ' |
661 | 688 | </div> |
662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
663 | 690 | |
664 | - if ($_GET['verse'] == '2:18') |
|
665 | - echo ' |
|
691 | + if ($_GET['verse'] == '2:18') { |
|
692 | + echo ' |
|
666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
667 | - elseif ($_GET['verse'] == '4:16') |
|
668 | - echo ' |
|
694 | + } elseif ($_GET['verse'] == '4:16') { |
|
695 | + echo ' |
|
669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
670 | - elseif ($_GET['verse'] == '22:1-2') |
|
671 | - echo ' |
|
697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
698 | + echo ' |
|
672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
700 | + } |
|
673 | 701 | |
674 | 702 | echo ' |
675 | 703 | </div> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | static $timezone_array = array(); |
134 | 136 | require_once($sourcedir . '/Subs.php'); |
135 | 137 | |
136 | - if (empty($timezone_array['default'])) |
|
137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
138 | + if (empty($timezone_array['default'])) { |
|
139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $low_object = date_create($low_date); |
140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
162 | 165 | { |
163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
165 | - continue; |
|
167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
168 | + continue; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // Force a censor of the title - as often these are used by others. |
168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
170 | 174 | // Get the various time and date properties for this event |
171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
172 | 176 | |
173 | - if (empty($timezone_array[$tz])) |
|
174 | - $timezone_array[$tz] = timezone_open($tz); |
|
177 | + if (empty($timezone_array[$tz])) { |
|
178 | + $timezone_array[$tz] = timezone_open($tz); |
|
179 | + } |
|
175 | 180 | |
176 | 181 | // Sanity check |
177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
178 | - continue; |
|
182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
183 | + continue; |
|
184 | + } |
|
179 | 185 | |
180 | 186 | // Get set up for the loop |
181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
239 | 245 | ); |
240 | 246 | |
241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
242 | - if ($use_permissions) |
|
243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
248 | + if ($use_permissions) { |
|
249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
250 | 256 | )); |
257 | + } |
|
251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
252 | - else |
|
253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
259 | + else { |
|
260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
260 | 267 | 'poster' => $row['id_member'], |
261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
262 | 269 | )); |
270 | + } |
|
263 | 271 | |
264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
270 | 278 | if ($use_permissions) |
271 | 279 | { |
272 | - foreach ($events as $mday => $array) |
|
273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
280 | + foreach ($events as $mday => $array) { |
|
281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
282 | + } |
|
274 | 283 | } |
275 | 284 | |
276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
290 | 299 | global $smcFunc; |
291 | 300 | |
292 | 301 | // Get the lowest and highest dates for "all years". |
293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
296 | - else |
|
297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
305 | + } else { |
|
306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
307 | + } |
|
298 | 308 | |
299 | 309 | // Find some holidays... ;). |
300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
314 | 324 | $holidays = array(); |
315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
316 | 326 | { |
317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
319 | - else |
|
320 | - $event_year = substr($low_date, 0, 4); |
|
327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
329 | + } else { |
|
330 | + $event_year = substr($low_date, 0, 4); |
|
331 | + } |
|
321 | 332 | |
322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
343 | 354 | isAllowedTo('calendar_post'); |
344 | 355 | |
345 | 356 | // No board? No topic?!? |
346 | - if (empty($board)) |
|
347 | - fatal_lang_error('missing_board_id', false); |
|
348 | - if (empty($topic)) |
|
349 | - fatal_lang_error('missing_topic_id', false); |
|
357 | + if (empty($board)) { |
|
358 | + fatal_lang_error('missing_board_id', false); |
|
359 | + } |
|
360 | + if (empty($topic)) { |
|
361 | + fatal_lang_error('missing_topic_id', false); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Administrator, Moderator, or owner. Period. |
352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 378 | { |
366 | 379 | // Not the owner of the topic. |
367 | - if ($row['id_member_started'] != $user_info['id']) |
|
368 | - fatal_lang_error('not_your_topic', 'user'); |
|
380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
381 | + fatal_lang_error('not_your_topic', 'user'); |
|
382 | + } |
|
369 | 383 | } |
370 | 384 | // Topic/Board doesn't exist..... |
371 | - else |
|
372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
385 | + else { |
|
386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
387 | + } |
|
373 | 388 | $smcFunc['db_free_result']($result); |
374 | 389 | } |
375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
457 | 472 | if (!empty($calendarOptions['start_day'])) |
458 | 473 | { |
459 | 474 | $nShift -= $calendarOptions['start_day']; |
460 | - if ($nShift < 0) |
|
461 | - $nShift = 7 + $nShift; |
|
475 | + if ($nShift < 0) { |
|
476 | + $nShift = 7 + $nShift; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Number of rows required to fit the month. |
465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
467 | - $nRows++; |
|
482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
483 | + $nRows++; |
|
484 | + } |
|
468 | 485 | |
469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
477 | 494 | { |
478 | 495 | $calendarGrid['week_days'][] = $count; |
479 | 496 | $count++; |
480 | - if ($count == 7) |
|
481 | - $count = 0; |
|
497 | + if ($count == 7) { |
|
498 | + $count = 0; |
|
499 | + } |
|
482 | 500 | } |
483 | 501 | |
484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
495 | 513 | { |
496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
497 | 515 | |
498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
499 | - $nDay = 0; |
|
516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
517 | + $nDay = 0; |
|
518 | + } |
|
500 | 519 | |
501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
514 | 533 | } |
515 | 534 | |
516 | 535 | // What is the last day of the month? |
517 | - if ($is_previous === true) |
|
518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
536 | + if ($is_previous === true) { |
|
537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
538 | + } |
|
519 | 539 | |
520 | 540 | // We'll use the shift in the template. |
521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
549 | 569 | { |
550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
552 | - if ($date_diff < 0) |
|
553 | - $date_diff += 7; |
|
572 | + if ($date_diff < 0) { |
|
573 | + $date_diff += 7; |
|
574 | + } |
|
554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
680 | 701 | { |
681 | 702 | foreach ($date_events as $event_key => $event_val) |
682 | 703 | { |
683 | - if (in_array($event_val['id'], $temp)) |
|
684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
685 | - else |
|
686 | - $temp[] = $event_val['id']; |
|
704 | + if (in_array($event_val['id'], $temp)) { |
|
705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
706 | + } else { |
|
707 | + $temp[] = $event_val['id']; |
|
708 | + } |
|
687 | 709 | } |
688 | 710 | } |
689 | 711 | |
690 | 712 | // Give birthdays and holidays a friendly format, without the year |
691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
692 | - $date_format = '%b %d'; |
|
693 | - else |
|
694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
714 | + $date_format = '%b %d'; |
|
715 | + } else { |
|
716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
717 | + } |
|
695 | 718 | |
696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
790 | 813 | // Holidays between now and now + days. |
791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
792 | 815 | { |
793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
818 | + } |
|
795 | 819 | } |
796 | 820 | } |
797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
805 | 829 | { |
806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
832 | + } |
|
808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
809 | 834 | } |
810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
820 | 845 | |
821 | 846 | // No events today? Check the next day. |
822 | - if (empty($cached_data['events'][$loop_date])) |
|
823 | - continue; |
|
847 | + if (empty($cached_data['events'][$loop_date])) { |
|
848 | + continue; |
|
849 | + } |
|
824 | 850 | |
825 | 851 | // Loop through all events to add a few last-minute values. |
826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
833 | 859 | { |
834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
835 | 861 | continue; |
862 | + } else { |
|
863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
836 | 864 | } |
837 | - else |
|
838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
839 | 865 | |
840 | 866 | // Might be set to true afterwards, depending on the permissions. |
841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
843 | 869 | $this_event['date'] = $loop_date; |
844 | 870 | } |
845 | 871 | |
846 | - if (!empty($cached_data['events'][$loop_date])) |
|
847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
874 | + } |
|
848 | 875 | } |
849 | 876 | } |
850 | 877 | |
851 | 878 | // Mark the last item so that a list separator can be used in the template. |
852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
881 | + } |
|
882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
884 | + } |
|
856 | 885 | |
857 | 886 | return array( |
858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
900 | 929 | if (isset($_POST['start_date'])) |
901 | 930 | { |
902 | 931 | $d = date_parse($_POST['start_date']); |
903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
904 | - fatal_lang_error('invalid_date', false); |
|
905 | - if (empty($d['year'])) |
|
906 | - fatal_lang_error('event_year_missing', false); |
|
907 | - if (empty($d['month'])) |
|
908 | - fatal_lang_error('event_month_missing', false); |
|
909 | - } |
|
910 | - elseif (isset($_POST['start_datetime'])) |
|
932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
933 | + fatal_lang_error('invalid_date', false); |
|
934 | + } |
|
935 | + if (empty($d['year'])) { |
|
936 | + fatal_lang_error('event_year_missing', false); |
|
937 | + } |
|
938 | + if (empty($d['month'])) { |
|
939 | + fatal_lang_error('event_month_missing', false); |
|
940 | + } |
|
941 | + } elseif (isset($_POST['start_datetime'])) |
|
911 | 942 | { |
912 | 943 | $d = date_parse($_POST['start_datetime']); |
913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
914 | - fatal_lang_error('invalid_date', false); |
|
915 | - if (empty($d['year'])) |
|
916 | - fatal_lang_error('event_year_missing', false); |
|
917 | - if (empty($d['month'])) |
|
918 | - fatal_lang_error('event_month_missing', false); |
|
944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
945 | + fatal_lang_error('invalid_date', false); |
|
946 | + } |
|
947 | + if (empty($d['year'])) { |
|
948 | + fatal_lang_error('event_year_missing', false); |
|
949 | + } |
|
950 | + if (empty($d['month'])) { |
|
951 | + fatal_lang_error('event_month_missing', false); |
|
952 | + } |
|
919 | 953 | } |
920 | 954 | // The 2.0 way |
921 | 955 | else |
922 | 956 | { |
923 | 957 | // No month? No year? |
924 | - if (!isset($_POST['month'])) |
|
925 | - fatal_lang_error('event_month_missing', false); |
|
926 | - if (!isset($_POST['year'])) |
|
927 | - fatal_lang_error('event_year_missing', false); |
|
958 | + if (!isset($_POST['month'])) { |
|
959 | + fatal_lang_error('event_month_missing', false); |
|
960 | + } |
|
961 | + if (!isset($_POST['year'])) { |
|
962 | + fatal_lang_error('event_year_missing', false); |
|
963 | + } |
|
928 | 964 | |
929 | 965 | // Check the month and year... |
930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
931 | - fatal_lang_error('invalid_month', false); |
|
932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
933 | - fatal_lang_error('invalid_year', false); |
|
966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
967 | + fatal_lang_error('invalid_month', false); |
|
968 | + } |
|
969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
970 | + fatal_lang_error('invalid_year', false); |
|
971 | + } |
|
934 | 972 | } |
935 | 973 | } |
936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
941 | 979 | if (isset($_POST['span'])) |
942 | 980 | { |
943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
944 | - fatal_lang_error('invalid_days_numb', false); |
|
981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
982 | + fatal_lang_error('invalid_days_numb', false); |
|
983 | + } |
|
945 | 984 | } |
946 | 985 | |
947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
952 | 991 | { |
953 | 992 | // No day? |
954 | - if (!isset($_POST['day'])) |
|
955 | - fatal_lang_error('event_day_missing', false); |
|
993 | + if (!isset($_POST['day'])) { |
|
994 | + fatal_lang_error('event_day_missing', false); |
|
995 | + } |
|
956 | 996 | |
957 | 997 | // Bad day? |
958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
959 | - fatal_lang_error('invalid_date', false); |
|
998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
999 | + fatal_lang_error('invalid_date', false); |
|
1000 | + } |
|
960 | 1001 | } |
961 | 1002 | |
962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
963 | - fatal_lang_error('event_title_missing', false); |
|
964 | - elseif (!isset($_POST['evtitle'])) |
|
965 | - $_POST['evtitle'] = $_POST['subject']; |
|
1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
1004 | + fatal_lang_error('event_title_missing', false); |
|
1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
1007 | + } |
|
966 | 1008 | |
967 | 1009 | // No title? |
968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
969 | - fatal_lang_error('no_event_title', false); |
|
970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1011 | + fatal_lang_error('no_event_title', false); |
|
1012 | + } |
|
1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1015 | + } |
|
972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
973 | 1017 | } |
974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
995 | 1039 | ); |
996 | 1040 | |
997 | 1041 | // No results, return false. |
998 | - if ($smcFunc['db_num_rows'] === 0) |
|
999 | - return false; |
|
1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1043 | + return false; |
|
1044 | + } |
|
1000 | 1045 | |
1001 | 1046 | // Grab the results and return. |
1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1131 | 1176 | |
1132 | 1177 | $column_clauses = array(); |
1133 | - foreach ($event_columns as $col => $crit) |
|
1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1178 | + foreach ($event_columns as $col => $crit) { |
|
1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1180 | + } |
|
1135 | 1181 | |
1136 | 1182 | $smcFunc['db_query']('', ' |
1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
1216 | 1262 | ); |
1217 | 1263 | |
1218 | 1264 | // If nothing returned, we are in poo, poo. |
1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1220 | - return false; |
|
1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1266 | + return false; |
|
1267 | + } |
|
1221 | 1268 | |
1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1226 | 1273 | |
1227 | 1274 | // Sanity check |
1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1229 | - return false; |
|
1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1276 | + return false; |
|
1277 | + } |
|
1230 | 1278 | |
1231 | 1279 | $return_value = array( |
1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
1363 | 1411 | |
1364 | 1412 | // Set $span, in case we need it |
1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1366 | - if ($span > 0) |
|
1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1414 | + if ($span > 0) { |
|
1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1416 | + } |
|
1368 | 1417 | |
1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1371 | - $tz = $eventOptions['tz']; |
|
1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1373 | - $tz = $_POST['tz']; |
|
1374 | - else |
|
1375 | - $tz = getUserTimezone(); |
|
1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1420 | + $tz = $eventOptions['tz']; |
|
1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1422 | + $tz = $_POST['tz']; |
|
1423 | + } else { |
|
1424 | + $tz = getUserTimezone(); |
|
1425 | + } |
|
1376 | 1426 | |
1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1378 | - if (isset($eventOptions['allday'])) |
|
1379 | - $allday = $eventOptions['allday']; |
|
1380 | - elseif (empty($_POST['allday'])) |
|
1381 | - $allday = false; |
|
1382 | - else |
|
1383 | - $allday = true; |
|
1428 | + if (isset($eventOptions['allday'])) { |
|
1429 | + $allday = $eventOptions['allday']; |
|
1430 | + } elseif (empty($_POST['allday'])) { |
|
1431 | + $allday = false; |
|
1432 | + } else { |
|
1433 | + $allday = true; |
|
1434 | + } |
|
1384 | 1435 | |
1385 | 1436 | // Input might come as individual parameters... |
1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1408 | 1459 | |
1409 | 1460 | // If the date and time were given in separate strings, combine them |
1410 | - if (empty($start_string) && isset($start_date_string)) |
|
1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1412 | - if (empty($end_string) && isset($end_date_string)) |
|
1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1463 | + } |
|
1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1466 | + } |
|
1414 | 1467 | |
1415 | 1468 | // If some form of string input was given, override individually defined options with it |
1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
1501 | 1554 | if ($start_object >= $end_object) |
1502 | 1555 | { |
1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1504 | - if ($span > 0) |
|
1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1506 | - else |
|
1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1557 | + if ($span > 0) { |
|
1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1559 | + } else { |
|
1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1561 | + } |
|
1508 | 1562 | } |
1509 | 1563 | |
1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
1517 | 1571 | { |
1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1574 | + } else { |
|
1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1520 | 1576 | } |
1521 | - else |
|
1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1523 | 1577 | } |
1524 | 1578 | } |
1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
1532 | 1586 | $start_time = null; |
1533 | 1587 | $end_time = null; |
1534 | 1588 | $tz = null; |
1535 | - } |
|
1536 | - else |
|
1589 | + } else |
|
1537 | 1590 | { |
1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
1560 | 1613 | if (empty($date_format)) |
1561 | 1614 | { |
1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1563 | - $date_format = '%F'; |
|
1564 | - else |
|
1565 | - $date_format = $matches[0]; |
|
1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1616 | + $date_format = '%F'; |
|
1617 | + } else { |
|
1618 | + $date_format = $matches[0]; |
|
1619 | + } |
|
1566 | 1620 | } |
1567 | 1621 | |
1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1569 | 1623 | if (empty($time_format)) |
1570 | 1624 | { |
1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1572 | - $time_format = '%k:%M'; |
|
1573 | - else |
|
1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1626 | + $time_format = '%k:%M'; |
|
1627 | + } else { |
|
1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1629 | + } |
|
1575 | 1630 | } |
1576 | 1631 | |
1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1582 | 1637 | |
1583 | 1638 | // We need to have a defined timezone in the steps below |
1584 | - if (empty($row['timezone'])) |
|
1585 | - $row['timezone'] = getUserTimezone(); |
|
1639 | + if (empty($row['timezone'])) { |
|
1640 | + $row['timezone'] = getUserTimezone(); |
|
1641 | + } |
|
1586 | 1642 | |
1587 | - if (empty($timezone_array[$row['timezone']])) |
|
1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1645 | + } |
|
1589 | 1646 | |
1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
1634 | 1691 | static $member_cache = array(); |
1635 | 1692 | |
1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1637 | - $id_member = $context['user']['id']; |
|
1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1694 | + $id_member = $context['user']['id']; |
|
1695 | + } |
|
1638 | 1696 | |
1639 | 1697 | //check if the cache got the data |
1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
1663 | 1721 | $smcFunc['db_free_result']($request); |
1664 | 1722 | } |
1665 | 1723 | |
1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1726 | + } |
|
1668 | 1727 | |
1669 | - if (isset($id_member)) |
|
1670 | - $member_cache[$id_member] = $timezone; |
|
1728 | + if (isset($id_member)) { |
|
1729 | + $member_cache[$id_member] = $timezone; |
|
1730 | + } |
|
1671 | 1731 | |
1672 | 1732 | return $timezone; |
1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
1696 | 1756 | ) |
1697 | 1757 | ); |
1698 | 1758 | $holidays = array(); |
1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1700 | - $holidays[] = $row; |
|
1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1760 | + $holidays[] = $row; |
|
1761 | + } |
|
1701 | 1762 | $smcFunc['db_free_result']($request); |
1702 | 1763 | |
1703 | 1764 | return $holidays; |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Interface cache_api_interface |
@@ -182,8 +183,9 @@ discard block |
||
182 | 183 | { |
183 | 184 | global $cache_enable; |
184 | 185 | |
185 | - if ($test) |
|
186 | - return true; |
|
186 | + if ($test) { |
|
187 | + return true; |
|
188 | + } |
|
187 | 189 | return !empty($cache_enable); |
188 | 190 | } |
189 | 191 | |
@@ -202,18 +204,20 @@ discard block |
||
202 | 204 | global $boardurl, $cachedir; |
203 | 205 | |
204 | 206 | // Find a valid good file to do mtime checks on. |
205 | - if (file_exists($cachedir . '/' . 'index.php')) |
|
206 | - $filemtime = $cachedir . '/' . 'index.php'; |
|
207 | - elseif (is_dir($cachedir . '/')) |
|
208 | - $filemtime = $cachedir . '/'; |
|
209 | - else |
|
210 | - $filemtime = $boardurl . '/index.php'; |
|
207 | + if (file_exists($cachedir . '/' . 'index.php')) { |
|
208 | + $filemtime = $cachedir . '/' . 'index.php'; |
|
209 | + } elseif (is_dir($cachedir . '/')) { |
|
210 | + $filemtime = $cachedir . '/'; |
|
211 | + } else { |
|
212 | + $filemtime = $boardurl . '/index.php'; |
|
213 | + } |
|
211 | 214 | |
212 | 215 | // Set the default if no prefix was specified. |
213 | - if (empty($prefix)) |
|
214 | - $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
215 | - else |
|
216 | - $this->prefix = $prefix; |
|
216 | + if (empty($prefix)) { |
|
217 | + $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
218 | + } else { |
|
219 | + $this->prefix = $prefix; |
|
220 | + } |
|
217 | 221 | |
218 | 222 | return true; |
219 | 223 | } |
@@ -276,8 +280,9 @@ discard block |
||
276 | 280 | |
277 | 281 | // Invalidate cache, to be sure! |
278 | 282 | // ... as long as index.php can be modified, anyway. |
279 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
280 | - @touch($cachedir . '/' . 'index.php'); |
|
283 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
284 | + @touch($cachedir . '/' . 'index.php'); |
|
285 | + } |
|
281 | 286 | |
282 | 287 | return true; |
283 | 288 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | |
50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
51 | 52 | |
52 | - if (pg_affected_rows($result) === 0) |
|
53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
53 | + if (pg_affected_rows($result) === 0) { |
|
54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | |
56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
60 | 62 | { |
61 | 63 | global $smcFunc, $db_connection; |
62 | 64 | |
63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
64 | - return false; |
|
65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
66 | + return false; |
|
67 | + } |
|
65 | 68 | |
66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
67 | 70 | $res = pg_fetch_assoc($result); |
68 | 71 | |
69 | - if ($res['server_version_num'] < 90500) |
|
70 | - return false; |
|
72 | + if ($res['server_version_num'] < 90500) { |
|
73 | + return false; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | return $test ? true : parent::isSupported(); |
73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
81 | 85 | |
82 | 86 | $ttl = time() - $ttl; |
83 | 87 | |
84 | - if (empty($this->pg_get_data_prep)) |
|
85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
88 | + if (empty($this->pg_get_data_prep)) { |
|
89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
88 | 93 | |
89 | - if (pg_affected_rows($result) === 0) |
|
90 | - return null; |
|
94 | + if (pg_affected_rows($result) === 0) { |
|
95 | + return null; |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $res = pg_fetch_assoc($result); |
93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
101 | 107 | { |
102 | 108 | global $db_prefix, $db_connection; |
103 | 109 | |
104 | - if (!isset($value)) |
|
105 | - $value = ''; |
|
110 | + if (!isset($value)) { |
|
111 | + $value = ''; |
|
112 | + } |
|
106 | 113 | |
107 | 114 | $ttl = time() + $ttl; |
108 | 115 | |
109 | - if (empty($this->pg_put_data_prep)) |
|
110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
116 | + if (empty($this->pg_put_data_prep)) { |
|
117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
113 | 120 | ); |
121 | + } |
|
114 | 122 | |
115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
116 | 124 | |
117 | - if (pg_affected_rows($result) > 0) |
|
118 | - return true; |
|
119 | - else |
|
120 | - return false; |
|
125 | + if (pg_affected_rows($result) > 0) { |
|
126 | + return true; |
|
127 | + } else { |
|
128 | + return false; |
|
129 | + } |
|
121 | 130 | } |
122 | 131 | |
123 | 132 | /** |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | } |
46 | 47 | |
47 | 48 | // Not allowed sort method? Bang! Error! |
48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Initialize the array that'll be returned later on. |
52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
63 | 65 | // Get any spiders if enabled. |
64 | 66 | $spiders = array(); |
65 | 67 | $spider_finds = array(); |
66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Load the users online right now. |
70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
92 | 95 | $membersOnlineStats['num_guests']++; |
93 | 96 | |
94 | 97 | continue; |
95 | - } |
|
96 | - |
|
97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | 99 | { |
99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
102 | 103 | } |
103 | 104 | |
104 | 105 | // Some basic color coding... |
105 | - if (!empty($row['online_color'])) |
|
106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
107 | - else |
|
108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
106 | + if (!empty($row['online_color'])) { |
|
107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
108 | + } else { |
|
109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | // Buddies get counted and highlighted. |
111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
133 | 135 | |
134 | 136 | // Store all distinct (primary) membergroups that are shown. |
135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | 139 | 'id' => $row['id_group'], |
138 | 140 | 'name' => $row['group_name'], |
139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
141 | 143 | 'type' => $row['group_type'], |
142 | 144 | 'parent' => $row['id_parent'], |
143 | 145 | ); |
146 | + } |
|
144 | 147 | } |
145 | 148 | $smcFunc['db_free_result']($request); |
146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
201 | 204 | $settingsToUpdate = array(); |
202 | 205 | |
203 | 206 | // More members on now than ever were? Update it! |
204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
205 | - $settingsToUpdate = array( |
|
207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
208 | + $settingsToUpdate = array( |
|
206 | 209 | 'mostOnline' => $total_users_online, |
207 | 210 | 'mostDate' => time() |
208 | 211 | ); |
212 | + } |
|
209 | 213 | |
210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
237 | 241 | { |
238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
239 | 243 | |
240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
241 | - trackStats(array('most_on' => $total_users_online)); |
|
244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
245 | + trackStats(array('most_on' => $total_users_online)); |
|
246 | + } |
|
242 | 247 | |
243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
256 | 261 | } |
257 | 262 | |
258 | - if (!empty($settingsToUpdate)) |
|
259 | - updateSettings($settingsToUpdate); |
|
260 | -} |
|
263 | + if (!empty($settingsToUpdate)) { |
|
264 | + updateSettings($settingsToUpdate); |
|
265 | + } |
|
266 | + } |
|
261 | 267 | |
262 | 268 | ?> |
263 | 269 | \ No newline at end of file |