@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 4 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
65 | 68 | @ini_set('session.serialize_handler', 'php'); |
66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
67 | 70 | @ini_set('session.gc_probability', '1'); |
71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
68 | 73 | } |
69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
71 | 74 | |
72 | 75 | // Use cache setting sessions? |
73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
74 | - call_integration_hook('integrate_session_handlers'); |
|
76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
77 | + call_integration_hook('integrate_session_handlers'); |
|
78 | + } |
|
75 | 79 | |
76 | 80 | session_start(); |
77 | 81 | |
78 | 82 | // Change it so the cache settings are a little looser than default. |
79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
80 | - header('Cache-Control: private'); |
|
83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
84 | + header('Cache-Control: private'); |
|
85 | + } |
|
81 | 86 | } |
82 | 87 | |
83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | { |
124 | 129 | global $smcFunc; |
125 | 130 | |
126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
127 | - return ''; |
|
131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
132 | + return ''; |
|
133 | + } |
|
128 | 134 | |
129 | 135 | // Look for it in the database. |
130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
153 | 159 | { |
154 | 160 | global $smcFunc; |
155 | 161 | |
156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
157 | - return false; |
|
162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
163 | + return false; |
|
164 | + } |
|
158 | 165 | |
159 | 166 | // First try to update an existing row... |
160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
169 | 176 | ); |
170 | 177 | |
171 | 178 | // If that didn't work, try inserting a new one. |
172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
173 | - $smcFunc['db_insert']('ignore', |
|
179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
180 | + $smcFunc['db_insert']('ignore', |
|
174 | 181 | '{db_prefix}sessions', |
175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
176 | 183 | array($session_id, $data, time()), |
177 | 184 | array('session_id') |
178 | 185 | ); |
186 | + } |
|
179 | 187 | |
180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
190 | 198 | { |
191 | 199 | global $smcFunc; |
192 | 200 | |
193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
194 | - return false; |
|
201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
202 | + return false; |
|
203 | + } |
|
195 | 204 | |
196 | 205 | // Just delete the row... |
197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
217 | 226 | global $modSettings, $smcFunc; |
218 | 227 | |
219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
231 | + } |
|
222 | 232 | |
223 | 233 | // Clean up after yerself ;). |
224 | 234 | $smcFunc['db_query']('', ' |
@@ -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 | * Allow the user to vote. |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | 'not_guest' => 0, |
52 | 53 | ) |
53 | 54 | ); |
54 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
55 | - fatal_lang_error('poll_error', false); |
|
55 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
56 | + fatal_lang_error('poll_error', false); |
|
57 | + } |
|
56 | 58 | $row = $smcFunc['db_fetch_assoc']($request); |
57 | 59 | $smcFunc['db_free_result']($request); |
58 | 60 | |
@@ -60,8 +62,9 @@ discard block |
||
60 | 62 | if ($user_info['is_guest']) |
61 | 63 | { |
62 | 64 | // Guest voting disabled? |
63 | - if (!$row['guest_vote']) |
|
64 | - fatal_lang_error('guest_vote_disabled'); |
|
65 | + if (!$row['guest_vote']) { |
|
66 | + fatal_lang_error('guest_vote_disabled'); |
|
67 | + } |
|
65 | 68 | // Guest already voted? |
66 | 69 | elseif (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $row['id_poll'] . ',') !== false) |
67 | 70 | { |
@@ -71,32 +74,36 @@ discard block |
||
71 | 74 | foreach ($guestinfo as $i => $guestvoted) |
72 | 75 | { |
73 | 76 | $guestvoted = explode(',', $guestvoted); |
74 | - if ($guestvoted[0] == $row['id_poll']) |
|
75 | - break; |
|
77 | + if ($guestvoted[0] == $row['id_poll']) { |
|
78 | + break; |
|
79 | + } |
|
76 | 80 | } |
77 | 81 | // Has the poll been reset since guest voted? |
78 | 82 | if ($row['reset_poll'] > $guestvoted[1]) |
79 | 83 | { |
80 | 84 | // Remove the poll info from the cookie to allow guest to vote again |
81 | 85 | unset($guestinfo[$i]); |
82 | - if (!empty($guestinfo)) |
|
83 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
84 | - else |
|
85 | - unset($_COOKIE['guest_poll_vote']); |
|
86 | + if (!empty($guestinfo)) { |
|
87 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
88 | + } else { |
|
89 | + unset($_COOKIE['guest_poll_vote']); |
|
90 | + } |
|
91 | + } else { |
|
92 | + fatal_lang_error('poll_error', false); |
|
86 | 93 | } |
87 | - else |
|
88 | - fatal_lang_error('poll_error', false); |
|
89 | 94 | unset($guestinfo, $guestvoted, $i); |
90 | 95 | } |
91 | 96 | } |
92 | 97 | |
93 | 98 | // Is voting locked or has it expired? |
94 | - if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
95 | - fatal_lang_error('poll_error', false); |
|
99 | + if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
100 | + fatal_lang_error('poll_error', false); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | // If they have already voted and aren't allowed to change their vote - hence they are outta here! |
98 | - if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) |
|
99 | - fatal_lang_error('poll_error', false); |
|
104 | + if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) { |
|
105 | + fatal_lang_error('poll_error', false); |
|
106 | + } |
|
100 | 107 | // Otherwise if they can change their vote yet they haven't sent any options... remove their vote and redirect. |
101 | 108 | elseif (!empty($row['change_vote']) && !$user_info['is_guest'] && empty($_POST['options'])) |
102 | 109 | { |
@@ -114,8 +121,9 @@ discard block |
||
114 | 121 | 'id_poll' => $row['id_poll'], |
115 | 122 | ) |
116 | 123 | ); |
117 | - while ($choice = $smcFunc['db_fetch_row']($request)) |
|
118 | - $pollOptions[] = $choice[0]; |
|
124 | + while ($choice = $smcFunc['db_fetch_row']($request)) { |
|
125 | + $pollOptions[] = $choice[0]; |
|
126 | + } |
|
119 | 127 | $smcFunc['db_free_result']($request); |
120 | 128 | |
121 | 129 | // Just skip it if they had voted for nothing before. |
@@ -148,19 +156,22 @@ discard block |
||
148 | 156 | } |
149 | 157 | |
150 | 158 | // Redirect back to the topic so the user can vote again! |
151 | - if (empty($_POST['options'])) |
|
152 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
159 | + if (empty($_POST['options'])) { |
|
160 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
161 | + } |
|
153 | 162 | } |
154 | 163 | |
155 | 164 | checkSession('request'); |
156 | 165 | |
157 | 166 | // Make sure the option(s) are valid. |
158 | - if (empty($_POST['options'])) |
|
159 | - fatal_lang_error('didnt_select_vote', false); |
|
167 | + if (empty($_POST['options'])) { |
|
168 | + fatal_lang_error('didnt_select_vote', false); |
|
169 | + } |
|
160 | 170 | |
161 | 171 | // Too many options checked! |
162 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
163 | - fatal_lang_error('poll_too_many_votes', false, array($row['max_votes'])); |
|
172 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
173 | + fatal_lang_error('poll_too_many_votes', false, array($row['max_votes'])); |
|
174 | + } |
|
164 | 175 | |
165 | 176 | $pollOptions = array(); |
166 | 177 | $inserts = array(); |
@@ -250,24 +261,30 @@ discard block |
||
250 | 261 | list ($memberID, $pollID, $voting_locked) = $smcFunc['db_fetch_row']($request); |
251 | 262 | |
252 | 263 | // If the user _can_ modify the poll.... |
253 | - if (!allowedTo('poll_lock_any')) |
|
254 | - isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any')); |
|
264 | + if (!allowedTo('poll_lock_any')) { |
|
265 | + isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any')); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // It's been locked by a non-moderator. |
257 | - if ($voting_locked == '1') |
|
258 | - $voting_locked = '0'; |
|
269 | + if ($voting_locked == '1') { |
|
270 | + $voting_locked = '0'; |
|
271 | + } |
|
259 | 272 | // Locked by a moderator, and this is a moderator. |
260 | - elseif ($voting_locked == '2' && allowedTo('moderate_board')) |
|
261 | - $voting_locked = '0'; |
|
273 | + elseif ($voting_locked == '2' && allowedTo('moderate_board')) { |
|
274 | + $voting_locked = '0'; |
|
275 | + } |
|
262 | 276 | // Sorry, a moderator locked it. |
263 | - elseif ($voting_locked == '2' && !allowedTo('moderate_board')) |
|
264 | - fatal_lang_error('locked_by_admin', 'user'); |
|
277 | + elseif ($voting_locked == '2' && !allowedTo('moderate_board')) { |
|
278 | + fatal_lang_error('locked_by_admin', 'user'); |
|
279 | + } |
|
265 | 280 | // A moderator *is* locking it. |
266 | - elseif ($voting_locked == '0' && allowedTo('moderate_board')) |
|
267 | - $voting_locked = '2'; |
|
281 | + elseif ($voting_locked == '0' && allowedTo('moderate_board')) { |
|
282 | + $voting_locked = '2'; |
|
283 | + } |
|
268 | 284 | // Well, it's gonna be locked one way or another otherwise... |
269 | - else |
|
270 | - $voting_locked = '1'; |
|
285 | + else { |
|
286 | + $voting_locked = '1'; |
|
287 | + } |
|
271 | 288 | |
272 | 289 | // Lock! *Poof* - no one can vote. |
273 | 290 | $smcFunc['db_query']('', ' |
@@ -302,8 +319,9 @@ discard block |
||
302 | 319 | { |
303 | 320 | global $txt, $user_info, $context, $topic, $board, $smcFunc, $sourcedir, $scripturl; |
304 | 321 | |
305 | - if (empty($topic)) |
|
306 | - fatal_lang_error('no_access', false); |
|
322 | + if (empty($topic)) { |
|
323 | + fatal_lang_error('no_access', false); |
|
324 | + } |
|
307 | 325 | |
308 | 326 | loadLanguage('Post'); |
309 | 327 | loadTemplate('Poll'); |
@@ -327,24 +345,28 @@ discard block |
||
327 | 345 | ); |
328 | 346 | |
329 | 347 | // Assume the the topic exists, right? |
330 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
331 | - fatal_lang_error('no_board'); |
|
348 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
349 | + fatal_lang_error('no_board'); |
|
350 | + } |
|
332 | 351 | // Get the poll information. |
333 | 352 | $pollinfo = $smcFunc['db_fetch_assoc']($request); |
334 | 353 | $smcFunc['db_free_result']($request); |
335 | 354 | |
336 | 355 | // If we are adding a new poll - make sure that there isn't already a poll there. |
337 | - if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) |
|
338 | - fatal_lang_error('poll_already_exists'); |
|
356 | + if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) { |
|
357 | + fatal_lang_error('poll_already_exists'); |
|
358 | + } |
|
339 | 359 | // Otherwise, if we're editing it, it does exist I assume? |
340 | - elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) |
|
341 | - fatal_lang_error('poll_not_found'); |
|
360 | + elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) { |
|
361 | + fatal_lang_error('poll_not_found'); |
|
362 | + } |
|
342 | 363 | |
343 | 364 | // Can you do this? |
344 | - if ($context['is_edit'] && !allowedTo('poll_edit_any')) |
|
345 | - isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
|
346 | - elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) |
|
347 | - isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any')); |
|
365 | + if ($context['is_edit'] && !allowedTo('poll_edit_any')) { |
|
366 | + isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
|
367 | + } elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) { |
|
368 | + isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any')); |
|
369 | + } |
|
348 | 370 | $context['can_moderate_poll'] = isset($_REQUEST['add']) ? true : allowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
349 | 371 | |
350 | 372 | // Do we enable guest voting? |
@@ -386,12 +408,14 @@ discard block |
||
386 | 408 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
387 | 409 | { |
388 | 410 | // Get the highest id so we can add more without reusing. |
389 | - if ($row['id_choice'] >= $last_id) |
|
390 | - $last_id = $row['id_choice'] + 1; |
|
411 | + if ($row['id_choice'] >= $last_id) { |
|
412 | + $last_id = $row['id_choice'] + 1; |
|
413 | + } |
|
391 | 414 | |
392 | 415 | // They cleared this by either omitting it or emptying it. |
393 | - if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') |
|
394 | - continue; |
|
416 | + if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') { |
|
417 | + continue; |
|
418 | + } |
|
395 | 419 | |
396 | 420 | censorText($row['label']); |
397 | 421 | |
@@ -409,9 +433,10 @@ discard block |
||
409 | 433 | |
410 | 434 | // Work out how many options we have, so we get the 'is_last' field right... |
411 | 435 | $totalPostOptions = 0; |
412 | - foreach ($_POST['options'] as $id => $label) |
|
413 | - if ($label != '') |
|
436 | + foreach ($_POST['options'] as $id => $label) { |
|
437 | + if ($label != '') |
|
414 | 438 | $totalPostOptions++; |
439 | + } |
|
415 | 440 | |
416 | 441 | $count = 1; |
417 | 442 | // If an option exists, update it. If it is new, add it - but don't reuse ids! |
@@ -420,30 +445,32 @@ discard block |
||
420 | 445 | $label = $smcFunc['htmlspecialchars']($label); |
421 | 446 | censorText($label); |
422 | 447 | |
423 | - if (isset($context['choices'][$id])) |
|
424 | - $context['choices'][$id]['label'] = $label; |
|
425 | - elseif ($label != '') |
|
426 | - $context['choices'][] = array( |
|
448 | + if (isset($context['choices'][$id])) { |
|
449 | + $context['choices'][$id]['label'] = $label; |
|
450 | + } elseif ($label != '') { |
|
451 | + $context['choices'][] = array( |
|
427 | 452 | 'id' => $last_id++, |
428 | 453 | 'number' => $number++, |
429 | 454 | 'label' => $label, |
430 | 455 | 'votes' => -1, |
431 | 456 | 'is_last' => $count++ == $totalPostOptions && $totalPostOptions > 1 ? true : false, |
432 | 457 | ); |
458 | + } |
|
433 | 459 | } |
434 | 460 | |
435 | 461 | // Make sure we have two choices for sure! |
436 | 462 | if ($totalPostOptions < 2) |
437 | 463 | { |
438 | 464 | // Need two? |
439 | - if ($totalPostOptions == 0) |
|
440 | - $context['choices'][] = array( |
|
465 | + if ($totalPostOptions == 0) { |
|
466 | + $context['choices'][] = array( |
|
441 | 467 | 'id' => $last_id++, |
442 | 468 | 'number' => $number++, |
443 | 469 | 'label' => '', |
444 | 470 | 'votes' => -1, |
445 | 471 | 'is_last' => false |
446 | 472 | ); |
473 | + } |
|
447 | 474 | $poll_errors[] = 'poll_few'; |
448 | 475 | } |
449 | 476 | |
@@ -458,12 +485,14 @@ discard block |
||
458 | 485 | |
459 | 486 | $context['last_choice_id'] = $last_id; |
460 | 487 | |
461 | - if ($context['can_moderate_poll']) |
|
462 | - $context['poll']['expiration'] = $_POST['poll_expire']; |
|
488 | + if ($context['can_moderate_poll']) { |
|
489 | + $context['poll']['expiration'] = $_POST['poll_expire']; |
|
490 | + } |
|
463 | 491 | |
464 | 492 | // Check the question/option count for errors. |
465 | - if (trim($_POST['question']) == '' && empty($context['poll_error'])) |
|
466 | - $poll_errors[] = 'no_question'; |
|
493 | + if (trim($_POST['question']) == '' && empty($context['poll_error'])) { |
|
494 | + $poll_errors[] = 'no_question'; |
|
495 | + } |
|
467 | 496 | |
468 | 497 | // No check is needed, since nothing is really posted. |
469 | 498 | checkSubmitOnce('free'); |
@@ -480,8 +509,7 @@ discard block |
||
480 | 509 | $context['poll_error']['messages'][] = $txt['error_' . $poll_error]; |
481 | 510 | } |
482 | 511 | } |
483 | - } |
|
484 | - else |
|
512 | + } else |
|
485 | 513 | { |
486 | 514 | // Basic theme info... |
487 | 515 | $context['poll'] = array( |
@@ -596,18 +624,22 @@ discard block |
||
596 | 624 | global $user_info, $smcFunc, $sourcedir; |
597 | 625 | |
598 | 626 | // Sneaking off, are we? |
599 | - if (empty($_POST)) |
|
600 | - redirectexit('action=editpoll;topic=' . $topic . '.0'); |
|
627 | + if (empty($_POST)) { |
|
628 | + redirectexit('action=editpoll;topic=' . $topic . '.0'); |
|
629 | + } |
|
601 | 630 | |
602 | - if (checkSession('post', '', false) != '') |
|
603 | - $poll_errors[] = 'session_timeout'; |
|
631 | + if (checkSession('post', '', false) != '') { |
|
632 | + $poll_errors[] = 'session_timeout'; |
|
633 | + } |
|
604 | 634 | |
605 | - if (isset($_POST['preview'])) |
|
606 | - return EditPoll(); |
|
635 | + if (isset($_POST['preview'])) { |
|
636 | + return EditPoll(); |
|
637 | + } |
|
607 | 638 | |
608 | 639 | // HACKERS (!!) can't edit :P. |
609 | - if (empty($topic)) |
|
610 | - fatal_lang_error('no_access', false); |
|
640 | + if (empty($topic)) { |
|
641 | + fatal_lang_error('no_access', false); |
|
642 | + } |
|
611 | 643 | |
612 | 644 | // Is this a new poll, or editing an existing? |
613 | 645 | $isEdit = isset($_REQUEST['add']) ? 0 : 1; |
@@ -623,23 +655,27 @@ discard block |
||
623 | 655 | 'current_topic' => $topic, |
624 | 656 | ) |
625 | 657 | ); |
626 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
627 | - fatal_lang_error('no_board'); |
|
658 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
659 | + fatal_lang_error('no_board'); |
|
660 | + } |
|
628 | 661 | $bcinfo = $smcFunc['db_fetch_assoc']($request); |
629 | 662 | $smcFunc['db_free_result']($request); |
630 | 663 | |
631 | 664 | // Check their adding/editing is valid. |
632 | - if (!$isEdit && !empty($bcinfo['id_poll'])) |
|
633 | - fatal_lang_error('poll_already_exists'); |
|
665 | + if (!$isEdit && !empty($bcinfo['id_poll'])) { |
|
666 | + fatal_lang_error('poll_already_exists'); |
|
667 | + } |
|
634 | 668 | // Are we editing a poll which doesn't exist? |
635 | - elseif ($isEdit && empty($bcinfo['id_poll'])) |
|
636 | - fatal_lang_error('poll_not_found'); |
|
669 | + elseif ($isEdit && empty($bcinfo['id_poll'])) { |
|
670 | + fatal_lang_error('poll_not_found'); |
|
671 | + } |
|
637 | 672 | |
638 | 673 | // Check if they have the power to add or edit the poll. |
639 | - if ($isEdit && !allowedTo('poll_edit_any')) |
|
640 | - isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any')); |
|
641 | - elseif (!$isEdit && !allowedTo('poll_add_any')) |
|
642 | - isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any')); |
|
674 | + if ($isEdit && !allowedTo('poll_edit_any')) { |
|
675 | + isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any')); |
|
676 | + } elseif (!$isEdit && !allowedTo('poll_add_any')) { |
|
677 | + isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any')); |
|
678 | + } |
|
643 | 679 | |
644 | 680 | $optionCount = 0; |
645 | 681 | $idCount = 0; |
@@ -652,14 +688,16 @@ discard block |
||
652 | 688 | $idCount = max($idCount, $k); |
653 | 689 | } |
654 | 690 | } |
655 | - if ($optionCount < 2) |
|
656 | - $poll_errors[] = 'poll_few'; |
|
657 | - elseif ($optionCount > 256 || $idCount > 255) |
|
658 | - $poll_errors[] = 'poll_many'; |
|
691 | + if ($optionCount < 2) { |
|
692 | + $poll_errors[] = 'poll_few'; |
|
693 | + } elseif ($optionCount > 256 || $idCount > 255) { |
|
694 | + $poll_errors[] = 'poll_many'; |
|
695 | + } |
|
659 | 696 | |
660 | 697 | // Also - ensure they are not removing the question. |
661 | - if (trim($_POST['question']) == '') |
|
662 | - $poll_errors[] = 'no_question'; |
|
698 | + if (trim($_POST['question']) == '') { |
|
699 | + $poll_errors[] = 'no_question'; |
|
700 | + } |
|
663 | 701 | |
664 | 702 | // Got any errors to report? |
665 | 703 | if (!empty($poll_errors)) |
@@ -695,8 +733,9 @@ discard block |
||
695 | 733 | { |
696 | 734 | require_once($sourcedir . '/Subs-Members.php'); |
697 | 735 | $allowedGroups = groupsAllowedTo('poll_vote', $board); |
698 | - if (!in_array(-1, $allowedGroups['allowed'])) |
|
699 | - $_POST['poll_guest_vote'] = 0; |
|
736 | + if (!in_array(-1, $allowedGroups['allowed'])) { |
|
737 | + $_POST['poll_guest_vote'] = 0; |
|
738 | + } |
|
700 | 739 | } |
701 | 740 | |
702 | 741 | // Ensure that the number options allowed makes sense, and the expiration date is valid. |
@@ -704,17 +743,19 @@ discard block |
||
704 | 743 | { |
705 | 744 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
706 | 745 | |
707 | - if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
708 | - $_POST['poll_hide'] = 1; |
|
709 | - elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) |
|
710 | - $_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24; |
|
711 | - else |
|
712 | - $_POST['poll_expire'] = $bcinfo['expire_time']; |
|
746 | + if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
747 | + $_POST['poll_hide'] = 1; |
|
748 | + } elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) { |
|
749 | + $_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24; |
|
750 | + } else { |
|
751 | + $_POST['poll_expire'] = $bcinfo['expire_time']; |
|
752 | + } |
|
713 | 753 | |
714 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
715 | - $_POST['poll_max_votes'] = 1; |
|
716 | - else |
|
717 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
754 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
755 | + $_POST['poll_max_votes'] = 1; |
|
756 | + } else { |
|
757 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
758 | + } |
|
718 | 759 | } |
719 | 760 | |
720 | 761 | // If we're editing, let's commit the changes. |
@@ -779,8 +820,9 @@ discard block |
||
779 | 820 | ) |
780 | 821 | ); |
781 | 822 | $choices = array(); |
782 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
783 | - $choices[] = $row['id_choice']; |
|
823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
824 | + $choices[] = $row['id_choice']; |
|
825 | + } |
|
784 | 826 | $smcFunc['db_free_result']($request); |
785 | 827 | |
786 | 828 | $delete_options = array(); |
@@ -793,8 +835,9 @@ discard block |
||
793 | 835 | if (trim($option) == '') |
794 | 836 | { |
795 | 837 | // They want it deleted. Bye. |
796 | - if (in_array($k, $choices)) |
|
797 | - $delete_options[] = $k; |
|
838 | + if (in_array($k, $choices)) { |
|
839 | + $delete_options[] = $k; |
|
840 | + } |
|
798 | 841 | |
799 | 842 | // Skip the rest... |
800 | 843 | continue; |
@@ -804,8 +847,8 @@ discard block |
||
804 | 847 | $option = $smcFunc['htmlspecialchars']($option); |
805 | 848 | |
806 | 849 | // If it's already there, update it. If it's not... add it. |
807 | - if (in_array($k, $choices)) |
|
808 | - $smcFunc['db_query']('', ' |
|
850 | + if (in_array($k, $choices)) { |
|
851 | + $smcFunc['db_query']('', ' |
|
809 | 852 | UPDATE {db_prefix}poll_choices |
810 | 853 | SET label = {string:option_name} |
811 | 854 | WHERE id_poll = {int:id_poll} |
@@ -816,8 +859,8 @@ discard block |
||
816 | 859 | 'option_name' => $option, |
817 | 860 | ) |
818 | 861 | ); |
819 | - else |
|
820 | - $smcFunc['db_insert']('', |
|
862 | + } else { |
|
863 | + $smcFunc['db_insert']('', |
|
821 | 864 | '{db_prefix}poll_choices', |
822 | 865 | array( |
823 | 866 | 'id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255', 'votes' => 'int', |
@@ -827,6 +870,7 @@ discard block |
||
827 | 870 | ), |
828 | 871 | array() |
829 | 872 | ); |
873 | + } |
|
830 | 874 | } |
831 | 875 | |
832 | 876 | // I'm sorry, but... well, no one was choosing you. Poor options, I'll put you out of your misery. |
@@ -892,13 +936,11 @@ discard block |
||
892 | 936 | { |
893 | 937 | // Added a poll |
894 | 938 | logAction('add_poll', array('topic' => $topic)); |
895 | - } |
|
896 | - elseif (isset($_REQUEST['deletevotes'])) |
|
939 | + } elseif (isset($_REQUEST['deletevotes'])) |
|
897 | 940 | { |
898 | 941 | // Reset votes |
899 | 942 | logAction('reset_poll', array('topic' => $topic)); |
900 | - } |
|
901 | - else |
|
943 | + } else |
|
902 | 944 | { |
903 | 945 | // Something else |
904 | 946 | logAction('editpoll', array('topic' => $topic)); |
@@ -921,8 +963,9 @@ discard block |
||
921 | 963 | global $topic, $user_info, $smcFunc; |
922 | 964 | |
923 | 965 | // Make sure the topic is not empty. |
924 | - if (empty($topic)) |
|
925 | - fatal_lang_error('no_access', false); |
|
966 | + if (empty($topic)) { |
|
967 | + fatal_lang_error('no_access', false); |
|
968 | + } |
|
926 | 969 | |
927 | 970 | // Verify the session. |
928 | 971 | checkSession('get'); |
@@ -940,8 +983,9 @@ discard block |
||
940 | 983 | 'current_topic' => $topic, |
941 | 984 | ) |
942 | 985 | ); |
943 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
944 | - fatal_lang_error('no_access', false); |
|
986 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
987 | + fatal_lang_error('no_access', false); |
|
988 | + } |
|
945 | 989 | list ($topicStarter, $pollStarter) = $smcFunc['db_fetch_row']($request); |
946 | 990 | $smcFunc['db_free_result']($request); |
947 | 991 |
@@ -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 | * Entry point function, permission checks, admin bars, etc. |
@@ -99,27 +100,27 @@ discard block |
||
99 | 100 | 'function' => function($rowData) use ($scripturl) |
100 | 101 | { |
101 | 102 | // Since the moderator group has no explicit members, no link is needed. |
102 | - if ($rowData['id_group'] == 3) |
|
103 | - $group_name = $rowData['group_name']; |
|
104 | - else |
|
103 | + if ($rowData['id_group'] == 3) { |
|
104 | + $group_name = $rowData['group_name']; |
|
105 | + } else |
|
105 | 106 | { |
106 | 107 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
107 | 108 | |
108 | 109 | if (allowedTo('manage_membergroups')) |
109 | 110 | { |
110 | 111 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
111 | - } |
|
112 | - else |
|
112 | + } else |
|
113 | 113 | { |
114 | 114 | $group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Add a help option for moderator and administrator. |
119 | - if ($rowData['id_group'] == 1) |
|
120 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
121 | - elseif ($rowData['id_group'] == 3) |
|
122 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
119 | + if ($rowData['id_group'] == 1) { |
|
120 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
121 | + } elseif ($rowData['id_group'] == 3) { |
|
122 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
123 | + } |
|
123 | 124 | |
124 | 125 | return $group_name; |
125 | 126 | }, |
@@ -198,8 +199,9 @@ discard block |
||
198 | 199 | $_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0; |
199 | 200 | |
200 | 201 | // No browsing of guests, membergroup 0 or moderators. |
201 | - if (in_array($_REQUEST['group'], array(-1, 0, 3))) |
|
202 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
202 | + if (in_array($_REQUEST['group'], array(-1, 0, 3))) { |
|
203 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
204 | + } |
|
203 | 205 | |
204 | 206 | // Load up the group details. |
205 | 207 | $request = $smcFunc['db_query']('', ' |
@@ -214,8 +216,9 @@ discard block |
||
214 | 216 | ) |
215 | 217 | ); |
216 | 218 | // Doesn't exist? |
217 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
218 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
219 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
220 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
221 | + } |
|
219 | 222 | $context['group'] = $smcFunc['db_fetch_assoc']($request); |
220 | 223 | $smcFunc['db_free_result']($request); |
221 | 224 | |
@@ -248,21 +251,25 @@ discard block |
||
248 | 251 | 'name' => $row['real_name'] |
249 | 252 | ); |
250 | 253 | |
251 | - if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) |
|
252 | - $context['group']['can_moderate'] = true; |
|
254 | + if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) { |
|
255 | + $context['group']['can_moderate'] = true; |
|
256 | + } |
|
253 | 257 | } |
254 | 258 | $smcFunc['db_free_result']($request); |
255 | 259 | |
256 | 260 | // If this group is hidden then it can only "exists" if the user can moderate it! |
257 | - if ($context['group']['hidden'] && !$context['group']['can_moderate']) |
|
258 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
261 | + if ($context['group']['hidden'] && !$context['group']['can_moderate']) { |
|
262 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
263 | + } |
|
259 | 264 | |
260 | 265 | // You can only assign membership if you are the moderator and/or can manage groups! |
261 | - if (!$context['group']['can_moderate']) |
|
262 | - $context['group']['assignable'] = 0; |
|
266 | + if (!$context['group']['can_moderate']) { |
|
267 | + $context['group']['assignable'] = 0; |
|
268 | + } |
|
263 | 269 | // Non-admins cannot assign admins. |
264 | - elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) |
|
265 | - $context['group']['assignable'] = 0; |
|
270 | + elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) { |
|
271 | + $context['group']['assignable'] = 0; |
|
272 | + } |
|
266 | 273 | |
267 | 274 | // Removing member from group? |
268 | 275 | if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable']) |
@@ -271,8 +278,9 @@ discard block |
||
271 | 278 | validateToken('mod-mgm'); |
272 | 279 | |
273 | 280 | // Make sure we're dealing with integers only. |
274 | - foreach ($_REQUEST['rem'] as $key => $group) |
|
275 | - $_REQUEST['rem'][$key] = (int) $group; |
|
281 | + foreach ($_REQUEST['rem'] as $key => $group) { |
|
282 | + $_REQUEST['rem'][$key] = (int) $group; |
|
283 | + } |
|
276 | 284 | |
277 | 285 | require_once($sourcedir . '/Subs-Membergroups.php'); |
278 | 286 | removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true); |
@@ -295,16 +303,18 @@ discard block |
||
295 | 303 | { |
296 | 304 | $member_names[$index] = trim($smcFunc['strtolower']($member_names[$index])); |
297 | 305 | |
298 | - if (strlen($member_names[$index]) == 0) |
|
299 | - unset($member_names[$index]); |
|
306 | + if (strlen($member_names[$index]) == 0) { |
|
307 | + unset($member_names[$index]); |
|
308 | + } |
|
300 | 309 | } |
301 | 310 | |
302 | 311 | // Any passed by ID? |
303 | 312 | $member_ids = array(); |
304 | - if (!empty($_REQUEST['member_add'])) |
|
305 | - foreach ($_REQUEST['member_add'] as $id) |
|
313 | + if (!empty($_REQUEST['member_add'])) { |
|
314 | + foreach ($_REQUEST['member_add'] as $id) |
|
306 | 315 | if ($id > 0) |
307 | 316 | $member_ids[] = (int) $id; |
317 | + } |
|
308 | 318 | |
309 | 319 | // Construct the query pelements. |
310 | 320 | if (!empty($member_ids)) |
@@ -332,8 +342,9 @@ discard block |
||
332 | 342 | 'id_group' => $_REQUEST['group'], |
333 | 343 | )) |
334 | 344 | ); |
335 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
336 | - $members[] = $row['id_member']; |
|
345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
346 | + $members[] = $row['id_member']; |
|
347 | + } |
|
337 | 348 | $smcFunc['db_free_result']($request); |
338 | 349 | } |
339 | 350 | |
@@ -372,10 +383,11 @@ discard block |
||
372 | 383 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
373 | 384 | |
374 | 385 | // The where on the query is interesting. Non-moderators should only see people who are in this group as primary. |
375 | - if ($context['group']['can_moderate']) |
|
376 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
377 | - else |
|
378 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
386 | + if ($context['group']['can_moderate']) { |
|
387 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
388 | + } else { |
|
389 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // Count members of the group. |
381 | 393 | $request = $smcFunc['db_query']('', ' |
@@ -416,8 +428,9 @@ discard block |
||
416 | 428 | $last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']); |
417 | 429 | |
418 | 430 | // Italicize the online note if they aren't activated. |
419 | - if ($row['is_activated'] % 10 != 1) |
|
420 | - $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
431 | + if ($row['is_activated'] % 10 != 1) { |
|
432 | + $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
433 | + } |
|
421 | 434 | |
422 | 435 | $context['members'][] = array( |
423 | 436 | 'id' => $row['id_member'], |
@@ -437,9 +450,10 @@ discard block |
||
437 | 450 | $context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name']; |
438 | 451 | createToken('mod-mgm'); |
439 | 452 | |
440 | - if ($context['group']['assignable']) |
|
441 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
442 | -} |
|
453 | + if ($context['group']['assignable']) { |
|
454 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
455 | + } |
|
456 | + } |
|
443 | 457 | |
444 | 458 | /** |
445 | 459 | * Show and manage all group requests. |
@@ -453,16 +467,18 @@ discard block |
||
453 | 467 | $context['sub_template'] = 'show_list'; |
454 | 468 | |
455 | 469 | // Verify we can be here. |
456 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
457 | - isAllowedTo('manage_membergroups'); |
|
470 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
471 | + isAllowedTo('manage_membergroups'); |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Normally, we act normally... |
460 | 475 | $where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']); |
461 | 476 | |
462 | - if (isset($_GET['closed'])) |
|
463 | - $where .= ' AND lgr.status != {int:status_open}'; |
|
464 | - else |
|
465 | - $where .= ' AND lgr.status = {int:status_open}'; |
|
477 | + if (isset($_GET['closed'])) { |
|
478 | + $where .= ' AND lgr.status != {int:status_open}'; |
|
479 | + } else { |
|
480 | + $where .= ' AND lgr.status = {int:status_open}'; |
|
481 | + } |
|
466 | 482 | |
467 | 483 | $where_parameters = array( |
468 | 484 | 'status_open' => 0, |
@@ -475,8 +491,9 @@ discard block |
||
475 | 491 | validateToken('mod-gr'); |
476 | 492 | |
477 | 493 | // Clean the values. |
478 | - foreach ($_POST['groupr'] as $k => $request) |
|
479 | - $_POST['groupr'][$k] = (int) $request; |
|
494 | + foreach ($_POST['groupr'] as $k => $request) { |
|
495 | + $_POST['groupr'][$k] = (int) $request; |
|
496 | + } |
|
480 | 497 | |
481 | 498 | $log_changes = array(); |
482 | 499 | |
@@ -513,8 +530,8 @@ discard block |
||
513 | 530 | $request_list = array(); |
514 | 531 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
515 | 532 | { |
516 | - if (!isset($log_changes[$row['id_request']])) |
|
517 | - $log_changes[$row['id_request']] = array( |
|
533 | + if (!isset($log_changes[$row['id_request']])) { |
|
534 | + $log_changes[$row['id_request']] = array( |
|
518 | 535 | 'id_request' => $row['id_request'], |
519 | 536 | 'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected |
520 | 537 | 'id_member_acted' => $user_info['id'], |
@@ -522,6 +539,7 @@ discard block |
||
522 | 539 | 'time_acted' => time(), |
523 | 540 | 'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '', |
524 | 541 | ); |
542 | + } |
|
525 | 543 | $request_list[] = $row['id_request']; |
526 | 544 | } |
527 | 545 | $smcFunc['db_free_result']($request); |
@@ -744,21 +762,24 @@ discard block |
||
744 | 762 | $group_requests = array(); |
745 | 763 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
746 | 764 | { |
747 | - if (empty($row['reason'])) |
|
748 | - $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
749 | - else |
|
750 | - $reason = censorText($row['reason']); |
|
765 | + if (empty($row['reason'])) { |
|
766 | + $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
767 | + } else { |
|
768 | + $reason = censorText($row['reason']); |
|
769 | + } |
|
751 | 770 | |
752 | 771 | if (isset($_GET['closed'])) |
753 | 772 | { |
754 | - if ($row['status'] == 1) |
|
755 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
756 | - elseif ($row['status'] == 2) |
|
757 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
773 | + if ($row['status'] == 1) { |
|
774 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
775 | + } elseif ($row['status'] == 2) { |
|
776 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | $reason .= ' (' . timeformat($row['time_acted']) . ')'; |
760 | - if (!empty($row['act_reason'])) |
|
761 | - $reason .= '<br><br>' . censorText($row['act_reason']); |
|
780 | + if (!empty($row['act_reason'])) { |
|
781 | + $reason .= '<br><br>' . censorText($row['act_reason']); |
|
782 | + } |
|
762 | 783 | } |
763 | 784 | |
764 | 785 | $group_requests[] = array( |
@@ -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 news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -154,11 +157,12 @@ discard block |
||
154 | 157 | 'data' => array( |
155 | 158 | 'function' => function($news) |
156 | 159 | { |
157 | - if (is_numeric($news['id'])) |
|
158 | - return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
160 | + if (is_numeric($news['id'])) { |
|
161 | + return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
159 | 162 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
160 | - else |
|
161 | - return $news['unparsed']; |
|
163 | + } else { |
|
164 | + return $news['unparsed']; |
|
165 | + } |
|
162 | 166 | }, |
163 | 167 | 'style' => 'width: 50%;', |
164 | 168 | ), |
@@ -183,10 +187,11 @@ discard block |
||
183 | 187 | 'data' => array( |
184 | 188 | 'function' => function($news) |
185 | 189 | { |
186 | - if (is_numeric($news['id'])) |
|
187 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
188 | - else |
|
189 | - return ''; |
|
190 | + if (is_numeric($news['id'])) { |
|
191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
192 | + } else { |
|
193 | + return ''; |
|
194 | + } |
|
190 | 195 | }, |
191 | 196 | 'class' => 'centercol', |
192 | 197 | ), |
@@ -280,12 +285,13 @@ discard block |
||
280 | 285 | |
281 | 286 | $admin_current_news = array(); |
282 | 287 | // Ready the current news. |
283 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
284 | - $admin_current_news[$id] = array( |
|
288 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
289 | + $admin_current_news[$id] = array( |
|
285 | 290 | 'id' => $id, |
286 | 291 | 'unparsed' => un_preparsecode($line), |
287 | 292 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
288 | 293 | ); |
294 | + } |
|
289 | 295 | |
290 | 296 | $admin_current_news['last'] = array( |
291 | 297 | 'id' => 'last', |
@@ -352,10 +358,11 @@ discard block |
||
352 | 358 | 'member_count' => 0, |
353 | 359 | ); |
354 | 360 | |
355 | - if ($row['min_posts'] == -1) |
|
356 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
357 | - else |
|
358 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
361 | + if ($row['min_posts'] == -1) { |
|
362 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
363 | + } else { |
|
364 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
365 | + } |
|
359 | 366 | } |
360 | 367 | $smcFunc['db_free_result']($request); |
361 | 368 | |
@@ -371,8 +378,9 @@ discard block |
||
371 | 378 | 'post_group_list' => $postGroups, |
372 | 379 | ) |
373 | 380 | ); |
374 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
375 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
381 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
382 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
383 | + } |
|
376 | 384 | $smcFunc['db_free_result']($query); |
377 | 385 | } |
378 | 386 | |
@@ -388,8 +396,9 @@ discard block |
||
388 | 396 | 'normal_group_list' => $normalGroups, |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
392 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
400 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
401 | + } |
|
393 | 402 | $smcFunc['db_free_result']($query); |
394 | 403 | |
395 | 404 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -406,8 +415,9 @@ discard block |
||
406 | 415 | 'blank_string' => '', |
407 | 416 | ) |
408 | 417 | ); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
410 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
418 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
419 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
420 | + } |
|
411 | 421 | $smcFunc['db_free_result']($query); |
412 | 422 | } |
413 | 423 | |
@@ -458,10 +468,11 @@ discard block |
||
458 | 468 | { |
459 | 469 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
460 | 470 | |
461 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
462 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
463 | - elseif (!empty($_REQUEST['xml'])) |
|
464 | - continue; |
|
471 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
472 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
473 | + } elseif (!empty($_REQUEST['xml'])) { |
|
474 | + continue; |
|
475 | + } |
|
465 | 476 | |
466 | 477 | preparsecode($context[$key]); |
467 | 478 | if ($html) |
@@ -540,10 +551,12 @@ discard block |
||
540 | 551 | |
541 | 552 | // Start by finding any members! |
542 | 553 | $toClean = array(); |
543 | - if (!empty($_POST['members'])) |
|
544 | - $toClean[] = 'members'; |
|
545 | - if (!empty($_POST['exclude_members'])) |
|
546 | - $toClean[] = 'exclude_members'; |
|
554 | + if (!empty($_POST['members'])) { |
|
555 | + $toClean[] = 'members'; |
|
556 | + } |
|
557 | + if (!empty($_POST['exclude_members'])) { |
|
558 | + $toClean[] = 'exclude_members'; |
|
559 | + } |
|
547 | 560 | if (!empty($toClean)) |
548 | 561 | { |
549 | 562 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -555,11 +568,13 @@ discard block |
||
555 | 568 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
556 | 569 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
557 | 570 | |
558 | - foreach ($_POST[$type] as $index => $member) |
|
559 | - if (strlen(trim($member)) > 0) |
|
571 | + foreach ($_POST[$type] as $index => $member) { |
|
572 | + if (strlen(trim($member)) > 0) |
|
560 | 573 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
561 | - else |
|
562 | - unset($_POST[$type][$index]); |
|
574 | + } |
|
575 | + else { |
|
576 | + unset($_POST[$type][$index]); |
|
577 | + } |
|
563 | 578 | |
564 | 579 | // Find the members |
565 | 580 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -569,16 +584,18 @@ discard block |
||
569 | 584 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
570 | 585 | { |
571 | 586 | $members = array(); |
572 | - foreach ($_POST['member_list'] as $member_id) |
|
573 | - $members[] = (int) $member_id; |
|
587 | + foreach ($_POST['member_list'] as $member_id) { |
|
588 | + $members[] = (int) $member_id; |
|
589 | + } |
|
574 | 590 | $_POST['members'] = implode(',', $members); |
575 | 591 | } |
576 | 592 | |
577 | 593 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
578 | 594 | { |
579 | 595 | $members = array(); |
580 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
581 | - $members[] = (int) $member_id; |
|
596 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
597 | + $members[] = (int) $member_id; |
|
598 | + } |
|
582 | 599 | $_POST['exclude_members'] = implode(',', $members); |
583 | 600 | } |
584 | 601 | |
@@ -602,8 +619,9 @@ discard block |
||
602 | 619 | 'current_time' => time(), |
603 | 620 | ) |
604 | 621 | ); |
605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
606 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
623 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
624 | + } |
|
607 | 625 | $smcFunc['db_free_result']($request); |
608 | 626 | |
609 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -638,8 +656,9 @@ discard block |
||
638 | 656 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
639 | 657 | $condition_array_params |
640 | 658 | ); |
641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
642 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
659 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
660 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
661 | + } |
|
643 | 662 | $smcFunc['db_free_result']($request); |
644 | 663 | } |
645 | 664 | |
@@ -657,10 +676,11 @@ discard block |
||
657 | 676 | ); |
658 | 677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
659 | 678 | { |
660 | - if (in_array(3, $context['recipients'])) |
|
661 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
662 | - else |
|
663 | - $context['recipients']['members'][] = $row['identifier']; |
|
679 | + if (in_array(3, $context['recipients'])) { |
|
680 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
681 | + } else { |
|
682 | + $context['recipients']['members'][] = $row['identifier']; |
|
683 | + } |
|
664 | 684 | } |
665 | 685 | $smcFunc['db_free_result']($request); |
666 | 686 | } |
@@ -707,8 +727,9 @@ discard block |
||
707 | 727 | $num_at_once = 1000; |
708 | 728 | |
709 | 729 | // If by PM's I suggest we half the above number. |
710 | - if (!empty($_POST['send_pm'])) |
|
711 | - $num_at_once /= 2; |
|
730 | + if (!empty($_POST['send_pm'])) { |
|
731 | + $num_at_once /= 2; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | checkSession(); |
714 | 735 | |
@@ -731,8 +752,7 @@ discard block |
||
731 | 752 | ); |
732 | 753 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
733 | 754 | $smcFunc['db_free_result']($request); |
734 | - } |
|
735 | - else |
|
755 | + } else |
|
736 | 756 | { |
737 | 757 | $context['total_members'] = (int) $_REQUEST['total_members']; |
738 | 758 | } |
@@ -750,32 +770,35 @@ discard block |
||
750 | 770 | if (!empty($_POST['exclude_members'])) |
751 | 771 | { |
752 | 772 | $members = explode(',', $_POST['exclude_members']); |
753 | - foreach ($members as $member) |
|
754 | - if ($member >= $context['start']) |
|
773 | + foreach ($members as $member) { |
|
774 | + if ($member >= $context['start']) |
|
755 | 775 | $context['recipients']['exclude_members'][] = (int) $member; |
776 | + } |
|
756 | 777 | } |
757 | 778 | |
758 | 779 | // What about members we *must* do? |
759 | 780 | if (!empty($_POST['members'])) |
760 | 781 | { |
761 | 782 | $members = explode(',', $_POST['members']); |
762 | - foreach ($members as $member) |
|
763 | - if ($member >= $context['start']) |
|
783 | + foreach ($members as $member) { |
|
784 | + if ($member >= $context['start']) |
|
764 | 785 | $context['recipients']['members'][] = (int) $member; |
786 | + } |
|
765 | 787 | } |
766 | 788 | // Cleaning groups is simple - although deal with both checkbox and commas. |
767 | 789 | if (isset($_POST['groups'])) |
768 | 790 | { |
769 | 791 | if (is_array($_POST['groups'])) |
770 | 792 | { |
771 | - foreach ($_POST['groups'] as $group => $dummy) |
|
772 | - $context['recipients']['groups'][] = (int) $group; |
|
773 | - } |
|
774 | - else |
|
793 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
794 | + $context['recipients']['groups'][] = (int) $group; |
|
795 | + } |
|
796 | + } else |
|
775 | 797 | { |
776 | 798 | $groups = explode(',', $_POST['groups']); |
777 | - foreach ($groups as $group) |
|
778 | - $context['recipients']['groups'][] = (int) $group; |
|
799 | + foreach ($groups as $group) { |
|
800 | + $context['recipients']['groups'][] = (int) $group; |
|
801 | + } |
|
779 | 802 | } |
780 | 803 | } |
781 | 804 | // Same for excluded groups |
@@ -783,15 +806,17 @@ discard block |
||
783 | 806 | { |
784 | 807 | if (is_array($_POST['exclude_groups'])) |
785 | 808 | { |
786 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
787 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
811 | + } |
|
788 | 812 | } |
789 | 813 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
790 | 814 | elseif ($_POST['exclude_groups'] != '') |
791 | 815 | { |
792 | 816 | $groups = explode(',', $_POST['exclude_groups']); |
793 | - foreach ($groups as $group) |
|
794 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
817 | + foreach ($groups as $group) { |
|
818 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
819 | + } |
|
795 | 820 | } |
796 | 821 | } |
797 | 822 | // Finally - emails! |
@@ -801,14 +826,16 @@ discard block |
||
801 | 826 | foreach ($addressed as $curmem) |
802 | 827 | { |
803 | 828 | $curmem = trim($curmem); |
804 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
805 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
829 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
830 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
831 | + } |
|
806 | 832 | } |
807 | 833 | } |
808 | 834 | |
809 | 835 | // If we're only cleaning drop out here. |
810 | - if ($clean_only) |
|
811 | - return; |
|
836 | + if ($clean_only) { |
|
837 | + return; |
|
838 | + } |
|
812 | 839 | |
813 | 840 | require_once($sourcedir . '/Subs-Post.php'); |
814 | 841 | |
@@ -824,16 +851,18 @@ discard block |
||
824 | 851 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
825 | 852 | { |
826 | 853 | // Prepare the message for HTML. |
827 | - if (!empty($_POST['parse_html'])) |
|
828 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
854 | + if (!empty($_POST['parse_html'])) { |
|
855 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
856 | + } |
|
829 | 857 | |
830 | 858 | // This is here to prevent spam filters from tagging this as spam. |
831 | 859 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
832 | 860 | { |
833 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
834 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
835 | - else |
|
836 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
861 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
862 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
863 | + } else { |
|
864 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
865 | + } |
|
837 | 866 | } |
838 | 867 | } |
839 | 868 | |
@@ -887,15 +916,17 @@ discard block |
||
887 | 916 | foreach ($context['recipients']['emails'] as $k => $email) |
888 | 917 | { |
889 | 918 | // Done as many as we can? |
890 | - if ($i >= $num_at_once) |
|
891 | - break; |
|
919 | + if ($i >= $num_at_once) { |
|
920 | + break; |
|
921 | + } |
|
892 | 922 | |
893 | 923 | // Don't sent it twice! |
894 | 924 | unset($context['recipients']['emails'][$k]); |
895 | 925 | |
896 | 926 | // Dammit - can't PM emails! |
897 | - if ($context['send_pm']) |
|
898 | - continue; |
|
927 | + if ($context['send_pm']) { |
|
928 | + continue; |
|
929 | + } |
|
899 | 930 | |
900 | 931 | $to_member = array( |
901 | 932 | $email, |
@@ -929,8 +960,9 @@ discard block |
||
929 | 960 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
930 | 961 | } |
931 | 962 | } |
932 | - if (!empty($queryBuild)) |
|
933 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
963 | + if (!empty($queryBuild)) { |
|
964 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
965 | + } |
|
934 | 966 | } |
935 | 967 | if (!empty($context['recipients']['members'])) |
936 | 968 | { |
@@ -949,8 +981,9 @@ discard block |
||
949 | 981 | } |
950 | 982 | |
951 | 983 | // Anything to exclude? |
952 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
953 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
984 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
985 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
986 | + } |
|
954 | 987 | if (!empty($context['recipients']['exclude_members'])) |
955 | 988 | { |
956 | 989 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -986,21 +1019,24 @@ discard block |
||
986 | 1019 | foreach ($rows as $row) |
987 | 1020 | { |
988 | 1021 | // Force them to have it? |
989 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
990 | - continue; |
|
1022 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1023 | + continue; |
|
1024 | + } |
|
991 | 1025 | |
992 | 1026 | // What groups are we looking at here? |
993 | - if (empty($row['additional_groups'])) |
|
994 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
995 | - else |
|
996 | - $groups = array_merge( |
|
1027 | + if (empty($row['additional_groups'])) { |
|
1028 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1029 | + } else { |
|
1030 | + $groups = array_merge( |
|
997 | 1031 | array($row['id_group'], $row['id_post_group']), |
998 | 1032 | explode(',', $row['additional_groups']) |
999 | 1033 | ); |
1034 | + } |
|
1000 | 1035 | |
1001 | 1036 | // Excluded groups? |
1002 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1003 | - continue; |
|
1037 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1038 | + continue; |
|
1039 | + } |
|
1004 | 1040 | |
1005 | 1041 | // We might need this |
1006 | 1042 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1023,10 +1059,11 @@ discard block |
||
1023 | 1059 | ), $_POST['subject']); |
1024 | 1060 | |
1025 | 1061 | // Send the actual email - or a PM! |
1026 | - if (!$context['send_pm']) |
|
1027 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1028 | - else |
|
1029 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1062 | + if (!$context['send_pm']) { |
|
1063 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1064 | + } else { |
|
1065 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1066 | + } |
|
1030 | 1067 | } |
1031 | 1068 | } |
1032 | 1069 | |
@@ -1076,8 +1113,9 @@ discard block |
||
1076 | 1113 | |
1077 | 1114 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1078 | 1115 | |
1079 | - if ($return_config) |
|
1080 | - return $config_vars; |
|
1116 | + if ($return_config) { |
|
1117 | + return $config_vars; |
|
1118 | + } |
|
1081 | 1119 | |
1082 | 1120 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1083 | 1121 | $context['sub_template'] = 'show_settings'; |
@@ -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 | * Generates the query to determine the list of available boards for a user |
@@ -25,8 +26,9 @@ discard block |
||
25 | 26 | { |
26 | 27 | global $smcFunc, $sourcedir; |
27 | 28 | |
28 | - if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) |
|
29 | - trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); |
|
29 | + if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) { |
|
30 | + trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); |
|
31 | + } |
|
30 | 32 | |
31 | 33 | $where = array(); |
32 | 34 | $where_parameters = array(); |
@@ -42,11 +44,11 @@ discard block |
||
42 | 44 | $where_parameters['included_boards'] = $boardListOptions['included_boards']; |
43 | 45 | } |
44 | 46 | |
45 | - if (!empty($boardListOptions['ignore_boards'])) |
|
46 | - $where[] = '{query_wanna_see_board}'; |
|
47 | - |
|
48 | - elseif (!empty($boardListOptions['use_permissions'])) |
|
49 | - $where[] = '{query_see_board}'; |
|
47 | + if (!empty($boardListOptions['ignore_boards'])) { |
|
48 | + $where[] = '{query_wanna_see_board}'; |
|
49 | + } elseif (!empty($boardListOptions['use_permissions'])) { |
|
50 | + $where[] = '{query_see_board}'; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | if (!empty($boardListOptions['not_redirection'])) |
52 | 54 | { |
@@ -68,12 +70,13 @@ discard block |
||
68 | 70 | { |
69 | 71 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
70 | 72 | { |
71 | - if (!isset($return_value[$row['id_cat']])) |
|
72 | - $return_value[$row['id_cat']] = array( |
|
73 | + if (!isset($return_value[$row['id_cat']])) { |
|
74 | + $return_value[$row['id_cat']] = array( |
|
73 | 75 | 'id' => $row['id_cat'], |
74 | 76 | 'name' => $row['cat_name'], |
75 | 77 | 'boards' => array(), |
76 | 78 | ); |
79 | + } |
|
77 | 80 | |
78 | 81 | $return_value[$row['id_cat']]['boards'][$row['id_board']] = array( |
79 | 82 | 'id' => $row['id_board'], |
@@ -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 |
@@ -183,8 +184,9 @@ discard block |
||
183 | 184 | { |
184 | 185 | global $cache_enable; |
185 | 186 | |
186 | - if ($test) |
|
187 | - return true; |
|
187 | + if ($test) { |
|
188 | + return true; |
|
189 | + } |
|
188 | 190 | return !empty($cache_enable); |
189 | 191 | } |
190 | 192 | |
@@ -203,10 +205,11 @@ discard block |
||
203 | 205 | global $boardurl, $cachedir; |
204 | 206 | |
205 | 207 | // Set the default if no prefix was specified. |
206 | - if (empty($prefix)) |
|
207 | - $this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-'; |
|
208 | - else |
|
209 | - $this->prefix = $prefix; |
|
208 | + if (empty($prefix)) { |
|
209 | + $this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-'; |
|
210 | + } else { |
|
211 | + $this->prefix = $prefix; |
|
212 | + } |
|
210 | 213 | |
211 | 214 | return true; |
212 | 215 | } |
@@ -269,8 +272,9 @@ discard block |
||
269 | 272 | |
270 | 273 | // Invalidate cache, to be sure! |
271 | 274 | // ... as long as index.php can be modified, anyway. |
272 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
273 | - @touch($cachedir . '/' . 'index.php'); |
|
275 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
276 | + @touch($cachedir . '/' . 'index.php'); |
|
277 | + } |
|
274 | 278 | |
275 | 279 | return true; |
276 | 280 | } |
@@ -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 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => true, |
32 | 33 | ); |
33 | -} |
|
34 | + } |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /** |
36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
54 | 56 | { |
55 | 57 | global $smcFunc; |
56 | 58 | |
57 | - if ($size == 'small') |
|
58 | - $size = 'smallint(5)'; |
|
59 | - elseif ($size == 'medium') |
|
60 | - $size = 'mediumint(8)'; |
|
61 | - else |
|
62 | - $size = 'int(10)'; |
|
59 | + if ($size == 'small') { |
|
60 | + $size = 'smallint(5)'; |
|
61 | + } elseif ($size == 'medium') { |
|
62 | + $size = 'mediumint(8)'; |
|
63 | + } else { |
|
64 | + $size = 'int(10)'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | $smcFunc['db_query']('', ' |
65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
246 | 247 | { |
247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
248 | - if (!empty($row['private'])) |
|
249 | - $row['subject'] = $txt['personal_message']; |
|
249 | + if (!empty($row['private'])) { |
|
250 | + $row['subject'] = $txt['personal_message']; |
|
251 | + } |
|
250 | 252 | |
251 | 253 | $mails[] = $row; |
252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
302 | 304 | } |
303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
304 | - $emails[$index] = $index; |
|
305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
306 | + $emails[$index] = $index; |
|
307 | + } |
|
305 | 308 | |
306 | 309 | $config_vars = array( |
307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
322 | 325 | |
323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
324 | 327 | |
325 | - if ($return_config) |
|
326 | - return $config_vars; |
|
328 | + if ($return_config) { |
|
329 | + return $config_vars; |
|
330 | + } |
|
327 | 331 | |
328 | 332 | // Saving? |
329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
398 | 402 | ); |
399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
400 | 404 | $smcFunc['db_free_result']($request); |
405 | + } else { |
|
406 | + $_GET['te'] = (int) $_GET['te']; |
|
401 | 407 | } |
402 | - else |
|
403 | - $_GET['te'] = (int) $_GET['te']; |
|
404 | 408 | |
405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
424 | 428 | |
425 | 429 | // Try get more time... |
426 | 430 | @set_time_limit(600); |
427 | - if (function_exists('apache_reset_timeout')) |
|
428 | - @apache_reset_timeout(); |
|
431 | + if (function_exists('apache_reset_timeout')) { |
|
432 | + @apache_reset_timeout(); |
|
433 | + } |
|
429 | 434 | |
430 | 435 | // Have we already used our maximum time? |
431 | - if (time() - array_sum(explode(' ', $time_start)) < 5) |
|
432 | - return; |
|
436 | + if (time() - array_sum(explode(' ', $time_start)) < 5) { |
|
437 | + return; |
|
438 | + } |
|
433 | 439 | |
434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
459 | 465 | { |
460 | 466 | global $txt; |
461 | 467 | |
462 | - if ($time_diff < 0) |
|
463 | - $time_diff = 0; |
|
468 | + if ($time_diff < 0) { |
|
469 | + $time_diff = 0; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | // Just do a bit of an if fest... |
466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
482 | 489 | } |
483 | 490 | // Otherwise must be second |
484 | - else |
|
485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
486 | -} |
|
491 | + else { |
|
492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
493 | + } |
|
494 | + } |
|
487 | 495 | |
488 | 496 | ?> |
489 | 497 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | { |
45 | 46 | $supported = function_exists('xcache_get') && function_exists('xcache_set') && ini_get('xcache.var_size') > 0; |
46 | 47 | |
47 | - if ($test) |
|
48 | - return $supported; |
|
48 | + if ($test) { |
|
49 | + return $supported; |
|
50 | + } |
|
49 | 51 | return parent::isSupported() && $supported; |
50 | 52 | } |
51 | 53 | |
@@ -66,10 +68,11 @@ discard block |
||
66 | 68 | { |
67 | 69 | $key = $this->prefix . strtr($key, ':/', '-_'); |
68 | 70 | |
69 | - if ($value === null) |
|
70 | - return xcache_unset($key); |
|
71 | - else |
|
72 | - return xcache_set($key, $value, $ttl); |
|
71 | + if ($value === null) { |
|
72 | + return xcache_unset($key); |
|
73 | + } else { |
|
74 | + return xcache_set($key, $value, $ttl); |
|
75 | + } |
|
73 | 76 | } |
74 | 77 | |
75 | 78 | /** |
@@ -88,10 +91,12 @@ discard block |
||
88 | 91 | } |
89 | 92 | |
90 | 93 | // if passed a type, clear that type out |
91 | - if ($type === '' || $type === 'user') |
|
92 | - xcache_clear_cache(XC_TYPE_VAR, 0); |
|
93 | - if ($type === '' || $type === 'data') |
|
94 | - xcache_clear_cache(XC_TYPE_PHP, 0); |
|
94 | + if ($type === '' || $type === 'user') { |
|
95 | + xcache_clear_cache(XC_TYPE_VAR, 0); |
|
96 | + } |
|
97 | + if ($type === '' || $type === 'data') { |
|
98 | + xcache_clear_cache(XC_TYPE_PHP, 0); |
|
99 | + } |
|
95 | 100 | |
96 | 101 | $this->invalidateCache(); |
97 | 102 | return true; |
@@ -110,8 +115,9 @@ discard block |
||
110 | 115 | // While we could md5 this when saving, this could be tricky to be sure it doesn't get corrupted on additional saves. |
111 | 116 | $config_vars[] = array('xcache_adminpass', $txt['cache_xcache_adminpass'], 'db', 'text', 0); |
112 | 117 | |
113 | - if (!isset($context['settings_post_javascript'])) |
|
114 | - $context['settings_post_javascript'] = ''; |
|
118 | + if (!isset($context['settings_post_javascript'])) { |
|
119 | + $context['settings_post_javascript'] = ''; |
|
120 | + } |
|
115 | 121 | |
116 | 122 | $context['settings_post_javascript'] .= ' |
117 | 123 | $("#cache_accelerator").change(function (e) { |