@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $context, $txt; |
32 | 33 | |
33 | 34 | // Old templates might still request this. |
34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $subActions = array( |
38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | checkSession(); |
100 | 102 | validateToken('admin-regc'); |
101 | 103 | |
102 | - foreach ($_POST as $key => $value) |
|
103 | - if (!is_array($_POST[$key])) |
|
104 | + foreach ($_POST as $key => $value) { |
|
105 | + if (!is_array($_POST[$key])) |
|
104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
107 | + } |
|
105 | 108 | |
106 | 109 | $regOptions = array( |
107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
161 | 164 | ) |
162 | 165 | ); |
163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
169 | + } |
|
166 | 170 | $smcFunc['db_free_result']($request); |
171 | + } else { |
|
172 | + $context['member_groups'] = array(); |
|
167 | 173 | } |
168 | - else |
|
169 | - $context['member_groups'] = array(); |
|
170 | 174 | |
171 | 175 | // Basic stuff. |
172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | { |
208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
209 | 213 | // Are we editing this? |
210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | } |
214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
223 | 228 | |
224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
225 | 230 | |
226 | - if ($bytes == strlen($to_write)) |
|
227 | - $context['saved_successful'] = true; |
|
228 | - else |
|
229 | - $context['could_not_save'] = true; |
|
231 | + if ($bytes == strlen($to_write)) { |
|
232 | + $context['saved_successful'] = true; |
|
233 | + } else { |
|
234 | + $context['could_not_save'] = true; |
|
235 | + } |
|
230 | 236 | } |
231 | 237 | |
232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
310 | 316 | |
311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
312 | 318 | |
313 | - if ($return_config) |
|
314 | - return $config_vars; |
|
319 | + if ($return_config) { |
|
320 | + return $config_vars; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // Setup the template |
317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
322 | 329 | checkSession(); |
323 | 330 | |
324 | 331 | // Are there some contacts missing? |
325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
334 | + } |
|
327 | 335 | |
328 | 336 | // Post needs to take into account line breaks. |
329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -860,8 +892,9 @@ discard block |
||
860 | 892 | |
861 | 893 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
862 | 894 | |
863 | - if ($return_config) |
|
864 | - return $config_vars; |
|
895 | + if ($return_config) { |
|
896 | + return $config_vars; |
|
897 | + } |
|
865 | 898 | |
866 | 899 | // Needed for the settings template. |
867 | 900 | require_once($sourcedir . '/ManageServer.php'); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
97 | 98 | |
98 | 99 | // Yep, sub-action time! |
99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
100 | - $subAction = $_REQUEST['sa']; |
|
101 | - else |
|
102 | - $subAction = 'routine'; |
|
100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
101 | + $subAction = $_REQUEST['sa']; |
|
102 | + } else { |
|
103 | + $subAction = 'routine'; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | // Doing something special? |
105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
106 | - $activity = $_REQUEST['activity']; |
|
107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
108 | + $activity = $_REQUEST['activity']; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | // Set a few things. |
109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
114 | 117 | call_helper($subActions[$subAction]['function']); |
115 | 118 | |
116 | 119 | // Any special activity? |
117 | - if (isset($activity)) |
|
118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
120 | + if (isset($activity)) { |
|
121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
122 | + } |
|
119 | 123 | |
120 | 124 | //converted to UTF-8? show a small maintenance info |
121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
127 | + } |
|
123 | 128 | |
124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
141 | 146 | db_extend('packages'); |
142 | 147 | |
143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
144 | - foreach ($colData as $column) |
|
145 | - if ($column['name'] == 'body') |
|
149 | + foreach ($colData as $column) { |
|
150 | + if ($column['name'] == 'body') |
|
146 | 151 | $body_type = $column['type']; |
152 | + } |
|
147 | 153 | |
148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
150 | 156 | } |
151 | 157 | |
152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
156 | -} |
|
158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
160 | + } |
|
161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
163 | + } |
|
164 | + } |
|
157 | 165 | |
158 | 166 | /** |
159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
162 | 170 | { |
163 | 171 | global $context, $txt; |
164 | 172 | |
165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
167 | -} |
|
173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
175 | + } |
|
176 | + } |
|
168 | 177 | |
169 | 178 | /** |
170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
195 | 204 | } |
196 | 205 | $smcFunc['db_free_result']($result); |
197 | 206 | |
198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
209 | + } |
|
200 | 210 | |
201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
222 | 232 | $context['categories'] = array(); |
223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
224 | 234 | { |
225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
226 | - $context['categories'][$row['id_cat']] = array( |
|
235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
236 | + $context['categories'][$row['id_cat']] = array( |
|
227 | 237 | 'name' => $row['cat_name'], |
228 | 238 | 'boards' => array() |
229 | 239 | ); |
240 | + } |
|
230 | 241 | |
231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
240 | 251 | sortCategories($context['categories']); |
241 | 252 | |
242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
246 | -} |
|
253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
257 | + } |
|
258 | + } |
|
247 | 259 | |
248 | 260 | /** |
249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
351 | 363 | // Show me your badge! |
352 | 364 | isAllowedTo('admin_forum'); |
353 | 365 | |
354 | - if ($db_type != 'mysql' && $db_type != 'mysqli') |
|
355 | - return; |
|
366 | + if ($db_type != 'mysql' && $db_type != 'mysqli') { |
|
367 | + return; |
|
368 | + } |
|
356 | 369 | |
357 | 370 | db_extend('packages'); |
358 | 371 | |
359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
360 | - foreach ($colData as $column) |
|
361 | - if ($column['name'] == 'body') |
|
373 | + foreach ($colData as $column) { |
|
374 | + if ($column['name'] == 'body') |
|
362 | 375 | $body_type = $column['type']; |
376 | + } |
|
363 | 377 | |
364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
365 | 379 | |
@@ -369,19 +383,22 @@ discard block |
||
369 | 383 | validateToken('admin-maint'); |
370 | 384 | |
371 | 385 | // Make it longer so we can do their limit. |
372 | - if ($body_type == 'text') |
|
373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
386 | + if ($body_type == 'text') { |
|
387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
388 | + } |
|
374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
375 | - else |
|
376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
390 | + else { |
|
391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
392 | + } |
|
377 | 393 | |
378 | 394 | // 3rd party integrations may be interested in knowning about this. |
379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
380 | 396 | |
381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
382 | - foreach ($colData as $column) |
|
383 | - if ($column['name'] == 'body') |
|
398 | + foreach ($colData as $column) { |
|
399 | + if ($column['name'] == 'body') |
|
384 | 400 | $body_type = $column['type']; |
401 | + } |
|
385 | 402 | |
386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
@@ -389,14 +406,14 @@ discard block |
||
389 | 406 | |
390 | 407 | return; |
391 | 408 | redirectexit('action=admin;area=maintain;sa=database'); |
392 | - } |
|
393 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
409 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
394 | 410 | { |
395 | 411 | checkSession(); |
396 | - if (empty($_REQUEST['start'])) |
|
397 | - validateToken('admin-maint'); |
|
398 | - else |
|
399 | - validateToken('admin-convertMsg'); |
|
412 | + if (empty($_REQUEST['start'])) { |
|
413 | + validateToken('admin-maint'); |
|
414 | + } else { |
|
415 | + validateToken('admin-convertMsg'); |
|
416 | + } |
|
400 | 417 | |
401 | 418 | $context['page_title'] = $txt['not_done_title']; |
402 | 419 | $context['continue_post_data'] = ''; |
@@ -428,8 +445,9 @@ discard block |
||
428 | 445 | 'increment' => $increment - 1, |
429 | 446 | ) |
430 | 447 | ); |
431 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
432 | - $id_msg_exceeding[] = $row['id_msg']; |
|
448 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
449 | + $id_msg_exceeding[] = $row['id_msg']; |
|
450 | + } |
|
433 | 451 | $smcFunc['db_free_result']($request); |
434 | 452 | |
435 | 453 | $_REQUEST['start'] += $increment; |
@@ -458,9 +476,9 @@ discard block |
||
458 | 476 | { |
459 | 477 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
460 | 478 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
479 | + } else { |
|
480 | + $query_msg = $id_msg_exceeding; |
|
461 | 481 | } |
462 | - else |
|
463 | - $query_msg = $id_msg_exceeding; |
|
464 | 482 | |
465 | 483 | $context['exceeding_messages'] = array(); |
466 | 484 | $request = $smcFunc['db_query']('', ' |
@@ -471,8 +489,9 @@ discard block |
||
471 | 489 | 'messages' => $query_msg, |
472 | 490 | ) |
473 | 491 | ); |
474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
475 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
492 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
493 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
494 | + } |
|
476 | 495 | $smcFunc['db_free_result']($request); |
477 | 496 | } |
478 | 497 | } |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | isAllowedTo('admin_forum'); |
497 | 516 | |
498 | 517 | // Check to see if UTF-8 is currently the default character set. |
499 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
500 | - fatal_lang_error('entity_convert_only_utf8'); |
|
518 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
519 | + fatal_lang_error('entity_convert_only_utf8'); |
|
520 | + } |
|
501 | 521 | |
502 | 522 | // Some starting values. |
503 | 523 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -559,8 +579,9 @@ discard block |
||
559 | 579 | // Make sure we keep stuff unique! |
560 | 580 | $primary_keys = array(); |
561 | 581 | |
562 | - if (function_exists('apache_reset_timeout')) |
|
563 | - @apache_reset_timeout(); |
|
582 | + if (function_exists('apache_reset_timeout')) { |
|
583 | + @apache_reset_timeout(); |
|
584 | + } |
|
564 | 585 | |
565 | 586 | // Get a list of text columns. |
566 | 587 | $columns = array(); |
@@ -571,9 +592,10 @@ discard block |
||
571 | 592 | 'cur_table' => $cur_table, |
572 | 593 | ) |
573 | 594 | ); |
574 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
575 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
595 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
596 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
576 | 597 | $columns[] = strtolower($column_info['Field']); |
598 | + } |
|
577 | 599 | |
578 | 600 | // Get the column with the (first) primary key. |
579 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +609,9 @@ discard block |
||
587 | 609 | { |
588 | 610 | if ($row['Key_name'] === 'PRIMARY') |
589 | 611 | { |
590 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
591 | - $primary_key = $row['Column_name']; |
|
612 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
613 | + $primary_key = $row['Column_name']; |
|
614 | + } |
|
592 | 615 | |
593 | 616 | $primary_keys[] = $row['Column_name']; |
594 | 617 | } |
@@ -597,8 +620,9 @@ discard block |
||
597 | 620 | |
598 | 621 | // No primary key, no glory. |
599 | 622 | // Same for columns. Just to be sure we've work to do! |
600 | - if (empty($primary_key) || empty($columns)) |
|
601 | - continue; |
|
623 | + if (empty($primary_key) || empty($columns)) { |
|
624 | + continue; |
|
625 | + } |
|
602 | 626 | |
603 | 627 | // Get the maximum value for the primary key. |
604 | 628 | $request = $smcFunc['db_query']('', ' |
@@ -612,8 +636,9 @@ discard block |
||
612 | 636 | list($max_value) = $smcFunc['db_fetch_row']($request); |
613 | 637 | $smcFunc['db_free_result']($request); |
614 | 638 | |
615 | - if (empty($max_value)) |
|
616 | - continue; |
|
639 | + if (empty($max_value)) { |
|
640 | + continue; |
|
641 | + } |
|
617 | 642 | |
618 | 643 | while ($context['start'] <= $max_value) |
619 | 644 | { |
@@ -637,10 +662,11 @@ discard block |
||
637 | 662 | { |
638 | 663 | $insertion_variables = array(); |
639 | 664 | $changes = array(); |
640 | - foreach ($row as $column_name => $column_value) |
|
641 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
665 | + foreach ($row as $column_name => $column_value) { |
|
666 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
642 | 667 | { |
643 | 668 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
669 | + } |
|
644 | 670 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value); |
645 | 671 | } |
646 | 672 | |
@@ -652,8 +678,8 @@ discard block |
||
652 | 678 | } |
653 | 679 | |
654 | 680 | // Update the row. |
655 | - if (!empty($changes)) |
|
656 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($changes)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
657 | 683 | UPDATE {db_prefix}' . $cur_table . ' |
658 | 684 | SET |
659 | 685 | ' . implode(', |
@@ -661,6 +687,7 @@ discard block |
||
661 | 687 | WHERE ' . implode(' AND ', $where), |
662 | 688 | $insertion_variables |
663 | 689 | ); |
690 | + } |
|
664 | 691 | } |
665 | 692 | $smcFunc['db_free_result']($request); |
666 | 693 | $context['start'] += 500; |
@@ -705,10 +732,11 @@ discard block |
||
705 | 732 | |
706 | 733 | checkSession('request'); |
707 | 734 | |
708 | - if (!isset($_SESSION['optimized_tables'])) |
|
709 | - validateToken('admin-maint'); |
|
710 | - else |
|
711 | - validateToken('admin-optimize', 'post', false); |
|
735 | + if (!isset($_SESSION['optimized_tables'])) { |
|
736 | + validateToken('admin-maint'); |
|
737 | + } else { |
|
738 | + validateToken('admin-optimize', 'post', false); |
|
739 | + } |
|
712 | 740 | |
713 | 741 | ignore_user_abort(true); |
714 | 742 | db_extend(); |
@@ -727,13 +755,15 @@ discard block |
||
727 | 755 | // Get a list of tables, as well as how many there are. |
728 | 756 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
729 | 757 | $tables = array(); |
730 | - foreach ($temp_tables as $table) |
|
731 | - $tables[] = array('table_name' => $table); |
|
758 | + foreach ($temp_tables as $table) { |
|
759 | + $tables[] = array('table_name' => $table); |
|
760 | + } |
|
732 | 761 | |
733 | 762 | // If there aren't any tables then I believe that would mean the world has exploded... |
734 | 763 | $context['num_tables'] = count($tables); |
735 | - if ($context['num_tables'] == 0) |
|
736 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
764 | + if ($context['num_tables'] == 0) { |
|
765 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
766 | + } |
|
737 | 767 | |
738 | 768 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
739 | 769 | |
@@ -744,8 +774,9 @@ discard block |
||
744 | 774 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
745 | 775 | for ($key=$_REQUEST['start']; $context['num_tables']-1; $key++) |
746 | 776 | { |
747 | - if (empty($tables[$key])) |
|
748 | - break; |
|
777 | + if (empty($tables[$key])) { |
|
778 | + break; |
|
779 | + } |
|
749 | 780 | |
750 | 781 | // Continue? |
751 | 782 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10) |
@@ -759,8 +790,9 @@ discard block |
||
759 | 790 | createToken('admin-optimize'); |
760 | 791 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
761 | 792 | |
762 | - if (function_exists('apache_reset_timeout')) |
|
763 | - apache_reset_timeout(); |
|
793 | + if (function_exists('apache_reset_timeout')) { |
|
794 | + apache_reset_timeout(); |
|
795 | + } |
|
764 | 796 | |
765 | 797 | return; |
766 | 798 | } |
@@ -768,11 +800,12 @@ discard block |
||
768 | 800 | // Optimize the table! We use backticks here because it might be a custom table. |
769 | 801 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
770 | 802 | |
771 | - if ($data_freed > 0) |
|
772 | - $_SESSION['optimized_tables'][] = array( |
|
803 | + if ($data_freed > 0) { |
|
804 | + $_SESSION['optimized_tables'][] = array( |
|
773 | 805 | 'name' => $tables[$key]['table_name'], |
774 | 806 | 'data_freed' => $data_freed, |
775 | 807 | ); |
808 | + } |
|
776 | 809 | } |
777 | 810 | |
778 | 811 | // Number of tables, etc... |
@@ -807,10 +840,11 @@ discard block |
||
807 | 840 | checkSession('request'); |
808 | 841 | |
809 | 842 | // validate the request or the loop |
810 | - if (!isset($_REQUEST['step'])) |
|
811 | - validateToken('admin-maint'); |
|
812 | - else |
|
813 | - validateToken('admin-boardrecount'); |
|
843 | + if (!isset($_REQUEST['step'])) { |
|
844 | + validateToken('admin-maint'); |
|
845 | + } else { |
|
846 | + validateToken('admin-boardrecount'); |
|
847 | + } |
|
814 | 848 | |
815 | 849 | $context['page_title'] = $txt['not_done_title']; |
816 | 850 | $context['continue_post_data'] = ''; |
@@ -831,8 +865,9 @@ discard block |
||
831 | 865 | $smcFunc['db_free_result']($request); |
832 | 866 | |
833 | 867 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
834 | - if (empty($_REQUEST['start'])) |
|
835 | - $_REQUEST['start'] = 0; |
|
868 | + if (empty($_REQUEST['start'])) { |
|
869 | + $_REQUEST['start'] = 0; |
|
870 | + } |
|
836 | 871 | |
837 | 872 | $total_steps = 8; |
838 | 873 | |
@@ -859,8 +894,8 @@ discard block |
||
859 | 894 | 'max_id' => $_REQUEST['start'] + $increment, |
860 | 895 | ) |
861 | 896 | ); |
862 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
863 | - $smcFunc['db_query']('', ' |
|
897 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
898 | + $smcFunc['db_query']('', ' |
|
864 | 899 | UPDATE {db_prefix}topics |
865 | 900 | SET num_replies = {int:num_replies} |
866 | 901 | WHERE id_topic = {int:id_topic}', |
@@ -869,6 +904,7 @@ discard block |
||
869 | 904 | 'id_topic' => $row['id_topic'], |
870 | 905 | ) |
871 | 906 | ); |
907 | + } |
|
872 | 908 | $smcFunc['db_free_result']($request); |
873 | 909 | |
874 | 910 | // Recount unapproved messages |
@@ -887,8 +923,8 @@ discard block |
||
887 | 923 | 'max_id' => $_REQUEST['start'] + $increment, |
888 | 924 | ) |
889 | 925 | ); |
890 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
891 | - $smcFunc['db_query']('', ' |
|
926 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
927 | + $smcFunc['db_query']('', ' |
|
892 | 928 | UPDATE {db_prefix}topics |
893 | 929 | SET unapproved_posts = {int:unapproved_posts} |
894 | 930 | WHERE id_topic = {int:id_topic}', |
@@ -897,6 +933,7 @@ discard block |
||
897 | 933 | 'id_topic' => $row['id_topic'], |
898 | 934 | ) |
899 | 935 | ); |
936 | + } |
|
900 | 937 | $smcFunc['db_free_result']($request); |
901 | 938 | |
902 | 939 | $_REQUEST['start'] += $increment; |
@@ -919,8 +956,8 @@ discard block |
||
919 | 956 | // Update the post count of each board. |
920 | 957 | if ($_REQUEST['step'] <= 1) |
921 | 958 | { |
922 | - if (empty($_REQUEST['start'])) |
|
923 | - $smcFunc['db_query']('', ' |
|
959 | + if (empty($_REQUEST['start'])) { |
|
960 | + $smcFunc['db_query']('', ' |
|
924 | 961 | UPDATE {db_prefix}boards |
925 | 962 | SET num_posts = {int:num_posts} |
926 | 963 | WHERE redirect = {string:redirect}', |
@@ -929,6 +966,7 @@ discard block |
||
929 | 966 | 'redirect' => '', |
930 | 967 | ) |
931 | 968 | ); |
969 | + } |
|
932 | 970 | |
933 | 971 | while ($_REQUEST['start'] < $max_topics) |
934 | 972 | { |
@@ -945,8 +983,8 @@ discard block |
||
945 | 983 | 'is_approved' => 1, |
946 | 984 | ) |
947 | 985 | ); |
948 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
949 | - $smcFunc['db_query']('', ' |
|
986 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
987 | + $smcFunc['db_query']('', ' |
|
950 | 988 | UPDATE {db_prefix}boards |
951 | 989 | SET num_posts = num_posts + {int:real_num_posts} |
952 | 990 | WHERE id_board = {int:id_board}', |
@@ -955,6 +993,7 @@ discard block |
||
955 | 993 | 'real_num_posts' => $row['real_num_posts'], |
956 | 994 | ) |
957 | 995 | ); |
996 | + } |
|
958 | 997 | $smcFunc['db_free_result']($request); |
959 | 998 | |
960 | 999 | $_REQUEST['start'] += $increment; |
@@ -977,14 +1016,15 @@ discard block |
||
977 | 1016 | // Update the topic count of each board. |
978 | 1017 | if ($_REQUEST['step'] <= 2) |
979 | 1018 | { |
980 | - if (empty($_REQUEST['start'])) |
|
981 | - $smcFunc['db_query']('', ' |
|
1019 | + if (empty($_REQUEST['start'])) { |
|
1020 | + $smcFunc['db_query']('', ' |
|
982 | 1021 | UPDATE {db_prefix}boards |
983 | 1022 | SET num_topics = {int:num_topics}', |
984 | 1023 | array( |
985 | 1024 | 'num_topics' => 0, |
986 | 1025 | ) |
987 | 1026 | ); |
1027 | + } |
|
988 | 1028 | |
989 | 1029 | while ($_REQUEST['start'] < $max_topics) |
990 | 1030 | { |
@@ -1001,8 +1041,8 @@ discard block |
||
1001 | 1041 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
1002 | 1042 | ) |
1003 | 1043 | ); |
1004 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1005 | - $smcFunc['db_query']('', ' |
|
1044 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1045 | + $smcFunc['db_query']('', ' |
|
1006 | 1046 | UPDATE {db_prefix}boards |
1007 | 1047 | SET num_topics = num_topics + {int:real_num_topics} |
1008 | 1048 | WHERE id_board = {int:id_board}', |
@@ -1011,6 +1051,7 @@ discard block |
||
1011 | 1051 | 'real_num_topics' => $row['real_num_topics'], |
1012 | 1052 | ) |
1013 | 1053 | ); |
1054 | + } |
|
1014 | 1055 | $smcFunc['db_free_result']($request); |
1015 | 1056 | |
1016 | 1057 | $_REQUEST['start'] += $increment; |
@@ -1033,14 +1074,15 @@ discard block |
||
1033 | 1074 | // Update the unapproved post count of each board. |
1034 | 1075 | if ($_REQUEST['step'] <= 3) |
1035 | 1076 | { |
1036 | - if (empty($_REQUEST['start'])) |
|
1037 | - $smcFunc['db_query']('', ' |
|
1077 | + if (empty($_REQUEST['start'])) { |
|
1078 | + $smcFunc['db_query']('', ' |
|
1038 | 1079 | UPDATE {db_prefix}boards |
1039 | 1080 | SET unapproved_posts = {int:unapproved_posts}', |
1040 | 1081 | array( |
1041 | 1082 | 'unapproved_posts' => 0, |
1042 | 1083 | ) |
1043 | 1084 | ); |
1085 | + } |
|
1044 | 1086 | |
1045 | 1087 | while ($_REQUEST['start'] < $max_topics) |
1046 | 1088 | { |
@@ -1057,8 +1099,8 @@ discard block |
||
1057 | 1099 | 'is_approved' => 0, |
1058 | 1100 | ) |
1059 | 1101 | ); |
1060 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1061 | - $smcFunc['db_query']('', ' |
|
1102 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1103 | + $smcFunc['db_query']('', ' |
|
1062 | 1104 | UPDATE {db_prefix}boards |
1063 | 1105 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
1064 | 1106 | WHERE id_board = {int:id_board}', |
@@ -1067,6 +1109,7 @@ discard block |
||
1067 | 1109 | 'unapproved_posts' => $row['real_unapproved_posts'], |
1068 | 1110 | ) |
1069 | 1111 | ); |
1112 | + } |
|
1070 | 1113 | $smcFunc['db_free_result']($request); |
1071 | 1114 | |
1072 | 1115 | $_REQUEST['start'] += $increment; |
@@ -1089,14 +1132,15 @@ discard block |
||
1089 | 1132 | // Update the unapproved topic count of each board. |
1090 | 1133 | if ($_REQUEST['step'] <= 4) |
1091 | 1134 | { |
1092 | - if (empty($_REQUEST['start'])) |
|
1093 | - $smcFunc['db_query']('', ' |
|
1135 | + if (empty($_REQUEST['start'])) { |
|
1136 | + $smcFunc['db_query']('', ' |
|
1094 | 1137 | UPDATE {db_prefix}boards |
1095 | 1138 | SET unapproved_topics = {int:unapproved_topics}', |
1096 | 1139 | array( |
1097 | 1140 | 'unapproved_topics' => 0, |
1098 | 1141 | ) |
1099 | 1142 | ); |
1143 | + } |
|
1100 | 1144 | |
1101 | 1145 | while ($_REQUEST['start'] < $max_topics) |
1102 | 1146 | { |
@@ -1113,8 +1157,8 @@ discard block |
||
1113 | 1157 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
1114 | 1158 | ) |
1115 | 1159 | ); |
1116 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1117 | - $smcFunc['db_query']('', ' |
|
1160 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1161 | + $smcFunc['db_query']('', ' |
|
1118 | 1162 | UPDATE {db_prefix}boards |
1119 | 1163 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
1120 | 1164 | WHERE id_board = {int:id_board}', |
@@ -1123,6 +1167,7 @@ discard block |
||
1123 | 1167 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
1124 | 1168 | ) |
1125 | 1169 | ); |
1170 | + } |
|
1126 | 1171 | $smcFunc['db_free_result']($request); |
1127 | 1172 | |
1128 | 1173 | $_REQUEST['start'] += $increment; |
@@ -1156,8 +1201,9 @@ discard block |
||
1156 | 1201 | 'is_not_deleted' => 0, |
1157 | 1202 | ) |
1158 | 1203 | ); |
1159 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1160 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1204 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1205 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1206 | + } |
|
1161 | 1207 | $smcFunc['db_free_result']($request); |
1162 | 1208 | |
1163 | 1209 | $request = $smcFunc['db_query']('', ' |
@@ -1172,8 +1218,9 @@ discard block |
||
1172 | 1218 | 'is_not_read' => 0, |
1173 | 1219 | ) |
1174 | 1220 | ); |
1175 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1176 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1221 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1222 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1223 | + } |
|
1177 | 1224 | $smcFunc['db_free_result']($request); |
1178 | 1225 | |
1179 | 1226 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) |
@@ -1205,12 +1252,13 @@ discard block |
||
1205 | 1252 | ) |
1206 | 1253 | ); |
1207 | 1254 | $boards = array(); |
1208 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1209 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
1255 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1256 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
1257 | + } |
|
1210 | 1258 | $smcFunc['db_free_result']($request); |
1211 | 1259 | |
1212 | - foreach ($boards as $board_id => $messages) |
|
1213 | - $smcFunc['db_query']('', ' |
|
1260 | + foreach ($boards as $board_id => $messages) { |
|
1261 | + $smcFunc['db_query']('', ' |
|
1214 | 1262 | UPDATE {db_prefix}messages |
1215 | 1263 | SET id_board = {int:id_board} |
1216 | 1264 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1219,6 +1267,7 @@ discard block |
||
1219 | 1267 | 'id_board' => $board_id, |
1220 | 1268 | ) |
1221 | 1269 | ); |
1270 | + } |
|
1222 | 1271 | |
1223 | 1272 | $_REQUEST['start'] += $increment; |
1224 | 1273 | |
@@ -1248,8 +1297,9 @@ discard block |
||
1248 | 1297 | ) |
1249 | 1298 | ); |
1250 | 1299 | $realBoardCounts = array(); |
1251 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1252 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1300 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1301 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1302 | + } |
|
1253 | 1303 | $smcFunc['db_free_result']($request); |
1254 | 1304 | |
1255 | 1305 | $request = $smcFunc['db_query']('', ' |
@@ -1269,18 +1319,20 @@ discard block |
||
1269 | 1319 | krsort($resort_me); |
1270 | 1320 | |
1271 | 1321 | $lastModifiedMsg = array(); |
1272 | - foreach ($resort_me as $rows) |
|
1273 | - foreach ($rows as $row) |
|
1322 | + foreach ($resort_me as $rows) { |
|
1323 | + foreach ($rows as $row) |
|
1274 | 1324 | { |
1275 | 1325 | // The latest message is the latest of the current board and its children. |
1276 | 1326 | if (isset($lastModifiedMsg[$row['id_board']])) |
1277 | 1327 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
1278 | - else |
|
1279 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
1328 | + } |
|
1329 | + else { |
|
1330 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
1331 | + } |
|
1280 | 1332 | |
1281 | 1333 | // If what is and what should be the latest message differ, an update is necessary. |
1282 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
1283 | - $smcFunc['db_query']('', ' |
|
1334 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
1335 | + $smcFunc['db_query']('', ' |
|
1284 | 1336 | UPDATE {db_prefix}boards |
1285 | 1337 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
1286 | 1338 | WHERE id_board = {int:id_board}', |
@@ -1290,12 +1342,14 @@ discard block |
||
1290 | 1342 | 'id_board' => $row['id_board'], |
1291 | 1343 | ) |
1292 | 1344 | ); |
1345 | + } |
|
1293 | 1346 | |
1294 | 1347 | // Parent boards inherit the latest modified message of their children. |
1295 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
1296 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1297 | - else |
|
1298 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1348 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
1349 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1350 | + } else { |
|
1351 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1352 | + } |
|
1299 | 1353 | } |
1300 | 1354 | |
1301 | 1355 | // Update all the basic statistics. |
@@ -1367,8 +1421,9 @@ discard block |
||
1367 | 1421 | require_once($sourcedir . '/Subs-Auth.php'); |
1368 | 1422 | $members = findMembers($_POST['to']); |
1369 | 1423 | |
1370 | - if (empty($members)) |
|
1371 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
1424 | + if (empty($members)) { |
|
1425 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
1426 | + } |
|
1372 | 1427 | |
1373 | 1428 | $memID = array_shift($members); |
1374 | 1429 | $memID = $memID['id']; |
@@ -1398,8 +1453,9 @@ discard block |
||
1398 | 1453 | validateToken('admin-maint'); |
1399 | 1454 | |
1400 | 1455 | $groups = array(); |
1401 | - foreach ($_POST['groups'] as $id => $dummy) |
|
1402 | - $groups[] = (int) $id; |
|
1456 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
1457 | + $groups[] = (int) $id; |
|
1458 | + } |
|
1403 | 1459 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
1404 | 1460 | $where_vars = array( |
1405 | 1461 | 'time_limit' => $time_limit, |
@@ -1408,9 +1464,9 @@ discard block |
||
1408 | 1464 | { |
1409 | 1465 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
1410 | 1466 | $where_vars['is_activated'] = 0; |
1467 | + } else { |
|
1468 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1411 | 1469 | } |
1412 | - else |
|
1413 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1414 | 1470 | |
1415 | 1471 | // Need to get *all* groups then work out which (if any) we avoid. |
1416 | 1472 | $request = $smcFunc['db_query']('', ' |
@@ -1429,8 +1485,7 @@ discard block |
||
1429 | 1485 | { |
1430 | 1486 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
1431 | 1487 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
1432 | - } |
|
1433 | - else |
|
1488 | + } else |
|
1434 | 1489 | { |
1435 | 1490 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
1436 | 1491 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1457,8 +1512,9 @@ discard block |
||
1457 | 1512 | $members = array(); |
1458 | 1513 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1459 | 1514 | { |
1460 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
1461 | - $members[] = $row['id_member']; |
|
1515 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
1516 | + $members[] = $row['id_member']; |
|
1517 | + } |
|
1462 | 1518 | } |
1463 | 1519 | $smcFunc['db_free_result']($request); |
1464 | 1520 | |
@@ -1505,8 +1561,9 @@ discard block |
||
1505 | 1561 | ) |
1506 | 1562 | ); |
1507 | 1563 | |
1508 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1509 | - $drafts[] = (int) $row[0]; |
|
1564 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1565 | + $drafts[] = (int) $row[0]; |
|
1566 | + } |
|
1510 | 1567 | $smcFunc['db_free_result']($request); |
1511 | 1568 | |
1512 | 1569 | // If we have old drafts, remove them |
@@ -1549,8 +1606,9 @@ discard block |
||
1549 | 1606 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
1550 | 1607 | |
1551 | 1608 | // No boards then this is your stop. |
1552 | - if (empty($id_board_from) || empty($id_board_to)) |
|
1553 | - return; |
|
1609 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
1610 | + return; |
|
1611 | + } |
|
1554 | 1612 | |
1555 | 1613 | // The big WHERE clause |
1556 | 1614 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1598,18 +1656,20 @@ discard block |
||
1598 | 1656 | ); |
1599 | 1657 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
1600 | 1658 | $smcFunc['db_free_result']($request); |
1659 | + } else { |
|
1660 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
1601 | 1661 | } |
1602 | - else |
|
1603 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
1604 | 1662 | |
1605 | 1663 | // Seems like we need this here. |
1606 | 1664 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
1607 | 1665 | |
1608 | - if ($locked) |
|
1609 | - $context['continue_get_data'] .= ';locked'; |
|
1666 | + if ($locked) { |
|
1667 | + $context['continue_get_data'] .= ';locked'; |
|
1668 | + } |
|
1610 | 1669 | |
1611 | - if ($sticky) |
|
1612 | - $context['continue_get_data'] .= ';sticky'; |
|
1670 | + if ($sticky) { |
|
1671 | + $context['continue_get_data'] .= ';sticky'; |
|
1672 | + } |
|
1613 | 1673 | |
1614 | 1674 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1615 | 1675 | |
@@ -1630,8 +1690,9 @@ discard block |
||
1630 | 1690 | |
1631 | 1691 | // Get the ids. |
1632 | 1692 | $topics = array(); |
1633 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1634 | - $topics[] = $row['id_topic']; |
|
1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1694 | + $topics[] = $row['id_topic']; |
|
1695 | + } |
|
1635 | 1696 | |
1636 | 1697 | // Just return if we don't have any topics left to move. |
1637 | 1698 | if (empty($topics)) |
@@ -1722,9 +1783,9 @@ discard block |
||
1722 | 1783 | // save it so we don't do this again for this task |
1723 | 1784 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
1724 | 1785 | $smcFunc['db_free_result']($request); |
1786 | + } else { |
|
1787 | + validateToken('admin-recountposts'); |
|
1725 | 1788 | } |
1726 | - else |
|
1727 | - validateToken('admin-recountposts'); |
|
1728 | 1789 | |
1729 | 1790 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
1730 | 1791 | $request = $smcFunc['db_query']('', ' |
@@ -1770,8 +1831,9 @@ discard block |
||
1770 | 1831 | createToken('admin-recountposts'); |
1771 | 1832 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
1772 | 1833 | |
1773 | - if (function_exists('apache_reset_timeout')) |
|
1774 | - apache_reset_timeout(); |
|
1834 | + if (function_exists('apache_reset_timeout')) { |
|
1835 | + apache_reset_timeout(); |
|
1836 | + } |
|
1775 | 1837 | return; |
1776 | 1838 | } |
1777 | 1839 | |
@@ -1857,10 +1919,9 @@ discard block |
||
1857 | 1919 | checkSession('request'); |
1858 | 1920 | validateToken('admin-hook', 'request'); |
1859 | 1921 | |
1860 | - if ($_REQUEST['do'] == 'remove') |
|
1861 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1862 | - |
|
1863 | - else |
|
1922 | + if ($_REQUEST['do'] == 'remove') { |
|
1923 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1924 | + } else |
|
1864 | 1925 | { |
1865 | 1926 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
1866 | 1927 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1910,11 +1971,11 @@ discard block |
||
1910 | 1971 | // Show a nice icon to indicate this is an instance. |
1911 | 1972 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="'. $txt['hooks_field_function_method'] .'"></span> ' : ''); |
1912 | 1973 | |
1913 | - if (!empty($data['included_file'])) |
|
1914 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1915 | - |
|
1916 | - else |
|
1917 | - return $instance . $data['real_function']; |
|
1974 | + if (!empty($data['included_file'])) { |
|
1975 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1976 | + } else { |
|
1977 | + return $instance . $data['real_function']; |
|
1978 | + } |
|
1918 | 1979 | }, |
1919 | 1980 | ), |
1920 | 1981 | 'sort' => array( |
@@ -1979,11 +2040,12 @@ discard block |
||
1979 | 2040 | 'data' => array( |
1980 | 2041 | 'function' => function ($data) use ($txt, $scripturl, $context) |
1981 | 2042 | { |
1982 | - if (!$data['hook_exists']) |
|
1983 | - return ' |
|
2043 | + if (!$data['hook_exists']) { |
|
2044 | + return ' |
|
1984 | 2045 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
1985 | 2046 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
1986 | 2047 | </a>'; |
2048 | + } |
|
1987 | 2049 | }, |
1988 | 2050 | 'class' => 'centertext', |
1989 | 2051 | ), |
@@ -2018,10 +2080,11 @@ discard block |
||
2018 | 2080 | { |
2019 | 2081 | if ($file != '.' && $file != '..') |
2020 | 2082 | { |
2021 | - if (is_dir($dir_path . '/' . $file)) |
|
2022 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2023 | - else |
|
2024 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2083 | + if (is_dir($dir_path . '/' . $file)) { |
|
2084 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2085 | + } else { |
|
2086 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2087 | + } |
|
2025 | 2088 | } |
2026 | 2089 | } |
2027 | 2090 | } |
@@ -2070,16 +2133,16 @@ discard block |
||
2070 | 2133 | // I need to know if there is at least one function called in this file. |
2071 | 2134 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
2072 | 2135 | unset($temp_hooks[$hook][$rawFunc]); |
2073 | - } |
|
2074 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2136 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2075 | 2137 | { |
2076 | 2138 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
2077 | 2139 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
2078 | 2140 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
2079 | 2141 | |
2080 | 2142 | // Does the hook has its own file? |
2081 | - if (!empty($hookParsedData['hookFile'])) |
|
2082 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2143 | + if (!empty($hookParsedData['hookFile'])) { |
|
2144 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2145 | + } |
|
2083 | 2146 | |
2084 | 2147 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
2085 | 2148 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2106,15 +2169,17 @@ discard block |
||
2106 | 2169 | $sort = array(); |
2107 | 2170 | $hooks_filters = array(); |
2108 | 2171 | |
2109 | - foreach ($hooks as $hook => $functions) |
|
2110 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2172 | + foreach ($hooks as $hook => $functions) { |
|
2173 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2174 | + } |
|
2111 | 2175 | |
2112 | - if (!empty($hooks_filters)) |
|
2113 | - $context['insert_after_template'] .= ' |
|
2176 | + if (!empty($hooks_filters)) { |
|
2177 | + $context['insert_after_template'] .= ' |
|
2114 | 2178 | <script> |
2115 | 2179 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
2116 | 2180 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>'). '; |
2117 | 2181 | </script>'; |
2182 | + } |
|
2118 | 2183 | |
2119 | 2184 | $temp_data = array(); |
2120 | 2185 | $id = 0; |
@@ -2157,10 +2222,11 @@ discard block |
||
2157 | 2222 | |
2158 | 2223 | foreach ($temp_data as $data) |
2159 | 2224 | { |
2160 | - if (++$counter < $start) |
|
2161 | - continue; |
|
2162 | - elseif ($counter == $start + $per_page) |
|
2163 | - break; |
|
2225 | + if (++$counter < $start) { |
|
2226 | + continue; |
|
2227 | + } elseif ($counter == $start + $per_page) { |
|
2228 | + break; |
|
2229 | + } |
|
2164 | 2230 | |
2165 | 2231 | $hooks_data[] = $data; |
2166 | 2232 | } |
@@ -2182,13 +2248,15 @@ discard block |
||
2182 | 2248 | $hooks_count = 0; |
2183 | 2249 | |
2184 | 2250 | $context['filter'] = false; |
2185 | - if (isset($_GET['filter'])) |
|
2186 | - $context['filter'] = $_GET['filter']; |
|
2251 | + if (isset($_GET['filter'])) { |
|
2252 | + $context['filter'] = $_GET['filter']; |
|
2253 | + } |
|
2187 | 2254 | |
2188 | 2255 | foreach ($hooks as $hook => $functions) |
2189 | 2256 | { |
2190 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
2191 | - $hooks_count += count($functions); |
|
2257 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
2258 | + $hooks_count += count($functions); |
|
2259 | + } |
|
2192 | 2260 | } |
2193 | 2261 | |
2194 | 2262 | return $hooks_count; |
@@ -2209,8 +2277,9 @@ discard block |
||
2209 | 2277 | $integration_hooks = array(); |
2210 | 2278 | foreach ($modSettings as $key => $value) |
2211 | 2279 | { |
2212 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
2213 | - $integration_hooks[$key] = explode(',', $value); |
|
2280 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
2281 | + $integration_hooks[$key] = explode(',', $value); |
|
2282 | + } |
|
2214 | 2283 | } |
2215 | 2284 | } |
2216 | 2285 | |
@@ -2241,8 +2310,9 @@ discard block |
||
2241 | 2310 | ); |
2242 | 2311 | |
2243 | 2312 | // Meh... |
2244 | - if (empty($rawData)) |
|
2245 | - return $hookData; |
|
2313 | + if (empty($rawData)) { |
|
2314 | + return $hookData; |
|
2315 | + } |
|
2246 | 2316 | |
2247 | 2317 | // For convenience purposes only! |
2248 | 2318 | $modFunc = $rawData; |
@@ -2253,11 +2323,11 @@ discard block |
||
2253 | 2323 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
2254 | 2324 | |
2255 | 2325 | // Does the file exists? who knows! |
2256 | - if (empty($settings['theme_dir'])) |
|
2257 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2258 | - |
|
2259 | - else |
|
2260 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2326 | + if (empty($settings['theme_dir'])) { |
|
2327 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2328 | + } else { |
|
2329 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2330 | + } |
|
2261 | 2331 | |
2262 | 2332 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
2263 | 2333 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2282,11 +2352,10 @@ discard block |
||
2282 | 2352 | { |
2283 | 2353 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
2284 | 2354 | $hookData['pureFunc'] = $hookData['method']; |
2355 | + } else { |
|
2356 | + $hookData['pureFunc'] = $modFunc; |
|
2285 | 2357 | } |
2286 | 2358 | |
2287 | - else |
|
2288 | - $hookData['pureFunc'] = $modFunc; |
|
2289 | - |
|
2290 | 2359 | return $hookData; |
2291 | 2360 | } |
2292 | 2361 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
28 | 29 | global $smcFunc, $user_info, $context; |
29 | 30 | |
30 | 31 | // Don't bother. |
31 | - if (empty($action) || empty($report_id)) |
|
32 | - return false; |
|
32 | + if (empty($action) || empty($report_id)) { |
|
33 | + return false; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | // Add the "_all" thingy. |
35 | - if ($action == 'ignore') |
|
36 | - $action = 'ignore_all'; |
|
37 | + if ($action == 'ignore') { |
|
38 | + $action = 'ignore_all'; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | // We don't need the board query for reported members |
39 | 42 | if ($context['report_type'] == 'members') |
40 | 43 | { |
41 | 44 | $board_query = ''; |
42 | - } |
|
43 | - else |
|
45 | + } else |
|
44 | 46 | { |
45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
76 | 78 | ) |
77 | 79 | ); |
78 | 80 | |
79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
80 | - $extra[$row['id_report']] = array( |
|
81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
82 | + $extra[$row['id_report']] = array( |
|
81 | 83 | 'report' => $row['id_report'], |
82 | 84 | 'board' => $row['id_board'], |
83 | 85 | 'message' => $row['id_msg'], |
84 | 86 | 'topic' => $row['id_topic'], |
85 | 87 | ); |
88 | + } |
|
86 | 89 | |
87 | 90 | $smcFunc['db_free_result']($request); |
88 | - } |
|
89 | - else |
|
91 | + } else |
|
90 | 92 | { |
91 | 93 | $request = $smcFunc['db_query']('', ' |
92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
97 | 99 | ) |
98 | 100 | ); |
99 | 101 | |
100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
101 | - $extra[$row['id_report']] = array( |
|
102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
103 | + $extra[$row['id_report']] = array( |
|
102 | 104 | 'report' => $row['id_report'], |
103 | 105 | 'member' => $row['id_member'], |
104 | 106 | ); |
107 | + } |
|
105 | 108 | |
106 | 109 | $smcFunc['db_free_result']($request); |
107 | 110 | } |
108 | 111 | |
109 | 112 | // Back to "ignore". |
110 | - if ($action == 'ignore_all') |
|
111 | - $action = 'ignore'; |
|
113 | + if ($action == 'ignore_all') { |
|
114 | + $action = 'ignore'; |
|
115 | + } |
|
112 | 116 | |
113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
114 | 118 | |
115 | - if ($context['report_type'] == 'members') |
|
116 | - $log_report .= '_user'; |
|
119 | + if ($context['report_type'] == 'members') { |
|
120 | + $log_report .= '_user'; |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Log this action. |
119 | - if (!empty($extra)) |
|
120 | - foreach ($extra as $report) |
|
124 | + if (!empty($extra)) { |
|
125 | + foreach ($extra as $report) |
|
121 | 126 | logAction($log_report . '_report', $report); |
127 | + } |
|
122 | 128 | |
123 | 129 | // Time to update. |
124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -142,14 +148,12 @@ discard block |
||
142 | 148 | if ($context['report_type'] == 'members') |
143 | 149 | { |
144 | 150 | $and = 'lr.id_board = 0'; |
145 | - } |
|
146 | - else |
|
151 | + } else |
|
147 | 152 | { |
148 | 153 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
149 | 154 | { |
150 | 155 | $bq = $user_info['mod_cache']['bq']; |
151 | - } |
|
152 | - else |
|
156 | + } else |
|
153 | 157 | { |
154 | 158 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
155 | 159 | } |
@@ -205,8 +209,7 @@ discard block |
||
205 | 209 | 'max' => 10, |
206 | 210 | ) |
207 | 211 | ); |
208 | - } |
|
209 | - else |
|
212 | + } else |
|
210 | 213 | { |
211 | 214 | $request = $smcFunc['db_query']('', ' |
212 | 215 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -254,8 +257,7 @@ discard block |
||
254 | 257 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
255 | 258 | ), |
256 | 259 | ); |
257 | - } |
|
258 | - else |
|
260 | + } else |
|
259 | 261 | { |
260 | 262 | $report_boards_ids[] = $row['id_board']; |
261 | 263 | $extraDetails = array( |
@@ -295,14 +297,16 @@ discard block |
||
295 | 297 | ) |
296 | 298 | ); |
297 | 299 | |
298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
299 | - $board_names[$row['id_board']] = $row['name']; |
|
300 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
301 | + $board_names[$row['id_board']] = $row['name']; |
|
302 | + } |
|
300 | 303 | |
301 | 304 | $smcFunc['db_free_result']($request); |
302 | 305 | |
303 | - foreach ($reports as $id_report => $report) |
|
304 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
306 | + foreach ($reports as $id_report => $report) { |
|
307 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
305 | 308 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
309 | + } |
|
306 | 310 | } |
307 | 311 | |
308 | 312 | // Now get all the people who reported it. |
@@ -352,10 +356,11 @@ discard block |
||
352 | 356 | { |
353 | 357 | global $user_info, $smcFunc; |
354 | 358 | |
355 | - if ($type == 'members') |
|
356 | - $bq = ''; |
|
357 | - else |
|
358 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
359 | + if ($type == 'members') { |
|
360 | + $bq = ''; |
|
361 | + } else { |
|
362 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
363 | + } |
|
359 | 364 | |
360 | 365 | $request = $smcFunc['db_query']('', ' |
361 | 366 | SELECT COUNT(*) |
@@ -394,8 +399,9 @@ discard block |
||
394 | 399 | { |
395 | 400 | global $smcFunc, $user_info, $context; |
396 | 401 | |
397 | - if (empty($report_id)) |
|
398 | - return false; |
|
402 | + if (empty($report_id)) { |
|
403 | + return false; |
|
404 | + } |
|
399 | 405 | |
400 | 406 | // We don't need all this info if we're only getting user info |
401 | 407 | if ($context['report_type'] == 'members') |
@@ -413,8 +419,7 @@ discard block |
||
413 | 419 | 'id_report' => $report_id, |
414 | 420 | ) |
415 | 421 | ); |
416 | - } |
|
417 | - else |
|
422 | + } else |
|
418 | 423 | { |
419 | 424 | // Get the report details, need this so we can limit access to a particular board. |
420 | 425 | $request = $smcFunc['db_query']('', ' |
@@ -433,8 +438,9 @@ discard block |
||
433 | 438 | } |
434 | 439 | |
435 | 440 | // So did we find anything? |
436 | - if (!$smcFunc['db_num_rows']($request)) |
|
437 | - return false; |
|
441 | + if (!$smcFunc['db_num_rows']($request)) { |
|
442 | + return false; |
|
443 | + } |
|
438 | 444 | |
439 | 445 | // Woohoo we found a report and they can see it! |
440 | 446 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -453,8 +459,9 @@ discard block |
||
453 | 459 | { |
454 | 460 | global $smcFunc, $scripturl, $user_info, $txt; |
455 | 461 | |
456 | - if (empty($report_id)) |
|
457 | - return false; |
|
462 | + if (empty($report_id)) { |
|
463 | + return false; |
|
464 | + } |
|
458 | 465 | |
459 | 466 | $report = array( |
460 | 467 | 'comments' => array(), |
@@ -537,8 +544,9 @@ discard block |
||
537 | 544 | |
538 | 545 | $comment = array(); |
539 | 546 | |
540 | - if (empty($comment_id)) |
|
541 | - return false; |
|
547 | + if (empty($comment_id)) { |
|
548 | + return false; |
|
549 | + } |
|
542 | 550 | |
543 | 551 | $request = $smcFunc['db_query']('', ' |
544 | 552 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -555,8 +563,9 @@ discard block |
||
555 | 563 | $smcFunc['db_free_result']($request); |
556 | 564 | |
557 | 565 | // Add the permission |
558 | - if (!empty($comment)) |
|
559 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
566 | + if (!empty($comment)) { |
|
567 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
568 | + } |
|
560 | 569 | |
561 | 570 | return $comment; |
562 | 571 | } |
@@ -572,8 +581,9 @@ discard block |
||
572 | 581 | { |
573 | 582 | global $smcFunc, $user_info, $context; |
574 | 583 | |
575 | - if (empty($data)) |
|
576 | - return false; |
|
584 | + if (empty($data)) { |
|
585 | + return false; |
|
586 | + } |
|
577 | 587 | |
578 | 588 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
579 | 589 | |
@@ -602,8 +612,7 @@ discard block |
||
602 | 612 | 'comment_id' => $last_comment, |
603 | 613 | 'time' => time(), |
604 | 614 | ); |
605 | - } |
|
606 | - else |
|
615 | + } else |
|
607 | 616 | { |
608 | 617 | $prefix = 'Msg'; |
609 | 618 | $data = array( |
@@ -619,14 +628,15 @@ discard block |
||
619 | 628 | } |
620 | 629 | |
621 | 630 | // And get ready to notify people. |
622 | - if (!empty($report)) |
|
623 | - $smcFunc['db_insert']('insert', |
|
631 | + if (!empty($report)) { |
|
632 | + $smcFunc['db_insert']('insert', |
|
624 | 633 | '{db_prefix}background_tasks', |
625 | 634 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
626 | 635 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', json_encode($data), 0), |
627 | 636 | array('id_task') |
628 | 637 | ); |
629 | -} |
|
638 | + } |
|
639 | + } |
|
630 | 640 | |
631 | 641 | /** |
632 | 642 | * Saves the new information whenever a moderator comment is edited. |
@@ -639,8 +649,9 @@ discard block |
||
639 | 649 | { |
640 | 650 | global $smcFunc; |
641 | 651 | |
642 | - if (empty($comment_id) || empty($edited_comment)) |
|
643 | - return false; |
|
652 | + if (empty($comment_id) || empty($edited_comment)) { |
|
653 | + return false; |
|
654 | + } |
|
644 | 655 | |
645 | 656 | $smcFunc['db_query']('', ' |
646 | 657 | UPDATE {db_prefix}log_comments |
@@ -663,8 +674,9 @@ discard block |
||
663 | 674 | { |
664 | 675 | global $smcFunc; |
665 | 676 | |
666 | - if (empty($comment_id)) |
|
667 | - return false; |
|
677 | + if (empty($comment_id)) { |
|
678 | + return false; |
|
679 | + } |
|
668 | 680 | |
669 | 681 | $smcFunc['db_query']('', ' |
670 | 682 | DELETE FROM {db_prefix}log_comments |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -569,8 +570,8 @@ discard block |
||
569 | 570 | ); |
570 | 571 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
571 | 572 | { |
572 | - if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
573 | - $smcFunc['db_query']('', ' |
|
573 | + if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
574 | + $smcFunc['db_query']('', ' |
|
574 | 575 | UPDATE {db_prefix}log_actions |
575 | 576 | SET extra = {string:extra} |
576 | 577 | WHERE id_action = {int:current_action}', |
@@ -579,6 +580,7 @@ discard block |
||
579 | 580 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
580 | 581 | ) |
581 | 582 | ); |
583 | + } |
|
582 | 584 | } |
583 | 585 | $smcFunc['db_free_result']($request); |
584 | 586 |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
53 | 55 | |
54 | 56 | // An extended key is needed to counteract a bug in APC. |
55 | - if ($value === null) |
|
56 | - return apc_delete($key . 'smf'); |
|
57 | - else |
|
58 | - return apc_store($key . 'smf', $value, $ttl); |
|
57 | + if ($value === null) { |
|
58 | + return apc_delete($key . 'smf'); |
|
59 | + } else { |
|
60 | + return apc_store($key . 'smf', $value, $ttl); |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | |
61 | 64 | /** |
@@ -69,9 +72,9 @@ discard block |
||
69 | 72 | // Always returns true. |
70 | 73 | apc_clear_cache('user'); |
71 | 74 | apc_clear_cache('system'); |
75 | + } elseif ($type === 'user') { |
|
76 | + apc_clear_cache('user'); |
|
72 | 77 | } |
73 | - elseif ($type === 'user') |
|
74 | - apc_clear_cache('user'); |
|
75 | 78 | |
76 | 79 | $this->invalidateCache(); |
77 | 80 | return true; |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
53 | 55 | |
54 | 56 | // An extended key is needed to counteract a bug in APC. |
55 | - if ($value === null) |
|
56 | - return apcu_delete($key . 'smf'); |
|
57 | - else |
|
58 | - return apcu_store($key . 'smf', $value, $ttl); |
|
57 | + if ($value === null) { |
|
58 | + return apcu_delete($key . 'smf'); |
|
59 | + } else { |
|
60 | + return apcu_store($key . 'smf', $value, $ttl); |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | |
61 | 64 | /** |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcached'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -54,9 +56,9 @@ discard block |
||
54 | 56 | $currentServers = $this->memcached->getServerList(); |
55 | 57 | foreach ($servers as $server) |
56 | 58 | { |
57 | - if (strpos($server,'/') !== false) |
|
58 | - $tempServer = array($server, 0); |
|
59 | - else |
|
59 | + if (strpos($server,'/') !== false) { |
|
60 | + $tempServer = array($server, 0); |
|
61 | + } else |
|
60 | 62 | { |
61 | 63 | $server = explode(':', $server); |
62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | } |
75 | 77 | |
76 | 78 | // Found it? |
77 | - if (empty($foundServer)) |
|
78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
79 | + if (empty($foundServer)) { |
|
80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | $value = $this->memcached->get($key); |
93 | 96 | |
94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
95 | - if ($value === false) |
|
96 | - return null; |
|
98 | + if ($value === false) { |
|
99 | + return null; |
|
100 | + } |
|
97 | 101 | return $value; |
98 | 102 | } |
99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
137 | 141 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
138 | 142 | |
139 | - if (!isset($context['settings_post_javascript'])) |
|
140 | - $context['settings_post_javascript'] = ''; |
|
143 | + if (!isset($context['settings_post_javascript'])) { |
|
144 | + $context['settings_post_javascript'] = ''; |
|
145 | + } |
|
141 | 146 | |
142 | 147 | $context['settings_post_javascript'] .= ' |
143 | 148 | $("#cache_accelerator").change(function (e) { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
15 | 15 | // SMF Payment Gateway: paypal |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
118 | 119 | { |
119 | 120 | $return_data['hidden']['p3'] = 1; |
120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
121 | - } |
|
122 | - else |
|
122 | + } else |
|
123 | 123 | { |
124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // If it's repeatable do some javascript to respect this idea. |
133 | - if (!empty($sub_data['repeatable'])) |
|
134 | - $return_data['javascript'] = ' |
|
133 | + if (!empty($sub_data['repeatable'])) { |
|
134 | + $return_data['javascript'] = ' |
|
135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\'); |
136 | 136 | |
137 | 137 | function switchPaypalRecur() |
138 | 138 | { |
139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
140 | 140 | }'; |
141 | + } |
|
141 | 142 | |
142 | 143 | return $return_data; |
143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
160 | 161 | global $modSettings; |
161 | 162 | |
162 | 163 | // Has the user set up an email address? |
163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
164 | - return false; |
|
164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
165 | + return false; |
|
166 | + } |
|
165 | 167 | // Check the correct transaction types are even here. |
166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
167 | - return false; |
|
168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
169 | + return false; |
|
170 | + } |
|
168 | 171 | // Correct email address? |
169 | - if (!isset($_POST['business'])) |
|
170 | - $_POST['business'] = $_POST['receiver_email']; |
|
172 | + if (!isset($_POST['business'])) { |
|
173 | + $_POST['business'] = $_POST['receiver_email']; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | // Are we testing? |
173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
174 | - return false; |
|
175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
176 | - return false; |
|
177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
178 | + return false; |
|
179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
180 | + return false; |
|
181 | + } |
|
177 | 182 | return true; |
178 | 183 | } |
179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
192 | 197 | global $modSettings, $txt; |
193 | 198 | |
194 | 199 | // Put this to some default value. |
195 | - if (!isset($_POST['txn_type'])) |
|
196 | - $_POST['txn_type'] = ''; |
|
200 | + if (!isset($_POST['txn_type'])) { |
|
201 | + $_POST['txn_type'] = ''; |
|
202 | + } |
|
197 | 203 | |
198 | 204 | // Build the request string - starting with the minimum requirement. |
199 | 205 | $requestString = 'cmd=_notify-validate'; |
200 | 206 | |
201 | 207 | // Now my dear, add all the posted bits in the order we got them |
202 | - foreach ($_POST as $k => $v) |
|
203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
208 | + foreach ($_POST as $k => $v) { |
|
209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
210 | + } |
|
204 | 211 | |
205 | 212 | // Can we use curl? |
206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'http://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
240 | 247 | $header .= 'Connection: close' . "\r\n\r\n"; |
241 | 248 | |
242 | 249 | // Open the connection. |
243 | - if (!empty($modSettings['paidsubs_test'])) |
|
244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
245 | - else |
|
246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
252 | + } else { |
|
253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
254 | + } |
|
247 | 255 | |
248 | 256 | // Did it work? |
249 | - if (!$fp) |
|
250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
257 | + if (!$fp) { |
|
258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
259 | + } |
|
251 | 260 | |
252 | 261 | // Put the data to the port. |
253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
256 | 265 | while (!feof($fp)) |
257 | 266 | { |
258 | 267 | $this->return_data = fgets($fp, 1024); |
259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
260 | - break; |
|
268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
269 | + break; |
|
270 | + } |
|
261 | 271 | } |
262 | 272 | |
263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
265 | 275 | } |
266 | 276 | |
267 | 277 | // If this isn't verified then give up... |
268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
269 | - exit; |
|
278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
279 | + exit; |
|
280 | + } |
|
270 | 281 | |
271 | 282 | // Check that this is intended for us. |
272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
273 | - exit; |
|
283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
284 | + exit; |
|
285 | + } |
|
274 | 286 | |
275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
280 | - // Calculate the subscription it relates to! |
|
289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
291 | + } |
|
292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
293 | + // Calculate the subscription it relates to! |
|
281 | 294 | $this->_findSubscription(); |
295 | + } |
|
282 | 296 | |
283 | 297 | // Verify the currency! |
284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
285 | - exit; |
|
298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
299 | + exit; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | // Can't exist if it doesn't contain anything. |
288 | - if (empty($_POST['item_number'])) |
|
289 | - exit; |
|
303 | + if (empty($_POST['item_number'])) { |
|
304 | + exit; |
|
305 | + } |
|
290 | 306 | |
291 | 307 | // Return the id_sub and id_member |
292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
299 | 315 | */ |
300 | 316 | public function isRefund() |
301 | 317 | { |
302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
303 | - return true; |
|
304 | - else |
|
305 | - return false; |
|
318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
319 | + return true; |
|
320 | + } else { |
|
321 | + return false; |
|
322 | + } |
|
306 | 323 | } |
307 | 324 | |
308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
312 | 329 | */ |
313 | 330 | public function isSubscription() |
314 | 331 | { |
315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
316 | - return true; |
|
317 | - else |
|
318 | - return false; |
|
332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
333 | + return true; |
|
334 | + } else { |
|
335 | + return false; |
|
336 | + } |
|
319 | 337 | } |
320 | 338 | |
321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
325 | 343 | */ |
326 | 344 | public function isPayment() |
327 | 345 | { |
328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
329 | - return true; |
|
330 | - else |
|
331 | - return false; |
|
346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
347 | + return true; |
|
348 | + } else { |
|
349 | + return false; |
|
350 | + } |
|
332 | 351 | } |
333 | 352 | |
334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
342 | 361 | // Neither require us to *do* anything as per performCancel(). |
343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
345 | - return true; |
|
346 | - else |
|
347 | - return false; |
|
363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
364 | + return true; |
|
365 | + } else { |
|
366 | + return false; |
|
367 | + } |
|
348 | 368 | } |
349 | 369 | |
350 | 370 | /** |
@@ -409,8 +429,9 @@ discard block |
||
409 | 429 | global $smcFunc; |
410 | 430 | |
411 | 431 | // Assume we have this? |
412 | - if (empty($_POST['subscr_id'])) |
|
413 | - return false; |
|
432 | + if (empty($_POST['subscr_id'])) { |
|
433 | + return false; |
|
434 | + } |
|
414 | 435 | |
415 | 436 | // Do we have this in the database? |
416 | 437 | $request = $smcFunc['db_query']('', ' |
@@ -439,11 +460,12 @@ discard block |
||
439 | 460 | 'payer_email' => $_POST['payer_email'], |
440 | 461 | ) |
441 | 462 | ); |
442 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
443 | - return false; |
|
463 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
464 | + return false; |
|
465 | + } |
|
466 | + } else { |
|
467 | + return false; |
|
444 | 468 | } |
445 | - else |
|
446 | - return false; |
|
447 | 469 | } |
448 | 470 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
449 | 471 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |