@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | // INET. |
356 | 356 | elseif ($param_info['type'] == 'inet') |
357 | 357 | { |
358 | - if(count($search_params[$param_name]) === 1) |
|
358 | + if (count($search_params[$param_name]) === 1) |
|
359 | 359 | { |
360 | 360 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
361 | 361 | $where_params[$param_name] = $search_params[$param_name][0]; |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | elseif (count($search_params[$param_name]) === 2) |
364 | 364 | { |
365 | 365 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
366 | - $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
|
367 | - $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
|
366 | + $where_params[$param_name . '_low'] = $search_params[$param_name]['low']; |
|
367 | + $where_params[$param_name . '_high'] = $search_params[$param_name]['high']; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | } |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
1013 | 1013 | $listOptions['additional_rows'][] = array( |
1014 | 1014 | 'position' => 'above_column_headers', |
1015 | - 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . ((isset($context['current_filter']) && isset($txt['admin_browse_filter_type_'.$context['current_filter']])) ? $txt['admin_browse_filter_type_'.$context['current_filter']] : $context['available_filters'][0]['desc']), |
|
1015 | + 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . ((isset($context['current_filter']) && isset($txt['admin_browse_filter_type_' . $context['current_filter']])) ? $txt['admin_browse_filter_type_' . $context['current_filter']] : $context['available_filters'][0]['desc']), |
|
1016 | 1016 | 'class' => 'filter_row generic_list_wrapper smalltext', |
1017 | 1017 | ); |
1018 | 1018 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -109,12 +110,13 @@ discard block |
||
109 | 110 | $context['tabs'][$context['last_tab']]['is_last'] = true; |
110 | 111 | |
111 | 112 | // Find the active tab. |
112 | - if (isset($context['tabs'][$context['current_subaction']])) |
|
113 | - $context['tabs'][$context['current_subaction']]['is_selected'] = true; |
|
114 | - elseif (isset($context['current_subaction'])) |
|
115 | - foreach ($context['tabs'] as $id_tab => $tab_data) |
|
113 | + if (isset($context['tabs'][$context['current_subaction']])) { |
|
114 | + $context['tabs'][$context['current_subaction']]['is_selected'] = true; |
|
115 | + } elseif (isset($context['current_subaction'])) { |
|
116 | + foreach ($context['tabs'] as $id_tab => $tab_data) |
|
116 | 117 | if (!empty($tab_data['selected_actions']) && in_array($context['current_subaction'], $tab_data['selected_actions'])) |
117 | 118 | $context['tabs'][$id_tab]['is_selected'] = true; |
119 | + } |
|
118 | 120 | |
119 | 121 | call_helper($subActions[$context['current_subaction']][0]); |
120 | 122 | } |
@@ -141,8 +143,9 @@ discard block |
||
141 | 143 | foreach ($_POST['delete'] as $key => $value) |
142 | 144 | { |
143 | 145 | // Don't delete yourself, idiot. |
144 | - if ($value != $user_info['id']) |
|
145 | - $delete[$key] = (int) $value; |
|
146 | + if ($value != $user_info['id']) { |
|
147 | + $delete[$key] = (int) $value; |
|
148 | + } |
|
146 | 149 | } |
147 | 150 | |
148 | 151 | if (!empty($delete)) |
@@ -178,17 +181,18 @@ discard block |
||
178 | 181 | ); |
179 | 182 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
180 | 183 | { |
181 | - if ($row['min_posts'] == -1) |
|
182 | - $context['membergroups'][] = array( |
|
184 | + if ($row['min_posts'] == -1) { |
|
185 | + $context['membergroups'][] = array( |
|
183 | 186 | 'id' => $row['id_group'], |
184 | 187 | 'name' => $row['group_name'], |
185 | 188 | 'can_be_additional' => true |
186 | 189 | ); |
187 | - else |
|
188 | - $context['postgroups'][] = array( |
|
190 | + } else { |
|
191 | + $context['postgroups'][] = array( |
|
189 | 192 | 'id' => $row['id_group'], |
190 | 193 | 'name' => $row['group_name'] |
191 | 194 | ); |
195 | + } |
|
192 | 196 | } |
193 | 197 | $smcFunc['db_free_result']($request); |
194 | 198 | |
@@ -260,14 +264,15 @@ discard block |
||
260 | 264 | call_integration_hook('integrate_view_members_params', array(&$params)); |
261 | 265 | |
262 | 266 | $search_params = array(); |
263 | - if ($context['current_subaction'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
264 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
265 | - elseif (!empty($_POST)) |
|
267 | + if ($context['current_subaction'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
268 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
269 | + } elseif (!empty($_POST)) |
|
266 | 270 | { |
267 | 271 | $search_params['types'] = $_POST['types']; |
268 | - foreach ($params as $param_name => $param_info) |
|
269 | - if (isset($_POST[$param_name])) |
|
272 | + foreach ($params as $param_name => $param_info) { |
|
273 | + if (isset($_POST[$param_name])) |
|
270 | 274 | $search_params[$param_name] = $_POST[$param_name]; |
275 | + } |
|
271 | 276 | } |
272 | 277 | |
273 | 278 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -280,34 +285,38 @@ discard block |
||
280 | 285 | foreach ($params as $param_name => $param_info) |
281 | 286 | { |
282 | 287 | // Not filled in? |
283 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
284 | - continue; |
|
288 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
289 | + continue; |
|
290 | + } |
|
285 | 291 | |
286 | 292 | // Make sure numeric values are really numeric. |
287 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
288 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
293 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
294 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
295 | + } |
|
289 | 296 | // Date values have to match the specified format. |
290 | 297 | elseif ($param_info['type'] == 'date') |
291 | 298 | { |
292 | 299 | // Check if this date format is valid. |
293 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
294 | - continue; |
|
300 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
301 | + continue; |
|
302 | + } |
|
295 | 303 | |
296 | 304 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
297 | - } |
|
298 | - elseif ($param_info['type'] == 'inet') |
|
305 | + } elseif ($param_info['type'] == 'inet') |
|
299 | 306 | { |
300 | 307 | $search_params[$param_name] = ip2range($search_params[$param_name]); |
301 | - if (empty($search_params[$param_name])) |
|
302 | - continue; |
|
308 | + if (empty($search_params[$param_name])) { |
|
309 | + continue; |
|
310 | + } |
|
303 | 311 | } |
304 | 312 | |
305 | 313 | // Those values that are in some kind of range (<, <=, =, >=, >). |
306 | 314 | if (!empty($param_info['range'])) |
307 | 315 | { |
308 | 316 | // Default to '=', just in case... |
309 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
310 | - $search_params['types'][$param_name] = '='; |
|
317 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
318 | + $search_params['types'][$param_name] = '='; |
|
319 | + } |
|
311 | 320 | |
312 | 321 | // Handle special case 'age'. |
313 | 322 | if ($param_info['type'] == 'age') |
@@ -335,16 +344,17 @@ discard block |
||
335 | 344 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
336 | 345 | { |
337 | 346 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
347 | + } else { |
|
348 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
338 | 349 | } |
339 | - else |
|
340 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
341 | 350 | } |
342 | 351 | // Checkboxes. |
343 | 352 | elseif ($param_info['type'] == 'checkbox') |
344 | 353 | { |
345 | 354 | // Each checkbox or no checkbox at all is checked -> ignore. |
346 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
347 | - continue; |
|
355 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
356 | + continue; |
|
357 | + } |
|
348 | 358 | |
349 | 359 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
350 | 360 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
@@ -356,24 +366,23 @@ discard block |
||
356 | 366 | { |
357 | 367 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
358 | 368 | $where_params[$param_name] = $search_params[$param_name][0]; |
359 | - } |
|
360 | - elseif (count($search_params[$param_name]) === 2) |
|
369 | + } elseif (count($search_params[$param_name]) === 2) |
|
361 | 370 | { |
362 | 371 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
363 | 372 | $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
364 | 373 | $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
365 | 374 | } |
366 | 375 | |
367 | - } |
|
368 | - elseif ($param_info['type'] != 'groups') |
|
376 | + } elseif ($param_info['type'] != 'groups') |
|
369 | 377 | { |
370 | 378 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
371 | 379 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
372 | 380 | |
373 | - if ($smcFunc['db_case_sensitive']) |
|
374 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
375 | - else |
|
376 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
381 | + if ($smcFunc['db_case_sensitive']) { |
|
382 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
383 | + } else { |
|
384 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
385 | + } |
|
377 | 386 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
378 | 387 | } |
379 | 388 | } |
@@ -389,16 +398,18 @@ discard block |
||
389 | 398 | } |
390 | 399 | |
391 | 400 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
392 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
393 | - foreach ($search_params['membergroups'][2] as $mg) |
|
401 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
402 | + foreach ($search_params['membergroups'][2] as $mg) |
|
394 | 403 | { |
395 | 404 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
405 | + } |
|
396 | 406 | $where_params['add_group_' . $mg] = $mg; |
397 | 407 | } |
398 | 408 | |
399 | 409 | // Combine the one or two membergroup parts into one query part linked with an OR. |
400 | - if (!empty($mg_query_parts)) |
|
401 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
410 | + if (!empty($mg_query_parts)) { |
|
411 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
412 | + } |
|
402 | 413 | |
403 | 414 | // Get all selected post count related membergroups. |
404 | 415 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -410,9 +421,9 @@ discard block |
||
410 | 421 | // Construct the where part of the query. |
411 | 422 | $where = empty($query_parts) ? '1=1' : implode(' |
412 | 423 | AND ', $query_parts); |
424 | + } else { |
|
425 | + $search_url_params = null; |
|
413 | 426 | } |
414 | - else |
|
415 | - $search_url_params = null; |
|
416 | 427 | |
417 | 428 | // Construct the additional URL part with the query info in it. |
418 | 429 | $context['params_url'] = $context['current_subaction'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -535,28 +546,32 @@ discard block |
||
535 | 546 | 'function' => function($rowData) use ($txt) |
536 | 547 | { |
537 | 548 | // Calculate number of days since last online. |
538 | - if (empty($rowData['last_login'])) |
|
539 | - $difference = $txt['never']; |
|
540 | - else |
|
549 | + if (empty($rowData['last_login'])) { |
|
550 | + $difference = $txt['never']; |
|
551 | + } else |
|
541 | 552 | { |
542 | 553 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
543 | 554 | |
544 | 555 | // Today. |
545 | - if (empty($num_days_difference)) |
|
546 | - $difference = $txt['viewmembers_today']; |
|
556 | + if (empty($num_days_difference)) { |
|
557 | + $difference = $txt['viewmembers_today']; |
|
558 | + } |
|
547 | 559 | |
548 | 560 | // Yesterday. |
549 | - elseif ($num_days_difference == 1) |
|
550 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
561 | + elseif ($num_days_difference == 1) { |
|
562 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
563 | + } |
|
551 | 564 | |
552 | 565 | // X days ago. |
553 | - else |
|
554 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
566 | + else { |
|
567 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
568 | + } |
|
555 | 569 | } |
556 | 570 | |
557 | 571 | // Show it in italics if they're not activated... |
558 | - if ($rowData['is_activated'] % 10 != 1) |
|
559 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
572 | + if ($rowData['is_activated'] % 10 != 1) { |
|
573 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
574 | + } |
|
560 | 575 | |
561 | 576 | return $difference; |
562 | 577 | }, |
@@ -608,8 +623,9 @@ discard block |
||
608 | 623 | ); |
609 | 624 | |
610 | 625 | // Without enough permissions, don't show 'delete members' checkboxes. |
611 | - if (!allowedTo('profile_remove_any')) |
|
612 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
626 | + if (!allowedTo('profile_remove_any')) { |
|
627 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
628 | + } |
|
613 | 629 | |
614 | 630 | require_once($sourcedir . '/Subs-List.php'); |
615 | 631 | createList($listOptions); |
@@ -652,17 +668,18 @@ discard block |
||
652 | 668 | ); |
653 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
654 | 670 | { |
655 | - if ($row['min_posts'] == -1) |
|
656 | - $context['membergroups'][] = array( |
|
671 | + if ($row['min_posts'] == -1) { |
|
672 | + $context['membergroups'][] = array( |
|
657 | 673 | 'id' => $row['id_group'], |
658 | 674 | 'name' => $row['group_name'], |
659 | 675 | 'can_be_additional' => true |
660 | 676 | ); |
661 | - else |
|
662 | - $context['postgroups'][] = array( |
|
677 | + } else { |
|
678 | + $context['postgroups'][] = array( |
|
663 | 679 | 'id' => $row['id_group'], |
664 | 680 | 'name' => $row['group_name'] |
665 | 681 | ); |
682 | + } |
|
666 | 683 | } |
667 | 684 | $smcFunc['db_free_result']($request); |
668 | 685 | |
@@ -689,8 +706,9 @@ discard block |
||
689 | 706 | $context['page_title'] = $txt['admin_members']; |
690 | 707 | $context['sub_template'] = 'admin_browse'; |
691 | 708 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
692 | - if (isset($context['tabs'][$context['browse_type']])) |
|
693 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
709 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
710 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
711 | + } |
|
694 | 712 | |
695 | 713 | // Allowed filters are those we can have, in theory. |
696 | 714 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -701,18 +719,20 @@ discard block |
||
701 | 719 | foreach ($context['activation_numbers'] as $type => $amount) |
702 | 720 | { |
703 | 721 | // We have some of these... |
704 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
705 | - $context['available_filters'][] = array( |
|
722 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
723 | + $context['available_filters'][] = array( |
|
706 | 724 | 'type' => $type, |
707 | 725 | 'amount' => $amount, |
708 | 726 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
709 | 727 | 'selected' => $type == $context['current_filter'] |
710 | 728 | ); |
729 | + } |
|
711 | 730 | } |
712 | 731 | |
713 | 732 | // If the filter was not sent, set it to whatever has people in it! |
714 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
715 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
733 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
734 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
735 | + } |
|
716 | 736 | |
717 | 737 | // This little variable is used to determine if we should flag where we are looking. |
718 | 738 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -727,44 +747,47 @@ discard block |
||
727 | 747 | ); |
728 | 748 | |
729 | 749 | // Are we showing duplicate information? |
730 | - if (isset($_GET['showdupes'])) |
|
731 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
750 | + if (isset($_GET['showdupes'])) { |
|
751 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
752 | + } |
|
732 | 753 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
733 | 754 | |
734 | 755 | // Determine which actions we should allow on this page. |
735 | 756 | if ($context['browse_type'] == 'approve') |
736 | 757 | { |
737 | 758 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
738 | - if ($context['current_filter'] == 4) |
|
739 | - $context['allowed_actions'] = array( |
|
759 | + if ($context['current_filter'] == 4) { |
|
760 | + $context['allowed_actions'] = array( |
|
740 | 761 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
741 | 762 | 'ok' => $txt['admin_browse_w_reject'], |
742 | 763 | ); |
743 | - else |
|
744 | - $context['allowed_actions'] = array( |
|
764 | + } else { |
|
765 | + $context['allowed_actions'] = array( |
|
745 | 766 | 'ok' => $txt['admin_browse_w_approve'], |
746 | 767 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
747 | 768 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
748 | 769 | 'reject' => $txt['admin_browse_w_reject'], |
749 | 770 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
750 | 771 | ); |
751 | - } |
|
752 | - elseif ($context['browse_type'] == 'activate') |
|
753 | - $context['allowed_actions'] = array( |
|
772 | + } |
|
773 | + } elseif ($context['browse_type'] == 'activate') { |
|
774 | + $context['allowed_actions'] = array( |
|
754 | 775 | 'ok' => $txt['admin_browse_w_activate'], |
755 | 776 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
756 | 777 | 'delete' => $txt['admin_browse_w_delete'], |
757 | 778 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
758 | 779 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
759 | 780 | ); |
781 | + } |
|
760 | 782 | |
761 | 783 | // Create an option list for actions allowed to be done with selected members. |
762 | 784 | $allowed_actions = ' |
763 | 785 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
764 | 786 | <option value="" disabled>-----------------------------</option>'; |
765 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
766 | - $allowed_actions .= ' |
|
787 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
788 | + $allowed_actions .= ' |
|
767 | 789 | <option value="' . $key . '">' . $desc . '</option>'; |
790 | + } |
|
768 | 791 | |
769 | 792 | // Setup the Javascript function for selecting an action for the list. |
770 | 793 | $javascript = ' |
@@ -776,15 +799,16 @@ discard block |
||
776 | 799 | var message = "";'; |
777 | 800 | |
778 | 801 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
779 | - if ($context['current_filter'] == 4) |
|
780 | - $javascript .= ' |
|
802 | + if ($context['current_filter'] == 4) { |
|
803 | + $javascript .= ' |
|
781 | 804 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
782 | 805 | message = "' . $txt['admin_browse_w_delete'] . '"; |
783 | 806 | else |
784 | 807 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
808 | + } |
|
785 | 809 | // Otherwise a nice standard message. |
786 | - else |
|
787 | - $javascript .= ' |
|
810 | + else { |
|
811 | + $javascript .= ' |
|
788 | 812 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
789 | 813 | message = "' . $txt['admin_browse_w_delete'] . '"; |
790 | 814 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -793,6 +817,7 @@ discard block |
||
793 | 817 | message = "' . $txt['admin_browse_w_remind'] . '"; |
794 | 818 | else |
795 | 819 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
820 | + } |
|
796 | 821 | $javascript .= ' |
797 | 822 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
798 | 823 | document.forms.postForm.submit(); |
@@ -925,10 +950,11 @@ discard block |
||
925 | 950 | $member_links = array(); |
926 | 951 | foreach ($rowData['duplicate_members'] as $member) |
927 | 952 | { |
928 | - if ($member['id']) |
|
929 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
930 | - else |
|
931 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
953 | + if ($member['id']) { |
|
954 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
955 | + } else { |
|
956 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
957 | + } |
|
932 | 958 | } |
933 | 959 | return implode(', ', $member_links); |
934 | 960 | }, |
@@ -977,14 +1003,16 @@ discard block |
||
977 | 1003 | ); |
978 | 1004 | |
979 | 1005 | // Pick what column to actually include if we're showing duplicates. |
980 | - if ($context['show_duplicates']) |
|
981 | - unset($listOptions['columns']['email']); |
|
982 | - else |
|
983 | - unset($listOptions['columns']['duplicates']); |
|
1006 | + if ($context['show_duplicates']) { |
|
1007 | + unset($listOptions['columns']['email']); |
|
1008 | + } else { |
|
1009 | + unset($listOptions['columns']['duplicates']); |
|
1010 | + } |
|
984 | 1011 | |
985 | 1012 | // Only show hostname on duplicates as it takes a lot of time. |
986 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
987 | - unset($listOptions['columns']['hostname']); |
|
1013 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1014 | + unset($listOptions['columns']['hostname']); |
|
1015 | + } |
|
988 | 1016 | |
989 | 1017 | // Is there any need to show filters? |
990 | 1018 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -992,9 +1020,10 @@ discard block |
||
992 | 1020 | $filterOptions = ' |
993 | 1021 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
994 | 1022 | <select name="filter" onchange="this.form.submit();">'; |
995 | - foreach ($context['available_filters'] as $filter) |
|
996 | - $filterOptions .= ' |
|
1023 | + foreach ($context['available_filters'] as $filter) { |
|
1024 | + $filterOptions .= ' |
|
997 | 1025 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1026 | + } |
|
998 | 1027 | $filterOptions .= ' |
999 | 1028 | </select> |
1000 | 1029 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -1006,12 +1035,13 @@ discard block |
||
1006 | 1035 | } |
1007 | 1036 | |
1008 | 1037 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
1009 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
1010 | - $listOptions['additional_rows'][] = array( |
|
1038 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1039 | + $listOptions['additional_rows'][] = array( |
|
1011 | 1040 | 'position' => 'above_column_headers', |
1012 | 1041 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . ((isset($context['current_filter']) && isset($txt['admin_browse_filter_type_'.$context['current_filter']])) ? $txt['admin_browse_filter_type_'.$context['current_filter']] : $context['available_filters'][0]['desc']), |
1013 | 1042 | 'class' => 'filter_row generic_list_wrapper smalltext', |
1014 | 1043 | ); |
1044 | + } |
|
1015 | 1045 | |
1016 | 1046 | // Now that we have all the options, create the list. |
1017 | 1047 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1041,12 +1071,14 @@ discard block |
||
1041 | 1071 | $current_filter = (int) $_REQUEST['orig_filter']; |
1042 | 1072 | |
1043 | 1073 | // If we are applying a filter do just that - then redirect. |
1044 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1045 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1074 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1075 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1076 | + } |
|
1046 | 1077 | |
1047 | 1078 | // Nothing to do? |
1048 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1049 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1079 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1080 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1081 | + } |
|
1050 | 1082 | |
1051 | 1083 | // Are we dealing with members who have been waiting for > set amount of time? |
1052 | 1084 | if (isset($_POST['time_passed'])) |
@@ -1059,8 +1091,9 @@ discard block |
||
1059 | 1091 | else |
1060 | 1092 | { |
1061 | 1093 | $members = array(); |
1062 | - foreach ($_POST['todoAction'] as $id) |
|
1063 | - $members[] = (int) $id; |
|
1094 | + foreach ($_POST['todoAction'] as $id) { |
|
1095 | + $members[] = (int) $id; |
|
1096 | + } |
|
1064 | 1097 | $condition = ' |
1065 | 1098 | AND id_member IN ({array_int:members})'; |
1066 | 1099 | } |
@@ -1081,8 +1114,9 @@ discard block |
||
1081 | 1114 | $member_count = $smcFunc['db_num_rows']($request); |
1082 | 1115 | |
1083 | 1116 | // If no results then just return! |
1084 | - if ($member_count == 0) |
|
1085 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1117 | + if ($member_count == 0) { |
|
1118 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1119 | + } |
|
1086 | 1120 | |
1087 | 1121 | $member_info = array(); |
1088 | 1122 | $members = array(); |
@@ -1121,8 +1155,9 @@ discard block |
||
1121 | 1155 | // Do we have to let the integration code know about the activations? |
1122 | 1156 | if (!empty($modSettings['integrate_activate'])) |
1123 | 1157 | { |
1124 | - foreach ($member_info as $member) |
|
1125 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1158 | + foreach ($member_info as $member) { |
|
1159 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1160 | + } |
|
1126 | 1161 | } |
1127 | 1162 | |
1128 | 1163 | // Check for email. |
@@ -1252,20 +1287,23 @@ discard block |
||
1252 | 1287 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
1253 | 1288 | |
1254 | 1289 | require_once($sourcedir . '/Logging.php'); |
1255 | - foreach ($member_info as $member) |
|
1256 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1290 | + foreach ($member_info as $member) { |
|
1291 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1292 | + } |
|
1257 | 1293 | } |
1258 | 1294 | |
1259 | 1295 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1260 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1261 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1296 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1297 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1298 | + } |
|
1262 | 1299 | |
1263 | 1300 | // Update the member's stats. (but, we know the member didn't change their name.) |
1264 | 1301 | updateStats('member', false); |
1265 | 1302 | |
1266 | 1303 | // If they haven't been deleted, update the post group statistics on them... |
1267 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1268 | - updateStats('postgroups', $members); |
|
1304 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1305 | + updateStats('postgroups', $members); |
|
1306 | + } |
|
1269 | 1307 | |
1270 | 1308 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1271 | 1309 | } |
@@ -1290,10 +1328,11 @@ discard block |
||
1290 | 1328 | $dis = time() - $old; |
1291 | 1329 | |
1292 | 1330 | // Before midnight? |
1293 | - if ($dis < $sinceMidnight) |
|
1294 | - return 0; |
|
1295 | - else |
|
1296 | - $dis -= $sinceMidnight; |
|
1331 | + if ($dis < $sinceMidnight) { |
|
1332 | + return 0; |
|
1333 | + } else { |
|
1334 | + $dis -= $sinceMidnight; |
|
1335 | + } |
|
1297 | 1336 | |
1298 | 1337 | // Divide out the seconds in a day to get the number of days. |
1299 | 1338 | return ceil($dis / (24 * 60 * 60)); |
@@ -1320,16 +1359,18 @@ discard block |
||
1320 | 1359 | $context['activation_numbers'] = array(); |
1321 | 1360 | $context['awaiting_activation'] = 0; |
1322 | 1361 | $context['awaiting_approval'] = 0; |
1323 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1324 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
1362 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1363 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
1364 | + } |
|
1325 | 1365 | $smcFunc['db_free_result']($request); |
1326 | 1366 | |
1327 | 1367 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
1328 | 1368 | { |
1329 | - if (in_array($activation_type, array(0, 2))) |
|
1330 | - $context['awaiting_activation'] += $total_members; |
|
1331 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
1332 | - $context['awaiting_approval'] += $total_members; |
|
1369 | + if (in_array($activation_type, array(0, 2))) { |
|
1370 | + $context['awaiting_activation'] += $total_members; |
|
1371 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
1372 | + $context['awaiting_approval'] += $total_members; |
|
1373 | + } |
|
1333 | 1374 | } |
1334 | 1375 | |
1335 | 1376 | } |
@@ -191,12 +191,15 @@ discard block |
||
191 | 191 | $tasksdir = $sourcedir . '/tasks'; |
192 | 192 | |
193 | 193 | # Make sure the paths are correct... at least try to fix them. |
194 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
194 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
195 | 195 | $boarddir = dirname(__FILE__); |
196 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
196 | +} |
|
197 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
197 | 198 | $sourcedir = $boarddir . '/Sources'; |
198 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
199 | +} |
|
200 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
199 | 201 | $cachedir = $boarddir . '/cache'; |
202 | +} |
|
200 | 203 | |
201 | 204 | ######### Legacy Settings ######### |
202 | 205 | # UTF-8 is now the only character set supported in 2.1. |
@@ -204,8 +207,9 @@ discard block |
||
204 | 207 | |
205 | 208 | ########## Error-Catching ########## |
206 | 209 | # Note: You shouldn't touch these settings. |
207 | -if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) |
|
210 | +if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) { |
|
208 | 211 | include((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php'); |
212 | +} |
|
209 | 213 | |
210 | 214 | if (!isset($db_last_error)) |
211 | 215 | { |
@@ -217,10 +221,11 @@ discard block |
||
217 | 221 | if (file_exists(dirname(__FILE__) . '/install.php')) |
218 | 222 | { |
219 | 223 | $secure = false; |
220 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
221 | - $secure = true; |
|
222 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
223 | - $secure = true; |
|
224 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
225 | + $secure = true; |
|
226 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
227 | + $secure = true; |
|
228 | + } |
|
224 | 229 | |
225 | 230 | header('location: http' . ($secure ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit; |
226 | 231 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Scheduled tasks management dispatcher. This function checks permissions and delegates |
@@ -41,10 +42,11 @@ discard block |
||
41 | 42 | ); |
42 | 43 | |
43 | 44 | // We need to find what's the action. |
44 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
45 | - $context['sub_action'] = $_REQUEST['sa']; |
|
46 | - else |
|
47 | - $context['sub_action'] = 'tasks'; |
|
45 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
46 | + $context['sub_action'] = $_REQUEST['sa']; |
|
47 | + } else { |
|
48 | + $context['sub_action'] = 'tasks'; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | // Now for the lovely tabs. That we all love. |
50 | 52 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -94,9 +96,10 @@ discard block |
||
94 | 96 | |
95 | 97 | // Enable and disable as required. |
96 | 98 | $enablers = array(0); |
97 | - foreach ($_POST['enable_task'] as $id => $enabled) |
|
98 | - if ($enabled) |
|
99 | + foreach ($_POST['enable_task'] as $id => $enabled) { |
|
100 | + if ($enabled) |
|
99 | 101 | $enablers[] = (int) $id; |
102 | + } |
|
100 | 103 | |
101 | 104 | // Do the update! |
102 | 105 | $smcFunc['db_query']('', ' |
@@ -134,8 +137,9 @@ discard block |
||
134 | 137 | |
135 | 138 | // Lets figure out which ones they want to run. |
136 | 139 | $tasks = array(); |
137 | - foreach ($_POST['run_task'] as $task => $dummy) |
|
138 | - $tasks[] = (int) $task; |
|
140 | + foreach ($_POST['run_task'] as $task => $dummy) { |
|
141 | + $tasks[] = (int) $task; |
|
142 | + } |
|
139 | 143 | |
140 | 144 | // Load up the tasks. |
141 | 145 | $request = $smcFunc['db_query']('', ' |
@@ -155,36 +159,41 @@ discard block |
||
155 | 159 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
156 | 160 | { |
157 | 161 | // What kind of task are we handling? |
158 | - if (!empty($row['callable'])) |
|
159 | - $task_string = $row['callable']; |
|
162 | + if (!empty($row['callable'])) { |
|
163 | + $task_string = $row['callable']; |
|
164 | + } |
|
160 | 165 | |
161 | 166 | // Default SMF task or old mods? |
162 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
163 | - $task_string = 'scheduled_' . $row['task']; |
|
167 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
168 | + $task_string = 'scheduled_' . $row['task']; |
|
169 | + } |
|
164 | 170 | |
165 | 171 | // One last resource, the task name. |
166 | - elseif (!empty($row['task'])) |
|
167 | - $task_string = $row['task']; |
|
172 | + elseif (!empty($row['task'])) { |
|
173 | + $task_string = $row['task']; |
|
174 | + } |
|
168 | 175 | |
169 | 176 | $start_time = microtime(true); |
170 | 177 | // The functions got to exist for us to use it. |
171 | - if (empty($task_string)) |
|
172 | - continue; |
|
178 | + if (empty($task_string)) { |
|
179 | + continue; |
|
180 | + } |
|
173 | 181 | |
174 | 182 | // Try to stop a timeout, this would be bad... |
175 | 183 | @set_time_limit(300); |
176 | - if (function_exists('apache_reset_timeout')) |
|
177 | - @apache_reset_timeout(); |
|
184 | + if (function_exists('apache_reset_timeout')) { |
|
185 | + @apache_reset_timeout(); |
|
186 | + } |
|
178 | 187 | |
179 | 188 | // Get the callable. |
180 | 189 | $callable_task = call_helper($task_string, true); |
181 | 190 | |
182 | 191 | // Perform the task. |
183 | - if (!empty($callable_task)) |
|
184 | - $completed = call_user_func($callable_task); |
|
185 | - |
|
186 | - else |
|
187 | - $completed = false; |
|
192 | + if (!empty($callable_task)) { |
|
193 | + $completed = call_user_func($callable_task); |
|
194 | + } else { |
|
195 | + $completed = false; |
|
196 | + } |
|
188 | 197 | |
189 | 198 | // Log that we did it ;) |
190 | 199 | if ($completed) |
@@ -201,8 +210,9 @@ discard block |
||
201 | 210 | $smcFunc['db_free_result']($request); |
202 | 211 | |
203 | 212 | // If we had any errors, push them to session so we can pick them up next time to tell the user. |
204 | - if (!empty($context['scheduled_errors'])) |
|
205 | - $_SESSION['st_error'] = $context['scheduled_errors']; |
|
213 | + if (!empty($context['scheduled_errors'])) { |
|
214 | + $_SESSION['st_error'] = $context['scheduled_errors']; |
|
215 | + } |
|
206 | 216 | |
207 | 217 | redirectexit('action=admin;area=scheduledtasks;done'); |
208 | 218 | } |
@@ -374,8 +384,9 @@ discard block |
||
374 | 384 | $context['server_time'] = timeformat(time(), false, 'server'); |
375 | 385 | |
376 | 386 | // Cleaning... |
377 | - if (!isset($_GET['tid'])) |
|
378 | - fatal_lang_error('no_access', false); |
|
387 | + if (!isset($_GET['tid'])) { |
|
388 | + fatal_lang_error('no_access', false); |
|
389 | + } |
|
379 | 390 | $_GET['tid'] = (int) $_GET['tid']; |
380 | 391 | |
381 | 392 | // Saving? |
@@ -391,10 +402,12 @@ discard block |
||
391 | 402 | preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches); |
392 | 403 | |
393 | 404 | // If a half is empty then assume zero offset! |
394 | - if (!isset($matches[2]) || $matches[2] > 59) |
|
395 | - $matches[2] = 0; |
|
396 | - if (!isset($matches[1]) || $matches[1] > 23) |
|
397 | - $matches[1] = 0; |
|
405 | + if (!isset($matches[2]) || $matches[2] > 59) { |
|
406 | + $matches[2] = 0; |
|
407 | + } |
|
408 | + if (!isset($matches[1]) || $matches[1] > 23) { |
|
409 | + $matches[1] = 0; |
|
410 | + } |
|
398 | 411 | |
399 | 412 | // Now the offset is easy; easy peasy - except we need to offset by a few hours... |
400 | 413 | $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); |
@@ -404,8 +417,9 @@ discard block |
||
404 | 417 | $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; |
405 | 418 | |
406 | 419 | // Don't allow one minute intervals. |
407 | - if ($interval == 1 && $unit == 'm') |
|
408 | - $interval = 2; |
|
420 | + if ($interval == 1 && $unit == 'm') { |
|
421 | + $interval = 2; |
|
422 | + } |
|
409 | 423 | |
410 | 424 | // Is it disabled? |
411 | 425 | $disabled = !isset($_POST['enabled']) ? 1 : 0; |
@@ -443,8 +457,9 @@ discard block |
||
443 | 457 | ); |
444 | 458 | |
445 | 459 | // Should never, ever, happen! |
446 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
447 | - fatal_lang_error('no_access', false); |
|
460 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
461 | + fatal_lang_error('no_access', false); |
|
462 | + } |
|
448 | 463 | |
449 | 464 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
450 | 465 | { |
@@ -602,13 +617,14 @@ discard block |
||
602 | 617 | ) |
603 | 618 | ); |
604 | 619 | $log_entries = array(); |
605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
606 | - $log_entries[] = array( |
|
620 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
621 | + $log_entries[] = array( |
|
607 | 622 | 'id' => $row['id_log'], |
608 | 623 | 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], |
609 | 624 | 'time_run' => $row['time_run'], |
610 | 625 | 'time_taken' => $row['time_taken'], |
611 | 626 | ); |
627 | + } |
|
612 | 628 | $smcFunc['db_free_result']($request); |
613 | 629 | |
614 | 630 | return $log_entries; |
@@ -649,8 +665,9 @@ discard block |
||
649 | 665 | |
650 | 666 | call_integration_hook('integrate_scheduled_tasks_settings', array(&$config_vars)); |
651 | 667 | |
652 | - if ($return_config) |
|
653 | - return $config_vars; |
|
668 | + if ($return_config) { |
|
669 | + return $config_vars; |
|
670 | + } |
|
654 | 671 | |
655 | 672 | // Set up the template. |
656 | 673 | $context['page_title'] = $txt['scheduled_tasks_settings']; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $smcFunc['db_free_result']($result_boards); |
136 | 136 | |
137 | 137 | // Run through the categories and boards (or only boards).... |
138 | - for (reset($row_boards); key($row_boards)!==null; next($row_boards)) |
|
138 | + for (reset($row_boards); key($row_boards) !== null; next($row_boards)) |
|
139 | 139 | { |
140 | 140 | $row_board = current($row_boards); |
141 | 141 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $row_boards[$row_board['id_parent']]['id_msg'] = $row_board['id_msg']; |
304 | 304 | $row_boards[$row_board['id_parent']]['subject'] = $row_board['subject']; |
305 | 305 | $row_boards[$row_board['id_parent']]['poster_time'] = $row_board['poster_time']; |
306 | - $row_boards[$row_board['id_parent']]['short_subject'] = (!empty($row_board['short_subject']) ? $row_board['short_subject'] : '') ; |
|
306 | + $row_boards[$row_board['id_parent']]['short_subject'] = (!empty($row_board['short_subject']) ? $row_board['short_subject'] : ''); |
|
307 | 307 | $row_boards[$row_board['id_parent']]['poster_name'] = $row_board['poster_name']; |
308 | 308 | $row_boards[$row_board['id_parent']]['real_name'] = $row_board['real_name']; |
309 | 309 | $row_boards[$row_board['id_parent']]['id_member'] = $row_board['id_member']; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | // Set the last post in the root board |
370 | 370 | if (!$isChild && !empty($row_board['poster_time']) |
371 | - && ( empty($this_category[$row_board['id_board']]['last_post']['timestamp']) |
|
371 | + && (empty($this_category[$row_board['id_board']]['last_post']['timestamp']) |
|
372 | 372 | || $this_category[$row_board['id_board']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']) |
373 | 373 | ) |
374 | 374 | ) |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | if ($boardIndexOptions['include_categories']) |
399 | 399 | foreach ($categories as &$category) |
400 | 400 | { |
401 | - foreach ($category['boards'] as &$board ) |
|
401 | + foreach ($category['boards'] as &$board) |
|
402 | 402 | { |
403 | 403 | if (!empty($moderators[$board['id']])) |
404 | 404 | { |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | } |
422 | 422 | else |
423 | - foreach ($this_category as &$board ) |
|
423 | + foreach ($this_category as &$board) |
|
424 | 424 | { |
425 | 425 | if (!empty($moderators[$board['id']])) |
426 | 426 | { |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']); |
442 | 442 | } |
443 | 443 | |
444 | - unset($category,$board); |
|
444 | + unset($category, $board); |
|
445 | 445 | |
446 | 446 | if ($boardIndexOptions['include_categories']) |
447 | 447 | sortCategories($categories); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,19 +38,21 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
38 | 39 | |
39 | 40 | // For performance, track the latest post while going through the boards. |
40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
41 | - $latest_post = array( |
|
41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
42 | + $latest_post = array( |
|
42 | 43 | 'timestamp' => 0, |
43 | 44 | 'ref' => 0, |
44 | 45 | ); |
46 | + } |
|
45 | 47 | |
46 | 48 | // This setting is not allowed to be empty |
47 | - if (empty($modSettings['boardindex_max_depth'])) |
|
48 | - $modSettings['boardindex_max_depth'] = 1; |
|
49 | + if (empty($modSettings['boardindex_max_depth'])) { |
|
50 | + $modSettings['boardindex_max_depth'] = 1; |
|
51 | + } |
|
49 | 52 | |
50 | 53 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
51 | - if ($boardIndexOptions['parent_id'] != 0 && $smcFunc['db_cte_support']()) |
|
52 | - $result_boards = $smcFunc['db_query']('', ' |
|
54 | + if ($boardIndexOptions['parent_id'] != 0 && $smcFunc['db_cte_support']()) { |
|
55 | + $result_boards = $smcFunc['db_query']('', ' |
|
53 | 56 | WITH RECURSIVE |
54 | 57 | boards_cte (child_level, id_board, name , description, redirect, num_posts, num_topics, unapproved_posts, unapproved_topics, id_parent, id_msg_updated, id_cat, id_last_msg, board_order) |
55 | 58 | as |
@@ -91,8 +94,8 @@ discard block |
||
91 | 94 | 'id_parent' => $boardIndexOptions['parent_id'], |
92 | 95 | ) |
93 | 96 | ); |
94 | - else |
|
95 | - $result_boards = $smcFunc['db_query']('', ' |
|
97 | + } else { |
|
98 | + $result_boards = $smcFunc['db_query']('', ' |
|
96 | 99 | SELECT' . ($boardIndexOptions['include_categories'] ? ' |
97 | 100 | c.id_cat, c.name AS cat_name, c.description AS cat_desc,' : '') . ' |
98 | 101 | b.id_board, b.name AS board_name, b.description, |
@@ -120,18 +123,21 @@ discard block |
||
120 | 123 | 'blank_string' => '', |
121 | 124 | ) |
122 | 125 | ); |
126 | + } |
|
123 | 127 | |
124 | 128 | // Start with an empty array. |
125 | - if ($boardIndexOptions['include_categories']) |
|
126 | - $categories = array(); |
|
127 | - else |
|
128 | - $this_category = array(); |
|
129 | + if ($boardIndexOptions['include_categories']) { |
|
130 | + $categories = array(); |
|
131 | + } else { |
|
132 | + $this_category = array(); |
|
133 | + } |
|
129 | 134 | $boards = array(); |
130 | 135 | |
131 | 136 | // Children can affect parents, so we need to gather all the boards first and then process them after. |
132 | 137 | $row_boards = array(); |
133 | - while ($row_board = $smcFunc['db_fetch_assoc']($result_boards)) |
|
134 | - $row_boards[$row_board['id_board']] = $row_board; |
|
138 | + while ($row_board = $smcFunc['db_fetch_assoc']($result_boards)) { |
|
139 | + $row_boards[$row_board['id_board']] = $row_board; |
|
140 | + } |
|
135 | 141 | $smcFunc['db_free_result']($result_boards); |
136 | 142 | |
137 | 143 | // Run through the categories and boards (or only boards).... |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
145 | 151 | |
146 | 152 | // Add parent boards to the $boards list later used to fetch moderators |
147 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
148 | - $boards[] = $row_board['id_board']; |
|
153 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
154 | + $boards[] = $row_board['id_board']; |
|
155 | + } |
|
149 | 156 | |
150 | 157 | if ($boardIndexOptions['include_categories']) |
151 | 158 | { |
@@ -167,8 +174,9 @@ discard block |
||
167 | 174 | } |
168 | 175 | |
169 | 176 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
170 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
171 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']); |
|
177 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
178 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']); |
|
179 | + } |
|
172 | 180 | |
173 | 181 | // Avoid showing category unread link where it only has redirection boards. |
174 | 182 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -187,8 +195,9 @@ discard block |
||
187 | 195 | $isChild = false; |
188 | 196 | |
189 | 197 | // We might or might not have already added this board, so... |
190 | - if (!isset($this_category[$row_board['id_board']])) |
|
191 | - $this_category[$row_board['id_board']] = array(); |
|
198 | + if (!isset($this_category[$row_board['id_board']])) { |
|
199 | + $this_category[$row_board['id_board']] = array(); |
|
200 | + } |
|
192 | 201 | |
193 | 202 | $this_category[$row_board['id_board']] += array( |
194 | 203 | 'new' => empty($row_board['is_read']), |
@@ -221,14 +230,12 @@ discard block |
||
221 | 230 | { |
222 | 231 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
223 | 232 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
224 | - } |
|
225 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
233 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
226 | 234 | { |
227 | 235 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
228 | 236 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
229 | 237 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
230 | - } |
|
231 | - else |
|
238 | + } else |
|
232 | 239 | { |
233 | 240 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
234 | 241 | } |
@@ -240,12 +247,13 @@ discard block |
||
240 | 247 | $isChild = true; |
241 | 248 | |
242 | 249 | // Ensure the parent has at least the most important info defined |
243 | - if (!isset($this_category[$row_board['id_parent']])) |
|
244 | - $this_category[$row_board['id_parent']] = array( |
|
250 | + if (!isset($this_category[$row_board['id_parent']])) { |
|
251 | + $this_category[$row_board['id_parent']] = array( |
|
245 | 252 | 'children' => array(), |
246 | 253 | 'children_new' => false, |
247 | 254 | 'board_class' => 'off', |
248 | 255 | ); |
256 | + } |
|
249 | 257 | |
250 | 258 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']] = array( |
251 | 259 | 'id' => $row_board['id_board'], |
@@ -289,8 +297,9 @@ discard block |
||
289 | 297 | // Propagate some values to the parent board |
290 | 298 | if (isset($row_boards[$row_board['id_parent']])) |
291 | 299 | { |
292 | - if (empty($row_board['is_read'])) |
|
293 | - $row_boards[$row_board['id_parent']]['is_read'] = $row_board['is_read']; |
|
300 | + if (empty($row_board['is_read'])) { |
|
301 | + $row_boards[$row_board['id_parent']]['is_read'] = $row_board['is_read']; |
|
302 | + } |
|
294 | 303 | |
295 | 304 | if (!empty($boardIndexOptions['countChildPosts']) && !$row_board['is_redirect']) |
296 | 305 | { |
@@ -341,20 +350,20 @@ discard block |
||
341 | 350 | 'topic' => $row_board['id_topic'] |
342 | 351 | ); |
343 | 352 | |
344 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
345 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
353 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
354 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
346 | 355 | 'avatar' => $row_board['avatar'], |
347 | 356 | 'email' => $row_board['email_address'], |
348 | 357 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
349 | 358 | )); |
359 | + } |
|
350 | 360 | |
351 | 361 | // Provide the href and link. |
352 | 362 | if ($row_board['subject'] != '') |
353 | 363 | { |
354 | 364 | $this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new'; |
355 | 365 | $this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>'; |
356 | - } |
|
357 | - else |
|
366 | + } else |
|
358 | 367 | { |
359 | 368 | $this_last_post['href'] = ''; |
360 | 369 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -363,27 +372,31 @@ discard block |
||
363 | 372 | |
364 | 373 | // Set the last post in the parent board. |
365 | 374 | if ($isChild && !empty($row_board['poster_time']) |
366 | - && $row_boards[$row_board['id_parent']]['poster_time'] < $row_board['poster_time']) |
|
367 | - $this_category[$row_board['id_parent']]['last_post'] = $this_last_post; |
|
375 | + && $row_boards[$row_board['id_parent']]['poster_time'] < $row_board['poster_time']) { |
|
376 | + $this_category[$row_board['id_parent']]['last_post'] = $this_last_post; |
|
377 | + } |
|
368 | 378 | |
369 | 379 | // Set the last post in the root board |
370 | 380 | if (!$isChild && !empty($row_board['poster_time']) |
371 | 381 | && ( empty($this_category[$row_board['id_board']]['last_post']['timestamp']) |
372 | 382 | || $this_category[$row_board['id_board']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']) |
373 | 383 | ) |
374 | - ) |
|
375 | - $this_category[$row_board['id_board']]['last_post'] = $this_last_post; |
|
384 | + ) { |
|
385 | + $this_category[$row_board['id_board']]['last_post'] = $this_last_post; |
|
386 | + } |
|
376 | 387 | |
377 | 388 | // Just in the child...? |
378 | - if ($isChild) |
|
379 | - $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post; |
|
389 | + if ($isChild) { |
|
390 | + $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post; |
|
391 | + } |
|
380 | 392 | |
381 | 393 | // Determine a global most recent topic. |
382 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
383 | - $latest_post = array( |
|
394 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
395 | + $latest_post = array( |
|
384 | 396 | 'timestamp' => $row_board['poster_time'], |
385 | 397 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
386 | 398 | ); |
399 | + } |
|
387 | 400 | } |
388 | 401 | |
389 | 402 | /* The board's and children's 'last_post's have: |
@@ -395,16 +408,18 @@ discard block |
||
395 | 408 | $boards = array_unique($boards); |
396 | 409 | $moderators = getBoardModerators($boards); |
397 | 410 | $groups = getBoardModeratorGroups($boards); |
398 | - if ($boardIndexOptions['include_categories']) |
|
399 | - foreach ($categories as &$category) |
|
411 | + if ($boardIndexOptions['include_categories']) { |
|
412 | + foreach ($categories as &$category) |
|
400 | 413 | { |
401 | 414 | foreach ($category['boards'] as &$board ) |
402 | 415 | { |
403 | 416 | if (!empty($moderators[$board['id']])) |
404 | 417 | { |
405 | 418 | $board['moderators'] = $moderators[$board['id']]; |
406 | - foreach ($moderators[$board['id']] as $moderator) |
|
407 | - $board['link_moderators'][] = $moderator['link']; |
|
419 | + } |
|
420 | + foreach ($moderators[$board['id']] as $moderator) { |
|
421 | + $board['link_moderators'][] = $moderator['link']; |
|
422 | + } |
|
408 | 423 | } |
409 | 424 | if (!empty($groups[$board['id']])) |
410 | 425 | { |
@@ -415,18 +430,20 @@ discard block |
||
415 | 430 | $board['link_moderator_groups'][] = $group['link']; |
416 | 431 | } |
417 | 432 | } |
418 | - if (!empty($board['last_post'])) |
|
419 | - $board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']); |
|
433 | + if (!empty($board['last_post'])) { |
|
434 | + $board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']); |
|
435 | + } |
|
420 | 436 | } |
421 | - } |
|
422 | - else |
|
423 | - foreach ($this_category as &$board ) |
|
437 | + } else { |
|
438 | + foreach ($this_category as &$board ) |
|
424 | 439 | { |
425 | 440 | if (!empty($moderators[$board['id']])) |
426 | 441 | { |
427 | 442 | $board['moderators'] = $moderators[$board['id']]; |
428 | - foreach ($moderators[$board['id']] as $moderator) |
|
429 | - $board['link_moderators'][] = $moderator['link']; |
|
443 | + } |
|
444 | + foreach ($moderators[$board['id']] as $moderator) { |
|
445 | + $board['link_moderators'][] = $moderator['link']; |
|
446 | + } |
|
430 | 447 | } |
431 | 448 | if (!empty($groups[$board['id']])) |
432 | 449 | { |
@@ -437,26 +454,30 @@ discard block |
||
437 | 454 | $board['link_moderator_groups'][] = $group['link']; |
438 | 455 | } |
439 | 456 | } |
440 | - if (!empty($board['last_post'])) |
|
441 | - $board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']); |
|
457 | + if (!empty($board['last_post'])) { |
|
458 | + $board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']); |
|
459 | + } |
|
442 | 460 | } |
443 | 461 | |
444 | 462 | unset($category,$board); |
445 | 463 | |
446 | - if ($boardIndexOptions['include_categories']) |
|
447 | - sortCategories($categories); |
|
448 | - else |
|
449 | - sortBoards($this_category); |
|
464 | + if ($boardIndexOptions['include_categories']) { |
|
465 | + sortCategories($categories); |
|
466 | + } else { |
|
467 | + sortBoards($this_category); |
|
468 | + } |
|
450 | 469 | |
451 | 470 | // By now we should know the most recent post...if we wanna know it that is. |
452 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
453 | - $context['latest_post'] = $latest_post['ref']; |
|
471 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
472 | + $context['latest_post'] = $latest_post['ref']; |
|
473 | + } |
|
454 | 474 | |
455 | 475 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
456 | - if ($boardIndexOptions['include_categories']) |
|
457 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
458 | - else |
|
459 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
476 | + if ($boardIndexOptions['include_categories']) { |
|
477 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
478 | + } else { |
|
479 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
480 | + } |
|
460 | 481 | |
461 | 482 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
462 | 483 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Check if the current directory is still valid or not. |
@@ -28,22 +29,24 @@ discard block |
||
28 | 29 | global $smcFunc, $boarddir, $modSettings, $context; |
29 | 30 | |
30 | 31 | // Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found. |
31 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') |
|
32 | - $doit = true; |
|
33 | - elseif (empty($modSettings['automanage_attachments'])) |
|
34 | - return; |
|
35 | - elseif (!isset($_FILES)) |
|
36 | - return; |
|
37 | - elseif (isset($_FILES['attachment'])) |
|
38 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
32 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') { |
|
33 | + $doit = true; |
|
34 | + } elseif (empty($modSettings['automanage_attachments'])) { |
|
35 | + return; |
|
36 | + } elseif (!isset($_FILES)) { |
|
37 | + return; |
|
38 | + } elseif (isset($_FILES['attachment'])) { |
|
39 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
39 | 40 | if (!empty($dummy)) |
40 | 41 | { |
41 | 42 | $doit = true; |
43 | + } |
|
42 | 44 | break; |
43 | 45 | } |
44 | 46 | |
45 | - if (!isset($doit)) |
|
46 | - return; |
|
47 | + if (!isset($doit)) { |
|
48 | + return; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $year = date('Y'); |
49 | 52 | $month = date('m'); |
@@ -54,21 +57,25 @@ discard block |
||
54 | 57 | |
55 | 58 | if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments'])) |
56 | 59 | { |
57 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
58 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
60 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
61 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
62 | + } |
|
59 | 63 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
64 | + } else { |
|
65 | + $base_dir = 0; |
|
60 | 66 | } |
61 | - else |
|
62 | - $base_dir = 0; |
|
63 | 67 | |
64 | 68 | if ($modSettings['automanage_attachments'] == 1) |
65 | 69 | { |
66 | - if (!isset($modSettings['last_attachments_directory'])) |
|
67 | - $modSettings['last_attachments_directory'] = array(); |
|
68 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
69 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
70 | - if (!isset($modSettings['last_attachments_directory'][$base_dir])) |
|
71 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
70 | + if (!isset($modSettings['last_attachments_directory'])) { |
|
71 | + $modSettings['last_attachments_directory'] = array(); |
|
72 | + } |
|
73 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
74 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
75 | + } |
|
76 | + if (!isset($modSettings['last_attachments_directory'][$base_dir])) { |
|
77 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
78 | + } |
|
72 | 79 | } |
73 | 80 | |
74 | 81 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
@@ -97,12 +104,14 @@ discard block |
||
97 | 104 | $updir = ''; |
98 | 105 | } |
99 | 106 | |
100 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
101 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
102 | - if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) |
|
103 | - $outputCreation = automanage_attachments_create_directory($updir); |
|
104 | - elseif (in_array($updir, $modSettings['attachmentUploadDir'])) |
|
105 | - $outputCreation = true; |
|
107 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
108 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
109 | + } |
|
110 | + if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) { |
|
111 | + $outputCreation = automanage_attachments_create_directory($updir); |
|
112 | + } elseif (in_array($updir, $modSettings['attachmentUploadDir'])) { |
|
113 | + $outputCreation = true; |
|
114 | + } |
|
106 | 115 | |
107 | 116 | if ($outputCreation) |
108 | 117 | { |
@@ -139,8 +148,9 @@ discard block |
||
139 | 148 | $count = count($tree); |
140 | 149 | |
141 | 150 | $directory = attachments_init_dir($tree, $count); |
142 | - if ($directory === false) |
|
143 | - return false; |
|
151 | + if ($directory === false) { |
|
152 | + return false; |
|
153 | + } |
|
144 | 154 | } |
145 | 155 | |
146 | 156 | $directory .= DIRECTORY_SEPARATOR . array_shift($tree); |
@@ -168,8 +178,9 @@ discard block |
||
168 | 178 | } |
169 | 179 | |
170 | 180 | // Everything seems fine...let's create the .htaccess |
171 | - if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) |
|
172 | - secureDirectory($updir, true); |
|
181 | + if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) { |
|
182 | + secureDirectory($updir, true); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | $sep = (DIRECTORY_SEPARATOR === '\\') ? '\/' : DIRECTORY_SEPARATOR; |
175 | 186 | $updir = rtrim($updir, $sep); |
@@ -201,8 +212,9 @@ discard block |
||
201 | 212 | { |
202 | 213 | global $smcFunc, $modSettings, $boarddir; |
203 | 214 | |
204 | - if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) |
|
205 | - return; |
|
215 | + if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) { |
|
216 | + return; |
|
217 | + } |
|
206 | 218 | |
207 | 219 | $basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir; |
208 | 220 | // Just to be sure: I don't want directory separators at the end |
@@ -214,13 +226,14 @@ discard block |
||
214 | 226 | { |
215 | 227 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
216 | 228 | $base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0; |
229 | + } else { |
|
230 | + $base_dir = 0; |
|
217 | 231 | } |
218 | - else |
|
219 | - $base_dir = 0; |
|
220 | 232 | |
221 | 233 | // Get the last attachment directory for that base directory |
222 | - if (empty($modSettings['last_attachments_directory'][$base_dir])) |
|
223 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
234 | + if (empty($modSettings['last_attachments_directory'][$base_dir])) { |
|
235 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
236 | + } |
|
224 | 237 | // And increment it. |
225 | 238 | $modSettings['last_attachments_directory'][$base_dir]++; |
226 | 239 | |
@@ -235,10 +248,10 @@ discard block |
||
235 | 248 | $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
236 | 249 | |
237 | 250 | return true; |
251 | + } else { |
|
252 | + return false; |
|
253 | + } |
|
238 | 254 | } |
239 | - else |
|
240 | - return false; |
|
241 | -} |
|
242 | 255 | |
243 | 256 | /** |
244 | 257 | * Split a path into a list of all directories and subdirectories |
@@ -256,12 +269,13 @@ discard block |
||
256 | 269 | * in Windows we need to explode for both \ and / |
257 | 270 | * while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR) |
258 | 271 | */ |
259 | - if (DIRECTORY_SEPARATOR === '\\') |
|
260 | - $tree = preg_split('#[\\\/]#', $directory); |
|
261 | - else |
|
272 | + if (DIRECTORY_SEPARATOR === '\\') { |
|
273 | + $tree = preg_split('#[\\\/]#', $directory); |
|
274 | + } else |
|
262 | 275 | { |
263 | - if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
|
264 | - return false; |
|
276 | + if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) { |
|
277 | + return false; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | $tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR)); |
267 | 281 | } |
@@ -285,10 +299,11 @@ discard block |
||
285 | 299 | //Better be sure that the first part of the path is actually a drive letter... |
286 | 300 | //...even if, I should check this in the admin page...isn't it? |
287 | 301 | //...NHAAA Let's leave space for users' complains! :P |
288 | - if (preg_match('/^[a-z]:$/i', $tree[0])) |
|
289 | - $directory = array_shift($tree); |
|
290 | - else |
|
291 | - return false; |
|
302 | + if (preg_match('/^[a-z]:$/i', $tree[0])) { |
|
303 | + $directory = array_shift($tree); |
|
304 | + } else { |
|
305 | + return false; |
|
306 | + } |
|
292 | 307 | |
293 | 308 | $count--; |
294 | 309 | } |
@@ -303,18 +318,20 @@ discard block |
||
303 | 318 | global $context, $modSettings, $smcFunc, $txt, $user_info; |
304 | 319 | |
305 | 320 | // Make sure we're uploading to the right place. |
306 | - if (!empty($modSettings['automanage_attachments'])) |
|
307 | - automanage_attachments_check_directory(); |
|
321 | + if (!empty($modSettings['automanage_attachments'])) { |
|
322 | + automanage_attachments_check_directory(); |
|
323 | + } |
|
308 | 324 | |
309 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
310 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
325 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
326 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
327 | + } |
|
311 | 328 | |
312 | 329 | $context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
313 | 330 | |
314 | 331 | // Is the attachments folder actualy there? |
315 | - if (!empty($context['dir_creation_error'])) |
|
316 | - $initial_error = $context['dir_creation_error']; |
|
317 | - elseif (!is_dir($context['attach_dir'])) |
|
332 | + if (!empty($context['dir_creation_error'])) { |
|
333 | + $initial_error = $context['dir_creation_error']; |
|
334 | + } elseif (!is_dir($context['attach_dir'])) |
|
318 | 335 | { |
319 | 336 | $initial_error = 'attach_folder_warning'; |
320 | 337 | log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical'); |
@@ -337,12 +354,12 @@ discard block |
||
337 | 354 | ); |
338 | 355 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
339 | 356 | $smcFunc['db_free_result']($request); |
340 | - } |
|
341 | - else |
|
342 | - $context['attachments'] = array( |
|
357 | + } else { |
|
358 | + $context['attachments'] = array( |
|
343 | 359 | 'quantity' => 0, |
344 | 360 | 'total_size' => 0, |
345 | 361 | ); |
362 | + } |
|
346 | 363 | } |
347 | 364 | |
348 | 365 | // Hmm. There are still files in session. |
@@ -352,39 +369,44 @@ discard block |
||
352 | 369 | // Let's try to keep them. But... |
353 | 370 | $ignore_temp = true; |
354 | 371 | // If new files are being added. We can't ignore those |
355 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
356 | - if (!empty($dummy)) |
|
372 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) { |
|
373 | + if (!empty($dummy)) |
|
357 | 374 | { |
358 | 375 | $ignore_temp = false; |
376 | + } |
|
359 | 377 | break; |
360 | 378 | } |
361 | 379 | |
362 | 380 | // Need to make space for the new files. So, bye bye. |
363 | 381 | if (!$ignore_temp) |
364 | 382 | { |
365 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
366 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
383 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
384 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
367 | 385 | unlink($attachment['tmp_name']); |
386 | + } |
|
368 | 387 | |
369 | 388 | $context['we_are_history'] = $txt['error_temp_attachments_flushed']; |
370 | 389 | $_SESSION['temp_attachments'] = array(); |
371 | 390 | } |
372 | 391 | } |
373 | 392 | |
374 | - if (!isset($_FILES['attachment']['name'])) |
|
375 | - $_FILES['attachment']['tmp_name'] = array(); |
|
393 | + if (!isset($_FILES['attachment']['name'])) { |
|
394 | + $_FILES['attachment']['tmp_name'] = array(); |
|
395 | + } |
|
376 | 396 | |
377 | - if (!isset($_SESSION['temp_attachments'])) |
|
378 | - $_SESSION['temp_attachments'] = array(); |
|
397 | + if (!isset($_SESSION['temp_attachments'])) { |
|
398 | + $_SESSION['temp_attachments'] = array(); |
|
399 | + } |
|
379 | 400 | |
380 | 401 | // Remember where we are at. If it's anywhere at all. |
381 | - if (!$ignore_temp) |
|
382 | - $_SESSION['temp_attachments']['post'] = array( |
|
402 | + if (!$ignore_temp) { |
|
403 | + $_SESSION['temp_attachments']['post'] = array( |
|
383 | 404 | 'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0, |
384 | 405 | 'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0, |
385 | 406 | 'topic' => !empty($topic) ? $topic : 0, |
386 | 407 | 'board' => !empty($board) ? $board : 0, |
387 | 408 | ); |
409 | + } |
|
388 | 410 | |
389 | 411 | // If we have an initial error, lets just display it. |
390 | 412 | if (!empty($initial_error)) |
@@ -392,9 +414,10 @@ discard block |
||
392 | 414 | $_SESSION['temp_attachments']['initial_error'] = $initial_error; |
393 | 415 | |
394 | 416 | // And delete the files 'cos they ain't going nowhere. |
395 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
396 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
417 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
418 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
397 | 419 | unlink($_FILES['attachment']['tmp_name'][$n]); |
420 | + } |
|
398 | 421 | |
399 | 422 | $_FILES['attachment']['tmp_name'] = array(); |
400 | 423 | } |
@@ -402,21 +425,24 @@ discard block |
||
402 | 425 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
403 | 426 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
404 | 427 | { |
405 | - if ($_FILES['attachment']['name'][$n] == '') |
|
406 | - continue; |
|
428 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
429 | + continue; |
|
430 | + } |
|
407 | 431 | |
408 | 432 | // First, let's first check for PHP upload errors. |
409 | 433 | $errors = array(); |
410 | 434 | if (!empty($_FILES['attachment']['error'][$n])) |
411 | 435 | { |
412 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
413 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
414 | - elseif ($_FILES['attachment']['error'][$n] == 6) |
|
415 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
416 | - else |
|
417 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
418 | - if (empty($errors)) |
|
419 | - $errors[] = 'attach_php_error'; |
|
436 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
437 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
438 | + } elseif ($_FILES['attachment']['error'][$n] == 6) { |
|
439 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
440 | + } else { |
|
441 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
442 | + } |
|
443 | + if (empty($errors)) { |
|
444 | + $errors[] = 'attach_php_error'; |
|
445 | + } |
|
420 | 446 | } |
421 | 447 | |
422 | 448 | // Try to move and rename the file before doing any more checks on it. |
@@ -426,8 +452,9 @@ discard block |
||
426 | 452 | { |
427 | 453 | // The reported MIME type of the attachment might not be reliable. |
428 | 454 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
429 | - if (function_exists('mime_content_type')) |
|
430 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
455 | + if (function_exists('mime_content_type')) { |
|
456 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
457 | + } |
|
431 | 458 | |
432 | 459 | $_SESSION['temp_attachments'][$attachID] = array( |
433 | 460 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -439,16 +466,16 @@ discard block |
||
439 | 466 | ); |
440 | 467 | |
441 | 468 | // Move the file to the attachments folder with a temp name for now. |
442 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
443 | - smf_chmod($destName, 0644); |
|
444 | - else |
|
469 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
470 | + smf_chmod($destName, 0644); |
|
471 | + } else |
|
445 | 472 | { |
446 | 473 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
447 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
448 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
474 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
475 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
476 | + } |
|
449 | 477 | } |
450 | - } |
|
451 | - else |
|
478 | + } else |
|
452 | 479 | { |
453 | 480 | $_SESSION['temp_attachments'][$attachID] = array( |
454 | 481 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -456,12 +483,14 @@ discard block |
||
456 | 483 | 'errors' => $errors, |
457 | 484 | ); |
458 | 485 | |
459 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
460 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
486 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
487 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
488 | + } |
|
461 | 489 | } |
462 | 490 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
463 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
464 | - attachmentChecks($attachID); |
|
491 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
492 | + attachmentChecks($attachID); |
|
493 | + } |
|
465 | 494 | } |
466 | 495 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
467 | 496 | // Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand()) |
@@ -488,21 +517,20 @@ discard block |
||
488 | 517 | global $modSettings, $context, $sourcedir, $smcFunc; |
489 | 518 | |
490 | 519 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
491 | - if (empty($_SESSION['temp_attachments'][$attachID])) |
|
492 | - $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
493 | - |
|
494 | - elseif (empty($attachID)) |
|
495 | - $error = '$attachID'; |
|
496 | - |
|
497 | - elseif (empty($context['attachments'])) |
|
498 | - $error = '$context[\'attachments\']'; |
|
499 | - |
|
500 | - elseif (empty($context['attach_dir'])) |
|
501 | - $error = '$context[\'attach_dir\']'; |
|
520 | + if (empty($_SESSION['temp_attachments'][$attachID])) { |
|
521 | + $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
522 | + } elseif (empty($attachID)) { |
|
523 | + $error = '$attachID'; |
|
524 | + } elseif (empty($context['attachments'])) { |
|
525 | + $error = '$context[\'attachments\']'; |
|
526 | + } elseif (empty($context['attach_dir'])) { |
|
527 | + $error = '$context[\'attach_dir\']'; |
|
528 | + } |
|
502 | 529 | |
503 | 530 | // Let's get their attention. |
504 | - if (!empty($error)) |
|
505 | - fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
531 | + if (!empty($error)) { |
|
532 | + fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
533 | + } |
|
506 | 534 | |
507 | 535 | // Just in case this slipped by the first checks, we stop it here and now |
508 | 536 | if ($_SESSION['temp_attachments'][$attachID]['size'] == 0) |
@@ -531,8 +559,9 @@ discard block |
||
531 | 559 | $size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']); |
532 | 560 | if (!(empty($size)) && ($size[2] != $old_format)) |
533 | 561 | { |
534 | - if (isset($context['valid_image_types'][$size[2]])) |
|
535 | - $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
562 | + if (isset($context['valid_image_types'][$size[2]])) { |
|
563 | + $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
564 | + } |
|
536 | 565 | } |
537 | 566 | } |
538 | 567 | } |
@@ -586,42 +615,48 @@ discard block |
||
586 | 615 | // Or, let the user know that it ain't gonna happen. |
587 | 616 | else |
588 | 617 | { |
589 | - if (isset($context['dir_creation_error'])) |
|
590 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
591 | - else |
|
592 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
618 | + if (isset($context['dir_creation_error'])) { |
|
619 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
620 | + } else { |
|
621 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
622 | + } |
|
593 | 623 | } |
624 | + } else { |
|
625 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
594 | 626 | } |
595 | - else |
|
596 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
597 | 627 | } |
598 | 628 | } |
599 | 629 | |
600 | 630 | // Is the file too big? |
601 | 631 | $context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size']; |
602 | - if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) |
|
603 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
632 | + if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) { |
|
633 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
634 | + } |
|
604 | 635 | |
605 | 636 | // Check the total upload size for this post... |
606 | - if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) |
|
607 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
637 | + if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) { |
|
638 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
639 | + } |
|
608 | 640 | |
609 | 641 | // Have we reached the maximum number of files we are allowed? |
610 | 642 | $context['attachments']['quantity']++; |
611 | 643 | |
612 | 644 | // Set a max limit if none exists |
613 | - if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) |
|
614 | - $modSettings['attachmentNumPerPostLimit'] = 50; |
|
645 | + if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) { |
|
646 | + $modSettings['attachmentNumPerPostLimit'] = 50; |
|
647 | + } |
|
615 | 648 | |
616 | - if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) |
|
617 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
649 | + if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) { |
|
650 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
651 | + } |
|
618 | 652 | |
619 | 653 | // File extension check |
620 | 654 | if (!empty($modSettings['attachmentCheckExtensions'])) |
621 | 655 | { |
622 | 656 | $allowed = explode(',', strtolower($modSettings['attachmentExtensions'])); |
623 | - foreach ($allowed as $k => $dummy) |
|
624 | - $allowed[$k] = trim($dummy); |
|
657 | + foreach ($allowed as $k => $dummy) { |
|
658 | + $allowed[$k] = trim($dummy); |
|
659 | + } |
|
625 | 660 | |
626 | 661 | if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed)) |
627 | 662 | { |
@@ -633,10 +668,12 @@ discard block |
||
633 | 668 | // Undo the math if there's an error |
634 | 669 | if (!empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
635 | 670 | { |
636 | - if (isset($context['dir_size'])) |
|
637 | - $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
638 | - if (isset($context['dir_files'])) |
|
639 | - $context['dir_files']--; |
|
671 | + if (isset($context['dir_size'])) { |
|
672 | + $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
673 | + } |
|
674 | + if (isset($context['dir_files'])) { |
|
675 | + $context['dir_files']--; |
|
676 | + } |
|
640 | 677 | $context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
641 | 678 | $context['attachments']['quantity']--; |
642 | 679 | return false; |
@@ -668,12 +705,14 @@ discard block |
||
668 | 705 | if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width']) |
669 | 706 | { |
670 | 707 | // Got a proper mime type? |
671 | - if (!empty($size['mime'])) |
|
672 | - $attachmentOptions['mime_type'] = $size['mime']; |
|
708 | + if (!empty($size['mime'])) { |
|
709 | + $attachmentOptions['mime_type'] = $size['mime']; |
|
710 | + } |
|
673 | 711 | |
674 | 712 | // Otherwise a valid one? |
675 | - elseif (isset($context['valid_image_types'][$size[2]])) |
|
676 | - $attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
713 | + elseif (isset($context['valid_image_types'][$size[2]])) { |
|
714 | + $attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
715 | + } |
|
677 | 716 | } |
678 | 717 | |
679 | 718 | // It is possible we might have a MIME type that isn't actually an image but still have a size. |
@@ -685,15 +724,17 @@ discard block |
||
685 | 724 | } |
686 | 725 | |
687 | 726 | // Get the hash if no hash has been given yet. |
688 | - if (empty($attachmentOptions['file_hash'])) |
|
689 | - $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
727 | + if (empty($attachmentOptions['file_hash'])) { |
|
728 | + $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
729 | + } |
|
690 | 730 | |
691 | 731 | // Assuming no-one set the extension let's take a look at it. |
692 | 732 | if (empty($attachmentOptions['fileext'])) |
693 | 733 | { |
694 | 734 | $attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : ''); |
695 | - if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) |
|
696 | - $attachmentOptions['fileext'] = ''; |
|
735 | + if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) { |
|
736 | + $attachmentOptions['fileext'] = ''; |
|
737 | + } |
|
697 | 738 | } |
698 | 739 | |
699 | 740 | // Last chance to change stuff! |
@@ -702,8 +743,9 @@ discard block |
||
702 | 743 | // Make sure the folder is valid... |
703 | 744 | $tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
704 | 745 | $folders = array_keys($tmp); |
705 | - if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) |
|
706 | - $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
746 | + if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) { |
|
747 | + $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
748 | + } |
|
707 | 749 | |
708 | 750 | $attachmentOptions['id'] = $smcFunc['db_insert']('', |
709 | 751 | '{db_prefix}attachments', |
@@ -734,8 +776,8 @@ discard block |
||
734 | 776 | rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']); |
735 | 777 | |
736 | 778 | // If it's not approved then add to the approval queue. |
737 | - if (!$attachmentOptions['approved']) |
|
738 | - $smcFunc['db_insert']('', |
|
779 | + if (!$attachmentOptions['approved']) { |
|
780 | + $smcFunc['db_insert']('', |
|
739 | 781 | '{db_prefix}approval_queue', |
740 | 782 | array( |
741 | 783 | 'id_attach' => 'int', 'id_msg' => 'int', |
@@ -745,9 +787,11 @@ discard block |
||
745 | 787 | ), |
746 | 788 | array() |
747 | 789 | ); |
790 | + } |
|
748 | 791 | |
749 | - if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) |
|
750 | - return true; |
|
792 | + if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) { |
|
793 | + return true; |
|
794 | + } |
|
751 | 795 | |
752 | 796 | // Like thumbnails, do we? |
753 | 797 | if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight'])) |
@@ -758,13 +802,15 @@ discard block |
||
758 | 802 | $size = @getimagesize($attachmentOptions['destination'] . '_thumb'); |
759 | 803 | list ($thumb_width, $thumb_height) = $size; |
760 | 804 | |
761 | - if (!empty($size['mime'])) |
|
762 | - $thumb_mime = $size['mime']; |
|
763 | - elseif (isset($context['valid_image_types'][$size[2]])) |
|
764 | - $thumb_mime = 'image/' . $context['valid_image_types'][$size[2]]; |
|
805 | + if (!empty($size['mime'])) { |
|
806 | + $thumb_mime = $size['mime']; |
|
807 | + } elseif (isset($context['valid_image_types'][$size[2]])) { |
|
808 | + $thumb_mime = 'image/' . $context['valid_image_types'][$size[2]]; |
|
809 | + } |
|
765 | 810 | // Lord only knows how this happened... |
766 | - else |
|
767 | - $thumb_mime = ''; |
|
811 | + else { |
|
812 | + $thumb_mime = ''; |
|
813 | + } |
|
768 | 814 | |
769 | 815 | $thumb_filename = $attachmentOptions['name'] . '_thumb'; |
770 | 816 | $thumb_size = filesize($attachmentOptions['destination'] . '_thumb'); |
@@ -844,15 +890,17 @@ discard block |
||
844 | 890 | global $smcFunc; |
845 | 891 | |
846 | 892 | // Oh, come on! |
847 | - if (empty($attachIDs) || empty($msgID)) |
|
848 | - return false; |
|
893 | + if (empty($attachIDs) || empty($msgID)) { |
|
894 | + return false; |
|
895 | + } |
|
849 | 896 | |
850 | 897 | // "I see what is right and approve, but I do what is wrong." |
851 | 898 | call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID)); |
852 | 899 | |
853 | 900 | // One last check |
854 | - if (empty($attachIDs)) |
|
855 | - return false; |
|
901 | + if (empty($attachIDs)) { |
|
902 | + return false; |
|
903 | + } |
|
856 | 904 | |
857 | 905 | // Perform. |
858 | 906 | $smcFunc['db_query']('', ' |
@@ -880,8 +928,9 @@ discard block |
||
880 | 928 | global $board, $modSettings, $context, $scripturl, $smcFunc; |
881 | 929 | |
882 | 930 | // Meh... |
883 | - if (empty($attachID)) |
|
884 | - return 'attachments_no_data_loaded'; |
|
931 | + if (empty($attachID)) { |
|
932 | + return 'attachments_no_data_loaded'; |
|
933 | + } |
|
885 | 934 | |
886 | 935 | // Make it easy. |
887 | 936 | $msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0; |
@@ -890,20 +939,23 @@ discard block |
||
890 | 939 | $externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID)); |
891 | 940 | |
892 | 941 | // "I am innocent of the blood of this just person: see ye to it." |
893 | - if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) |
|
894 | - return $externalParse; |
|
942 | + if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) { |
|
943 | + return $externalParse; |
|
944 | + } |
|
895 | 945 | |
896 | 946 | //Are attachments enable? |
897 | - if (empty($modSettings['attachmentEnable'])) |
|
898 | - return 'attachments_not_enable'; |
|
947 | + if (empty($modSettings['attachmentEnable'])) { |
|
948 | + return 'attachments_not_enable'; |
|
949 | + } |
|
899 | 950 | |
900 | 951 | // Previewing much? no msg ID has been set yet. |
901 | 952 | if (!empty($context['preview_message'])) |
902 | 953 | { |
903 | 954 | $allAttachments = getAttachsByMsg(0); |
904 | 955 | |
905 | - if (empty($allAttachments[0][$attachID])) |
|
906 | - return 'attachments_no_data_loaded'; |
|
956 | + if (empty($allAttachments[0][$attachID])) { |
|
957 | + return 'attachments_no_data_loaded'; |
|
958 | + } |
|
907 | 959 | |
908 | 960 | $attachLoaded = loadAttachmentContext(0, $allAttachments); |
909 | 961 | |
@@ -915,57 +967,66 @@ discard block |
||
915 | 967 | $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
916 | 968 | |
917 | 969 | // Fix the thumbnail too, if the image has one. |
918 | - if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) |
|
919 | - $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
970 | + if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) { |
|
971 | + $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
972 | + } |
|
920 | 973 | |
921 | 974 | return $attachContext; |
922 | 975 | } |
923 | 976 | |
924 | 977 | // There is always the chance someone else has already done our dirty work... |
925 | 978 | // If so, all pertinent checks were already done. Hopefully... |
926 | - if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) |
|
927 | - return $context['current_attachments'][$attachID]; |
|
979 | + if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) { |
|
980 | + return $context['current_attachments'][$attachID]; |
|
981 | + } |
|
928 | 982 | |
929 | 983 | // If we are lucky enough to be in $board's scope then check it! |
930 | - if (!empty($board) && !allowedTo('view_attachments', $board)) |
|
931 | - return 'attachments_not_allowed_to_see'; |
|
984 | + if (!empty($board) && !allowedTo('view_attachments', $board)) { |
|
985 | + return 'attachments_not_allowed_to_see'; |
|
986 | + } |
|
932 | 987 | |
933 | 988 | // Get the message info associated with this particular attach ID. |
934 | 989 | $attachInfo = getAttachMsgInfo($attachID); |
935 | 990 | |
936 | 991 | // There is always the chance this attachment no longer exists or isn't associated to a message anymore... |
937 | - if (empty($attachInfo) || empty($attachInfo['msg'])) |
|
938 | - return 'attachments_no_msg_associated'; |
|
992 | + if (empty($attachInfo) || empty($attachInfo['msg'])) { |
|
993 | + return 'attachments_no_msg_associated'; |
|
994 | + } |
|
939 | 995 | |
940 | 996 | // Hold it! got the info now check if you can see this attachment. |
941 | - if (!allowedTo('view_attachments', $attachInfo['board'])) |
|
942 | - return 'attachments_not_allowed_to_see'; |
|
997 | + if (!allowedTo('view_attachments', $attachInfo['board'])) { |
|
998 | + return 'attachments_not_allowed_to_see'; |
|
999 | + } |
|
943 | 1000 | |
944 | 1001 | $allAttachments = getAttachsByMsg($attachInfo['msg']); |
945 | 1002 | $attachContext = $allAttachments[$attachInfo['msg']][$attachID]; |
946 | 1003 | |
947 | 1004 | // No point in keep going further. |
948 | - if (!allowedTo('view_attachments', $attachContext['board'])) |
|
949 | - return 'attachments_not_allowed_to_see'; |
|
1005 | + if (!allowedTo('view_attachments', $attachContext['board'])) { |
|
1006 | + return 'attachments_not_allowed_to_see'; |
|
1007 | + } |
|
950 | 1008 | |
951 | 1009 | // Load this particular attach's context. |
952 | - if (!empty($attachContext)) |
|
953 | - $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1010 | + if (!empty($attachContext)) { |
|
1011 | + $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1012 | + } |
|
954 | 1013 | |
955 | 1014 | // One last check, you know, gotta be paranoid... |
956 | - else |
|
957 | - return 'attachments_no_data_loaded'; |
|
1015 | + else { |
|
1016 | + return 'attachments_no_data_loaded'; |
|
1017 | + } |
|
958 | 1018 | |
959 | 1019 | // This is the last "if" I promise! |
960 | - if (empty($attachLoaded)) |
|
961 | - return 'attachments_no_data_loaded'; |
|
962 | - |
|
963 | - else |
|
964 | - $attachContext = $attachLoaded[$attachID]; |
|
1020 | + if (empty($attachLoaded)) { |
|
1021 | + return 'attachments_no_data_loaded'; |
|
1022 | + } else { |
|
1023 | + $attachContext = $attachLoaded[$attachID]; |
|
1024 | + } |
|
965 | 1025 | |
966 | 1026 | // You may or may not want to show this under the post. |
967 | - if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) |
|
968 | - $context['show_attach_under_post'][$attachID] = $attachID; |
|
1027 | + if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) { |
|
1028 | + $context['show_attach_under_post'][$attachID] = $attachID; |
|
1029 | + } |
|
969 | 1030 | |
970 | 1031 | // Last minute changes? |
971 | 1032 | call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext)); |
@@ -985,8 +1046,9 @@ discard block |
||
985 | 1046 | { |
986 | 1047 | global $smcFunc, $modSettings; |
987 | 1048 | |
988 | - if (empty($attachIDs)) |
|
989 | - return array(); |
|
1049 | + if (empty($attachIDs)) { |
|
1050 | + return array(); |
|
1051 | + } |
|
990 | 1052 | |
991 | 1053 | $return = array(); |
992 | 1054 | |
@@ -1002,11 +1064,12 @@ discard block |
||
1002 | 1064 | ) |
1003 | 1065 | ); |
1004 | 1066 | |
1005 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1006 | - return array(); |
|
1067 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1068 | + return array(); |
|
1069 | + } |
|
1007 | 1070 | |
1008 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1009 | - $return[$row['id_attach']] = array( |
|
1071 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1072 | + $return[$row['id_attach']] = array( |
|
1010 | 1073 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
1011 | 1074 | 'size' => $row['size'], |
1012 | 1075 | 'attachID' => $row['id_attach'], |
@@ -1015,6 +1078,7 @@ discard block |
||
1015 | 1078 | 'mime_type' => $row['mime_type'], |
1016 | 1079 | 'thumb' => $row['id_thumb'], |
1017 | 1080 | ); |
1081 | + } |
|
1018 | 1082 | $smcFunc['db_free_result']($request); |
1019 | 1083 | |
1020 | 1084 | return $return; |
@@ -1031,8 +1095,9 @@ discard block |
||
1031 | 1095 | { |
1032 | 1096 | global $smcFunc; |
1033 | 1097 | |
1034 | - if (empty($attachID)) |
|
1035 | - return array(); |
|
1098 | + if (empty($attachID)) { |
|
1099 | + return array(); |
|
1100 | + } |
|
1036 | 1101 | |
1037 | 1102 | $request = $smcFunc['db_query']('', ' |
1038 | 1103 | SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board |
@@ -1045,8 +1110,9 @@ discard block |
||
1045 | 1110 | ) |
1046 | 1111 | ); |
1047 | 1112 | |
1048 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1049 | - return array(); |
|
1113 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1114 | + return array(); |
|
1115 | + } |
|
1050 | 1116 | |
1051 | 1117 | $row = $smcFunc['db_fetch_assoc']($request); |
1052 | 1118 | $smcFunc['db_free_result']($request); |
@@ -1087,8 +1153,9 @@ discard block |
||
1087 | 1153 | $temp = array(); |
1088 | 1154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1089 | 1155 | { |
1090 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1091 | - continue; |
|
1156 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1157 | + continue; |
|
1158 | + } |
|
1092 | 1159 | |
1093 | 1160 | $temp[$row['id_attach']] = $row; |
1094 | 1161 | } |
@@ -1117,8 +1184,9 @@ discard block |
||
1117 | 1184 | { |
1118 | 1185 | global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc; |
1119 | 1186 | |
1120 | - if (empty($attachments) || empty($attachments[$id_msg])) |
|
1121 | - return array(); |
|
1187 | + if (empty($attachments) || empty($attachments[$id_msg])) { |
|
1188 | + return array(); |
|
1189 | + } |
|
1122 | 1190 | |
1123 | 1191 | // Set up the attachment info - based on code by Meriadoc. |
1124 | 1192 | $attachmentData = array(); |
@@ -1142,11 +1210,13 @@ discard block |
||
1142 | 1210 | ); |
1143 | 1211 | |
1144 | 1212 | // If something is unapproved we'll note it so we can sort them. |
1145 | - if (!$attachment['approved']) |
|
1146 | - $have_unapproved = true; |
|
1213 | + if (!$attachment['approved']) { |
|
1214 | + $have_unapproved = true; |
|
1215 | + } |
|
1147 | 1216 | |
1148 | - if (!$attachmentData[$i]['is_image']) |
|
1149 | - continue; |
|
1217 | + if (!$attachmentData[$i]['is_image']) { |
|
1218 | + continue; |
|
1219 | + } |
|
1150 | 1220 | |
1151 | 1221 | $attachmentData[$i]['real_width'] = $attachment['width']; |
1152 | 1222 | $attachmentData[$i]['width'] = $attachment['width']; |
@@ -1167,11 +1237,11 @@ discard block |
||
1167 | 1237 | // So what folder are we putting this image in? |
1168 | 1238 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1169 | 1239 | { |
1170 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1171 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1240 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1241 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1242 | + } |
|
1172 | 1243 | $id_folder_thumb = $modSettings['currentAttachmentUploadDir']; |
1173 | - } |
|
1174 | - else |
|
1244 | + } else |
|
1175 | 1245 | { |
1176 | 1246 | $id_folder_thumb = 1; |
1177 | 1247 | } |
@@ -1185,10 +1255,11 @@ discard block |
||
1185 | 1255 | $thumb_ext = isset($context['valid_image_types'][$size[2]]) ? $context['valid_image_types'][$size[2]] : ''; |
1186 | 1256 | |
1187 | 1257 | // Figure out the mime type. |
1188 | - if (!empty($size['mime'])) |
|
1189 | - $thumb_mime = $size['mime']; |
|
1190 | - else |
|
1191 | - $thumb_mime = 'image/' . $thumb_ext; |
|
1258 | + if (!empty($size['mime'])) { |
|
1259 | + $thumb_mime = $size['mime']; |
|
1260 | + } else { |
|
1261 | + $thumb_mime = 'image/' . $thumb_ext; |
|
1262 | + } |
|
1192 | 1263 | |
1193 | 1264 | $thumb_filename = $attachment['filename'] . '_thumb'; |
1194 | 1265 | $thumb_hash = getAttachmentFilename($thumb_filename, false, null, true); |
@@ -1236,11 +1307,12 @@ discard block |
||
1236 | 1307 | } |
1237 | 1308 | } |
1238 | 1309 | |
1239 | - if (!empty($attachment['id_thumb'])) |
|
1240 | - $attachmentData[$i]['thumbnail'] = array( |
|
1310 | + if (!empty($attachment['id_thumb'])) { |
|
1311 | + $attachmentData[$i]['thumbnail'] = array( |
|
1241 | 1312 | 'id' => $attachment['id_thumb'], |
1242 | 1313 | 'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image', |
1243 | 1314 | ); |
1315 | + } |
|
1244 | 1316 | $attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']); |
1245 | 1317 | |
1246 | 1318 | // If thumbnails are disabled, check the maximum size of the image. |
@@ -1250,30 +1322,31 @@ discard block |
||
1250 | 1322 | { |
1251 | 1323 | $attachmentData[$i]['width'] = $modSettings['max_image_width']; |
1252 | 1324 | $attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']); |
1253 | - } |
|
1254 | - elseif (!empty($modSettings['max_image_width'])) |
|
1325 | + } elseif (!empty($modSettings['max_image_width'])) |
|
1255 | 1326 | { |
1256 | 1327 | $attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']); |
1257 | 1328 | $attachmentData[$i]['height'] = $modSettings['max_image_height']; |
1258 | 1329 | } |
1259 | - } |
|
1260 | - elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1330 | + } elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1261 | 1331 | { |
1262 | 1332 | // If the image is too large to show inline, make it a popup. |
1263 | - if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) |
|
1264 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1265 | - else |
|
1266 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1333 | + if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) { |
|
1334 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1335 | + } else { |
|
1336 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1337 | + } |
|
1267 | 1338 | } |
1268 | 1339 | |
1269 | - if (!$attachmentData[$i]['thumbnail']['has_thumb']) |
|
1270 | - $attachmentData[$i]['downloads']++; |
|
1340 | + if (!$attachmentData[$i]['thumbnail']['has_thumb']) { |
|
1341 | + $attachmentData[$i]['downloads']++; |
|
1342 | + } |
|
1271 | 1343 | } |
1272 | 1344 | } |
1273 | 1345 | |
1274 | 1346 | // Do we need to instigate a sort? |
1275 | - if ($have_unapproved) |
|
1276 | - usort($attachmentData, 'approved_attach_sort'); |
|
1347 | + if ($have_unapproved) { |
|
1348 | + usort($attachmentData, 'approved_attach_sort'); |
|
1349 | + } |
|
1277 | 1350 | |
1278 | 1351 | return $attachmentData; |
1279 | 1352 | } |
@@ -51,9 +51,10 @@ discard block |
||
51 | 51 | <dd> |
52 | 52 | <div id="known_themes_list">'; |
53 | 53 | |
54 | - foreach ($context['themes'] as $theme) |
|
55 | - echo ' |
|
54 | + foreach ($context['themes'] as $theme) { |
|
55 | + echo ' |
|
56 | 56 | <label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>'; |
57 | + } |
|
57 | 58 | |
58 | 59 | echo ' |
59 | 60 | </div> |
@@ -70,9 +71,10 @@ discard block |
||
70 | 71 | <select name="options[theme_guests]" id="theme_guests">'; |
71 | 72 | |
72 | 73 | // Put an option for each theme in the select box. |
73 | - foreach ($context['themes'] as $theme) |
|
74 | - echo ' |
|
74 | + foreach ($context['themes'] as $theme) { |
|
75 | + echo ' |
|
75 | 76 | <option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
77 | + } |
|
76 | 78 | |
77 | 79 | echo ' |
78 | 80 | </select> |
@@ -87,9 +89,10 @@ discard block |
||
87 | 89 | <option value="0">', $txt['theme_forum_default'], '</option>'; |
88 | 90 | |
89 | 91 | // Same thing, this time for changing the theme of everyone. |
90 | - foreach ($context['themes'] as $theme) |
|
91 | - echo ' |
|
92 | + foreach ($context['themes'] as $theme) { |
|
93 | + echo ' |
|
92 | 94 | <option value="', $theme['id'], '">', $theme['name'], '</option>'; |
95 | + } |
|
93 | 96 | |
94 | 97 | echo ' |
95 | 98 | </select> |
@@ -183,11 +186,12 @@ discard block |
||
183 | 186 | global $context, $scripturl, $txt; |
184 | 187 | |
185 | 188 | // Show a nice confirmation message. |
186 | - if (isset($_GET['done'])) |
|
187 | - echo ' |
|
189 | + if (isset($_GET['done'])) { |
|
190 | + echo ' |
|
188 | 191 | <div class="infobox"> |
189 | 192 | ', $txt['theme_confirmed_' . $_GET['done']], ' |
190 | 193 | </div>'; |
194 | + } |
|
191 | 195 | |
192 | 196 | echo ' |
193 | 197 | <div class="cat_bar"> |
@@ -344,11 +348,12 @@ discard block |
||
344 | 348 | if (empty($setting) || !is_array($setting)) |
345 | 349 | { |
346 | 350 | // Insert a separator (unless this is the first item in the list) |
347 | - if ($i !== $first_option_key) |
|
348 | - echo ' |
|
351 | + if ($i !== $first_option_key) { |
|
352 | + echo ' |
|
349 | 353 | </dl> |
350 | 354 | <hr> |
351 | 355 | <dl class="settings">'; |
356 | + } |
|
352 | 357 | |
353 | 358 | // Should we give a name to this section? |
354 | 359 | if (is_string($setting) && !empty($setting)) |
@@ -357,9 +362,9 @@ discard block |
||
357 | 362 | echo ' |
358 | 363 | <dt><strong>' . $setting . '</strong></dt> |
359 | 364 | <dd></dd>'; |
365 | + } else { |
|
366 | + $titled_section = false; |
|
360 | 367 | } |
361 | - else |
|
362 | - $titled_section = false; |
|
363 | 368 | |
364 | 369 | continue; |
365 | 370 | } |
@@ -368,8 +373,8 @@ discard block |
||
368 | 373 | <dt>'; |
369 | 374 | |
370 | 375 | // Show the change option box? |
371 | - if ($context['theme_options_reset']) |
|
372 | - echo ' |
|
376 | + if ($context['theme_options_reset']) { |
|
377 | + echo ' |
|
373 | 378 | <span class="floatleft"> |
374 | 379 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;"> |
375 | 380 | <option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option> |
@@ -377,23 +382,26 @@ discard block |
||
377 | 382 | <option value="2">', $txt['themeadmin_reset_options_default'], '</option> |
378 | 383 | </select> |
379 | 384 | </span>'; |
385 | + } |
|
380 | 386 | |
381 | 387 | echo ' |
382 | 388 | <label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
383 | 389 | |
384 | - if (isset($setting['description'])) |
|
385 | - echo ' |
|
390 | + if (isset($setting['description'])) { |
|
391 | + echo ' |
|
386 | 392 | <br> |
387 | 393 | <span class="smalltext">', $setting['description'], '</span>'; |
394 | + } |
|
388 | 395 | echo ' |
389 | 396 | </dt>'; |
390 | 397 | |
391 | 398 | // Display checkbox options |
392 | - if ($setting['type'] == 'checkbox') |
|
393 | - echo ' |
|
399 | + if ($setting['type'] == 'checkbox') { |
|
400 | + echo ' |
|
394 | 401 | <dd> |
395 | 402 | <input type="hidden" name="' . (!empty($setting['default']) ? 'default_' : '') . 'options[' . $setting['id'] . ']" value="0"> |
396 | 403 | <input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', $context['theme_options_reset'] ? ' disabled' : '', ' value="1" class="floatleft">'; |
404 | + } |
|
397 | 405 | |
398 | 406 | // How about selection lists, we all love them |
399 | 407 | elseif ($setting['type'] == 'list') |
@@ -402,9 +410,10 @@ discard block |
||
402 | 410 | <dd> |
403 | 411 | <select class="floatleft" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', $context['theme_options_reset'] ? ' disabled' : '', '>'; |
404 | 412 | |
405 | - foreach ($setting['options'] as $value => $label) |
|
406 | - echo ' |
|
413 | + foreach ($setting['options'] as $value => $label) { |
|
414 | + echo ' |
|
407 | 415 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
416 | + } |
|
408 | 417 | |
409 | 418 | echo ' |
410 | 419 | </select>'; |
@@ -423,14 +432,13 @@ discard block |
||
423 | 432 | |
424 | 433 | echo ' |
425 | 434 | <input type="number"', $min . $max . $step; |
426 | - } |
|
427 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
428 | - echo' |
|
435 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
436 | + echo' |
|
429 | 437 | <input type="url"'; |
430 | - |
|
431 | - else |
|
432 | - echo ' |
|
438 | + } else { |
|
439 | + echo ' |
|
433 | 440 | <input type="text"'; |
441 | + } |
|
434 | 442 | |
435 | 443 | echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', $context['theme_options_reset'] ? ' disabled' : '', '>'; |
436 | 444 | } |
@@ -468,8 +476,8 @@ discard block |
||
468 | 476 | <div class="windowbg">'; |
469 | 477 | |
470 | 478 | // @todo Why can't I edit the default theme popup. |
471 | - if ($context['theme_settings']['theme_id'] != 1) |
|
472 | - echo ' |
|
479 | + if ($context['theme_settings']['theme_id'] != 1) { |
|
480 | + echo ' |
|
473 | 481 | <div class="title_bar"> |
474 | 482 | <h3 class="titlebg config_hd"> |
475 | 483 | ', $txt['theme_edit'], ' |
@@ -485,6 +493,7 @@ discard block |
||
485 | 493 | </li> |
486 | 494 | </ul> |
487 | 495 | </div>'; |
496 | + } |
|
488 | 497 | |
489 | 498 | echo ' |
490 | 499 | <div class="title_bar"> |
@@ -535,9 +544,10 @@ discard block |
||
535 | 544 | <dd> |
536 | 545 | <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">'; |
537 | 546 | |
538 | - foreach ($context['theme_variants'] as $key => $variant) |
|
539 | - echo ' |
|
547 | + foreach ($context['theme_variants'] as $key => $variant) { |
|
548 | + echo ' |
|
540 | 549 | <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
550 | + } |
|
541 | 551 | |
542 | 552 | echo ' |
543 | 553 | </select> |
@@ -571,11 +581,12 @@ discard block |
||
571 | 581 | if (empty($setting) || !is_array($setting)) |
572 | 582 | { |
573 | 583 | // We don't need a separator before the first list element |
574 | - if ($i !== $first_setting_key) |
|
575 | - echo ' |
|
584 | + if ($i !== $first_setting_key) { |
|
585 | + echo ' |
|
576 | 586 | </dl> |
577 | 587 | <hr> |
578 | 588 | <dl class="settings">'; |
589 | + } |
|
579 | 590 | |
580 | 591 | // Add a fake heading? |
581 | 592 | if (is_string($setting) && !empty($setting)) |
@@ -584,9 +595,9 @@ discard block |
||
584 | 595 | echo ' |
585 | 596 | <dt><strong>' . $setting . '</strong></dt> |
586 | 597 | <dd></dd>'; |
598 | + } else { |
|
599 | + $titled_section = false; |
|
587 | 600 | } |
588 | - else |
|
589 | - $titled_section = false; |
|
590 | 601 | |
591 | 602 | continue; |
592 | 603 | } |
@@ -595,20 +606,22 @@ discard block |
||
595 | 606 | <dt> |
596 | 607 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:'; |
597 | 608 | |
598 | - if (isset($setting['description'])) |
|
599 | - echo '<br> |
|
609 | + if (isset($setting['description'])) { |
|
610 | + echo '<br> |
|
600 | 611 | <span class="smalltext">', $setting['description'], '</span>'; |
612 | + } |
|
601 | 613 | |
602 | 614 | echo ' |
603 | 615 | </dt>'; |
604 | 616 | |
605 | 617 | // A checkbox? |
606 | - if ($setting['type'] == 'checkbox') |
|
607 | - echo ' |
|
618 | + if ($setting['type'] == 'checkbox') { |
|
619 | + echo ' |
|
608 | 620 | <dd> |
609 | 621 | <input type="hidden" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" value="0"> |
610 | 622 | <input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', ' value="1"> |
611 | 623 | </dd>'; |
624 | + } |
|
612 | 625 | |
613 | 626 | // A list with options? |
614 | 627 | elseif ($setting['type'] == 'list') |
@@ -617,9 +630,10 @@ discard block |
||
617 | 630 | <dd> |
618 | 631 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">'; |
619 | 632 | |
620 | - foreach ($setting['options'] as $value => $label) |
|
621 | - echo ' |
|
633 | + foreach ($setting['options'] as $value => $label) { |
|
634 | + echo ' |
|
622 | 635 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
636 | + } |
|
623 | 637 | |
624 | 638 | echo ' |
625 | 639 | </select> |
@@ -647,14 +661,13 @@ discard block |
||
647 | 661 | |
648 | 662 | echo ' |
649 | 663 | <input type="number"', $min . $max . $step; |
650 | - } |
|
651 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
652 | - echo' |
|
664 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
665 | + echo' |
|
653 | 666 | <input type="url"'; |
654 | - |
|
655 | - else |
|
656 | - echo ' |
|
667 | + } else { |
|
668 | + echo ' |
|
657 | 669 | <input type="text"'; |
670 | + } |
|
658 | 671 | |
659 | 672 | echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : (empty($setting['size']) ? ' size="40"' : ' size="' . $setting['size'] . '"'), '> |
660 | 673 | </dd>'; |
@@ -726,9 +739,10 @@ discard block |
||
726 | 739 | <label for="variant', $theme['id'], '"><strong>', $theme['pick_label'], '</strong></label>: |
727 | 740 | <select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant', $theme['id'], '(this.value);">'; |
728 | 741 | |
729 | - foreach ($theme['variants'] as $key => $variant) |
|
730 | - echo ' |
|
742 | + foreach ($theme['variants'] as $key => $variant) { |
|
743 | + echo ' |
|
731 | 744 | <option value="', $key, '"', $theme['selected_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
745 | + } |
|
732 | 746 | |
733 | 747 | echo ' |
734 | 748 | </select> |
@@ -805,21 +819,23 @@ discard block |
||
805 | 819 | <div class="windowbg">'; |
806 | 820 | |
807 | 821 | // Oops! there was an error :( |
808 | - if (!empty($context['error_message'])) |
|
809 | - echo ' |
|
822 | + if (!empty($context['error_message'])) { |
|
823 | + echo ' |
|
810 | 824 | <p> |
811 | 825 | ', $context['error_message'], ' |
812 | 826 | </p>'; |
827 | + } |
|
813 | 828 | |
814 | 829 | // Not much to show except a link back... |
815 | - else |
|
816 | - echo ' |
|
830 | + else { |
|
831 | + echo ' |
|
817 | 832 | <p> |
818 | 833 | <a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], ' |
819 | 834 | </p> |
820 | 835 | <p> |
821 | 836 | <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a> |
822 | 837 | </p>'; |
838 | + } |
|
823 | 839 | |
824 | 840 | echo ' |
825 | 841 | </div><!-- .windowbg -->'; |
@@ -884,11 +900,12 @@ discard block |
||
884 | 900 | <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span> |
885 | 901 | <span class="floatright">'; |
886 | 902 | |
887 | - if ($template['can_copy']) |
|
888 | - echo ' |
|
903 | + if ($template['can_copy']) { |
|
904 | + echo ' |
|
889 | 905 | <a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
890 | - else |
|
891 | - echo $txt['themeadmin_edit_no_copy']; |
|
906 | + } else { |
|
907 | + echo $txt['themeadmin_edit_no_copy']; |
|
908 | + } |
|
892 | 909 | |
893 | 910 | echo ' |
894 | 911 | </span> |
@@ -907,11 +924,12 @@ discard block |
||
907 | 924 | { |
908 | 925 | global $context, $txt; |
909 | 926 | |
910 | - if (!empty($context['browse_title'])) |
|
911 | - echo ' |
|
927 | + if (!empty($context['browse_title'])) { |
|
928 | + echo ' |
|
912 | 929 | <div class="cat_bar"> |
913 | 930 | <h3 class="catbg">', $context['browse_title'], '</h3> |
914 | 931 | </div>'; |
932 | + } |
|
915 | 933 | |
916 | 934 | echo ' |
917 | 935 | <table class="table_grid tborder"> |
@@ -930,16 +948,15 @@ discard block |
||
930 | 948 | <tr class="windowbg"> |
931 | 949 | <td>'; |
932 | 950 | |
933 | - if ($file['is_editable']) |
|
934 | - echo ' |
|
951 | + if ($file['is_editable']) { |
|
952 | + echo ' |
|
935 | 953 | <a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
936 | - |
|
937 | - elseif ($file['is_directory']) |
|
938 | - echo ' |
|
954 | + } elseif ($file['is_directory']) { |
|
955 | + echo ' |
|
939 | 956 | <a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
940 | - |
|
941 | - else |
|
942 | - echo $file['filename']; |
|
957 | + } else { |
|
958 | + echo $file['filename']; |
|
959 | + } |
|
943 | 960 | |
944 | 961 | echo ' |
945 | 962 | </td> |
@@ -960,11 +977,12 @@ discard block |
||
960 | 977 | { |
961 | 978 | global $context, $settings, $scripturl, $txt; |
962 | 979 | |
963 | - if ($context['session_error']) |
|
964 | - echo ' |
|
980 | + if ($context['session_error']) { |
|
981 | + echo ' |
|
965 | 982 | <div class="errorbox"> |
966 | 983 | ', $txt['error_session_timeout'], ' |
967 | 984 | </div>'; |
985 | + } |
|
968 | 986 | |
969 | 987 | // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com. |
970 | 988 | echo ' |
@@ -1027,17 +1045,18 @@ discard block |
||
1027 | 1045 | { |
1028 | 1046 | '; |
1029 | 1047 | |
1030 | - if (isBrowser('is_ie')) |
|
1031 | - echo ' |
|
1048 | + if (isBrowser('is_ie')) { |
|
1049 | + echo ' |
|
1032 | 1050 | var sheets = frames["css_preview_box"].document.styleSheets; |
1033 | 1051 | for (var j = 0; j < sheets.length; j++) |
1034 | 1052 | { |
1035 | 1053 | if (sheets[j].id == "css_preview_box") |
1036 | 1054 | sheets[j].cssText = document.forms.stylesheetForm.entire_file.value; |
1037 | 1055 | }'; |
1038 | - else |
|
1039 | - echo ' |
|
1056 | + } else { |
|
1057 | + echo ' |
|
1040 | 1058 | setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);'; |
1059 | + } |
|
1041 | 1060 | echo ' |
1042 | 1061 | } |
1043 | 1062 | catch (e) |
@@ -1089,9 +1108,10 @@ discard block |
||
1089 | 1108 | </div> |
1090 | 1109 | <div class="windowbg">'; |
1091 | 1110 | |
1092 | - if (!$context['allow_save']) |
|
1093 | - echo ' |
|
1111 | + if (!$context['allow_save']) { |
|
1112 | + echo ' |
|
1094 | 1113 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1114 | + } |
|
1095 | 1115 | |
1096 | 1116 | echo ' |
1097 | 1117 | <textarea class="edit_file" name="entire_file" cols="80" rows="20" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea> |
@@ -1105,9 +1125,10 @@ discard block |
||
1105 | 1125 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1106 | 1126 | |
1107 | 1127 | // Hopefully it exists. |
1108 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1109 | - echo ' |
|
1128 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1129 | + echo ' |
|
1110 | 1130 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1131 | + } |
|
1111 | 1132 | |
1112 | 1133 | echo ' |
1113 | 1134 | </form>'; |
@@ -1120,18 +1141,20 @@ discard block |
||
1120 | 1141 | { |
1121 | 1142 | global $context, $scripturl, $txt; |
1122 | 1143 | |
1123 | - if ($context['session_error']) |
|
1124 | - echo ' |
|
1144 | + if ($context['session_error']) { |
|
1145 | + echo ' |
|
1125 | 1146 | <div class="errorbox"> |
1126 | 1147 | ', $txt['error_session_timeout'], ' |
1127 | 1148 | </div>'; |
1149 | + } |
|
1128 | 1150 | |
1129 | - if (isset($context['parse_error'])) |
|
1130 | - echo ' |
|
1151 | + if (isset($context['parse_error'])) { |
|
1152 | + echo ' |
|
1131 | 1153 | <div class="errorbox"> |
1132 | 1154 | ', $txt['themeadmin_edit_error'], ' |
1133 | 1155 | <div><pre>', $context['parse_error'], '</pre></div> |
1134 | 1156 | </div>'; |
1157 | + } |
|
1135 | 1158 | |
1136 | 1159 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1137 | 1160 | echo ' |
@@ -1141,16 +1164,18 @@ discard block |
||
1141 | 1164 | </div> |
1142 | 1165 | <div class="windowbg">'; |
1143 | 1166 | |
1144 | - if (!$context['allow_save']) |
|
1145 | - echo ' |
|
1167 | + if (!$context['allow_save']) { |
|
1168 | + echo ' |
|
1146 | 1169 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1170 | + } |
|
1147 | 1171 | |
1148 | - foreach ($context['file_parts'] as $part) |
|
1149 | - echo ' |
|
1172 | + foreach ($context['file_parts'] as $part) { |
|
1173 | + echo ' |
|
1150 | 1174 | <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br> |
1151 | 1175 | <div class="centertext"> |
1152 | 1176 | <textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea> |
1153 | 1177 | </div>'; |
1178 | + } |
|
1154 | 1179 | |
1155 | 1180 | echo ' |
1156 | 1181 | <div class="padding righttext"> |
@@ -1159,9 +1184,10 @@ discard block |
||
1159 | 1184 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1160 | 1185 | |
1161 | 1186 | // Hopefully it exists. |
1162 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1163 | - echo ' |
|
1187 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1188 | + echo ' |
|
1164 | 1189 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1190 | + } |
|
1165 | 1191 | |
1166 | 1192 | echo ' |
1167 | 1193 | </div><!-- .righttext --> |
@@ -1176,18 +1202,20 @@ discard block |
||
1176 | 1202 | { |
1177 | 1203 | global $context, $scripturl, $txt; |
1178 | 1204 | |
1179 | - if ($context['session_error']) |
|
1180 | - echo ' |
|
1205 | + if ($context['session_error']) { |
|
1206 | + echo ' |
|
1181 | 1207 | <div class="errorbox"> |
1182 | 1208 | ', $txt['error_session_timeout'], ' |
1183 | 1209 | </div>'; |
1210 | + } |
|
1184 | 1211 | |
1185 | 1212 | // Is this file writeable? |
1186 | - if (!$context['allow_save']) |
|
1187 | - echo ' |
|
1213 | + if (!$context['allow_save']) { |
|
1214 | + echo ' |
|
1188 | 1215 | <div class="errorbox"> |
1189 | 1216 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], ' |
1190 | 1217 | </div>'; |
1218 | + } |
|
1191 | 1219 | |
1192 | 1220 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1193 | 1221 | echo ' |
@@ -1202,9 +1230,10 @@ discard block |
||
1202 | 1230 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1203 | 1231 | |
1204 | 1232 | // Hopefully it exists. |
1205 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1206 | - echo ' |
|
1233 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1234 | + echo ' |
|
1207 | 1235 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1236 | + } |
|
1208 | 1237 | |
1209 | 1238 | echo ' |
1210 | 1239 | </div><!-- .windowbg --> |