@@ -42,42 +42,42 @@ discard block |
||
42 | 42 | |
43 | 43 | // You can filter by any of the following columns: |
44 | 44 | $filters = array( |
45 | - 'id_member' => array ( |
|
45 | + 'id_member' => array( |
|
46 | 46 | 'txt' => $txt['username'], |
47 | 47 | 'operator' => '=', |
48 | 48 | 'datatype' => 'int', |
49 | 49 | ), |
50 | - 'ip' => array ( |
|
50 | + 'ip' => array( |
|
51 | 51 | 'txt' => $txt['ip_address'], |
52 | 52 | 'operator' => '=', |
53 | 53 | 'datatype' => 'inet', |
54 | 54 | ), |
55 | - 'session' => array ( |
|
55 | + 'session' => array( |
|
56 | 56 | 'txt' => $txt['session'], |
57 | 57 | 'operator' => 'LIKE', |
58 | 58 | 'datatype' => 'string', |
59 | 59 | ), |
60 | - 'url' => array ( |
|
60 | + 'url' => array( |
|
61 | 61 | 'txt' => $txt['error_url'], |
62 | 62 | 'operator' => 'LIKE', |
63 | 63 | 'datatype' => 'string', |
64 | 64 | ), |
65 | - 'message' => array ( |
|
65 | + 'message' => array( |
|
66 | 66 | 'txt' => $txt['error_message'], |
67 | 67 | 'operator' => 'LIKE', |
68 | 68 | 'datatype' => 'string', |
69 | 69 | ), |
70 | - 'error_type' => array ( |
|
70 | + 'error_type' => array( |
|
71 | 71 | 'txt' => $txt['error_type'], |
72 | 72 | 'operator' => 'LIKE', |
73 | 73 | 'datatype' => 'string', |
74 | 74 | ), |
75 | - 'file' => array ( |
|
75 | + 'file' => array( |
|
76 | 76 | 'txt' => $txt['file'], |
77 | 77 | 'operator' => 'LIKE', |
78 | 78 | 'datatype' => 'string', |
79 | 79 | ), |
80 | - 'line' => array ( |
|
80 | + 'line' => array( |
|
81 | 81 | 'txt' => $txt['line'], |
82 | 82 | 'operator' => '=', |
83 | 83 | 'datatype' => 'int', |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $result = $smcFunc['db_query']('', ' |
104 | 104 | SELECT COUNT(*) |
105 | 105 | FROM {db_prefix}log_errors' . (isset($filter) ? ' |
106 | - WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : ''), |
|
106 | + WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : ''), |
|
107 | 107 | array( |
108 | 108 | 'filter' => isset($filter) ? $filter['value']['sql'] : '', |
109 | 109 | ) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $request = $smcFunc['db_query']('', ' |
147 | 147 | SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line |
148 | 148 | FROM {db_prefix}log_errors' . (isset($filter) ? ' |
149 | - WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : '') . ' |
|
149 | + WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : '') . ' |
|
150 | 150 | ORDER BY id_error ' . ($context['sort_direction'] == 'down' ? 'DESC' : '') . ' |
151 | 151 | LIMIT {int:start}, {int:max}', |
152 | 152 | array( |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $context['errors'] = array(); |
159 | 159 | $members = array(); |
160 | 160 | |
161 | - for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
|
161 | + for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
|
162 | 162 | { |
163 | 163 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | 164 | if ($search_message == $filter['value']['sql']) |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'id' => $row['id_error'], |
185 | 185 | 'error_type' => array( |
186 | 186 | 'type' => $row['error_type'], |
187 | - 'name' => isset($txt['errortype_'.$row['error_type']]) ? $txt['errortype_'.$row['error_type']] : $row['error_type'], |
|
187 | + 'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type'], |
|
188 | 188 | ), |
189 | 189 | 'file' => array(), |
190 | 190 | ); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | // We don't want to slice off too many so lets make sure we stop at the last one |
413 | 413 | $max = min($max, max(array_keys($file_data))); |
414 | 414 | |
415 | - $file_data = array_slice($file_data, $min-1, $max - $min); |
|
415 | + $file_data = array_slice($file_data, $min - 1, $max - $min); |
|
416 | 416 | |
417 | 417 | $context['file_data'] = array( |
418 | 418 | 'contents' => $file_data, |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Check for the administrative permission to do this. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
85 | 87 | ); |
86 | 88 | |
87 | 89 | // Set up the filtering... |
88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
89 | - $filter = array( |
|
90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
91 | + $filter = array( |
|
90 | 92 | 'variable' => $_GET['filter'], |
91 | 93 | 'value' => array( |
92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
96 | 98 | ); |
99 | + } |
|
97 | 100 | |
98 | 101 | // Deleting, are we? |
99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
100 | - deleteErrors(); |
|
102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
103 | + deleteErrors(); |
|
104 | + } |
|
101 | 105 | |
102 | 106 | // Just how many errors are there? |
103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
112 | 116 | $smcFunc['db_free_result']($result); |
113 | 117 | |
114 | 118 | // If this filter is empty... |
115 | - if ($num_errors == 0 && isset($filter)) |
|
116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
119 | + if ($num_errors == 0 && isset($filter)) { |
|
120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Clean up start. |
119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
120 | - $_GET['start'] = 0; |
|
124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
125 | + $_GET['start'] = 0; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Do we want to reverse error listing? |
123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
127 | 133 | $context['start'] = $_GET['start']; |
128 | 134 | |
129 | 135 | // Update the error count |
130 | - if (!isset($filter)) |
|
131 | - $context['num_errors'] = $num_errors; |
|
132 | - else |
|
136 | + if (!isset($filter)) { |
|
137 | + $context['num_errors'] = $num_errors; |
|
138 | + } else |
|
133 | 139 | { |
134 | 140 | // We want all errors, not just the number of filtered messages... |
135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
162 | 168 | { |
163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | - if ($search_message == $filter['value']['sql']) |
|
165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
170 | + if ($search_message == $filter['value']['sql']) { |
|
171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
172 | + } |
|
166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
167 | 174 | |
168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
221 | 228 | 'members' => count($members), |
222 | 229 | ) |
223 | 230 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
225 | - $members[$row['id_member']] = $row; |
|
231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
232 | + $members[$row['id_member']] = $row; |
|
233 | + } |
|
226 | 234 | $smcFunc['db_free_result']($request); |
227 | 235 | |
228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
254 | 262 | $id = $filter['value']['sql']; |
255 | 263 | loadMemberData($id, false, 'minimal'); |
256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
257 | - } |
|
258 | - elseif ($filter['variable'] == 'url') |
|
259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
260 | - elseif ($filter['variable'] == 'message') |
|
265 | + } elseif ($filter['variable'] == 'url') { |
|
266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
267 | + } elseif ($filter['variable'] == 'message') |
|
261 | 268 | { |
262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
264 | - } |
|
265 | - elseif ($filter['variable'] == 'error_type') |
|
271 | + } elseif ($filter['variable'] == 'error_type') |
|
266 | 272 | { |
267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
274 | + } else { |
|
275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
268 | 276 | } |
269 | - else |
|
270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
271 | 277 | } |
272 | 278 | |
273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
309 | 315 | |
310 | 316 | // Finally, work out what is the last tab! |
311 | - if (isset($context['error_types'][$sum])) |
|
312 | - $context['error_types'][$sum]['is_last'] = true; |
|
313 | - else |
|
314 | - $context['error_types']['all']['is_last'] = true; |
|
317 | + if (isset($context['error_types'][$sum])) { |
|
318 | + $context['error_types'][$sum]['is_last'] = true; |
|
319 | + } else { |
|
320 | + $context['error_types']['all']['is_last'] = true; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // And this is pretty basic ;). |
317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
337 | 344 | validateToken('admin-el'); |
338 | 345 | |
339 | 346 | // Delete all or just some? |
340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
341 | - $smcFunc['db_query']('truncate_table', ' |
|
347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
348 | + $smcFunc['db_query']('truncate_table', ' |
|
342 | 349 | TRUNCATE {db_prefix}log_errors', |
343 | 350 | array( |
344 | 351 | ) |
345 | 352 | ); |
353 | + } |
|
346 | 354 | // Deleting all with a filter? |
347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
348 | - $smcFunc['db_query']('', ' |
|
355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
356 | + $smcFunc['db_query']('', ' |
|
349 | 357 | DELETE FROM {db_prefix}log_errors |
350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
351 | 359 | array( |
352 | 360 | 'filter' => $filter['value']['sql'], |
353 | 361 | ) |
354 | 362 | ); |
363 | + } |
|
355 | 364 | // Just specific errors? |
356 | 365 | elseif (!empty($_POST['delete'])) |
357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
398 | 407 | |
399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
411 | + } |
|
402 | 412 | |
403 | 413 | // get the min and max lines |
404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
406 | 416 | |
407 | - if ($max <= 0 || $min >= $max) |
|
408 | - fatal_lang_error('error_bad_line'); |
|
417 | + if ($max <= 0 || $min >= $max) { |
|
418 | + fatal_lang_error('error_bad_line'); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
411 | 422 |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
346 | 346 | return $val; |
347 | 347 | |
348 | - $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function ($m) use ($scripturl) |
|
348 | + $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl) |
|
349 | 349 | { |
350 | 350 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? $m[2] : ""); |
351 | 351 | }, $val); |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | 'title' => $row['subject'], |
669 | 669 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
670 | 670 | 'description' => $row['body'], |
671 | - 'author' => (allowedTo('moderate_forum') || $row['id_member'] == $user_info['id']) ? $row['poster_email'] . ' ('.$row['poster_name'].')' : null, |
|
671 | + 'author' => (allowedTo('moderate_forum') || $row['id_member'] == $user_info['id']) ? $row['poster_email'] . ' (' . $row['poster_name'] . ')' : null, |
|
672 | 672 | 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0', |
673 | 673 | 'category' => $row['bname'], |
674 | 674 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Outputs xml data representing recent information or a profile. |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | global $query_this_board, $smcFunc, $forum_version; |
38 | 39 | |
39 | 40 | // If it's not enabled, die. |
40 | - if (empty($modSettings['xmlnews_enable'])) |
|
41 | - obExit(false); |
|
41 | + if (empty($modSettings['xmlnews_enable'])) { |
|
42 | + obExit(false); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | loadLanguage('Stats'); |
44 | 46 | |
@@ -53,8 +55,9 @@ discard block |
||
53 | 55 | if (!empty($_REQUEST['c']) && empty($board)) |
54 | 56 | { |
55 | 57 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
56 | - foreach ($_REQUEST['c'] as $i => $c) |
|
57 | - $_REQUEST['c'][$i] = (int) $c; |
|
58 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
59 | + $_REQUEST['c'][$i] = (int) $c; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | if (count($_REQUEST['c']) == 1) |
60 | 63 | { |
@@ -90,18 +93,20 @@ discard block |
||
90 | 93 | } |
91 | 94 | $smcFunc['db_free_result']($request); |
92 | 95 | |
93 | - if (!empty($boards)) |
|
94 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
96 | + if (!empty($boards)) { |
|
97 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
98 | + } |
|
95 | 99 | |
96 | 100 | // Try to limit the number of messages we look through. |
97 | - if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
|
98 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
99 | - } |
|
100 | - elseif (!empty($_REQUEST['boards'])) |
|
101 | + if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) { |
|
102 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
103 | + } |
|
104 | + } elseif (!empty($_REQUEST['boards'])) |
|
101 | 105 | { |
102 | 106 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
103 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
104 | - $_REQUEST['boards'][$i] = (int) $b; |
|
107 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
108 | + $_REQUEST['boards'][$i] = (int) $b; |
|
109 | + } |
|
105 | 110 | |
106 | 111 | $request = $smcFunc['db_query']('', ' |
107 | 112 | SELECT b.id_board, b.num_posts, b.name |
@@ -117,29 +122,32 @@ discard block |
||
117 | 122 | |
118 | 123 | // Either the board specified doesn't exist or you have no access. |
119 | 124 | $num_boards = $smcFunc['db_num_rows']($request); |
120 | - if ($num_boards == 0) |
|
121 | - fatal_lang_error('no_board'); |
|
125 | + if ($num_boards == 0) { |
|
126 | + fatal_lang_error('no_board'); |
|
127 | + } |
|
122 | 128 | |
123 | 129 | $total_posts = 0; |
124 | 130 | $boards = array(); |
125 | 131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
126 | 132 | { |
127 | - if ($num_boards == 1) |
|
128 | - $feed_title = ' - ' . strip_tags($row['name']); |
|
133 | + if ($num_boards == 1) { |
|
134 | + $feed_title = ' - ' . strip_tags($row['name']); |
|
135 | + } |
|
129 | 136 | |
130 | 137 | $boards[] = $row['id_board']; |
131 | 138 | $total_posts += $row['num_posts']; |
132 | 139 | } |
133 | 140 | $smcFunc['db_free_result']($request); |
134 | 141 | |
135 | - if (!empty($boards)) |
|
136 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
142 | + if (!empty($boards)) { |
|
143 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
144 | + } |
|
137 | 145 | |
138 | 146 | // The more boards, the more we're going to look through... |
139 | - if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
|
140 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
141 | - } |
|
142 | - elseif (!empty($board)) |
|
147 | + if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) { |
|
148 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
149 | + } |
|
150 | + } elseif (!empty($board)) |
|
143 | 151 | { |
144 | 152 | $request = $smcFunc['db_query']('', ' |
145 | 153 | SELECT num_posts |
@@ -158,10 +166,10 @@ discard block |
||
158 | 166 | $query_this_board = 'b.id_board = ' . $board; |
159 | 167 | |
160 | 168 | // Try to look through just a few messages, if at all possible. |
161 | - if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) |
|
162 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
163 | - } |
|
164 | - else |
|
169 | + if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) { |
|
170 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
171 | + } |
|
172 | + } else |
|
165 | 173 | { |
166 | 174 | $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
167 | 175 | AND b.id_board != ' . $modSettings['recycle_board'] : ''); |
@@ -184,30 +192,35 @@ discard block |
||
184 | 192 | // Easy adding of sub actions |
185 | 193 | call_integration_hook('integrate_xmlfeeds', array(&$subActions)); |
186 | 194 | |
187 | - if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
188 | - $_GET['sa'] = 'recent'; |
|
195 | + if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
196 | + $_GET['sa'] = 'recent'; |
|
197 | + } |
|
189 | 198 | |
190 | 199 | // We only want some information, not all of it. |
191 | 200 | $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']); |
192 | - foreach (array('board', 'boards', 'c') as $var) |
|
193 | - if (isset($_REQUEST[$var])) |
|
201 | + foreach (array('board', 'boards', 'c') as $var) { |
|
202 | + if (isset($_REQUEST[$var])) |
|
194 | 203 | $cachekey[] = $_REQUEST[$var]; |
204 | + } |
|
195 | 205 | $cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : '')); |
196 | 206 | $cache_t = microtime(); |
197 | 207 | |
198 | 208 | // Get the associative array representing the xml. |
199 | - if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) |
|
200 | - $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
209 | + if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) { |
|
210 | + $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
211 | + } |
|
201 | 212 | if (empty($xml)) |
202 | 213 | { |
203 | 214 | $call = call_helper($subActions[$_GET['sa']][0], true); |
204 | 215 | |
205 | - if (!empty($call)) |
|
206 | - $xml = call_user_func($call, $xml_format); |
|
216 | + if (!empty($call)) { |
|
217 | + $xml = call_user_func($call, $xml_format); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3) |
209 | - || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) |
|
210 | - cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
221 | + || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) { |
|
222 | + cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
223 | + } |
|
211 | 224 | } |
212 | 225 | |
213 | 226 | $feed_title = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_title) ? $feed_title : ''); |
@@ -218,19 +231,21 @@ discard block |
||
218 | 231 | |
219 | 232 | // This is an xml file.... |
220 | 233 | ob_end_clean(); |
221 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
222 | - @ob_start('ob_gzhandler'); |
|
223 | - else |
|
224 | - ob_start(); |
|
234 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
235 | + @ob_start('ob_gzhandler'); |
|
236 | + } else { |
|
237 | + ob_start(); |
|
238 | + } |
|
225 | 239 | |
226 | - if ($xml_format == 'smf' || isset($_REQUEST['debug'])) |
|
227 | - header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
228 | - elseif ($xml_format == 'rss' || $xml_format == 'rss2') |
|
229 | - header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
230 | - elseif ($xml_format == 'atom') |
|
231 | - header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
232 | - elseif ($xml_format == 'rdf') |
|
233 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
240 | + if ($xml_format == 'smf' || isset($_REQUEST['debug'])) { |
|
241 | + header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
242 | + } elseif ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
243 | + header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
244 | + } elseif ($xml_format == 'atom') { |
|
245 | + header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
246 | + } elseif ($xml_format == 'rdf') { |
|
247 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
248 | + } |
|
234 | 249 | |
235 | 250 | // First, output the xml header. |
236 | 251 | echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>'; |
@@ -247,8 +262,9 @@ discard block |
||
247 | 262 | <description>', cdata_parse(strip_tags($txt['xml_rss_desc'])), '</description>'; |
248 | 263 | |
249 | 264 | // RSS2 calls for this. |
250 | - if ($xml_format == 'rss2') |
|
251 | - echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />'; |
|
265 | + if ($xml_format == 'rss2') { |
|
266 | + echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />'; |
|
267 | + } |
|
252 | 268 | |
253 | 269 | // Output all of the associative array, start indenting with 2 tabs, and name everything "item". |
254 | 270 | dumpTags($xml, 2, 'item', $xml_format); |
@@ -257,12 +273,12 @@ discard block |
||
257 | 273 | echo ' |
258 | 274 | </channel> |
259 | 275 | </rss>'; |
260 | - } |
|
261 | - elseif ($xml_format == 'atom') |
|
276 | + } elseif ($xml_format == 'atom') |
|
262 | 277 | { |
263 | - foreach ($_REQUEST as $var => $val) |
|
264 | - if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
278 | + foreach ($_REQUEST as $var => $val) { |
|
279 | + if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
265 | 280 | $url_parts[] = $var . '=' . (is_array($_REQUEST[$var]) ? implode(',', $_REQUEST[$var]) : $_REQUEST[$var]); |
281 | + } |
|
266 | 282 | |
267 | 283 | echo ' |
268 | 284 | <feed xmlns="http://www.w3.org/2005/Atom"> |
@@ -283,8 +299,7 @@ discard block |
||
283 | 299 | |
284 | 300 | echo ' |
285 | 301 | </feed>'; |
286 | - } |
|
287 | - elseif ($xml_format == 'rdf') |
|
302 | + } elseif ($xml_format == 'rdf') |
|
288 | 303 | { |
289 | 304 | echo ' |
290 | 305 | <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/"> |
@@ -295,9 +310,10 @@ discard block |
||
295 | 310 | <items> |
296 | 311 | <rdf:Seq>'; |
297 | 312 | |
298 | - foreach ($xml as $item) |
|
299 | - echo ' |
|
313 | + foreach ($xml as $item) { |
|
314 | + echo ' |
|
300 | 315 | <rdf:li rdf:resource="', $item['link'], '" />'; |
316 | + } |
|
301 | 317 | |
302 | 318 | echo ' |
303 | 319 | </rdf:Seq> |
@@ -337,13 +353,15 @@ discard block |
||
337 | 353 | { |
338 | 354 | global $modSettings, $context, $scripturl; |
339 | 355 | |
340 | - if (substr($val, 0, strlen($scripturl)) != $scripturl) |
|
341 | - return $val; |
|
356 | + if (substr($val, 0, strlen($scripturl)) != $scripturl) { |
|
357 | + return $val; |
|
358 | + } |
|
342 | 359 | |
343 | 360 | call_integration_hook('integrate_fix_url', array(&$val)); |
344 | 361 | |
345 | - if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
|
346 | - return $val; |
|
362 | + if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) { |
|
363 | + return $val; |
|
364 | + } |
|
347 | 365 | |
348 | 366 | $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function ($m) use ($scripturl) |
349 | 367 | { |
@@ -365,8 +383,9 @@ discard block |
||
365 | 383 | global $smcFunc; |
366 | 384 | |
367 | 385 | // Do we even need to do this? |
368 | - if (strpbrk($data, '<>&') == false) |
|
369 | - return $data; |
|
386 | + if (strpbrk($data, '<>&') == false) { |
|
387 | + return $data; |
|
388 | + } |
|
370 | 389 | |
371 | 390 | $cdata = '<, |
377 | 396 | $smcFunc['strpos']($data, ']', $pos), |
378 | 397 | ); |
379 | - if ($ns != '') |
|
380 | - $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
398 | + if ($ns != '') { |
|
399 | + $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
400 | + } |
|
381 | 401 | foreach ($positions as $k => $dummy) |
382 | 402 | { |
383 | - if ($dummy === false) |
|
384 | - unset($positions[$k]); |
|
403 | + if ($dummy === false) { |
|
404 | + unset($positions[$k]); |
|
405 | + } |
|
385 | 406 | } |
386 | 407 | |
387 | 408 | $old = $pos; |
388 | 409 | $pos = empty($positions) ? $n : min($positions); |
389 | 410 | |
390 | - if ($pos - $old > 0) |
|
391 | - $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
392 | - if ($pos >= $n) |
|
393 | - break; |
|
411 | + if ($pos - $old > 0) { |
|
412 | + $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
413 | + } |
|
414 | + if ($pos >= $n) { |
|
415 | + break; |
|
416 | + } |
|
394 | 417 | |
395 | 418 | if ($smcFunc['substr']($data, $pos, 1) == '<') |
396 | 419 | { |
397 | 420 | $pos2 = $smcFunc['strpos']($data, '>', $pos); |
398 | - if ($pos2 === false) |
|
399 | - $pos2 = $n; |
|
400 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '/') |
|
401 | - $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
402 | - else |
|
403 | - $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == '/') { |
|
425 | + $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
426 | + } else { |
|
427 | + $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == ']') |
|
430 | + } elseif ($smcFunc['substr']($data, $pos, 1) == ']') |
|
407 | 431 | { |
408 | 432 | $cdata .= ']]>]< == '&') |
|
434 | + } elseif ($smcFunc['substr']($data, $pos, 1) == '&') |
|
412 | 435 | { |
413 | 436 | $pos2 = $smcFunc['strpos']($data, ';', $pos); |
414 | - if ($pos2 === false) |
|
415 | - $pos2 = $n; |
|
437 | + if ($pos2 === false) { |
|
438 | + $pos2 = $n; |
|
439 | + } |
|
416 | 440 | $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1); |
417 | 441 | |
418 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '#') |
|
419 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
420 | - elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
|
421 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '< == '#') { |
|
443 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
444 | + } elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) { |
|
445 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
446 | + } |
|
422 | 447 | |
423 | 448 | $pos = $pos2 + 1; |
424 | 449 | } |
@@ -456,19 +481,22 @@ discard block |
||
456 | 481 | 'gender', |
457 | 482 | 'blurb', |
458 | 483 | ); |
459 | - if ($xml_format != 'atom') |
|
460 | - $keysToCdata[] = 'category'; |
|
484 | + if ($xml_format != 'atom') { |
|
485 | + $keysToCdata[] = 'category'; |
|
486 | + } |
|
461 | 487 | |
462 | 488 | // For every array in the data... |
463 | 489 | foreach ($data as $key => $val) |
464 | 490 | { |
465 | 491 | // Skip it, it's been set to null. |
466 | - if ($val === null) |
|
467 | - continue; |
|
492 | + if ($val === null) { |
|
493 | + continue; |
|
494 | + } |
|
468 | 495 | |
469 | 496 | // If the value should maybe be CDATA, do that now. |
470 | - if (!is_array($val) && in_array($key, $keysToCdata)) |
|
471 | - $val = cdata_parse($val); |
|
497 | + if (!is_array($val) && in_array($key, $keysToCdata)) { |
|
498 | + $val = cdata_parse($val); |
|
499 | + } |
|
472 | 500 | |
473 | 501 | // If a tag was passed, use it instead of the key. |
474 | 502 | $key = isset($tag) ? $tag : $key; |
@@ -484,11 +512,11 @@ discard block |
||
484 | 512 | } |
485 | 513 | |
486 | 514 | // If it's empty/0/nothing simply output an empty tag. |
487 | - if ($val == '') |
|
488 | - echo '<', $key, ' />'; |
|
489 | - elseif ($xml_format == 'atom' && $key == 'category') |
|
490 | - echo '<', $key, ' term="', $val, '" />'; |
|
491 | - else |
|
515 | + if ($val == '') { |
|
516 | + echo '<', $key, ' />'; |
|
517 | + } elseif ($xml_format == 'atom' && $key == 'category') { |
|
518 | + echo '<', $key, ' term="', $val, '" />'; |
|
519 | + } else |
|
492 | 520 | { |
493 | 521 | // Beginning tag. |
494 | 522 | if ($xml_format == 'rdf' && $key == 'item' && isset($val['link'])) |
@@ -496,11 +524,11 @@ discard block |
||
496 | 524 | echo '<', $key, ' rdf:about="', fix_possible_url($val['link']), '">'; |
497 | 525 | echo "\n", str_repeat("\t", $i + 1); |
498 | 526 | echo '<dc:format>text/html</dc:format>'; |
527 | + } elseif ($xml_format == 'atom' && $key == 'summary') { |
|
528 | + echo '<', $key, ' type="html">'; |
|
529 | + } else { |
|
530 | + echo '<', $key, '>'; |
|
499 | 531 | } |
500 | - elseif ($xml_format == 'atom' && $key == 'summary') |
|
501 | - echo '<', $key, ' type="html">'; |
|
502 | - else |
|
503 | - echo '<', $key, '>'; |
|
504 | 532 | |
505 | 533 | // The element's value. |
506 | 534 | if (is_array($val)) |
@@ -510,11 +538,13 @@ discard block |
||
510 | 538 | echo "\n", str_repeat("\t", $i); |
511 | 539 | } |
512 | 540 | // A string with returns in it.... show this as a multiline element. |
513 | - elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) |
|
514 | - echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
541 | + elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) { |
|
542 | + echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
543 | + } |
|
515 | 544 | // A simple string. |
516 | - else |
|
517 | - echo fix_possible_url($val); |
|
545 | + else { |
|
546 | + echo fix_possible_url($val); |
|
547 | + } |
|
518 | 548 | |
519 | 549 | // Ending tag. |
520 | 550 | echo '</', $key, '>'; |
@@ -534,8 +564,9 @@ discard block |
||
534 | 564 | { |
535 | 565 | global $scripturl, $smcFunc; |
536 | 566 | |
537 | - if (!allowedTo('view_mlist')) |
|
538 | - return array(); |
|
567 | + if (!allowedTo('view_mlist')) { |
|
568 | + return array(); |
|
569 | + } |
|
539 | 570 | |
540 | 571 | // Find the most recent members. |
541 | 572 | $request = $smcFunc['db_query']('', ' |
@@ -551,35 +582,37 @@ discard block |
||
551 | 582 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
552 | 583 | { |
553 | 584 | // Make the data look rss-ish. |
554 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
555 | - $data[] = array( |
|
585 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
586 | + $data[] = array( |
|
556 | 587 | 'title' => $row['real_name'], |
557 | 588 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
558 | 589 | 'comments' => $scripturl . '?action=pm;sa=send;u=' . $row['id_member'], |
559 | 590 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['date_registered']), |
560 | 591 | 'guid' => $scripturl . '?action=profile;u=' . $row['id_member'], |
561 | 592 | ); |
562 | - elseif ($xml_format == 'rdf') |
|
563 | - $data[] = array( |
|
593 | + } elseif ($xml_format == 'rdf') { |
|
594 | + $data[] = array( |
|
564 | 595 | 'title' => $row['real_name'], |
565 | 596 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
566 | 597 | ); |
567 | - elseif ($xml_format == 'atom') |
|
568 | - $data[] = array( |
|
598 | + } elseif ($xml_format == 'atom') { |
|
599 | + $data[] = array( |
|
569 | 600 | 'title' => $row['real_name'], |
570 | 601 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
571 | 602 | 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['date_registered']), |
572 | 603 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['last_login']), |
573 | 604 | 'id' => $scripturl . '?action=profile;u=' . $row['id_member'], |
574 | 605 | ); |
606 | + } |
|
575 | 607 | // More logical format for the data, but harder to apply. |
576 | - else |
|
577 | - $data[] = array( |
|
608 | + else { |
|
609 | + $data[] = array( |
|
578 | 610 | 'name' => $row['real_name'], |
579 | 611 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['date_registered']))), |
580 | 612 | 'id' => $row['id_member'], |
581 | 613 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'] |
582 | 614 | ); |
615 | + } |
|
583 | 616 | } |
584 | 617 | $smcFunc['db_free_result']($request); |
585 | 618 | |
@@ -640,22 +673,24 @@ discard block |
||
640 | 673 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
641 | 674 | { |
642 | 675 | $smcFunc['db_free_result']($request); |
643 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
644 | - unset($context['optimize_msg']['lowest']); |
|
645 | - else |
|
646 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
676 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
677 | + unset($context['optimize_msg']['lowest']); |
|
678 | + } else { |
|
679 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
680 | + } |
|
647 | 681 | $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg'; |
648 | 682 | $loops++; |
683 | + } else { |
|
684 | + $done = true; |
|
649 | 685 | } |
650 | - else |
|
651 | - $done = true; |
|
652 | 686 | } |
653 | 687 | $data = array(); |
654 | 688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
655 | 689 | { |
656 | 690 | // Limit the length of the message, if the option is set. |
657 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
658 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
691 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
692 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
693 | + } |
|
659 | 694 | |
660 | 695 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
661 | 696 | |
@@ -663,8 +698,8 @@ discard block |
||
663 | 698 | censorText($row['subject']); |
664 | 699 | |
665 | 700 | // Being news, this actually makes sense in rss format. |
666 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
667 | - $data[] = array( |
|
701 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
702 | + $data[] = array( |
|
668 | 703 | 'title' => $row['subject'], |
669 | 704 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
670 | 705 | 'description' => $row['body'], |
@@ -674,14 +709,14 @@ discard block |
||
674 | 709 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
675 | 710 | 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
676 | 711 | ); |
677 | - elseif ($xml_format == 'rdf') |
|
678 | - $data[] = array( |
|
712 | + } elseif ($xml_format == 'rdf') { |
|
713 | + $data[] = array( |
|
679 | 714 | 'title' => $row['subject'], |
680 | 715 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
681 | 716 | 'description' => $row['body'], |
682 | 717 | ); |
683 | - elseif ($xml_format == 'atom') |
|
684 | - $data[] = array( |
|
718 | + } elseif ($xml_format == 'atom') { |
|
719 | + $data[] = array( |
|
685 | 720 | 'title' => $row['subject'], |
686 | 721 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
687 | 722 | 'summary' => $row['body'], |
@@ -695,9 +730,10 @@ discard block |
||
695 | 730 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), |
696 | 731 | 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
697 | 732 | ); |
733 | + } |
|
698 | 734 | // The biggest difference here is more information. |
699 | - else |
|
700 | - $data[] = array( |
|
735 | + else { |
|
736 | + $data[] = array( |
|
701 | 737 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))), |
702 | 738 | 'id' => $row['id_topic'], |
703 | 739 | 'subject' => $row['subject'], |
@@ -715,6 +751,7 @@ discard block |
||
715 | 751 | ), |
716 | 752 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
717 | 753 | ); |
754 | + } |
|
718 | 755 | } |
719 | 756 | $smcFunc['db_free_result']($request); |
720 | 757 | |
@@ -761,22 +798,25 @@ discard block |
||
761 | 798 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
762 | 799 | { |
763 | 800 | $smcFunc['db_free_result']($request); |
764 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
765 | - unset($context['optimize_msg']['lowest']); |
|
766 | - else |
|
767 | - $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
801 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
802 | + unset($context['optimize_msg']['lowest']); |
|
803 | + } else { |
|
804 | + $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
805 | + } |
|
768 | 806 | $loops++; |
807 | + } else { |
|
808 | + $done = true; |
|
769 | 809 | } |
770 | - else |
|
771 | - $done = true; |
|
772 | 810 | } |
773 | 811 | $messages = array(); |
774 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
775 | - $messages[] = $row['id_msg']; |
|
812 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
813 | + $messages[] = $row['id_msg']; |
|
814 | + } |
|
776 | 815 | $smcFunc['db_free_result']($request); |
777 | 816 | |
778 | - if (empty($messages)) |
|
779 | - return array(); |
|
817 | + if (empty($messages)) { |
|
818 | + return array(); |
|
819 | + } |
|
780 | 820 | |
781 | 821 | // Find the most recent posts this user can see. |
782 | 822 | $request = $smcFunc['db_query']('', ' |
@@ -806,8 +846,9 @@ discard block |
||
806 | 846 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
807 | 847 | { |
808 | 848 | // Limit the length of the message, if the option is set. |
809 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
810 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
849 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
850 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
851 | + } |
|
811 | 852 | |
812 | 853 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
813 | 854 | |
@@ -815,8 +856,8 @@ discard block |
||
815 | 856 | censorText($row['subject']); |
816 | 857 | |
817 | 858 | // Doesn't work as well as news, but it kinda does.. |
818 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
819 | - $data[] = array( |
|
859 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
860 | + $data[] = array( |
|
820 | 861 | 'title' => $row['subject'], |
821 | 862 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
822 | 863 | 'description' => $row['body'], |
@@ -826,14 +867,14 @@ discard block |
||
826 | 867 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
827 | 868 | 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] |
828 | 869 | ); |
829 | - elseif ($xml_format == 'rdf') |
|
830 | - $data[] = array( |
|
870 | + } elseif ($xml_format == 'rdf') { |
|
871 | + $data[] = array( |
|
831 | 872 | 'title' => $row['subject'], |
832 | 873 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
833 | 874 | 'description' => $row['body'], |
834 | 875 | ); |
835 | - elseif ($xml_format == 'atom') |
|
836 | - $data[] = array( |
|
876 | + } elseif ($xml_format == 'atom') { |
|
877 | + $data[] = array( |
|
837 | 878 | 'title' => $row['subject'], |
838 | 879 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
839 | 880 | 'summary' => $row['body'], |
@@ -847,9 +888,10 @@ discard block |
||
847 | 888 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), |
848 | 889 | 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
849 | 890 | ); |
891 | + } |
|
850 | 892 | // A lot of information here. Should be enough to please the rss-ers. |
851 | - else |
|
852 | - $data[] = array( |
|
893 | + else { |
|
894 | + $data[] = array( |
|
853 | 895 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))), |
854 | 896 | 'id' => $row['id_msg'], |
855 | 897 | 'subject' => $row['subject'], |
@@ -876,6 +918,7 @@ discard block |
||
876 | 918 | ), |
877 | 919 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] |
878 | 920 | ); |
921 | + } |
|
879 | 922 | } |
880 | 923 | $smcFunc['db_free_result']($request); |
881 | 924 | |
@@ -895,20 +938,22 @@ discard block |
||
895 | 938 | global $scripturl, $memberContext, $user_profile, $user_info; |
896 | 939 | |
897 | 940 | // You must input a valid user.... |
898 | - if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) |
|
899 | - return array(); |
|
941 | + if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) { |
|
942 | + return array(); |
|
943 | + } |
|
900 | 944 | |
901 | 945 | // Make sure the id is a number and not "I like trying to hack the database". |
902 | 946 | $_GET['u'] = (int) $_GET['u']; |
903 | 947 | // Load the member's contextual information! |
904 | - if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) |
|
905 | - return array(); |
|
948 | + if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) { |
|
949 | + return array(); |
|
950 | + } |
|
906 | 951 | |
907 | 952 | // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. |
908 | 953 | $profile = &$memberContext[$_GET['u']]; |
909 | 954 | |
910 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
911 | - $data = array(array( |
|
955 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
956 | + $data = array(array( |
|
912 | 957 | 'title' => $profile['name'], |
913 | 958 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
914 | 959 | 'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
@@ -916,14 +961,14 @@ discard block |
||
916 | 961 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered']), |
917 | 962 | 'guid' => $scripturl . '?action=profile;u=' . $profile['id'], |
918 | 963 | )); |
919 | - elseif ($xml_format == 'rdf') |
|
920 | - $data = array(array( |
|
964 | + } elseif ($xml_format == 'rdf') { |
|
965 | + $data = array(array( |
|
921 | 966 | 'title' => $profile['name'], |
922 | 967 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
923 | 968 | 'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
924 | 969 | )); |
925 | - elseif ($xml_format == 'atom') |
|
926 | - $data[] = array( |
|
970 | + } elseif ($xml_format == 'atom') { |
|
971 | + $data[] = array( |
|
927 | 972 | 'title' => $profile['name'], |
928 | 973 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
929 | 974 | 'summary' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
@@ -937,7 +982,7 @@ discard block |
||
937 | 982 | 'id' => $scripturl . '?action=profile;u=' . $profile['id'], |
938 | 983 | 'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : '', |
939 | 984 | ); |
940 | - else |
|
985 | + } else |
|
941 | 986 | { |
942 | 987 | $data = array( |
943 | 988 | 'username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? $profile['username'] : '', |
@@ -951,34 +996,43 @@ discard block |
||
951 | 996 | ); |
952 | 997 | |
953 | 998 | // Everything below here might not be set, and thus maybe shouldn't be displayed. |
954 | - if ($profile['gender']['name'] != '') |
|
955 | - $data['gender'] = $profile['gender']['name']; |
|
999 | + if ($profile['gender']['name'] != '') { |
|
1000 | + $data['gender'] = $profile['gender']['name']; |
|
1001 | + } |
|
956 | 1002 | |
957 | - if ($profile['avatar']['name'] != '') |
|
958 | - $data['avatar'] = $profile['avatar']['url']; |
|
1003 | + if ($profile['avatar']['name'] != '') { |
|
1004 | + $data['avatar'] = $profile['avatar']['url']; |
|
1005 | + } |
|
959 | 1006 | |
960 | 1007 | // If they are online, show an empty tag... no reason to put anything inside it. |
961 | - if ($profile['online']['is_online']) |
|
962 | - $data['online'] = ''; |
|
963 | - |
|
964 | - if ($profile['signature'] != '') |
|
965 | - $data['signature'] = $profile['signature']; |
|
966 | - if ($profile['blurb'] != '') |
|
967 | - $data['blurb'] = $profile['blurb']; |
|
968 | - if ($profile['title'] != '') |
|
969 | - $data['title'] = $profile['title']; |
|
970 | - |
|
971 | - if ($profile['website']['title'] != '') |
|
972 | - $data['website'] = array( |
|
1008 | + if ($profile['online']['is_online']) { |
|
1009 | + $data['online'] = ''; |
|
1010 | + } |
|
1011 | + |
|
1012 | + if ($profile['signature'] != '') { |
|
1013 | + $data['signature'] = $profile['signature']; |
|
1014 | + } |
|
1015 | + if ($profile['blurb'] != '') { |
|
1016 | + $data['blurb'] = $profile['blurb']; |
|
1017 | + } |
|
1018 | + if ($profile['title'] != '') { |
|
1019 | + $data['title'] = $profile['title']; |
|
1020 | + } |
|
1021 | + |
|
1022 | + if ($profile['website']['title'] != '') { |
|
1023 | + $data['website'] = array( |
|
973 | 1024 | 'title' => $profile['website']['title'], |
974 | 1025 | 'link' => $profile['website']['url'] |
975 | 1026 | ); |
1027 | + } |
|
976 | 1028 | |
977 | - if ($profile['group'] != '') |
|
978 | - $data['position'] = $profile['group']; |
|
1029 | + if ($profile['group'] != '') { |
|
1030 | + $data['position'] = $profile['group']; |
|
1031 | + } |
|
979 | 1032 | |
980 | - if ($profile['show_email']) |
|
981 | - $data['email'] = $profile['email']; |
|
1033 | + if ($profile['show_email']) { |
|
1034 | + $data['email'] = $profile['email']; |
|
1035 | + } |
|
982 | 1036 | |
983 | 1037 | if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') |
984 | 1038 | { |
@@ -273,7 +273,6 @@ |
||
273 | 273 | * Modify any setting related to topics. |
274 | 274 | * Requires the admin_forum permission. |
275 | 275 | * Accessed from ?action=admin;area=postsettings;sa=topics. |
276 | - |
|
277 | 276 | * @param bool $return_config Whether or not to return the config_vars array (used for admin search) |
278 | 277 | * @return void|array Returns nothing or returns $config_vars if $return_config is true |
279 | 278 | * @uses Admin template, edit_topic_settings sub-template. |
@@ -1799,9 +1799,9 @@ |
||
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | /** |
1802 | - * Callback for createList(). |
|
1803 | - * @return int The total number of warning templates |
|
1804 | - */ |
|
1802 | + * Callback for createList(). |
|
1803 | + * @return int The total number of warning templates |
|
1804 | + */ |
|
1805 | 1805 | function list_getWarningTemplateCount() |
1806 | 1806 | { |
1807 | 1807 | global $smcFunc, $user_info; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 403 | $smcFunc['db_free_result']($get_owner); |
404 | 404 | |
405 | - if(empty($note_owner)) |
|
405 | + if (empty($note_owner)) |
|
406 | 406 | fatal_lang_error('mc_notes_delete_own', false); |
407 | 407 | } |
408 | 408 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | 'status_open' => 0, |
586 | 586 | ) |
587 | 587 | ); |
588 | - for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
|
588 | + for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
|
589 | 589 | { |
590 | 590 | $context['group_requests'][] = array( |
591 | 591 | 'id' => $row['id_request'], |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $smcFunc['db_free_result']($request); |
736 | 736 | |
737 | 737 | // Stick this in string format for consistency |
738 | - $extra['member'] = (string)$extra['member']; |
|
738 | + $extra['member'] = (string) $extra['member']; |
|
739 | 739 | |
740 | 740 | // Tell the user about it. |
741 | 741 | $context['report_member_action'] = isset($_GET['ignore']) ? (!empty($_GET['ignore']) ? 'ignore' : 'unignore') : (!empty($_GET['close']) ? 'close' : 'open'); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | 'extra' => array( |
778 | 778 | 'report' => $reports['id_report'], |
779 | 779 | 'membername' => $reports['membername'], |
780 | - 'member' => (string)$reports['id_member'], |
|
780 | + 'member' => (string) $reports['id_member'], |
|
781 | 781 | ), |
782 | 782 | ); |
783 | 783 | } |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | 'value' => $txt['mc_watched_users_warning'], |
1074 | 1074 | ), |
1075 | 1075 | 'data' => array( |
1076 | - 'function' => function ($member) use ($scripturl) |
|
1076 | + 'function' => function($member) use ($scripturl) |
|
1077 | 1077 | { |
1078 | 1078 | return allowedTo('issue_warning') ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $member['id'] . '">' . $member['warning'] . '%</a>' : $member['warning'] . '%'; |
1079 | 1079 | }, |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | 'value' => $txt['mc_watched_users_last_post'], |
1119 | 1119 | ), |
1120 | 1120 | 'data' => array( |
1121 | - 'function' => function ($member) use ($scripturl) |
|
1121 | + 'function' => function($member) use ($scripturl) |
|
1122 | 1122 | { |
1123 | 1123 | if ($member['last_post_id']) |
1124 | 1124 | return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | $listOptions['columns'] = array( |
1154 | 1154 | 'posts' => array( |
1155 | 1155 | 'data' => array( |
1156 | - 'function' => function ($post) |
|
1156 | + 'function' => function($post) |
|
1157 | 1157 | { |
1158 | 1158 | return template_user_watch_post_callback($post); |
1159 | 1159 | }, |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | call_integration_hook('integrate_warning_log_actions', array(&$subActions)); |
1395 | 1395 | |
1396 | - $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) && (empty($subActions[$_REQUEST['sa']][1]) || allowedTo($subActions[$_REQUEST['sa']]))? $_REQUEST['sa'] : 'log'; |
|
1396 | + $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) && (empty($subActions[$_REQUEST['sa']][1]) || allowedTo($subActions[$_REQUEST['sa']])) ? $_REQUEST['sa'] : 'log'; |
|
1397 | 1397 | |
1398 | 1398 | // Some of this stuff is overseas, so to speak. |
1399 | 1399 | loadTemplate('ModerationCenter'); |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | 'type' => $search_params_type, |
1460 | 1460 | ); |
1461 | 1461 | |
1462 | - $context['url_start'] = '?action=moderate;area=warnings;sa=log;sort='. $context['order']; |
|
1462 | + $context['url_start'] = '?action=moderate;area=warnings;sa=log;sort=' . $context['order']; |
|
1463 | 1463 | |
1464 | 1464 | // Setup the search context. |
1465 | 1465 | $context['search_params'] = empty($search_params['string']) ? '' : base64_encode(json_encode($search_params)); |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | 'value' => $txt['profile_warning_previous_reason'], |
1529 | 1529 | ), |
1530 | 1530 | 'data' => array( |
1531 | - 'function' => function ($rowData) use ($scripturl, $txt) |
|
1531 | + 'function' => function($rowData) use ($scripturl, $txt) |
|
1532 | 1532 | { |
1533 | 1533 | $output = ' |
1534 | 1534 | <div class="floatleft"> |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | array( |
1565 | 1565 | 'position' => 'below_table_data', |
1566 | 1566 | 'value' => ' |
1567 | - ' . $txt['modlog_search'] .': |
|
1567 | + ' . $txt['modlog_search'] . ': |
|
1568 | 1568 | <input type="text" name="search" size="18" value="' . $smcFunc['htmlspecialchars']($context['search']['string']) . '" class="input_text"> |
1569 | 1569 | <input type="submit" name="is_search" value="' . $txt['modlog_go'] . '" class="button_submit">', |
1570 | 1570 | 'class' => 'floatright', |
@@ -1766,7 +1766,7 @@ discard block |
||
1766 | 1766 | 'class' => 'centercol', |
1767 | 1767 | ), |
1768 | 1768 | 'data' => array( |
1769 | - 'function' => function ($rowData) |
|
1769 | + 'function' => function($rowData) |
|
1770 | 1770 | { |
1771 | 1771 | return '<input type="checkbox" name="deltpl[]" value="' . $rowData['id_comment'] . '" class="input_check">'; |
1772 | 1772 | }, |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if(empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if(empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function ($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
1457 | 1487 | $search_params = array( |
@@ -1535,9 +1565,10 @@ discard block |
||
1535 | 1565 | ' . $rowData['reason'] . ' |
1536 | 1566 | </div>'; |
1537 | 1567 | |
1538 | - if (!empty($rowData['id_notice'])) |
|
1539 | - $output .= ' |
|
1568 | + if (!empty($rowData['id_notice'])) { |
|
1569 | + $output .= ' |
|
1540 | 1570 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1571 | + } |
|
1541 | 1572 | return $output; |
1542 | 1573 | }, |
1543 | 1574 | ), |
@@ -1655,9 +1686,9 @@ discard block |
||
1655 | 1686 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1656 | 1687 | |
1657 | 1688 | // Submitting a new one? |
1658 | - if (isset($_POST['add'])) |
|
1659 | - return ModifyWarningTemplate(); |
|
1660 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1689 | + if (isset($_POST['add'])) { |
|
1690 | + return ModifyWarningTemplate(); |
|
1691 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1661 | 1692 | { |
1662 | 1693 | checkSession(); |
1663 | 1694 | validateToken('mod-wt'); |
@@ -1676,8 +1707,9 @@ discard block |
||
1676 | 1707 | 'current_member' => $user_info['id'], |
1677 | 1708 | ) |
1678 | 1709 | ); |
1679 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1680 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1710 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1711 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1712 | + } |
|
1681 | 1713 | $smcFunc['db_free_result']($request); |
1682 | 1714 | |
1683 | 1715 | // Do the deletes. |
@@ -1968,16 +2000,18 @@ discard block |
||
1968 | 2000 | ); |
1969 | 2001 | |
1970 | 2002 | // If it wasn't visible and now is they've effectively added it. |
1971 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1972 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2003 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2004 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2005 | + } |
|
1973 | 2006 | // Conversely if they made it personal it's a delete. |
1974 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1975 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2007 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2008 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2009 | + } |
|
1976 | 2010 | // Otherwise just an edit. |
1977 | - else |
|
1978 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1979 | - } |
|
1980 | - else |
|
2011 | + else { |
|
2012 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2013 | + } |
|
2014 | + } else |
|
1981 | 2015 | { |
1982 | 2016 | $smcFunc['db_insert']('', |
1983 | 2017 | '{db_prefix}log_comments', |
@@ -1997,17 +2031,18 @@ discard block |
||
1997 | 2031 | |
1998 | 2032 | // Get out of town... |
1999 | 2033 | redirectexit('action=moderate;area=warnings;sa=templates'); |
2000 | - } |
|
2001 | - else |
|
2034 | + } else |
|
2002 | 2035 | { |
2003 | 2036 | $context['warning_errors'] = array(); |
2004 | 2037 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2005 | 2038 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2006 | 2039 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2007 | - if (empty($_POST['template_title'])) |
|
2008 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2009 | - if (empty($_POST['template_body'])) |
|
2010 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2040 | + if (empty($_POST['template_title'])) { |
|
2041 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2042 | + } |
|
2043 | + if (empty($_POST['template_body'])) { |
|
2044 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2045 | + } |
|
2011 | 2046 | } |
2012 | 2047 | } |
2013 | 2048 | |
@@ -2054,8 +2089,9 @@ discard block |
||
2054 | 2089 | // Now check other options! |
2055 | 2090 | $pref_binary = 0; |
2056 | 2091 | |
2057 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2058 | - $pref_binary |= 4; |
|
2092 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2093 | + $pref_binary |= 4; |
|
2094 | + } |
|
2059 | 2095 | |
2060 | 2096 | // Put it all together. |
2061 | 2097 | $mod_prefs = '0||' . $pref_binary; |
@@ -2079,9 +2115,10 @@ discard block |
||
2079 | 2115 | unset($_SESSION['moderate_time']); |
2080 | 2116 | |
2081 | 2117 | // Clean any moderator tokens as well. |
2082 | - foreach ($_SESSION['token'] as $key => $token) |
|
2083 | - if (strpos($key, '-mod') !== false) |
|
2118 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2119 | + if (strpos($key, '-mod') !== false) |
|
2084 | 2120 | unset($_SESSION['token'][$key]); |
2121 | + } |
|
2085 | 2122 | |
2086 | 2123 | redirectexit(); |
2087 | 2124 | } |
@@ -273,7 +273,6 @@ |
||
273 | 273 | * Modify any setting related to topics. |
274 | 274 | * Requires the admin_forum permission. |
275 | 275 | * Accessed from ?action=admin;area=postsettings;sa=topics. |
276 | - |
|
277 | 276 | * @param bool $return_config Whether or not to return the config_vars array (used for admin search) |
278 | 277 | * @return void|array Returns nothing or returns $config_vars if $return_config is true |
279 | 278 | * @uses Admin template, edit_topic_settings sub-template. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
98 | 99 | { |
99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
100 | 101 | |
101 | - foreach ($_POST['censortext'] as $c) |
|
102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
103 | - } |
|
104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
102 | + foreach ($_POST['censortext'] as $c) { |
|
103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
104 | + } |
|
105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
105 | 106 | { |
106 | 107 | if (is_array($_POST['censor_vulgar'])) |
107 | 108 | { |
108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
109 | 110 | { |
110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | |
114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
115 | 117 | $censored_proper = $_POST['censor_proper']; |
116 | - } |
|
117 | - else |
|
118 | + } else |
|
118 | 119 | { |
119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
151 | 152 | $context['censored_words'] = array(); |
152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
153 | 154 | { |
154 | - if (empty($censor_vulgar[$i])) |
|
155 | - continue; |
|
155 | + if (empty($censor_vulgar[$i])) { |
|
156 | + continue; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | // Skip it, it's either spaces or stars only. |
158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
159 | - continue; |
|
160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
161 | + continue; |
|
162 | + } |
|
160 | 163 | |
161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
187 | 190 | |
188 | 191 | // Make an inline conditional a little shorter... |
189 | 192 | $can_spell_check = false; |
190 | - if (function_exists('pspell_new')) |
|
191 | - $can_spell_check = true; |
|
192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
193 | - $can_spell_check = true; |
|
193 | + if (function_exists('pspell_new')) { |
|
194 | + $can_spell_check = true; |
|
195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
196 | + $can_spell_check = true; |
|
197 | + } |
|
194 | 198 | |
195 | 199 | // All the settings... |
196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
221 | 225 | |
222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
223 | 227 | |
224 | - if ($return_config) |
|
225 | - return $config_vars; |
|
228 | + if ($return_config) { |
|
229 | + return $config_vars; |
|
230 | + } |
|
226 | 231 | |
227 | 232 | // We'll want this for our easy save. |
228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
242 | 247 | db_extend('packages'); |
243 | 248 | |
244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
245 | - foreach ($colData as $column) |
|
246 | - if ($column['name'] == 'body') |
|
250 | + foreach ($colData as $column) { |
|
251 | + if ($column['name'] == 'body') |
|
247 | 252 | $body_type = $column['type']; |
253 | + } |
|
248 | 254 | |
249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
257 | + } |
|
251 | 258 | } |
252 | 259 | |
253 | 260 | // If we're changing the post preview length let's check its valid |
254 | - if (!empty($_POST['preview_characters'])) |
|
255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
261 | + if (!empty($_POST['preview_characters'])) { |
|
262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | call_integration_hook('integrate_save_post_settings'); |
258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
313 | 321 | |
314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
315 | 323 | |
316 | - if ($return_config) |
|
317 | - return $config_vars; |
|
324 | + if ($return_config) { |
|
325 | + return $config_vars; |
|
326 | + } |
|
318 | 327 | |
319 | 328 | // Get the settings template ready. |
320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
368 | 377 | ); |
369 | 378 | |
370 | - if ($return_config) |
|
371 | - return $config_vars; |
|
379 | + if ($return_config) { |
|
380 | + return $config_vars; |
|
381 | + } |
|
372 | 382 | |
373 | 383 | // Get the settings template ready. |
374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 3 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
65 | 68 | @ini_set('session.serialize_handler', 'php'); |
66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
67 | 70 | @ini_set('session.gc_probability', '1'); |
71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
68 | 73 | } |
69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
71 | 74 | |
72 | 75 | // Use cache setting sessions? |
73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
74 | - call_integration_hook('integrate_session_handlers'); |
|
76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
77 | + call_integration_hook('integrate_session_handlers'); |
|
78 | + } |
|
75 | 79 | |
76 | 80 | session_start(); |
77 | 81 | |
78 | 82 | // Change it so the cache settings are a little looser than default. |
79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
80 | - header('Cache-Control: private'); |
|
83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
84 | + header('Cache-Control: private'); |
|
85 | + } |
|
81 | 86 | } |
82 | 87 | |
83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | { |
124 | 129 | global $smcFunc; |
125 | 130 | |
126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
127 | - return ''; |
|
131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
132 | + return ''; |
|
133 | + } |
|
128 | 134 | |
129 | 135 | // Look for it in the database. |
130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
153 | 159 | { |
154 | 160 | global $smcFunc; |
155 | 161 | |
156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
157 | - return false; |
|
162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
163 | + return false; |
|
164 | + } |
|
158 | 165 | |
159 | 166 | // First try to update an existing row... |
160 | 167 | $result = $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
169 | 176 | ); |
170 | 177 | |
171 | 178 | // If that didn't work, try inserting a new one. |
172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
173 | - $result = $smcFunc['db_insert']('ignore', |
|
179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
180 | + $result = $smcFunc['db_insert']('ignore', |
|
174 | 181 | '{db_prefix}sessions', |
175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
176 | 183 | array($session_id, $data, time()), |
177 | 184 | array('session_id') |
178 | 185 | ); |
186 | + } |
|
179 | 187 | |
180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
190 | 198 | { |
191 | 199 | global $smcFunc; |
192 | 200 | |
193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
194 | - return false; |
|
201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
202 | + return false; |
|
203 | + } |
|
195 | 204 | |
196 | 205 | // Just delete the row... |
197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
217 | 226 | global $modSettings, $smcFunc; |
218 | 227 | |
219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
231 | + } |
|
222 | 232 | |
223 | 233 | // Clean up after yerself ;). |
224 | 234 | $smcFunc['db_query']('', ' |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | { |
33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
34 | 35 | |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $request = $smcFunc['db_query']('', ' |
39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | $smcFunc['db_free_result']($request); |
50 | 52 | |
51 | 53 | // Can they see it - if not approved? |
52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
53 | - isAllowedTo('approve_posts'); |
|
54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
55 | + isAllowedTo('approve_posts'); |
|
56 | + } |
|
54 | 57 | |
55 | 58 | // Permission check! |
56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
59 | 62 | if ($id_member_started == $user_info['id']) |
60 | 63 | { |
61 | 64 | isAllowedTo('move_own'); |
65 | + } else { |
|
66 | + isAllowedTo('move_any'); |
|
62 | 67 | } |
63 | - else |
|
64 | - isAllowedTo('move_any'); |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
83 | 86 | 'not_redirection' => true, |
84 | 87 | ); |
85 | 88 | |
86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
91 | + } |
|
88 | 92 | |
89 | - if (!$context['move_any']) |
|
90 | - $options['included_boards'] = $boards; |
|
93 | + if (!$context['move_any']) { |
|
94 | + $options['included_boards'] = $boards; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
139 | 144 | global $board, $language, $user_info, $smcFunc; |
140 | 145 | |
141 | - if (empty($topic)) |
|
142 | - fatal_lang_error('no_access', false); |
|
146 | + if (empty($topic)) { |
|
147 | + fatal_lang_error('no_access', false); |
|
148 | + } |
|
143 | 149 | |
144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
146 | - fatal_lang_error('movetopic_no_reason', false); |
|
151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
152 | + fatal_lang_error('movetopic_no_reason', false); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | moveTopicConcurrence(); |
149 | 156 | |
@@ -163,8 +170,9 @@ discard block |
||
163 | 170 | $smcFunc['db_free_result']($request); |
164 | 171 | |
165 | 172 | // Can they see it? |
166 | - if (!$context['is_approved']) |
|
167 | - isAllowedTo('approve_posts'); |
|
173 | + if (!$context['is_approved']) { |
|
174 | + isAllowedTo('approve_posts'); |
|
175 | + } |
|
168 | 176 | |
169 | 177 | // Can they move topics on this board? |
170 | 178 | if (!allowedTo('move_any')) |
@@ -173,12 +181,12 @@ discard block |
||
173 | 181 | { |
174 | 182 | isAllowedTo('move_own'); |
175 | 183 | $boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any')); |
184 | + } else { |
|
185 | + isAllowedTo('move_any'); |
|
176 | 186 | } |
177 | - else |
|
178 | - isAllowedTo('move_any'); |
|
187 | + } else { |
|
188 | + $boards = boardsAllowedTo('move_any'); |
|
179 | 189 | } |
180 | - else |
|
181 | - $boards = boardsAllowedTo('move_any'); |
|
182 | 190 | |
183 | 191 | // If this topic isn't approved don't let them move it if they can't approve it! |
184 | 192 | if ($modSettings['postmod_active'] && !$context['is_approved'] && !allowedTo('approve_posts')) |
@@ -210,8 +218,9 @@ discard block |
||
210 | 218 | 'blank_redirect' => '', |
211 | 219 | ) |
212 | 220 | ); |
213 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
214 | - fatal_lang_error('no_board'); |
|
221 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
222 | + fatal_lang_error('no_board'); |
|
223 | + } |
|
215 | 224 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
216 | 225 | $smcFunc['db_free_result']($request); |
217 | 226 | |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | { |
224 | 233 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
225 | 234 | // Keep checking the length. |
226 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
227 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
235 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
236 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // If it's still valid move onwards and upwards. |
230 | 240 | if ($_POST['custom_subject'] != '') |
@@ -234,9 +244,9 @@ discard block |
||
234 | 244 | // Get a response prefix, but in the forum's default language. |
235 | 245 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
236 | 246 | { |
237 | - if ($language === $user_info['language']) |
|
238 | - $context['response_prefix'] = $txt['response_prefix']; |
|
239 | - else |
|
247 | + if ($language === $user_info['language']) { |
|
248 | + $context['response_prefix'] = $txt['response_prefix']; |
|
249 | + } else |
|
240 | 250 | { |
241 | 251 | loadLanguage('index', $language, false); |
242 | 252 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -276,8 +286,9 @@ discard block |
||
276 | 286 | if (isset($_POST['postRedirect'])) |
277 | 287 | { |
278 | 288 | // Should be in the boardwide language. |
279 | - if ($user_info['language'] != $language) |
|
280 | - loadLanguage('index', $language); |
|
289 | + if ($user_info['language'] != $language) { |
|
290 | + loadLanguage('index', $language); |
|
291 | + } |
|
281 | 292 | |
282 | 293 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
283 | 294 | preparsecode($_POST['reason']); |
@@ -341,8 +352,9 @@ discard block |
||
341 | 352 | $posters = array(); |
342 | 353 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
343 | 354 | { |
344 | - if (!isset($posters[$row['id_member']])) |
|
345 | - $posters[$row['id_member']] = 0; |
|
355 | + if (!isset($posters[$row['id_member']])) { |
|
356 | + $posters[$row['id_member']] = 0; |
|
357 | + } |
|
346 | 358 | |
347 | 359 | $posters[$row['id_member']]++; |
348 | 360 | } |
@@ -351,11 +363,13 @@ discard block |
||
351 | 363 | foreach ($posters as $id_member => $posts) |
352 | 364 | { |
353 | 365 | // The board we're moving from counted posts, but not to. |
354 | - if (empty($pcounter_from)) |
|
355 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
366 | + if (empty($pcounter_from)) { |
|
367 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
368 | + } |
|
356 | 369 | // The reverse: from didn't, to did. |
357 | - else |
|
358 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
370 | + else { |
|
371 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
372 | + } |
|
359 | 373 | } |
360 | 374 | } |
361 | 375 | |
@@ -363,17 +377,19 @@ discard block |
||
363 | 377 | moveTopics($topic, $_POST['toboard']); |
364 | 378 | |
365 | 379 | // Log that they moved this topic. |
366 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
367 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
380 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
381 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
382 | + } |
|
368 | 383 | // Notify people that this topic has been moved? |
369 | 384 | sendNotifications($topic, 'move'); |
370 | 385 | |
371 | 386 | // Why not go back to the original board in case they want to keep moving? |
372 | - if (!isset($_REQUEST['goback'])) |
|
373 | - redirectexit('board=' . $board . '.0'); |
|
374 | - else |
|
375 | - redirectexit('topic=' . $topic . '.0'); |
|
376 | -} |
|
387 | + if (!isset($_REQUEST['goback'])) { |
|
388 | + redirectexit('board=' . $board . '.0'); |
|
389 | + } else { |
|
390 | + redirectexit('topic=' . $topic . '.0'); |
|
391 | + } |
|
392 | + } |
|
377 | 393 | |
378 | 394 | /** |
379 | 395 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -389,18 +405,21 @@ discard block |
||
389 | 405 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
390 | 406 | |
391 | 407 | // Empty array? |
392 | - if (empty($topics)) |
|
393 | - return; |
|
408 | + if (empty($topics)) { |
|
409 | + return; |
|
410 | + } |
|
394 | 411 | |
395 | 412 | // Only a single topic. |
396 | - if (is_numeric($topics)) |
|
397 | - $topics = array($topics); |
|
413 | + if (is_numeric($topics)) { |
|
414 | + $topics = array($topics); |
|
415 | + } |
|
398 | 416 | $num_topics = count($topics); |
399 | 417 | $fromBoards = array(); |
400 | 418 | |
401 | 419 | // Destination board empty or equal to 0? |
402 | - if (empty($toBoard)) |
|
403 | - return; |
|
420 | + if (empty($toBoard)) { |
|
421 | + return; |
|
422 | + } |
|
404 | 423 | |
405 | 424 | // Are we moving to the recycle board? |
406 | 425 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -408,8 +427,9 @@ discard block |
||
408 | 427 | // Callback for search APIs to do their thing |
409 | 428 | require_once($sourcedir . '/Search.php'); |
410 | 429 | $searchAPI = findSearchAPI(); |
411 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
412 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
430 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
431 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
432 | + } |
|
413 | 433 | |
414 | 434 | // Determine the source boards... |
415 | 435 | $request = $smcFunc['db_query']('', ' |
@@ -423,8 +443,9 @@ discard block |
||
423 | 443 | ) |
424 | 444 | ); |
425 | 445 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
426 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
427 | - return; |
|
446 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
447 | + return; |
|
448 | + } |
|
428 | 449 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
429 | 450 | { |
430 | 451 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -442,10 +463,11 @@ discard block |
||
442 | 463 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
443 | 464 | |
444 | 465 | // Add the topics to the right type. |
445 | - if ($row['approved']) |
|
446 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
447 | - else |
|
448 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
466 | + if ($row['approved']) { |
|
467 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
468 | + } else { |
|
469 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
470 | + } |
|
449 | 471 | } |
450 | 472 | $smcFunc['db_free_result']($request); |
451 | 473 | |
@@ -571,13 +593,14 @@ discard block |
||
571 | 593 | ) |
572 | 594 | ); |
573 | 595 | $approval_msgs = array(); |
574 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
575 | - $approval_msgs[] = $row['id_msg']; |
|
596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
597 | + $approval_msgs[] = $row['id_msg']; |
|
598 | + } |
|
576 | 599 | $smcFunc['db_free_result']($request); |
577 | 600 | |
578 | 601 | // Empty the approval queue for these, as we're going to approve them next. |
579 | - if (!empty($approval_msgs)) |
|
580 | - $smcFunc['db_query']('', ' |
|
602 | + if (!empty($approval_msgs)) { |
|
603 | + $smcFunc['db_query']('', ' |
|
581 | 604 | DELETE FROM {db_prefix}approval_queue |
582 | 605 | WHERE id_msg IN ({array_int:message_list}) |
583 | 606 | AND id_attach = {int:id_attach}', |
@@ -586,6 +609,7 @@ discard block |
||
586 | 609 | 'id_attach' => 0, |
587 | 610 | ) |
588 | 611 | ); |
612 | + } |
|
589 | 613 | |
590 | 614 | // Get all the current max and mins. |
591 | 615 | $request = $smcFunc['db_query']('', ' |
@@ -619,8 +643,8 @@ discard block |
||
619 | 643 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
620 | 644 | { |
621 | 645 | // If not, update. |
622 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
623 | - $smcFunc['db_query']('', ' |
|
646 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
647 | + $smcFunc['db_query']('', ' |
|
624 | 648 | UPDATE {db_prefix}topics |
625 | 649 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
626 | 650 | WHERE id_topic = {int:selected_topic}', |
@@ -630,6 +654,7 @@ discard block |
||
630 | 654 | 'selected_topic' => $row['id_topic'], |
631 | 655 | ) |
632 | 656 | ); |
657 | + } |
|
633 | 658 | } |
634 | 659 | $smcFunc['db_free_result']($request); |
635 | 660 | } |
@@ -688,9 +713,10 @@ discard block |
||
688 | 713 | } |
689 | 714 | |
690 | 715 | // Update the cache? |
691 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
692 | - foreach ($topics as $topic_id) |
|
716 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
717 | + foreach ($topics as $topic_id) |
|
693 | 718 | cache_put_data('topic_board-' . $topic_id, null, 120); |
719 | + } |
|
694 | 720 | |
695 | 721 | require_once($sourcedir . '/Subs-Post.php'); |
696 | 722 | |
@@ -714,15 +740,17 @@ discard block |
||
714 | 740 | { |
715 | 741 | global $board, $topic, $smcFunc, $scripturl; |
716 | 742 | |
717 | - if (isset($_GET['current_board'])) |
|
718 | - $move_from = (int) $_GET['current_board']; |
|
743 | + if (isset($_GET['current_board'])) { |
|
744 | + $move_from = (int) $_GET['current_board']; |
|
745 | + } |
|
719 | 746 | |
720 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
721 | - return true; |
|
747 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
748 | + return true; |
|
749 | + } |
|
722 | 750 | |
723 | - if ($move_from == $board) |
|
724 | - return true; |
|
725 | - else |
|
751 | + if ($move_from == $board) { |
|
752 | + return true; |
|
753 | + } else |
|
726 | 754 | { |
727 | 755 | $request = $smcFunc['db_query']('', ' |
728 | 756 | SELECT m.subject, b.name |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => true, |
32 | 33 | ); |
33 | -} |
|
34 | + } |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /** |
36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
54 | 56 | { |
55 | 57 | global $smcFunc; |
56 | 58 | |
57 | - if ($size == 'small') |
|
58 | - $size = 'smallint(5)'; |
|
59 | - elseif ($size == 'medium') |
|
60 | - $size = 'mediumint(8)'; |
|
61 | - else |
|
62 | - $size = 'int(10)'; |
|
59 | + if ($size == 'small') { |
|
60 | + $size = 'smallint(5)'; |
|
61 | + } elseif ($size == 'medium') { |
|
62 | + $size = 'mediumint(8)'; |
|
63 | + } else { |
|
64 | + $size = 'int(10)'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | $smcFunc['db_query']('', ' |
65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | is_not_guest(); |
35 | 36 | |
36 | 37 | // You have to specify a board to turn notifications on! |
37 | - if (empty($board)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($board)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // No subaction: find out what to do. |
41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
50 | 52 | |
51 | - if ($mode > 1) |
|
52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | + if ($mode > 1) { |
|
54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | 55 | $smcFunc['db_insert']('ignore', |
54 | 56 | '{db_prefix}log_notify', |
55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
56 | 58 | array($user_info['id'], $board), |
57 | 59 | array('id_member', 'id_board') |
58 | 60 | ); |
59 | - else |
|
60 | - $smcFunc['db_query']('', ' |
|
61 | + } else { |
|
62 | + $smcFunc['db_query']('', ' |
|
61 | 63 | DELETE FROM {db_prefix}log_notify |
62 | 64 | WHERE id_member = {int:current_member} |
63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
66 | 68 | 'current_member' => $user_info['id'], |
67 | 69 | ) |
68 | 70 | ); |
71 | + } |
|
69 | 72 | |
70 | 73 | } |
71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
81 | 84 | ), |
82 | 85 | ); |
83 | 86 | $context['sub_template'] = 'generic_xml'; |
87 | + } else { |
|
88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
89 | + } |
|
84 | 90 | } |
85 | - else |
|
86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
87 | -} |
|
88 | 91 | |
89 | 92 | /** |
90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
108 | 111 | $mode = (int) $_GET['mode']; |
109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
110 | 113 | |
111 | - if (empty($mode)) |
|
112 | - $mode = 1; |
|
114 | + if (empty($mode)) { |
|
115 | + $mode = 1; |
|
116 | + } |
|
113 | 117 | |
114 | 118 | $request = $smcFunc['db_query']('', ' |
115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
132 | 136 | 'id_msg' => 0, |
133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
134 | 138 | ); |
135 | - } |
|
136 | - else |
|
139 | + } else |
|
137 | 140 | { |
138 | 141 | $insert = false; |
139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
160 | 163 | array($user_info['id'], $log['id_topic']), |
161 | 164 | array('id_member', 'id_board') |
162 | 165 | ); |
163 | - } |
|
164 | - else |
|
165 | - $smcFunc['db_query']('', ' |
|
166 | + } else { |
|
167 | + $smcFunc['db_query']('', ' |
|
166 | 168 | DELETE FROM {db_prefix}log_notify |
167 | 169 | WHERE id_topic = {int:topic} |
168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | 'topic' => $log['id_topic'], |
171 | 173 | 'member' => $user_info['id'], |
172 | 174 | )); |
175 | + } |
|
173 | 176 | |
174 | 177 | } |
175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
186 | 189 | ), |
187 | 190 | ); |
188 | 191 | $context['sub_template'] = 'generic_xml'; |
192 | + } else { |
|
193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
194 | + } |
|
189 | 195 | } |
190 | - else |
|
191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
192 | -} |
|
193 | 196 | |
194 | 197 | ?> |
195 | 198 | \ No newline at end of file |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
105 | 105 | |
106 | 106 | if (!empty($modSettings['automanage_attachments'])) |
107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
107 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
108 | 108 | |
109 | 109 | else |
110 | 110 | $context['valid_basedirectory'] = true; |
111 | 111 | |
112 | 112 | // A bit of razzle dazzle with the $txt strings. :) |
113 | 113 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
114 | - $txt['basedirectory_for_attachments_path']= isset($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
|
114 | + $txt['basedirectory_for_attachments_path'] = isset($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
|
115 | 115 | $txt['use_subdirectories_for_attachments_note'] = empty($modSettings['attachment_basedirectories']) || empty($modSettings['use_subdirectories_for_attachments']) ? $txt['use_subdirectories_for_attachments_note'] : ''; |
116 | 116 | $txt['attachmentUploadDir_multiple_configure'] = '<a href="' . $scripturl . '?action=admin;area=manageattachments;sa=attachpaths">[' . $txt['attachmentUploadDir_multiple_configure'] . ']</a>'; |
117 | 117 | $txt['attach_current_dir'] = empty($modSettings['automanage_attachments']) ? $txt['attach_current_dir'] : $txt['attach_last_dir']; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | array('select', 'automanage_attachments', array(0 => $txt['attachments_normal'], 1 => $txt['attachments_auto_space'], 2 => $txt['attachments_auto_years'], 3 => $txt['attachments_auto_months'], 4 => $txt['attachments_auto_16'])), |
137 | 137 | array('check', 'use_subdirectories_for_attachments', 'subtext' => $txt['use_subdirectories_for_attachments_note']), |
138 | 138 | (empty($modSettings['attachment_basedirectories']) ? array('text', 'basedirectory_for_attachments', 40,) : array('var_message', 'basedirectory_for_attachments', 'message' => 'basedirectory_for_attachments_path', 'invalid' => empty($context['valid_basedirectory']), 'text_label' => (!empty($context['valid_basedirectory']) ? $txt['basedirectory_for_attachments_current'] : $txt['basedirectory_for_attachments_warning']))), |
139 | - empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1 ? array('json', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir'], 'disabled' => true) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])), |
|
139 | + empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1 ? array('json', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir'], 'disabled' => true) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])), |
|
140 | 140 | array('int', 'attachmentDirFileLimit', 'subtext' => $txt['zero_for_no_limit'], 6), |
141 | 141 | array('int', 'attachmentDirSizeLimit', 'subtext' => $txt['zero_for_no_limit'], 6, 'postinput' => $txt['kilobyte']), |
142 | 142 | array('check', 'dont_show_attach_under_post', 'subtext' => $txt['dont_show_attach_under_post_sub']), |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | |
350 | 350 | // These settings cannot be left empty! |
351 | 351 | if (empty($_POST['custom_avatar_dir'])) |
352 | - $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
352 | + $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
353 | 353 | |
354 | 354 | if (empty($_POST['custom_avatar_url'])) |
355 | - $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
355 | + $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
356 | 356 | |
357 | 357 | if (empty($_POST['avatar_directory'])) |
358 | - $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
358 | + $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
359 | 359 | |
360 | 360 | if (empty($_POST['avatar_url'])) |
361 | - $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
361 | + $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
362 | 362 | |
363 | 363 | call_integration_hook('integrate_save_avatar_settings'); |
364 | 364 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | 'items_per_page' => $modSettings['defaultMaxListItems'], |
423 | 423 | 'base_href' => $scripturl . '?action=admin;area=manageattachments;sa=browse' . ($context['browse_type'] === 'avatars' ? ';avatars' : ($context['browse_type'] === 'thumbs' ? ';thumbs' : '')), |
424 | 424 | 'default_sort_col' => 'name', |
425 | - 'no_items_label' => $txt['attachment_manager_' . ($context['browse_type'] === 'avatars' ? 'avatars' : ( $context['browse_type'] === 'thumbs' ? 'thumbs' : 'attachments')) . '_no_entries'], |
|
425 | + 'no_items_label' => $txt['attachment_manager_' . ($context['browse_type'] === 'avatars' ? 'avatars' : ($context['browse_type'] === 'thumbs' ? 'thumbs' : 'attachments')) . '_no_entries'], |
|
426 | 426 | 'get_items' => array( |
427 | 427 | 'function' => 'list_getFiles', |
428 | 428 | 'params' => array( |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | 'value' => $txt['attachment_name'], |
442 | 442 | ), |
443 | 443 | 'data' => array( |
444 | - 'function' => function ($rowData) use ($modSettings, $context, $scripturl, $smcFunc) |
|
444 | + 'function' => function($rowData) use ($modSettings, $context, $scripturl, $smcFunc) |
|
445 | 445 | { |
446 | 446 | $link = '<a href="'; |
447 | 447 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | 'value' => $txt['attachment_file_size'], |
483 | 483 | ), |
484 | 484 | 'data' => array( |
485 | - 'function' => function ($rowData) use ($txt) |
|
485 | + 'function' => function($rowData) use ($txt) |
|
486 | 486 | { |
487 | 487 | return sprintf('%1$s%2$s', round($rowData['size'] / 1024, 2), $txt['kilobyte']); |
488 | 488 | }, |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | 'value' => $context['browse_type'] == 'avatars' ? $txt['attachment_manager_member'] : $txt['posted_by'], |
498 | 498 | ), |
499 | 499 | 'data' => array( |
500 | - 'function' => function ($rowData) use ($scripturl, $smcFunc) |
|
500 | + 'function' => function($rowData) use ($scripturl, $smcFunc) |
|
501 | 501 | { |
502 | 502 | // In case of an attachment, return the poster of the attachment. |
503 | 503 | if (empty($rowData['id_member'])) |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | 'value' => $context['browse_type'] == 'avatars' ? $txt['attachment_manager_last_active'] : $txt['date'], |
519 | 519 | ), |
520 | 520 | 'data' => array( |
521 | - 'function' => function ($rowData) use ($txt, $context, $scripturl) |
|
521 | + 'function' => function($rowData) use ($txt, $context, $scripturl) |
|
522 | 522 | { |
523 | 523 | // The date the message containing the attachment was posted or the owner of the avatar was active. |
524 | 524 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1337 | 1337 | { |
1338 | 1338 | // Get the attachment name with out the folder. |
1339 | - $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat'; |
|
1339 | + $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat'; |
|
1340 | 1340 | |
1341 | 1341 | // Loop through the other folders. |
1342 | 1342 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
@@ -1952,7 +1952,7 @@ discard block |
||
1952 | 1952 | if (automanage_attachments_create_directory($path)) |
1953 | 1953 | $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
1954 | 1954 | else |
1955 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
1955 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
1956 | 1956 | } |
1957 | 1957 | |
1958 | 1958 | // Changing a directory name? |
@@ -2074,7 +2074,7 @@ discard block |
||
2074 | 2074 | } |
2075 | 2075 | |
2076 | 2076 | // If the user wishes to go back, update the last_dir array |
2077 | - if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
|
2077 | + if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
|
2078 | 2078 | { |
2079 | 2079 | if (!is_array($modSettings['last_attachments_directory'])) |
2080 | 2080 | $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | $use_subdirectories_for_attachments = 0; |
2088 | 2088 | if (!empty($modSettings['attachment_basedirectories'])) |
2089 | 2089 | foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
2090 | - if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false) |
|
2090 | + if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false) |
|
2091 | 2091 | { |
2092 | 2092 | $use_subdirectories_for_attachments = 1; |
2093 | 2093 | break; |
@@ -2263,7 +2263,7 @@ discard block |
||
2263 | 2263 | 'class' => 'centercol', |
2264 | 2264 | ), |
2265 | 2265 | 'data' => array( |
2266 | - 'function' => function ($rowData) |
|
2266 | + 'function' => function($rowData) |
|
2267 | 2267 | { |
2268 | 2268 | return '<input type="radio" name="current_dir" value="' . $rowData['id'] . '"' . ($rowData['current'] ? ' checked' : '') . (!empty($rowData['disable_current']) ? ' disabled' : '') . ' class="input_radio">'; |
2269 | 2269 | }, |
@@ -2276,7 +2276,7 @@ discard block |
||
2276 | 2276 | 'value' => $txt['attach_path'], |
2277 | 2277 | ), |
2278 | 2278 | 'data' => array( |
2279 | - 'function' => function ($rowData) |
|
2279 | + 'function' => function($rowData) |
|
2280 | 2280 | { |
2281 | 2281 | return '<input type="hidden" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"><input type="text" size="40" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"' . (!empty($rowData['disable_base_dir']) ? ' disabled' : '') . ' class="input_text" style="width: 100%">'; |
2282 | 2282 | }, |
@@ -2355,7 +2355,7 @@ discard block |
||
2355 | 2355 | 'class' => 'centercol', |
2356 | 2356 | ), |
2357 | 2357 | 'data' => array( |
2358 | - 'function' => function ($rowData) |
|
2358 | + 'function' => function($rowData) |
|
2359 | 2359 | { |
2360 | 2360 | return '<input type="radio" name="current_base_dir" value="' . $rowData['id'] . '"' . ($rowData['current'] ? ' checked' : '') . ' class="input_radio">'; |
2361 | 2361 | }, |
@@ -2726,7 +2726,7 @@ discard block |
||
2726 | 2726 | $dir_size += !empty($row['size']) ? $row['size'] : filesize($source); |
2727 | 2727 | |
2728 | 2728 | // If we've reached a limit. Do something. |
2729 | - if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files > $modSettings['attachmentDirFileLimit'])) |
|
2729 | + if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files > $modSettings['attachmentDirFileLimit'])) |
|
2730 | 2730 | { |
2731 | 2731 | if (!empty($_POST['auto'])) |
2732 | 2732 | { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The main 'Attachments and Avatars' management function. |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | call_integration_hook('integrate_manage_attachments', array(&$subActions)); |
64 | 65 | |
65 | 66 | // Pick the correct sub-action. |
66 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
67 | - $context['sub_action'] = $_REQUEST['sa']; |
|
68 | - else |
|
69 | - $context['sub_action'] = 'browse'; |
|
67 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
68 | + $context['sub_action'] = $_REQUEST['sa']; |
|
69 | + } else { |
|
70 | + $context['sub_action'] = 'browse'; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | // Default page title is good. |
72 | 74 | $context['page_title'] = $txt['attachments_avatars']; |
@@ -94,20 +96,20 @@ discard block |
||
94 | 96 | $context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
95 | 97 | |
96 | 98 | // If not set, show a default path for the base directory |
97 | - if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) |
|
98 | - if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
99 | + if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) { |
|
100 | + if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
99 | 101 | $modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1]; |
100 | - |
|
101 | - else |
|
102 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
102 | + } else { |
|
103 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
105 | 107 | |
106 | - if (!empty($modSettings['automanage_attachments'])) |
|
107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
108 | - |
|
109 | - else |
|
110 | - $context['valid_basedirectory'] = true; |
|
108 | + if (!empty($modSettings['automanage_attachments'])) { |
|
109 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
110 | + } else { |
|
111 | + $context['valid_basedirectory'] = true; |
|
112 | + } |
|
111 | 113 | |
112 | 114 | // A bit of razzle dazzle with the $txt strings. :) |
113 | 115 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
@@ -185,8 +187,9 @@ discard block |
||
185 | 187 | |
186 | 188 | call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); |
187 | 189 | |
188 | - if ($return_config) |
|
189 | - return $config_vars; |
|
190 | + if ($return_config) { |
|
191 | + return $config_vars; |
|
192 | + } |
|
190 | 193 | |
191 | 194 | // These are very likely to come in handy! (i.e. without them we're doomed!) |
192 | 195 | require_once($sourcedir . '/ManagePermissions.php'); |
@@ -197,21 +200,24 @@ discard block |
||
197 | 200 | { |
198 | 201 | checkSession(); |
199 | 202 | |
200 | - if (isset($_POST['attachmentUploadDir'])) |
|
201 | - unset($_POST['attachmentUploadDir']); |
|
203 | + if (isset($_POST['attachmentUploadDir'])) { |
|
204 | + unset($_POST['attachmentUploadDir']); |
|
205 | + } |
|
202 | 206 | |
203 | 207 | if (!empty($_POST['use_subdirectories_for_attachments'])) |
204 | 208 | { |
205 | - if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) |
|
206 | - $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
209 | + if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) { |
|
210 | + $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
211 | + } |
|
207 | 212 | |
208 | 213 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) |
209 | 214 | { |
210 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
211 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
216 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
217 | + } |
|
218 | + } else { |
|
219 | + $modSettings['attachment_basedirectories'] = array(); |
|
212 | 220 | } |
213 | - else |
|
214 | - $modSettings['attachment_basedirectories'] = array(); |
|
215 | 221 | |
216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | |
220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
221 | 227 | { |
222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
230 | + } |
|
224 | 231 | } |
225 | 232 | |
226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
336 | 343 | |
337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
338 | 345 | |
339 | - if ($return_config) |
|
340 | - return $config_vars; |
|
346 | + if ($return_config) { |
|
347 | + return $config_vars; |
|
348 | + } |
|
341 | 349 | |
342 | 350 | // We need this file for the settings template. |
343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
348 | 356 | checkSession(); |
349 | 357 | |
350 | 358 | // These settings cannot be left empty! |
351 | - if (empty($_POST['custom_avatar_dir'])) |
|
352 | - $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
360 | + $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
361 | + } |
|
353 | 362 | |
354 | - if (empty($_POST['custom_avatar_url'])) |
|
355 | - $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
363 | + if (empty($_POST['custom_avatar_url'])) { |
|
364 | + $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
365 | + } |
|
356 | 366 | |
357 | - if (empty($_POST['avatar_directory'])) |
|
358 | - $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
367 | + if (empty($_POST['avatar_directory'])) { |
|
368 | + $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
369 | + } |
|
359 | 370 | |
360 | - if (empty($_POST['avatar_url'])) |
|
361 | - $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
371 | + if (empty($_POST['avatar_url'])) { |
|
372 | + $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
373 | + } |
|
362 | 374 | |
363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
407 | 419 | foreach ($titles as $browse_type => $details) |
408 | 420 | { |
409 | - if ($browse_type != 'attachments') |
|
410 | - $list_title .= ' | '; |
|
421 | + if ($browse_type != 'attachments') { |
|
422 | + $list_title .= ' | '; |
|
423 | + } |
|
411 | 424 | |
412 | - if ($context['browse_type'] == $browse_type) |
|
413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
425 | + if ($context['browse_type'] == $browse_type) { |
|
426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
427 | + } |
|
414 | 428 | |
415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
446 | 460 | $link = '<a href="'; |
447 | 461 | |
448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
449 | - if ($rowData['attachment_type'] == 1) |
|
450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
463 | + if ($rowData['attachment_type'] == 1) { |
|
464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
465 | + } |
|
451 | 466 | |
452 | 467 | // By default avatars are downloaded almost as attachments. |
453 | - elseif ($context['browse_type'] == 'avatars') |
|
454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
468 | + elseif ($context['browse_type'] == 'avatars') { |
|
469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
470 | + } |
|
455 | 471 | |
456 | 472 | // Normal attachments are always linked to a topic ID. |
457 | - else |
|
458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
473 | + else { |
|
474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
475 | + } |
|
459 | 476 | |
460 | 477 | $link .= '"'; |
461 | 478 | |
462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
482 | + } |
|
465 | 483 | |
466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
467 | 485 | |
468 | 486 | // Show the dimensions. |
469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
489 | + } |
|
471 | 490 | |
472 | 491 | return $link; |
473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
500 | 519 | 'function' => function ($rowData) use ($scripturl, $smcFunc) |
501 | 520 | { |
502 | 521 | // In case of an attachment, return the poster of the attachment. |
503 | - if (empty($rowData['id_member'])) |
|
504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
522 | + if (empty($rowData['id_member'])) { |
|
523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
524 | + } |
|
505 | 525 | |
506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
507 | - else |
|
508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
527 | + else { |
|
528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
529 | + } |
|
509 | 530 | }, |
510 | 531 | ), |
511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
525 | 546 | |
526 | 547 | // Add a link to the topic in case of an attachment. |
527 | - if ($context['browse_type'] !== 'avatars') |
|
528 | - $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
548 | + if ($context['browse_type'] !== 'avatars') { |
|
549 | + $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
550 | + } |
|
529 | 551 | |
530 | 552 | return $date; |
531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
610 | 632 | global $smcFunc, $txt; |
611 | 633 | |
612 | 634 | // Choose a query depending on what we are viewing. |
613 | - if ($browse_type === 'avatars') |
|
614 | - $request = $smcFunc['db_query']('', ' |
|
635 | + if ($browse_type === 'avatars') { |
|
636 | + $request = $smcFunc['db_query']('', ' |
|
615 | 637 | SELECT |
616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
630 | 652 | 'per_page' => $items_per_page, |
631 | 653 | ) |
632 | 654 | ); |
633 | - else |
|
634 | - $request = $smcFunc['db_query']('', ' |
|
655 | + } else { |
|
656 | + $request = $smcFunc['db_query']('', ' |
|
635 | 657 | SELECT |
636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
650 | 672 | 'per_page' => $items_per_page, |
651 | 673 | ) |
652 | 674 | ); |
675 | + } |
|
653 | 676 | $files = array(); |
654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
655 | - $files[] = $row; |
|
677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
678 | + $files[] = $row; |
|
679 | + } |
|
656 | 680 | $smcFunc['db_free_result']($request); |
657 | 681 | |
658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
670 | 694 | global $smcFunc; |
671 | 695 | |
672 | 696 | // Depending on the type of file, different queries are used. |
673 | - if ($browse_type === 'avatars') |
|
674 | - $request = $smcFunc['db_query']('', ' |
|
697 | + if ($browse_type === 'avatars') { |
|
698 | + $request = $smcFunc['db_query']('', ' |
|
675 | 699 | SELECT COUNT(*) |
676 | 700 | FROM {db_prefix}attachments |
677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
679 | 703 | 'guest_id_member' => 0, |
680 | 704 | ) |
681 | 705 | ); |
682 | - else |
|
683 | - $request = $smcFunc['db_query']('', ' |
|
706 | + } else { |
|
707 | + $request = $smcFunc['db_query']('', ' |
|
684 | 708 | SELECT COUNT(*) AS num_attach |
685 | 709 | FROM {db_prefix}attachments AS a |
686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
693 | 717 | 'guest_id_member' => 0, |
694 | 718 | ) |
695 | 719 | ); |
720 | + } |
|
696 | 721 | |
697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
775 | 800 | $current_dir_size /= 1024; |
776 | 801 | |
777 | 802 | // If they specified a limit only.... |
778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
805 | + } |
|
780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
781 | 807 | |
782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
810 | + } |
|
784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
785 | 812 | |
786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
818 | 845 | |
819 | 846 | // Update the messages to reflect the change. |
820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
821 | - $smcFunc['db_query']('', ' |
|
847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
848 | + $smcFunc['db_query']('', ' |
|
822 | 849 | UPDATE {db_prefix}messages |
823 | 850 | SET body = CONCAT(body, {string:notice}) |
824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
828 | 855 | ) |
829 | 856 | ); |
830 | - } |
|
831 | - else |
|
857 | + } |
|
858 | + } else |
|
832 | 859 | { |
833 | 860 | // Remove all the old avatars. |
834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
854 | 881 | |
855 | 882 | // And make a note on the post. |
856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
857 | - $smcFunc['db_query']('', ' |
|
883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
884 | + $smcFunc['db_query']('', ' |
|
858 | 885 | UPDATE {db_prefix}messages |
859 | 886 | SET body = CONCAT(body, {string:notice}) |
860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
864 | 891 | ) |
865 | 892 | ); |
893 | + } |
|
866 | 894 | |
867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
882 | 910 | { |
883 | 911 | $attachments = array(); |
884 | 912 | // There must be a quicker way to pass this safety test?? |
885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
886 | - $attachments[] = (int) $removeID; |
|
913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
914 | + $attachments[] = (int) $removeID; |
|
915 | + } |
|
887 | 916 | |
888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
889 | 918 | $filesRemoved = false; |
890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
891 | 920 | |
892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
893 | - removeAttachments(array('id_attach' => $attachments)); |
|
894 | - else if (!empty($attachments)) |
|
921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
922 | + removeAttachments(array('id_attach' => $attachments)); |
|
923 | + } else if (!empty($attachments)) |
|
895 | 924 | { |
896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
930 | 959 | |
931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
932 | 961 | |
933 | - if (!isset($_POST['notice'])) |
|
934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
962 | + if (!isset($_POST['notice'])) { |
|
963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
964 | + } |
|
935 | 965 | |
936 | 966 | // Add the notice on the end of the changed messages. |
937 | - if (!empty($messages)) |
|
938 | - $smcFunc['db_query']('', ' |
|
967 | + if (!empty($messages)) { |
|
968 | + $smcFunc['db_query']('', ' |
|
939 | 969 | UPDATE {db_prefix}messages |
940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
945 | 975 | ) |
946 | 976 | ); |
977 | + } |
|
947 | 978 | |
948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
984 | 1015 | |
985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
987 | - elseif ($type == 'attachment_type') |
|
988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
989 | - elseif ($type == 'poster_time') |
|
990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
991 | - elseif ($type == 'last_login') |
|
992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
993 | - elseif ($type == 'size') |
|
994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
995 | - elseif ($type == 'id_topic') |
|
996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1018 | + } elseif ($type == 'attachment_type') { |
|
1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
1020 | + } elseif ($type == 'poster_time') { |
|
1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
1022 | + } elseif ($type == 'last_login') { |
|
1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
1024 | + } elseif ($type == 'size') { |
|
1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
1026 | + } elseif ($type == 'id_topic') { |
|
1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1028 | + } |
|
997 | 1029 | |
998 | 1030 | // Add the parameter! |
999 | 1031 | $query_parameter[$real_type] = $restriction; |
1000 | 1032 | |
1001 | - if ($type == 'do_logging') |
|
1002 | - $do_logging = $condition['id_attach']; |
|
1033 | + if ($type == 'do_logging') { |
|
1034 | + $do_logging = $condition['id_attach']; |
|
1035 | + } |
|
1003 | 1036 | } |
1004 | 1037 | $condition = implode(' AND ', $new_condition); |
1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
1031 | 1064 | // wasn't it obvious? :P |
1032 | 1065 | // @todo look again at this. |
1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
1034 | - } |
|
1035 | - else |
|
1067 | + } else |
|
1036 | 1068 | { |
1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
1038 | 1070 | @unlink($filename); |
1039 | 1071 | |
1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
1041 | - if (!empty($row['id_parent'])) |
|
1042 | - $parents[] = $row['id_parent']; |
|
1073 | + if (!empty($row['id_parent'])) { |
|
1074 | + $parents[] = $row['id_parent']; |
|
1075 | + } |
|
1043 | 1076 | |
1044 | 1077 | // If this attachments has a thumb, remove it as well. |
1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
1051 | 1084 | } |
1052 | 1085 | |
1053 | 1086 | // Make a list. |
1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
1055 | - $msgs[] = $row['id_msg']; |
|
1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
1088 | + $msgs[] = $row['id_msg']; |
|
1089 | + } |
|
1056 | 1090 | |
1057 | 1091 | $attach[] = $row['id_attach']; |
1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
1060 | 1094 | |
1061 | 1095 | // Removed attachments don't have to be updated anymore. |
1062 | 1096 | $parents = array_diff($parents, $attach); |
1063 | - if (!empty($parents)) |
|
1064 | - $smcFunc['db_query']('', ' |
|
1097 | + if (!empty($parents)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1065 | 1099 | UPDATE {db_prefix}attachments |
1066 | 1100 | SET id_thumb = {int:no_thumb} |
1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
1070 | 1104 | 'no_thumb' => 0, |
1071 | 1105 | ) |
1072 | 1106 | ); |
1107 | + } |
|
1073 | 1108 | |
1074 | 1109 | if (!empty($do_logging)) |
1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
1086 | 1121 | ) |
1087 | 1122 | ); |
1088 | 1123 | |
1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1090 | - logAction( |
|
1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1125 | + logAction( |
|
1091 | 1126 | 'remove_attach', |
1092 | 1127 | array( |
1093 | 1128 | 'message' => $row['id_msg'], |
1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
1095 | 1130 | ) |
1096 | 1131 | ); |
1132 | + } |
|
1097 | 1133 | $smcFunc['db_free_result']($request); |
1098 | 1134 | } |
1099 | 1135 | |
1100 | - if (!empty($attach)) |
|
1101 | - $smcFunc['db_query']('', ' |
|
1136 | + if (!empty($attach)) { |
|
1137 | + $smcFunc['db_query']('', ' |
|
1102 | 1138 | DELETE FROM {db_prefix}attachments |
1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
1104 | 1140 | array( |
1105 | 1141 | 'attachment_list' => $attach, |
1106 | 1142 | ) |
1107 | 1143 | ); |
1144 | + } |
|
1108 | 1145 | |
1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
1110 | 1147 | |
1111 | - if ($return_affected_messages) |
|
1112 | - return array_unique($msgs); |
|
1113 | -} |
|
1148 | + if ($return_affected_messages) { |
|
1149 | + return array_unique($msgs); |
|
1150 | + } |
|
1151 | + } |
|
1114 | 1152 | |
1115 | 1153 | /** |
1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
1122 | 1160 | checkSession('get'); |
1123 | 1161 | |
1124 | 1162 | // If we choose cancel, redirect right back. |
1125 | - if (isset($_POST['cancel'])) |
|
1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1163 | + if (isset($_POST['cancel'])) { |
|
1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1165 | + } |
|
1127 | 1166 | |
1128 | 1167 | // Try give us a while to sort this out... |
1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
1140 | 1179 | if (isset($_GET['fixErrors'])) |
1141 | 1180 | { |
1142 | 1181 | // Nothing? |
1143 | - if (empty($_POST['to_fix'])) |
|
1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1182 | + if (empty($_POST['to_fix'])) { |
|
1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1184 | + } |
|
1145 | 1185 | |
1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
1147 | 1187 | // @todo No need to do this I think. |
1148 | - foreach ($_POST['to_fix'] as $value) |
|
1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
1188 | + foreach ($_POST['to_fix'] as $value) { |
|
1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
1190 | + } |
|
1150 | 1191 | } |
1151 | 1192 | } |
1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
1213 | 1254 | } |
1214 | 1255 | } |
1215 | 1256 | } |
1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
1259 | + } |
|
1218 | 1260 | $smcFunc['db_free_result']($result); |
1219 | 1261 | |
1220 | 1262 | // Do we need to delete what we have? |
1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
1222 | - $smcFunc['db_query']('', ' |
|
1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
1264 | + $smcFunc['db_query']('', ' |
|
1223 | 1265 | DELETE FROM {db_prefix}attachments |
1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
1228 | 1270 | 'attachment_type' => 3, |
1229 | 1271 | ) |
1230 | 1272 | ); |
1273 | + } |
|
1231 | 1274 | |
1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
1272 | 1315 | $to_update[] = $row['id_attach']; |
1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
1274 | 1317 | } |
1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
1320 | + } |
|
1277 | 1321 | $smcFunc['db_free_result']($result); |
1278 | 1322 | |
1279 | 1323 | // Do we need to delete what we have? |
1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
1281 | - $smcFunc['db_query']('', ' |
|
1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
1325 | + $smcFunc['db_query']('', ' |
|
1282 | 1326 | UPDATE {db_prefix}attachments |
1283 | 1327 | SET id_thumb = {int:no_thumb} |
1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
1287 | 1331 | 'no_thumb' => 0, |
1288 | 1332 | ) |
1289 | 1333 | ); |
1334 | + } |
|
1290 | 1335 | |
1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1325 | 1370 | { |
1326 | 1371 | // Get the filename. |
1327 | - if ($row['attachment_type'] == 1) |
|
1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1329 | - else |
|
1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1372 | + if ($row['attachment_type'] == 1) { |
|
1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1374 | + } else { |
|
1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1376 | + } |
|
1331 | 1377 | |
1332 | 1378 | // File doesn't exist? |
1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat'; |
1340 | 1386 | |
1341 | 1387 | // Loop through the other folders. |
1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
1344 | 1390 | { |
1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
1392 | + } |
|
1346 | 1393 | $errors_found[] = 'wrong_folder'; |
1347 | 1394 | |
1348 | 1395 | // Are we going to fix this now? |
1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
1350 | - $smcFunc['db_query']('', ' |
|
1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
1397 | + $smcFunc['db_query']('', ' |
|
1351 | 1398 | UPDATE {db_prefix}attachments |
1352 | 1399 | SET id_folder = {int:new_folder} |
1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
1356 | 1403 | 'id_attach' => $row['id_attach'], |
1357 | 1404 | ) |
1358 | 1405 | ); |
1406 | + } |
|
1359 | 1407 | |
1360 | 1408 | continue 2; |
1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
1364 | 1412 | $to_remove[] = $row['id_attach']; |
1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
1367 | - } |
|
1368 | - elseif (filesize($filename) == 0) |
|
1415 | + } elseif (filesize($filename) == 0) |
|
1369 | 1416 | { |
1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
1376 | 1423 | $to_remove[] = $row['id_attach']; |
1377 | 1424 | @unlink($filename); |
1378 | 1425 | } |
1379 | - } |
|
1380 | - elseif (filesize($filename) != $row['size']) |
|
1426 | + } elseif (filesize($filename) != $row['size']) |
|
1381 | 1427 | { |
1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
1398 | 1444 | } |
1399 | 1445 | } |
1400 | 1446 | |
1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
1404 | - $to_fix[] = 'file_size_of_zero'; |
|
1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
1406 | - $to_fix[] = 'file_wrong_size'; |
|
1407 | - if (in_array('wrong_folder', $errors_found)) |
|
1408 | - $to_fix[] = 'wrong_folder'; |
|
1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
1449 | + } |
|
1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
1451 | + $to_fix[] = 'file_size_of_zero'; |
|
1452 | + } |
|
1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
1454 | + $to_fix[] = 'file_wrong_size'; |
|
1455 | + } |
|
1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
1457 | + $to_fix[] = 'wrong_folder'; |
|
1458 | + } |
|
1409 | 1459 | $smcFunc['db_free_result']($result); |
1410 | 1460 | |
1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
1475 | 1525 | // If we are repairing remove the file from disk now. |
1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
1477 | 1527 | { |
1478 | - if ($row['attachment_type'] == 1) |
|
1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1480 | - else |
|
1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1528 | + if ($row['attachment_type'] == 1) { |
|
1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1530 | + } else { |
|
1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1532 | + } |
|
1482 | 1533 | @unlink($filename); |
1483 | 1534 | } |
1484 | 1535 | } |
1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1486 | - $to_fix[] = 'avatar_no_member'; |
|
1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1537 | + $to_fix[] = 'avatar_no_member'; |
|
1538 | + } |
|
1487 | 1539 | $smcFunc['db_free_result']($result); |
1488 | 1540 | |
1489 | 1541 | // Do we need to delete what we have? |
1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
1491 | - $smcFunc['db_query']('', ' |
|
1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
1543 | + $smcFunc['db_query']('', ' |
|
1492 | 1544 | DELETE FROM {db_prefix}attachments |
1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
1499 | 1551 | 'no_msg' => 0, |
1500 | 1552 | ) |
1501 | 1553 | ); |
1554 | + } |
|
1502 | 1555 | |
1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1504 | 1557 | } |
@@ -1554,13 +1607,14 @@ discard block |
||
1554 | 1607 | @unlink($filename); |
1555 | 1608 | } |
1556 | 1609 | } |
1557 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1558 | - $to_fix[] = 'attachment_no_msg'; |
|
1610 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1611 | + $to_fix[] = 'attachment_no_msg'; |
|
1612 | + } |
|
1559 | 1613 | $smcFunc['db_free_result']($result); |
1560 | 1614 | |
1561 | 1615 | // Do we need to delete what we have? |
1562 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
1563 | - $smcFunc['db_query']('', ' |
|
1616 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
1617 | + $smcFunc['db_query']('', ' |
|
1564 | 1618 | DELETE FROM {db_prefix}attachments |
1565 | 1619 | WHERE id_attach IN ({array_int:to_remove}) |
1566 | 1620 | AND id_member = {int:no_member} |
@@ -1571,6 +1625,7 @@ discard block |
||
1571 | 1625 | 'no_msg' => 0, |
1572 | 1626 | ) |
1573 | 1627 | ); |
1628 | + } |
|
1574 | 1629 | |
1575 | 1630 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1576 | 1631 | } |
@@ -1594,8 +1649,9 @@ discard block |
||
1594 | 1649 | { |
1595 | 1650 | while ($file = readdir($dir)) |
1596 | 1651 | { |
1597 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
1598 | - continue; |
|
1652 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
1653 | + continue; |
|
1654 | + } |
|
1599 | 1655 | |
1600 | 1656 | if ($files_checked <= $current_check) |
1601 | 1657 | { |
@@ -1603,8 +1659,9 @@ discard block |
||
1603 | 1659 | if (strpos($file, 'post_tmp_') !== false) |
1604 | 1660 | { |
1605 | 1661 | // Temp file is more than 5 hours old! |
1606 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1607 | - @unlink($attach_dir . '/' . $file); |
|
1662 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1663 | + @unlink($attach_dir . '/' . $file); |
|
1664 | + } |
|
1608 | 1665 | } |
1609 | 1666 | // That should be an attachment, let's check if we have it in the database |
1610 | 1667 | elseif (strpos($file, '_') !== false) |
@@ -1626,8 +1683,7 @@ discard block |
||
1626 | 1683 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1627 | 1684 | { |
1628 | 1685 | @unlink($attach_dir . '/' . $file); |
1629 | - } |
|
1630 | - else |
|
1686 | + } else |
|
1631 | 1687 | { |
1632 | 1688 | $context['repair_errors']['files_without_attachment']++; |
1633 | 1689 | $to_fix[] = 'files_without_attachment'; |
@@ -1635,14 +1691,12 @@ discard block |
||
1635 | 1691 | } |
1636 | 1692 | $smcFunc['db_free_result']($request); |
1637 | 1693 | } |
1638 | - } |
|
1639 | - else |
|
1694 | + } else |
|
1640 | 1695 | { |
1641 | 1696 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1642 | 1697 | { |
1643 | 1698 | @unlink($attach_dir . '/' . $file); |
1644 | - } |
|
1645 | - else |
|
1699 | + } else |
|
1646 | 1700 | { |
1647 | 1701 | $context['repair_errors']['files_without_attachment']++; |
1648 | 1702 | $to_fix[] = 'files_without_attachment'; |
@@ -1651,8 +1705,9 @@ discard block |
||
1651 | 1705 | } |
1652 | 1706 | $current_check++; |
1653 | 1707 | $_GET['substep'] = $current_check; |
1654 | - if ($current_check - $files_checked >= $max_checks) |
|
1655 | - pauseAttachmentMaintenance($to_fix); |
|
1708 | + if ($current_check - $files_checked >= $max_checks) { |
|
1709 | + pauseAttachmentMaintenance($to_fix); |
|
1710 | + } |
|
1656 | 1711 | } |
1657 | 1712 | closedir($dir); |
1658 | 1713 | } |
@@ -1688,12 +1743,14 @@ discard block |
||
1688 | 1743 | |
1689 | 1744 | // Try get more time... |
1690 | 1745 | @set_time_limit(600); |
1691 | - if (function_exists('apache_reset_timeout')) |
|
1692 | - @apache_reset_timeout(); |
|
1746 | + if (function_exists('apache_reset_timeout')) { |
|
1747 | + @apache_reset_timeout(); |
|
1748 | + } |
|
1693 | 1749 | |
1694 | 1750 | // Have we already used our maximum time? |
1695 | - if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
1696 | - return; |
|
1751 | + if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
1752 | + return; |
|
1753 | + } |
|
1697 | 1754 | |
1698 | 1755 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1699 | 1756 | $context['page_title'] = $txt['not_done_title']; |
@@ -1705,10 +1762,11 @@ discard block |
||
1705 | 1762 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
1706 | 1763 | |
1707 | 1764 | // Change these two if more steps are added! |
1708 | - if (empty($max_substep)) |
|
1709 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
1710 | - else |
|
1711 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
1765 | + if (empty($max_substep)) { |
|
1766 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
1767 | + } else { |
|
1768 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
1769 | + } |
|
1712 | 1770 | |
1713 | 1771 | // Never more than 100%! |
1714 | 1772 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1750,15 +1808,17 @@ discard block |
||
1750 | 1808 | 'attachment_type' => 0, |
1751 | 1809 | ) |
1752 | 1810 | ); |
1753 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1754 | - $attachments[] = $row['id_attach']; |
|
1811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1812 | + $attachments[] = $row['id_attach']; |
|
1813 | + } |
|
1755 | 1814 | $smcFunc['db_free_result']($request); |
1815 | + } elseif (!empty($_GET['aid'])) { |
|
1816 | + $attachments[] = (int) $_GET['aid']; |
|
1756 | 1817 | } |
1757 | - elseif (!empty($_GET['aid'])) |
|
1758 | - $attachments[] = (int) $_GET['aid']; |
|
1759 | 1818 | |
1760 | - if (empty($attachments)) |
|
1761 | - fatal_lang_error('no_access', false); |
|
1819 | + if (empty($attachments)) { |
|
1820 | + fatal_lang_error('no_access', false); |
|
1821 | + } |
|
1762 | 1822 | |
1763 | 1823 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
1764 | 1824 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1791,17 +1851,18 @@ discard block |
||
1791 | 1851 | } |
1792 | 1852 | $smcFunc['db_free_result']($request); |
1793 | 1853 | |
1794 | - if (empty($attachments)) |
|
1795 | - fatal_lang_error('no_access', false); |
|
1854 | + if (empty($attachments)) { |
|
1855 | + fatal_lang_error('no_access', false); |
|
1856 | + } |
|
1796 | 1857 | |
1797 | 1858 | // Finally, we are there. Follow through! |
1798 | 1859 | if ($is_approve) |
1799 | 1860 | { |
1800 | 1861 | // Checked and deemed worthy. |
1801 | 1862 | ApproveAttachments($attachments); |
1863 | + } else { |
|
1864 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
1802 | 1865 | } |
1803 | - else |
|
1804 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
1805 | 1866 | |
1806 | 1867 | // Return to the topic.... |
1807 | 1868 | redirectexit($redirect); |
@@ -1817,8 +1878,9 @@ discard block |
||
1817 | 1878 | { |
1818 | 1879 | global $smcFunc; |
1819 | 1880 | |
1820 | - if (empty($attachments)) |
|
1821 | - return 0; |
|
1881 | + if (empty($attachments)) { |
|
1882 | + return 0; |
|
1883 | + } |
|
1822 | 1884 | |
1823 | 1885 | // For safety, check for thumbnails... |
1824 | 1886 | $request = $smcFunc['db_query']('', ' |
@@ -1837,15 +1899,17 @@ discard block |
||
1837 | 1899 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1838 | 1900 | { |
1839 | 1901 | // Update the thumbnail too... |
1840 | - if (!empty($row['id_thumb'])) |
|
1841 | - $attachments[] = $row['id_thumb']; |
|
1902 | + if (!empty($row['id_thumb'])) { |
|
1903 | + $attachments[] = $row['id_thumb']; |
|
1904 | + } |
|
1842 | 1905 | |
1843 | 1906 | $attachments[] = $row['id_attach']; |
1844 | 1907 | } |
1845 | 1908 | $smcFunc['db_free_result']($request); |
1846 | 1909 | |
1847 | - if (empty($attachments)) |
|
1848 | - return 0; |
|
1910 | + if (empty($attachments)) { |
|
1911 | + return 0; |
|
1912 | + } |
|
1849 | 1913 | |
1850 | 1914 | // Approving an attachment is not hard - it's easy. |
1851 | 1915 | $smcFunc['db_query']('', ' |
@@ -1871,14 +1935,15 @@ discard block |
||
1871 | 1935 | ) |
1872 | 1936 | ); |
1873 | 1937 | |
1874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1875 | - logAction( |
|
1938 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1939 | + logAction( |
|
1876 | 1940 | 'approve_attach', |
1877 | 1941 | array( |
1878 | 1942 | 'message' => $row['id_msg'], |
1879 | 1943 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
1880 | 1944 | ) |
1881 | 1945 | ); |
1946 | + } |
|
1882 | 1947 | $smcFunc['db_free_result']($request); |
1883 | 1948 | |
1884 | 1949 | // Remove from the approval queue. |
@@ -1901,11 +1966,11 @@ discard block |
||
1901 | 1966 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
1902 | 1967 | |
1903 | 1968 | // Since this needs to be done eventually. |
1904 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
1905 | - $modSettings['attachment_basedirectories'] = array(); |
|
1906 | - |
|
1907 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
1908 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
1969 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
1970 | + $modSettings['attachment_basedirectories'] = array(); |
|
1971 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
1972 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
1973 | + } |
|
1909 | 1974 | |
1910 | 1975 | $errors = array(); |
1911 | 1976 | |
@@ -1920,8 +1985,9 @@ discard block |
||
1920 | 1985 | { |
1921 | 1986 | $error = ''; |
1922 | 1987 | $id = (int) $id; |
1923 | - if ($id < 1) |
|
1924 | - continue; |
|
1988 | + if ($id < 1) { |
|
1989 | + continue; |
|
1990 | + } |
|
1925 | 1991 | |
1926 | 1992 | // Sorry, these dirs are NOT valid |
1927 | 1993 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1940,8 +2006,7 @@ discard block |
||
1940 | 2006 | { |
1941 | 2007 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
1942 | 2008 | continue; |
1943 | - } |
|
1944 | - elseif (empty($path)) |
|
2009 | + } elseif (empty($path)) |
|
1945 | 2010 | { |
1946 | 2011 | // Ignore this and set $id to one less |
1947 | 2012 | continue; |
@@ -1949,10 +2014,11 @@ discard block |
||
1949 | 2014 | |
1950 | 2015 | // OK, so let's try to create it then. |
1951 | 2016 | require_once($sourcedir . '/Subs-Attachments.php'); |
1952 | - if (automanage_attachments_create_directory($path)) |
|
1953 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
1954 | - else |
|
1955 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
2017 | + if (automanage_attachments_create_directory($path)) { |
|
2018 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2019 | + } else { |
|
2020 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
2021 | + } |
|
1956 | 2022 | } |
1957 | 2023 | |
1958 | 2024 | // Changing a directory name? |
@@ -1965,8 +2031,7 @@ discard block |
||
1965 | 2031 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
1966 | 2032 | $path = $modSettings['attachmentUploadDir'][$id]; |
1967 | 2033 | } |
1968 | - } |
|
1969 | - else |
|
2034 | + } else |
|
1970 | 2035 | { |
1971 | 2036 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
1972 | 2037 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1991,12 +2056,13 @@ discard block |
||
1991 | 2056 | $path = $modSettings['attachmentUploadDir'][$id]; |
1992 | 2057 | |
1993 | 2058 | // It's not a good idea to delete the current directory. |
1994 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
1995 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
2059 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
2060 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
2061 | + } |
|
1996 | 2062 | // Or the current base directory |
1997 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
1998 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
1999 | - else |
|
2063 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
2065 | + } else |
|
2000 | 2066 | { |
2001 | 2067 | // Let's not try to delete a path with files in it. |
2002 | 2068 | $request = $smcFunc['db_query']('', ' |
@@ -2015,17 +2081,18 @@ discard block |
||
2015 | 2081 | if (!empty($modSettings['attachment_basedirectories'])) |
2016 | 2082 | { |
2017 | 2083 | // Count any sub-folders. |
2018 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
2019 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
2084 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
2085 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
2020 | 2086 | $num_attach++; |
2087 | + } |
|
2021 | 2088 | } |
2022 | 2089 | |
2023 | 2090 | // It's safe to delete. So try to delete the folder also |
2024 | 2091 | if ($num_attach == 0) |
2025 | 2092 | { |
2026 | - if (is_dir($path)) |
|
2027 | - $doit = true; |
|
2028 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
2093 | + if (is_dir($path)) { |
|
2094 | + $doit = true; |
|
2095 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
2029 | 2096 | { |
2030 | 2097 | $doit = true; |
2031 | 2098 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2035,8 +2102,9 @@ discard block |
||
2035 | 2102 | { |
2036 | 2103 | unlink($path . '/.htaccess'); |
2037 | 2104 | unlink($path . '/index.php'); |
2038 | - if (!@rmdir($path)) |
|
2039 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
2105 | + if (!@rmdir($path)) { |
|
2106 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
2107 | + } |
|
2040 | 2108 | } |
2041 | 2109 | |
2042 | 2110 | // Remove it from the base directory list. |
@@ -2046,14 +2114,15 @@ discard block |
||
2046 | 2114 | updateSettings(array('attachment_basedirectories' => json_encode($modSettings['attachment_basedirectories']))); |
2047 | 2115 | $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
2048 | 2116 | } |
2117 | + } else { |
|
2118 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
2049 | 2119 | } |
2050 | - else |
|
2051 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
2052 | 2120 | |
2053 | - if (empty($error)) |
|
2054 | - continue; |
|
2055 | - else |
|
2056 | - $errors[] = $error; |
|
2121 | + if (empty($error)) { |
|
2122 | + continue; |
|
2123 | + } else { |
|
2124 | + $errors[] = $error; |
|
2125 | + } |
|
2057 | 2126 | } |
2058 | 2127 | } |
2059 | 2128 | |
@@ -2061,23 +2130,26 @@ discard block |
||
2061 | 2130 | } |
2062 | 2131 | |
2063 | 2132 | // We need to make sure the current directory is right. |
2064 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
2065 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2133 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
2134 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2135 | + } |
|
2066 | 2136 | |
2067 | 2137 | // Find the current directory if there's no value carried, |
2068 | 2138 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
2069 | 2139 | { |
2070 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
2071 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2072 | - else |
|
2073 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
2140 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
2141 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2142 | + } else { |
|
2143 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
2144 | + } |
|
2074 | 2145 | } |
2075 | 2146 | |
2076 | 2147 | // If the user wishes to go back, update the last_dir array |
2077 | 2148 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
2078 | 2149 | { |
2079 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
2080 | - $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
2150 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
2151 | + $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
2152 | + } |
|
2081 | 2153 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
2082 | 2154 | |
2083 | 2155 | if (is_numeric($num)) |
@@ -2085,16 +2157,18 @@ discard block |
||
2085 | 2157 | // Need to find the base folder. |
2086 | 2158 | $bid = -1; |
2087 | 2159 | $use_subdirectories_for_attachments = 0; |
2088 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2089 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
2160 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2161 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
2090 | 2162 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false) |
2091 | 2163 | { |
2092 | 2164 | $use_subdirectories_for_attachments = 1; |
2165 | + } |
|
2093 | 2166 | break; |
2094 | 2167 | } |
2095 | 2168 | |
2096 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
2097 | - $bid = 0; |
|
2169 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
2170 | + $bid = 0; |
|
2171 | + } |
|
2098 | 2172 | |
2099 | 2173 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
2100 | 2174 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2113,8 +2187,8 @@ discard block |
||
2113 | 2187 | // We might need to reset the paths. This loop will just loop through once. |
2114 | 2188 | foreach ($new_dirs as $id => $dir) |
2115 | 2189 | { |
2116 | - if ($id != 1) |
|
2117 | - $smcFunc['db_query']('', ' |
|
2190 | + if ($id != 1) { |
|
2191 | + $smcFunc['db_query']('', ' |
|
2118 | 2192 | UPDATE {db_prefix}attachments |
2119 | 2193 | SET id_folder = {int:default_folder} |
2120 | 2194 | WHERE id_folder = {int:current_folder}', |
@@ -2123,14 +2197,14 @@ discard block |
||
2123 | 2197 | 'current_folder' => $id, |
2124 | 2198 | ) |
2125 | 2199 | ); |
2200 | + } |
|
2126 | 2201 | |
2127 | 2202 | $update = array( |
2128 | 2203 | 'currentAttachmentUploadDir' => 1, |
2129 | 2204 | 'attachmentUploadDir' => json_encode(array(1 => $dir)), |
2130 | 2205 | ); |
2131 | 2206 | } |
2132 | - } |
|
2133 | - else |
|
2207 | + } else |
|
2134 | 2208 | { |
2135 | 2209 | // Save it to the database. |
2136 | 2210 | $update = array( |
@@ -2139,11 +2213,13 @@ discard block |
||
2139 | 2213 | ); |
2140 | 2214 | } |
2141 | 2215 | |
2142 | - if (!empty($update)) |
|
2143 | - updateSettings($update); |
|
2216 | + if (!empty($update)) { |
|
2217 | + updateSettings($update); |
|
2218 | + } |
|
2144 | 2219 | |
2145 | - if (!empty($errors)) |
|
2146 | - $_SESSION['errors']['dir'] = $errors; |
|
2220 | + if (!empty($errors)) { |
|
2221 | + $_SESSION['errors']['dir'] = $errors; |
|
2222 | + } |
|
2147 | 2223 | |
2148 | 2224 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
2149 | 2225 | } |
@@ -2157,10 +2233,11 @@ discard block |
||
2157 | 2233 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
2158 | 2234 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
2159 | 2235 | { |
2160 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
2161 | - $update = (array( |
|
2236 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
2237 | + $update = (array( |
|
2162 | 2238 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
2163 | 2239 | )); |
2240 | + } |
|
2164 | 2241 | } |
2165 | 2242 | |
2166 | 2243 | if (isset($_POST['base_dir'])) |
@@ -2208,13 +2285,15 @@ discard block |
||
2208 | 2285 | |
2209 | 2286 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
2210 | 2287 | { |
2211 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
2212 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
2288 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
2289 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
2290 | + } |
|
2213 | 2291 | } |
2214 | 2292 | |
2215 | 2293 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
2216 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
2217 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
2294 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
2295 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
2296 | + } |
|
2218 | 2297 | ksort($modSettings['attachment_basedirectories']); |
2219 | 2298 | |
2220 | 2299 | $update = (array( |
@@ -2224,11 +2303,13 @@ discard block |
||
2224 | 2303 | )); |
2225 | 2304 | } |
2226 | 2305 | |
2227 | - if (!empty($errors)) |
|
2228 | - $_SESSION['errors']['base'] = $errors; |
|
2306 | + if (!empty($errors)) { |
|
2307 | + $_SESSION['errors']['base'] = $errors; |
|
2308 | + } |
|
2229 | 2309 | |
2230 | - if (!empty($update)) |
|
2231 | - updateSettings($update); |
|
2310 | + if (!empty($update)) { |
|
2311 | + updateSettings($update); |
|
2312 | + } |
|
2232 | 2313 | |
2233 | 2314 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
2234 | 2315 | } |
@@ -2238,13 +2319,15 @@ discard block |
||
2238 | 2319 | if (is_array($_SESSION['errors'])) |
2239 | 2320 | { |
2240 | 2321 | $errors = array(); |
2241 | - if (!empty($_SESSION['errors']['dir'])) |
|
2242 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
2322 | + if (!empty($_SESSION['errors']['dir'])) { |
|
2323 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
2243 | 2324 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
2325 | + } |
|
2244 | 2326 | |
2245 | - if (!empty($_SESSION['errors']['base'])) |
|
2246 | - foreach ($_SESSION['errors']['base'] as $error) |
|
2327 | + if (!empty($_SESSION['errors']['base'])) { |
|
2328 | + foreach ($_SESSION['errors']['base'] as $error) |
|
2247 | 2329 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
2330 | + } |
|
2248 | 2331 | } |
2249 | 2332 | unset($_SESSION['errors']); |
2250 | 2333 | } |
@@ -2454,8 +2537,9 @@ discard block |
||
2454 | 2537 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
2455 | 2538 | { |
2456 | 2539 | // If there aren't any attachments in this directory this won't exist. |
2457 | - if (!isset($expected_files[$id])) |
|
2458 | - $expected_files[$id] = 0; |
|
2540 | + if (!isset($expected_files[$id])) { |
|
2541 | + $expected_files[$id] = 0; |
|
2542 | + } |
|
2459 | 2543 | |
2460 | 2544 | // Check if the directory is doing okay. |
2461 | 2545 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2468,10 +2552,11 @@ discard block |
||
2468 | 2552 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
2469 | 2553 | |
2470 | 2554 | // Count any sub-folders. |
2471 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
2472 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2555 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
2556 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2473 | 2557 | { |
2474 | 2558 | $expected_files[$id]++; |
2559 | + } |
|
2475 | 2560 | $sub_dirs++; |
2476 | 2561 | } |
2477 | 2562 | } |
@@ -2489,8 +2574,8 @@ discard block |
||
2489 | 2574 | } |
2490 | 2575 | |
2491 | 2576 | // Just stick a new directory on at the bottom. |
2492 | - if (isset($_REQUEST['new_path'])) |
|
2493 | - $attachdirs[] = array( |
|
2577 | + if (isset($_REQUEST['new_path'])) { |
|
2578 | + $attachdirs[] = array( |
|
2494 | 2579 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
2495 | 2580 | 'current' => false, |
2496 | 2581 | 'path' => '', |
@@ -2498,6 +2583,7 @@ discard block |
||
2498 | 2583 | 'num_files' => '', |
2499 | 2584 | 'status' => '', |
2500 | 2585 | ); |
2586 | + } |
|
2501 | 2587 | |
2502 | 2588 | return $attachdirs; |
2503 | 2589 | } |
@@ -2510,8 +2596,9 @@ discard block |
||
2510 | 2596 | { |
2511 | 2597 | global $modSettings, $txt; |
2512 | 2598 | |
2513 | - if (empty($modSettings['attachment_basedirectories'])) |
|
2514 | - return; |
|
2599 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
2600 | + return; |
|
2601 | + } |
|
2515 | 2602 | |
2516 | 2603 | $basedirs = array(); |
2517 | 2604 | // Get a list of the base directories. |
@@ -2519,16 +2606,18 @@ discard block |
||
2519 | 2606 | { |
2520 | 2607 | // Loop through the attach directory array to count any sub-directories |
2521 | 2608 | $expected_dirs = 0; |
2522 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
2523 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2609 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
2610 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2524 | 2611 | $expected_dirs++; |
2612 | + } |
|
2525 | 2613 | |
2526 | - if (!is_dir($dir)) |
|
2527 | - $status = 'does_not_exist'; |
|
2528 | - elseif (!is_writeable($dir)) |
|
2529 | - $status = 'not_writable'; |
|
2530 | - else |
|
2531 | - $status = 'ok'; |
|
2614 | + if (!is_dir($dir)) { |
|
2615 | + $status = 'does_not_exist'; |
|
2616 | + } elseif (!is_writeable($dir)) { |
|
2617 | + $status = 'not_writable'; |
|
2618 | + } else { |
|
2619 | + $status = 'ok'; |
|
2620 | + } |
|
2532 | 2621 | |
2533 | 2622 | $basedirs[] = array( |
2534 | 2623 | 'id' => $id, |
@@ -2539,14 +2628,15 @@ discard block |
||
2539 | 2628 | ); |
2540 | 2629 | } |
2541 | 2630 | |
2542 | - if (isset($_REQUEST['new_base_path'])) |
|
2543 | - $basedirs[] = array( |
|
2631 | + if (isset($_REQUEST['new_base_path'])) { |
|
2632 | + $basedirs[] = array( |
|
2544 | 2633 | 'id' => '', |
2545 | 2634 | 'current' => false, |
2546 | 2635 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
2547 | 2636 | 'num_dirs' => '', |
2548 | 2637 | 'status' => '', |
2549 | 2638 | ); |
2639 | + } |
|
2550 | 2640 | |
2551 | 2641 | return $basedirs; |
2552 | 2642 | } |
@@ -2562,10 +2652,11 @@ discard block |
||
2562 | 2652 | */ |
2563 | 2653 | function attachDirStatus($dir, $expected_files) |
2564 | 2654 | { |
2565 | - if (!is_dir($dir)) |
|
2566 | - return array('does_not_exist', true, ''); |
|
2567 | - elseif (!is_writable($dir)) |
|
2568 | - return array('not_writable', true, ''); |
|
2655 | + if (!is_dir($dir)) { |
|
2656 | + return array('does_not_exist', true, ''); |
|
2657 | + } elseif (!is_writable($dir)) { |
|
2658 | + return array('not_writable', true, ''); |
|
2659 | + } |
|
2569 | 2660 | |
2570 | 2661 | // Everything is okay so far, start to scan through the directory. |
2571 | 2662 | $num_files = 0; |
@@ -2573,22 +2664,26 @@ discard block |
||
2573 | 2664 | while ($file = $dir_handle->read()) |
2574 | 2665 | { |
2575 | 2666 | // Now do we have a real file here? |
2576 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
2577 | - continue; |
|
2667 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
2668 | + continue; |
|
2669 | + } |
|
2578 | 2670 | |
2579 | 2671 | $num_files++; |
2580 | 2672 | } |
2581 | 2673 | $dir_handle->close(); |
2582 | 2674 | |
2583 | - if ($num_files < $expected_files) |
|
2584 | - return array('files_missing', true, $num_files); |
|
2675 | + if ($num_files < $expected_files) { |
|
2676 | + return array('files_missing', true, $num_files); |
|
2677 | + } |
|
2585 | 2678 | // Empty? |
2586 | - elseif ($expected_files == 0) |
|
2587 | - return array('unused', false, $num_files); |
|
2679 | + elseif ($expected_files == 0) { |
|
2680 | + return array('unused', false, $num_files); |
|
2681 | + } |
|
2588 | 2682 | // All good! |
2589 | - else |
|
2590 | - return array('ok', false, $num_files); |
|
2591 | -} |
|
2683 | + else { |
|
2684 | + return array('ok', false, $num_files); |
|
2685 | + } |
|
2686 | + } |
|
2592 | 2687 | |
2593 | 2688 | /** |
2594 | 2689 | * Maintance function to move attachments from one directory to another |
@@ -2600,10 +2695,11 @@ discard block |
||
2600 | 2695 | checkSession(); |
2601 | 2696 | |
2602 | 2697 | $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
2603 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2604 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
2605 | - else |
|
2606 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
2698 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2699 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
2700 | + } else { |
|
2701 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
2702 | + } |
|
2607 | 2703 | |
2608 | 2704 | $_POST['from'] = (int) $_POST['from']; |
2609 | 2705 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2617,11 +2713,13 @@ discard block |
||
2617 | 2713 | $total_moved = 0; |
2618 | 2714 | $total_not_moved = 0; |
2619 | 2715 | |
2620 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
2621 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
2716 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
2717 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
2718 | + } |
|
2622 | 2719 | |
2623 | - if ($_POST['from'] == $_POST['to']) |
|
2624 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
2720 | + if ($_POST['from'] == $_POST['to']) { |
|
2721 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
2722 | + } |
|
2625 | 2723 | |
2626 | 2724 | if (empty($results)) |
2627 | 2725 | { |
@@ -2640,8 +2738,9 @@ discard block |
||
2640 | 2738 | $smcFunc['db_free_result']($request); |
2641 | 2739 | $total_progress -= $start; |
2642 | 2740 | |
2643 | - if ($total_progress < 1) |
|
2644 | - $results[] = $txt['attachment_transfer_no_find']; |
|
2741 | + if ($total_progress < 1) { |
|
2742 | + $results[] = $txt['attachment_transfer_no_find']; |
|
2743 | + } |
|
2645 | 2744 | } |
2646 | 2745 | |
2647 | 2746 | if (empty($results)) |
@@ -2657,9 +2756,9 @@ discard block |
||
2657 | 2756 | |
2658 | 2757 | automanage_attachments_check_directory(); |
2659 | 2758 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
2759 | + } else { |
|
2760 | + $new_dir = $_POST['to']; |
|
2660 | 2761 | } |
2661 | - else |
|
2662 | - $new_dir = $_POST['to']; |
|
2663 | 2762 | |
2664 | 2763 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
2665 | 2764 | |
@@ -2667,8 +2766,9 @@ discard block |
||
2667 | 2766 | while ($break == false) |
2668 | 2767 | { |
2669 | 2768 | @set_time_limit(300); |
2670 | - if (function_exists('apache_reset_timeout')) |
|
2671 | - @apache_reset_timeout(); |
|
2769 | + if (function_exists('apache_reset_timeout')) { |
|
2770 | + @apache_reset_timeout(); |
|
2771 | + } |
|
2672 | 2772 | |
2673 | 2773 | // If limits are set, get the file count and size for the destination folder |
2674 | 2774 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2704,13 +2804,15 @@ discard block |
||
2704 | 2804 | |
2705 | 2805 | if ($smcFunc['db_num_rows']($request) === 0) |
2706 | 2806 | { |
2707 | - if (empty($current_progress)) |
|
2708 | - $results[] = $txt['attachment_transfer_no_find']; |
|
2807 | + if (empty($current_progress)) { |
|
2808 | + $results[] = $txt['attachment_transfer_no_find']; |
|
2809 | + } |
|
2709 | 2810 | break; |
2710 | 2811 | } |
2711 | 2812 | |
2712 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
2713 | - $break = true; |
|
2813 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
2814 | + $break = true; |
|
2815 | + } |
|
2714 | 2816 | |
2715 | 2817 | // Move them |
2716 | 2818 | $moved = array(); |
@@ -2734,8 +2836,9 @@ discard block |
||
2734 | 2836 | automanage_attachments_by_space(); |
2735 | 2837 | |
2736 | 2838 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
2737 | - if (!empty($total_not_moved)) |
|
2738 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2839 | + if (!empty($total_not_moved)) { |
|
2840 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2841 | + } |
|
2739 | 2842 | |
2740 | 2843 | $dir_files = 0; |
2741 | 2844 | $total_moved = 0; |
@@ -2743,8 +2846,7 @@ discard block |
||
2743 | 2846 | |
2744 | 2847 | $break = false; |
2745 | 2848 | break; |
2746 | - } |
|
2747 | - else |
|
2849 | + } else |
|
2748 | 2850 | { |
2749 | 2851 | // Hmm, not in auto. Time to bail out then... |
2750 | 2852 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2759,9 +2861,9 @@ discard block |
||
2759 | 2861 | $total_moved++; |
2760 | 2862 | $current_progress++; |
2761 | 2863 | $moved[] = $row['id_attach']; |
2864 | + } else { |
|
2865 | + $total_not_moved++; |
|
2762 | 2866 | } |
2763 | - else |
|
2764 | - $total_not_moved++; |
|
2765 | 2867 | } |
2766 | 2868 | $smcFunc['db_free_result']($request); |
2767 | 2869 | |
@@ -2800,13 +2902,15 @@ discard block |
||
2800 | 2902 | } |
2801 | 2903 | |
2802 | 2904 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
2803 | - if (!empty($total_not_moved)) |
|
2804 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2905 | + if (!empty($total_not_moved)) { |
|
2906 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2907 | + } |
|
2805 | 2908 | } |
2806 | 2909 | |
2807 | 2910 | $_SESSION['results'] = $results; |
2808 | - if (file_exists($boarddir . '/progress.php')) |
|
2809 | - unlink($boarddir . '/progress.php'); |
|
2911 | + if (file_exists($boarddir . '/progress.php')) { |
|
2912 | + unlink($boarddir . '/progress.php'); |
|
2913 | + } |
|
2810 | 2914 | |
2811 | 2915 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
2812 | 2916 | } |