@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | * @param resource $socket Socket to send on |
1452 | 1452 | * @param string $code The expected response code |
1453 | 1453 | * @param string $response The response from the SMTP server |
1454 | - * @return bool Whether it responded as such. |
|
1454 | + * @return string|boolean Whether it responded as such. |
|
1455 | 1455 | */ |
1456 | 1456 | function server_parse($message, $socket, $code, &$response = null) |
1457 | 1457 | { |
@@ -2265,7 +2265,7 @@ discard block |
||
2265 | 2265 | * @param array $msgs Array of message ids |
2266 | 2266 | * @param bool $approve Whether to approve the posts (if false, posts are unapproved) |
2267 | 2267 | * @param bool $notify Whether to notify users |
2268 | - * @return bool Whether the operation was successful |
|
2268 | + * @return null|boolean Whether the operation was successful |
|
2269 | 2269 | */ |
2270 | 2270 | function approvePosts($msgs, $approve = true, $notify = true) |
2271 | 2271 | { |
@@ -2518,7 +2518,7 @@ discard block |
||
2518 | 2518 | * |
2519 | 2519 | * @param array $topics Array of topic ids |
2520 | 2520 | * @param bool $approve Whether to approve the topics. If false, unapproves them instead |
2521 | - * @return bool Whether the operation was successful |
|
2521 | + * @return null|boolean Whether the operation was successful |
|
2522 | 2522 | */ |
2523 | 2523 | function approveTopics($topics, $approve = true) |
2524 | 2524 | { |
@@ -2908,7 +2908,7 @@ discard block |
||
2908 | 2908 | * |
2909 | 2909 | * @param resource $dict An enchant or pspell dictionary resource set up by {@link spell_init()} |
2910 | 2910 | * @param string $word A word to check the spelling of |
2911 | - * @return bool Whether or not the specified word is spelled properly |
|
2911 | + * @return boolean|null Whether or not the specified word is spelled properly |
|
2912 | 2912 | */ |
2913 | 2913 | function spell_check($dict, $word) |
2914 | 2914 | { |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
32 | 33 | |
33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
34 | - if (empty($context['utf8'])) |
|
35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
35 | + if (empty($context['utf8'])) { |
|
36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | // Clean up after nobbc ;). |
38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
48 | 50 | |
49 | 51 | // Trim off trailing quotes - these often happen by accident. |
50 | - while (substr($message, -7) == '[quote]') |
|
51 | - $message = substr($message, 0, -7); |
|
52 | - while (substr($message, 0, 8) == '[/quote]') |
|
53 | - $message = substr($message, 8); |
|
52 | + while (substr($message, -7) == '[quote]') { |
|
53 | + $message = substr($message, 0, -7); |
|
54 | + } |
|
55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
56 | + $message = substr($message, 8); |
|
57 | + } |
|
54 | 58 | |
55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
56 | 60 | $in_tag = false; |
57 | 61 | $had_tag = false; |
58 | 62 | $codeopen = 0; |
59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
60 | - foreach ($matches[0] as $index => $dummy) |
|
63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
64 | + foreach ($matches[0] as $index => $dummy) |
|
61 | 65 | { |
62 | 66 | // Closing? |
63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
65 | 69 | // If it's closing and we're not in a tag we need to open it... |
66 | 70 | if (!$in_tag) |
67 | 71 | $codeopen = true; |
72 | + } |
|
68 | 73 | // Either way we ain't in one any more. |
69 | 74 | $in_tag = false; |
70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
73 | 78 | { |
74 | 79 | $had_tag = true; |
75 | 80 | // If we're in a tag don't do nought! |
76 | - if (!$in_tag) |
|
77 | - $in_tag = true; |
|
81 | + if (!$in_tag) { |
|
82 | + $in_tag = true; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } |
80 | 86 | |
81 | 87 | // If we have an open tag, close it. |
82 | - if ($in_tag) |
|
83 | - $message .= '[/code]'; |
|
88 | + if ($in_tag) { |
|
89 | + $message .= '[/code]'; |
|
90 | + } |
|
84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
85 | - if ($codeopen && !$had_tag) |
|
86 | - $message = '[code]' . $message; |
|
92 | + if ($codeopen && !$had_tag) { |
|
93 | + $message = '[code]' . $message; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | // Now that we've fixed all the code tags, let's fix the img and url tags... |
89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -109,23 +117,26 @@ discard block |
||
109 | 117 | fixTags($message); |
110 | 118 | |
111 | 119 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
112 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
113 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
114 | - else |
|
115 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
120 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
121 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
122 | + } else { |
|
123 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
124 | + } |
|
116 | 125 | |
117 | 126 | if (!$previewing && strpos($message, '[html]') !== false) |
118 | 127 | { |
119 | - if (allowedTo('admin_forum')) |
|
120 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
128 | + if (allowedTo('admin_forum')) { |
|
129 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
121 | 130 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
131 | + } |
|
122 | 132 | }, $message); |
123 | 133 | |
124 | 134 | // We should edit them out, or else if an admin edits the message they will get shown... |
125 | 135 | else |
126 | 136 | { |
127 | - while (strpos($message, '[html]') !== false) |
|
128 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
137 | + while (strpos($message, '[html]') !== false) { |
|
138 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
139 | + } |
|
129 | 140 | } |
130 | 141 | } |
131 | 142 | |
@@ -147,10 +158,12 @@ discard block |
||
147 | 158 | |
148 | 159 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
149 | 160 | $list_close = substr_count($message, '[/list]'); |
150 | - if ($list_close - $list_open > 0) |
|
151 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
152 | - if ($list_open - $list_close > 0) |
|
153 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
161 | + if ($list_close - $list_open > 0) { |
|
162 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
163 | + } |
|
164 | + if ($list_open - $list_close > 0) { |
|
165 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
166 | + } |
|
154 | 167 | |
155 | 168 | $mistake_fixes = array( |
156 | 169 | // Find [table]s not followed by [tr]. |
@@ -199,8 +212,9 @@ discard block |
||
199 | 212 | ); |
200 | 213 | |
201 | 214 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
202 | - for ($j = 0; $j < 3; $j++) |
|
203 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
215 | + for ($j = 0; $j < 3; $j++) { |
|
216 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
217 | + } |
|
204 | 218 | |
205 | 219 | // Remove empty bbc from the sections outside the code tags |
206 | 220 | $allowedEmpty = array( |
@@ -210,24 +224,28 @@ discard block |
||
210 | 224 | |
211 | 225 | require_once($sourcedir . '/Subs.php'); |
212 | 226 | |
213 | - foreach (($codes = parse_bbc(false)) as $code) |
|
214 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
227 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
228 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
215 | 229 | $alltags[] = $code['tag']; |
230 | + } |
|
216 | 231 | |
217 | 232 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
218 | 233 | |
219 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
220 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
234 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
235 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
236 | + } |
|
221 | 237 | |
222 | 238 | // Restore code blocks |
223 | - if (!empty($code_tags)) |
|
224 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
239 | + if (!empty($code_tags)) { |
|
240 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
241 | + } |
|
225 | 242 | |
226 | 243 | // Restore white space entities |
227 | - if (!$previewing) |
|
228 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
229 | - else |
|
230 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
244 | + if (!$previewing) { |
|
245 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
246 | + } else { |
|
247 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
248 | + } |
|
231 | 249 | |
232 | 250 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
233 | 251 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -270,8 +288,9 @@ discard block |
||
270 | 288 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
271 | 289 | }, $message); |
272 | 290 | |
273 | - if (!empty($code_tags)) |
|
274 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
291 | + if (!empty($code_tags)) { |
|
292 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
293 | + } |
|
275 | 294 | |
276 | 295 | // Change breaks back to \n's and &nsbp; back to spaces. |
277 | 296 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -352,8 +371,9 @@ discard block |
||
352 | 371 | ); |
353 | 372 | |
354 | 373 | // Fix each type of tag. |
355 | - foreach ($fixArray as $param) |
|
356 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
374 | + foreach ($fixArray as $param) { |
|
375 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
376 | + } |
|
357 | 377 | |
358 | 378 | // Now fix possible security problems with images loading links automatically... |
359 | 379 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -389,16 +409,19 @@ discard block |
||
389 | 409 | $desired_height = $height; |
390 | 410 | } |
391 | 411 | // Scale it to the width... |
392 | - elseif (empty($desired_width) && !empty($height)) |
|
393 | - $desired_width = (int) (($desired_height * $width) / $height); |
|
412 | + elseif (empty($desired_width) && !empty($height)) { |
|
413 | + $desired_width = (int) (($desired_height * $width) / $height); |
|
414 | + } |
|
394 | 415 | // Scale if to the height. |
395 | - elseif (!empty($width)) |
|
396 | - $desired_height = (int) (($desired_width * $height) / $width); |
|
416 | + elseif (!empty($width)) { |
|
417 | + $desired_height = (int) (($desired_width * $height) / $width); |
|
418 | + } |
|
397 | 419 | } |
398 | 420 | |
399 | 421 | // If the width and height are fine, just continue along... |
400 | - if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) |
|
401 | - continue; |
|
422 | + if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) { |
|
423 | + continue; |
|
424 | + } |
|
402 | 425 | |
403 | 426 | // Too bad, it's too wide. Make it as wide as the maximum. |
404 | 427 | if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width'])) |
@@ -418,8 +441,9 @@ discard block |
||
418 | 441 | } |
419 | 442 | |
420 | 443 | // If any img tags were actually changed... |
421 | - if (!empty($replaces)) |
|
422 | - $message = strtr($message, $replaces); |
|
444 | + if (!empty($replaces)) { |
|
445 | + $message = strtr($message, $replaces); |
|
446 | + } |
|
423 | 447 | } |
424 | 448 | } |
425 | 449 | |
@@ -438,10 +462,11 @@ discard block |
||
438 | 462 | { |
439 | 463 | global $boardurl, $scripturl; |
440 | 464 | |
441 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
442 | - $domain_url = $match[1]; |
|
443 | - else |
|
444 | - $domain_url = $boardurl . '/'; |
|
465 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
466 | + $domain_url = $match[1]; |
|
467 | + } else { |
|
468 | + $domain_url = $boardurl . '/'; |
|
469 | + } |
|
445 | 470 | |
446 | 471 | $replaces = array(); |
447 | 472 | |
@@ -449,11 +474,11 @@ discard block |
||
449 | 474 | { |
450 | 475 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
451 | 476 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
477 | + } elseif ($hasEqualSign) { |
|
478 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
479 | + } else { |
|
480 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
452 | 481 | } |
453 | - elseif ($hasEqualSign) |
|
454 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
455 | - else |
|
456 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
457 | 482 | |
458 | 483 | foreach ($matches[0] as $k => $dummy) |
459 | 484 | { |
@@ -466,49 +491,53 @@ discard block |
||
466 | 491 | foreach ($protocols as $protocol) |
467 | 492 | { |
468 | 493 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
469 | - if ($found) |
|
470 | - break; |
|
494 | + if ($found) { |
|
495 | + break; |
|
496 | + } |
|
471 | 497 | } |
472 | 498 | |
473 | 499 | if (!$found && $protocols[0] == 'http') |
474 | 500 | { |
475 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
476 | - $replace = $domain_url . $replace; |
|
477 | - elseif (substr($replace, 0, 1) == '?') |
|
478 | - $replace = $scripturl . $replace; |
|
479 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
501 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
502 | + $replace = $domain_url . $replace; |
|
503 | + } elseif (substr($replace, 0, 1) == '?') { |
|
504 | + $replace = $scripturl . $replace; |
|
505 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
480 | 506 | { |
481 | 507 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
482 | 508 | $this_tag = 'iurl'; |
483 | 509 | $this_close = 'iurl'; |
510 | + } elseif (substr($replace, 0, 2) != '//') { |
|
511 | + $replace = $protocols[0] . '://' . $replace; |
|
484 | 512 | } |
485 | - elseif (substr($replace, 0, 2) != '//') |
|
486 | - $replace = $protocols[0] . '://' . $replace; |
|
487 | - } |
|
488 | - elseif (!$found && $protocols[0] == 'ftp') |
|
489 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
490 | - elseif (!$found) |
|
491 | - $replace = $protocols[0] . '://' . $replace; |
|
492 | - |
|
493 | - if ($hasEqualSign && $embeddedUrl) |
|
494 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
495 | - elseif ($hasEqualSign) |
|
496 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
497 | - elseif ($embeddedUrl) |
|
498 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
499 | - else |
|
500 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
513 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
514 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
515 | + } elseif (!$found) { |
|
516 | + $replace = $protocols[0] . '://' . $replace; |
|
517 | + } |
|
518 | + |
|
519 | + if ($hasEqualSign && $embeddedUrl) { |
|
520 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
521 | + } elseif ($hasEqualSign) { |
|
522 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
523 | + } elseif ($embeddedUrl) { |
|
524 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
525 | + } else { |
|
526 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
527 | + } |
|
501 | 528 | } |
502 | 529 | |
503 | 530 | foreach ($replaces as $k => $v) |
504 | 531 | { |
505 | - if ($k == $v) |
|
506 | - unset($replaces[$k]); |
|
532 | + if ($k == $v) { |
|
533 | + unset($replaces[$k]); |
|
534 | + } |
|
507 | 535 | } |
508 | 536 | |
509 | - if (!empty($replaces)) |
|
510 | - $message = strtr($message, $replaces); |
|
511 | -} |
|
537 | + if (!empty($replaces)) { |
|
538 | + $message = strtr($message, $replaces); |
|
539 | + } |
|
540 | + } |
|
512 | 541 | |
513 | 542 | /** |
514 | 543 | * This function sends an email to the specified recipient(s). |
@@ -552,8 +581,9 @@ discard block |
||
552 | 581 | } |
553 | 582 | |
554 | 583 | // Nothing left? Nothing else to do |
555 | - if (empty($to_array)) |
|
556 | - return true; |
|
584 | + if (empty($to_array)) { |
|
585 | + return true; |
|
586 | + } |
|
557 | 587 | |
558 | 588 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
559 | 589 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -570,15 +600,17 @@ discard block |
||
570 | 600 | } |
571 | 601 | |
572 | 602 | // Call this function recursively for the hotmail addresses. |
573 | - if (!empty($hotmail_to)) |
|
574 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
603 | + if (!empty($hotmail_to)) { |
|
604 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | // The remaining addresses no longer need the fix. |
577 | 608 | $hotmail_fix = false; |
578 | 609 | |
579 | 610 | // No other addresses left? Return instantly. |
580 | - if (empty($to_array)) |
|
581 | - return $mail_result; |
|
611 | + if (empty($to_array)) { |
|
612 | + return $mail_result; |
|
613 | + } |
|
582 | 614 | } |
583 | 615 | |
584 | 616 | // Get rid of entities. |
@@ -603,13 +635,15 @@ discard block |
||
603 | 635 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
604 | 636 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
605 | 637 | |
606 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
607 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
638 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
639 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
640 | + } |
|
608 | 641 | $headers .= 'X-Mailer: SMF' . $line_break; |
609 | 642 | |
610 | 643 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
611 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
612 | - return false; |
|
644 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
645 | + return false; |
|
646 | + } |
|
613 | 647 | |
614 | 648 | // Save the original message... |
615 | 649 | $orig_message = $message; |
@@ -658,17 +692,19 @@ discard block |
||
658 | 692 | } |
659 | 693 | |
660 | 694 | // Are we using the mail queue, if so this is where we butt in... |
661 | - if ($priority != 0) |
|
662 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
695 | + if ($priority != 0) { |
|
696 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
697 | + } |
|
663 | 698 | |
664 | 699 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
665 | 700 | elseif (!empty($modSettings['mail_limit'])) |
666 | 701 | { |
667 | 702 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
668 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
669 | - $new_queue_stat = time() . '|' . 1; |
|
670 | - else |
|
671 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
703 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
704 | + $new_queue_stat = time() . '|' . 1; |
|
705 | + } else { |
|
706 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
707 | + } |
|
672 | 708 | |
673 | 709 | updateSettings(array('mail_recent' => $new_queue_stat)); |
674 | 710 | } |
@@ -693,12 +729,13 @@ discard block |
||
693 | 729 | |
694 | 730 | // Wait, wait, I'm still sending here! |
695 | 731 | @set_time_limit(300); |
696 | - if (function_exists('apache_reset_timeout')) |
|
697 | - @apache_reset_timeout(); |
|
732 | + if (function_exists('apache_reset_timeout')) { |
|
733 | + @apache_reset_timeout(); |
|
734 | + } |
|
698 | 735 | } |
736 | + } else { |
|
737 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
699 | 738 | } |
700 | - else |
|
701 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
702 | 739 | |
703 | 740 | // Everything go smoothly? |
704 | 741 | return $mail_result; |
@@ -724,8 +761,9 @@ discard block |
||
724 | 761 | static $cur_insert = array(); |
725 | 762 | static $cur_insert_len = 0; |
726 | 763 | |
727 | - if ($cur_insert_len == 0) |
|
728 | - $cur_insert = array(); |
|
764 | + if ($cur_insert_len == 0) { |
|
765 | + $cur_insert = array(); |
|
766 | + } |
|
729 | 767 | |
730 | 768 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
731 | 769 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -800,8 +838,9 @@ discard block |
||
800 | 838 | } |
801 | 839 | |
802 | 840 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
803 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
804 | - return AddMailQueue(true); |
|
841 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
842 | + return AddMailQueue(true); |
|
843 | + } |
|
805 | 844 | |
806 | 845 | return true; |
807 | 846 | } |
@@ -832,23 +871,26 @@ discard block |
||
832 | 871 | 'sent' => array() |
833 | 872 | ); |
834 | 873 | |
835 | - if ($from === null) |
|
836 | - $from = array( |
|
874 | + if ($from === null) { |
|
875 | + $from = array( |
|
837 | 876 | 'id' => $user_info['id'], |
838 | 877 | 'name' => $user_info['name'], |
839 | 878 | 'username' => $user_info['username'] |
840 | 879 | ); |
880 | + } |
|
841 | 881 | |
842 | 882 | // This is the one that will go in their inbox. |
843 | 883 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
844 | 884 | preparsecode($htmlmessage); |
845 | 885 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
846 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
847 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
886 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
887 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
888 | + } |
|
848 | 889 | |
849 | 890 | // Make sure is an array |
850 | - if (!is_array($recipients)) |
|
851 | - $recipients = array($recipients); |
|
891 | + if (!is_array($recipients)) { |
|
892 | + $recipients = array($recipients); |
|
893 | + } |
|
852 | 894 | |
853 | 895 | // Integrated PMs |
854 | 896 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -876,21 +918,23 @@ discard block |
||
876 | 918 | 'usernames' => array_keys($usernames), |
877 | 919 | ) |
878 | 920 | ); |
879 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
880 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
921 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
922 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
881 | 923 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
924 | + } |
|
882 | 925 | $smcFunc['db_free_result']($request); |
883 | 926 | |
884 | 927 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
885 | - foreach ($recipients as $rec_type => $rec) |
|
886 | - foreach ($rec as $id => $member) |
|
928 | + foreach ($recipients as $rec_type => $rec) { |
|
929 | + foreach ($rec as $id => $member) |
|
887 | 930 | { |
888 | 931 | if (is_numeric($recipients[$rec_type][$id])) |
889 | 932 | continue; |
933 | + } |
|
890 | 934 | |
891 | - if (!empty($usernames[$member])) |
|
892 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
893 | - else |
|
935 | + if (!empty($usernames[$member])) { |
|
936 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
937 | + } else |
|
894 | 938 | { |
895 | 939 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
896 | 940 | unset($recipients[$rec_type][$id]); |
@@ -928,8 +972,9 @@ discard block |
||
928 | 972 | $delete = false; |
929 | 973 | foreach ($criteria as $criterium) |
930 | 974 | { |
931 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
932 | - $delete = true; |
|
975 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
976 | + $delete = true; |
|
977 | + } |
|
933 | 978 | // If we're adding and one criteria don't match then we stop! |
934 | 979 | elseif (!$row['is_or']) |
935 | 980 | { |
@@ -937,8 +982,9 @@ discard block |
||
937 | 982 | break; |
938 | 983 | } |
939 | 984 | } |
940 | - if ($delete) |
|
941 | - $deletes[$row['id_member']] = 1; |
|
985 | + if ($delete) { |
|
986 | + $deletes[$row['id_member']] = 1; |
|
987 | + } |
|
942 | 988 | } |
943 | 989 | $smcFunc['db_free_result']($request); |
944 | 990 | |
@@ -953,8 +999,9 @@ discard block |
||
953 | 999 | array( |
954 | 1000 | ) |
955 | 1001 | ); |
956 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
957 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
1002 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1003 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
1004 | + } |
|
958 | 1005 | $smcFunc['db_free_result']($request); |
959 | 1006 | } |
960 | 1007 | |
@@ -962,8 +1009,9 @@ discard block |
||
962 | 1009 | require_once($sourcedir . '/Subs-Members.php'); |
963 | 1010 | $pmReadGroups = groupsAllowedTo('pm_read'); |
964 | 1011 | |
965 | - if (empty($modSettings['permission_enable_deny'])) |
|
966 | - $pmReadGroups['denied'] = array(); |
|
1012 | + if (empty($modSettings['permission_enable_deny'])) { |
|
1013 | + $pmReadGroups['denied'] = array(); |
|
1014 | + } |
|
967 | 1015 | |
968 | 1016 | // Load their alert preferences |
969 | 1017 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -995,8 +1043,9 @@ discard block |
||
995 | 1043 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
996 | 1044 | { |
997 | 1045 | // Don't do anything for members to be deleted! |
998 | - if (isset($deletes[$row['id_member']])) |
|
999 | - continue; |
|
1046 | + if (isset($deletes[$row['id_member']])) { |
|
1047 | + continue; |
|
1048 | + } |
|
1000 | 1049 | |
1001 | 1050 | // Load the preferences for this member (if any) |
1002 | 1051 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -1017,8 +1066,9 @@ discard block |
||
1017 | 1066 | { |
1018 | 1067 | foreach ($groups as $id) |
1019 | 1068 | { |
1020 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
1021 | - $message_limit = $message_limit_cache[$id]; |
|
1069 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
1070 | + $message_limit = $message_limit_cache[$id]; |
|
1071 | + } |
|
1022 | 1072 | } |
1023 | 1073 | |
1024 | 1074 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1066,8 +1116,9 @@ discard block |
||
1066 | 1116 | $smcFunc['db_free_result']($request); |
1067 | 1117 | |
1068 | 1118 | // Only 'send' the message if there are any recipients left. |
1069 | - if (empty($all_to)) |
|
1070 | - return $log; |
|
1119 | + if (empty($all_to)) { |
|
1120 | + return $log; |
|
1121 | + } |
|
1071 | 1122 | |
1072 | 1123 | // Insert the message itself and then grab the last insert id. |
1073 | 1124 | $id_pm = $smcFunc['db_insert']('', |
@@ -1088,8 +1139,8 @@ discard block |
||
1088 | 1139 | if (!empty($id_pm)) |
1089 | 1140 | { |
1090 | 1141 | // If this is new we need to set it part of it's own conversation. |
1091 | - if (empty($pm_head)) |
|
1092 | - $smcFunc['db_query']('', ' |
|
1142 | + if (empty($pm_head)) { |
|
1143 | + $smcFunc['db_query']('', ' |
|
1093 | 1144 | UPDATE {db_prefix}personal_messages |
1094 | 1145 | SET id_pm_head = {int:id_pm_head} |
1095 | 1146 | WHERE id_pm = {int:id_pm_head}', |
@@ -1097,6 +1148,7 @@ discard block |
||
1097 | 1148 | 'id_pm_head' => $id_pm, |
1098 | 1149 | ) |
1099 | 1150 | ); |
1151 | + } |
|
1100 | 1152 | |
1101 | 1153 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
1102 | 1154 | $smcFunc['db_query']('', ' |
@@ -1112,8 +1164,9 @@ discard block |
||
1112 | 1164 | foreach ($all_to as $to) |
1113 | 1165 | { |
1114 | 1166 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
1115 | - if (!in_array($to, $recipients['bcc'])) |
|
1116 | - $to_list[] = $to; |
|
1167 | + if (!in_array($to, $recipients['bcc'])) { |
|
1168 | + $to_list[] = $to; |
|
1169 | + } |
|
1117 | 1170 | } |
1118 | 1171 | |
1119 | 1172 | $smcFunc['db_insert']('insert', |
@@ -1131,9 +1184,9 @@ discard block |
||
1131 | 1184 | { |
1132 | 1185 | censorText($message); |
1133 | 1186 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
1187 | + } else { |
|
1188 | + $message = ''; |
|
1134 | 1189 | } |
1135 | - else |
|
1136 | - $message = ''; |
|
1137 | 1190 | |
1138 | 1191 | $to_names = array(); |
1139 | 1192 | if (count($to_list) > 1) |
@@ -1146,8 +1199,9 @@ discard block |
||
1146 | 1199 | 'to_members' => $to_list, |
1147 | 1200 | ) |
1148 | 1201 | ); |
1149 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1150 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1203 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1204 | + } |
|
1151 | 1205 | $smcFunc['db_free_result']($request); |
1152 | 1206 | } |
1153 | 1207 | $replacements = array( |
@@ -1175,11 +1229,13 @@ discard block |
||
1175 | 1229 | loadLanguage('index+PersonalMessage'); |
1176 | 1230 | |
1177 | 1231 | // Add one to their unread and read message counts. |
1178 | - foreach ($all_to as $k => $id) |
|
1179 | - if (isset($deletes[$id])) |
|
1232 | + foreach ($all_to as $k => $id) { |
|
1233 | + if (isset($deletes[$id])) |
|
1180 | 1234 | unset($all_to[$k]); |
1181 | - if (!empty($all_to)) |
|
1182 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1235 | + } |
|
1236 | + if (!empty($all_to)) { |
|
1237 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1238 | + } |
|
1183 | 1239 | |
1184 | 1240 | return $log; |
1185 | 1241 | } |
@@ -1209,15 +1265,17 @@ discard block |
||
1209 | 1265 | // Let's, for now, assume there are only 'ish characters. |
1210 | 1266 | $simple = true; |
1211 | 1267 | |
1212 | - foreach ($matches[1] as $entity) |
|
1213 | - if ($entity > 128) |
|
1268 | + foreach ($matches[1] as $entity) { |
|
1269 | + if ($entity > 128) |
|
1214 | 1270 | $simple = false; |
1271 | + } |
|
1215 | 1272 | unset($matches); |
1216 | 1273 | |
1217 | - if ($simple) |
|
1218 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1274 | + if ($simple) { |
|
1275 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1219 | 1276 | { |
1220 | 1277 | return chr("$m[1]"); |
1278 | + } |
|
1221 | 1279 | }, $string); |
1222 | 1280 | else |
1223 | 1281 | { |
@@ -1225,8 +1283,9 @@ discard block |
||
1225 | 1283 | if (!$context['utf8'] && function_exists('iconv')) |
1226 | 1284 | { |
1227 | 1285 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1228 | - if ($newstring) |
|
1229 | - $string = $newstring; |
|
1286 | + if ($newstring) { |
|
1287 | + $string = $newstring; |
|
1288 | + } |
|
1230 | 1289 | } |
1231 | 1290 | |
1232 | 1291 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1242,23 +1301,25 @@ discard block |
||
1242 | 1301 | if (!$context['utf8'] && function_exists('iconv')) |
1243 | 1302 | { |
1244 | 1303 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1245 | - if ($newstring) |
|
1246 | - $string = $newstring; |
|
1304 | + if ($newstring) { |
|
1305 | + $string = $newstring; |
|
1306 | + } |
|
1247 | 1307 | } |
1248 | 1308 | |
1249 | 1309 | $entityConvert = function($m) |
1250 | 1310 | { |
1251 | 1311 | $c = $m[1]; |
1252 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
1253 | - return $c; |
|
1254 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
1255 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1256 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
1257 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1258 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
1259 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1260 | - else |
|
1261 | - return ""; |
|
1312 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
1313 | + return $c; |
|
1314 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
1315 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1316 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
1317 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1318 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
1319 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1320 | + } else { |
|
1321 | + return ""; |
|
1322 | + } |
|
1262 | 1323 | }; |
1263 | 1324 | |
1264 | 1325 | // Convert all 'special' characters to HTML entities. |
@@ -1272,19 +1333,20 @@ discard block |
||
1272 | 1333 | $string = base64_encode($string); |
1273 | 1334 | |
1274 | 1335 | // Show the characterset and the transfer-encoding for header strings. |
1275 | - if ($with_charset) |
|
1276 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1336 | + if ($with_charset) { |
|
1337 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1338 | + } |
|
1277 | 1339 | |
1278 | 1340 | // Break it up in lines (mail body). |
1279 | - else |
|
1280 | - $string = chunk_split($string, 76, $line_break); |
|
1341 | + else { |
|
1342 | + $string = chunk_split($string, 76, $line_break); |
|
1343 | + } |
|
1281 | 1344 | |
1282 | 1345 | return array($charset, $string, 'base64'); |
1346 | + } else { |
|
1347 | + return array($charset, $string, '7bit'); |
|
1348 | + } |
|
1283 | 1349 | } |
1284 | - |
|
1285 | - else |
|
1286 | - return array($charset, $string, '7bit'); |
|
1287 | -} |
|
1288 | 1350 | |
1289 | 1351 | /** |
1290 | 1352 | * Sends mail, like mail() but over SMTP. |
@@ -1308,8 +1370,9 @@ discard block |
||
1308 | 1370 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
1309 | 1371 | { |
1310 | 1372 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
1311 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
1312 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1373 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
1374 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1375 | + } |
|
1313 | 1376 | |
1314 | 1377 | if ($socket) |
1315 | 1378 | { |
@@ -1330,8 +1393,9 @@ discard block |
||
1330 | 1393 | // Maybe we can still save this? The port might be wrong. |
1331 | 1394 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
1332 | 1395 | { |
1333 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
1334 | - log_error($txt['smtp_port_ssl']); |
|
1396 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
1397 | + log_error($txt['smtp_port_ssl']); |
|
1398 | + } |
|
1335 | 1399 | } |
1336 | 1400 | |
1337 | 1401 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1343,20 +1407,23 @@ discard block |
||
1343 | 1407 | } |
1344 | 1408 | |
1345 | 1409 | // Wait for a response of 220, without "-" continuer. |
1346 | - if (!server_parse(null, $socket, '220')) |
|
1347 | - return false; |
|
1410 | + if (!server_parse(null, $socket, '220')) { |
|
1411 | + return false; |
|
1412 | + } |
|
1348 | 1413 | |
1349 | 1414 | // Try and determine the servers name, fall back to the mail servers if not found |
1350 | 1415 | $helo = false; |
1351 | - if (function_exists('gethostname') && gethostname() !== false) |
|
1352 | - $helo = gethostname(); |
|
1353 | - elseif (function_exists('php_uname')) |
|
1354 | - $helo = php_uname('n'); |
|
1355 | - elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) |
|
1356 | - $helo = $_SERVER['SERVER_NAME']; |
|
1416 | + if (function_exists('gethostname') && gethostname() !== false) { |
|
1417 | + $helo = gethostname(); |
|
1418 | + } elseif (function_exists('php_uname')) { |
|
1419 | + $helo = php_uname('n'); |
|
1420 | + } elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) { |
|
1421 | + $helo = $_SERVER['SERVER_NAME']; |
|
1422 | + } |
|
1357 | 1423 | |
1358 | - if (empty($helo)) |
|
1359 | - $helo = $modSettings['smtp_host']; |
|
1424 | + if (empty($helo)) { |
|
1425 | + $helo = $modSettings['smtp_host']; |
|
1426 | + } |
|
1360 | 1427 | |
1361 | 1428 | // SMTP = 1, SMTP - STARTTLS = 2 |
1362 | 1429 | if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
@@ -1368,33 +1435,39 @@ discard block |
||
1368 | 1435 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
1369 | 1436 | { |
1370 | 1437 | // Send STARTTLS to enable encryption |
1371 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
1372 | - return false; |
|
1438 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
1439 | + return false; |
|
1440 | + } |
|
1373 | 1441 | // Enable the encryption |
1374 | - if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) |
|
1375 | - return false; |
|
1442 | + if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
1443 | + return false; |
|
1444 | + } |
|
1376 | 1445 | // Send the EHLO command again |
1377 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
1378 | - return false; |
|
1446 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
1447 | + return false; |
|
1448 | + } |
|
1379 | 1449 | } |
1380 | 1450 | |
1381 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
1382 | - return false; |
|
1451 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
1452 | + return false; |
|
1453 | + } |
|
1383 | 1454 | // Send the username and password, encoded. |
1384 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
1385 | - return false; |
|
1455 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
1456 | + return false; |
|
1457 | + } |
|
1386 | 1458 | // The password is already encoded ;) |
1387 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
1388 | - return false; |
|
1459 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
1460 | + return false; |
|
1461 | + } |
|
1462 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1463 | + return false; |
|
1389 | 1464 | } |
1390 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1391 | - return false; |
|
1392 | - } |
|
1393 | - else |
|
1465 | + } else |
|
1394 | 1466 | { |
1395 | 1467 | // Just say "helo". |
1396 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1397 | - return false; |
|
1468 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1469 | + return false; |
|
1470 | + } |
|
1398 | 1471 | } |
1399 | 1472 | |
1400 | 1473 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1407,31 +1480,38 @@ discard block |
||
1407 | 1480 | // Reset the connection to send another email. |
1408 | 1481 | if ($i != 0) |
1409 | 1482 | { |
1410 | - if (!server_parse('RSET', $socket, '250')) |
|
1411 | - return false; |
|
1483 | + if (!server_parse('RSET', $socket, '250')) { |
|
1484 | + return false; |
|
1485 | + } |
|
1412 | 1486 | } |
1413 | 1487 | |
1414 | 1488 | // From, to, and then start the data... |
1415 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
1416 | - return false; |
|
1417 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
1418 | - return false; |
|
1419 | - if (!server_parse('DATA', $socket, '354')) |
|
1420 | - return false; |
|
1489 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
1490 | + return false; |
|
1491 | + } |
|
1492 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
1493 | + return false; |
|
1494 | + } |
|
1495 | + if (!server_parse('DATA', $socket, '354')) { |
|
1496 | + return false; |
|
1497 | + } |
|
1421 | 1498 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
1422 | - if (strlen($mail_to) > 0) |
|
1423 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1499 | + if (strlen($mail_to) > 0) { |
|
1500 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1501 | + } |
|
1424 | 1502 | fputs($socket, $headers . "\r\n\r\n"); |
1425 | 1503 | fputs($socket, $message . "\r\n"); |
1426 | 1504 | |
1427 | 1505 | // Send a ., or in other words "end of data". |
1428 | - if (!server_parse('.', $socket, '250')) |
|
1429 | - return false; |
|
1506 | + if (!server_parse('.', $socket, '250')) { |
|
1507 | + return false; |
|
1508 | + } |
|
1430 | 1509 | |
1431 | 1510 | // Almost done, almost done... don't stop me just yet! |
1432 | 1511 | @set_time_limit(300); |
1433 | - if (function_exists('apache_reset_timeout')) |
|
1434 | - @apache_reset_timeout(); |
|
1512 | + if (function_exists('apache_reset_timeout')) { |
|
1513 | + @apache_reset_timeout(); |
|
1514 | + } |
|
1435 | 1515 | } |
1436 | 1516 | fputs($socket, 'QUIT' . "\r\n"); |
1437 | 1517 | fclose($socket); |
@@ -1455,8 +1535,9 @@ discard block |
||
1455 | 1535 | { |
1456 | 1536 | global $txt; |
1457 | 1537 | |
1458 | - if ($message !== null) |
|
1459 | - fputs($socket, $message . "\r\n"); |
|
1538 | + if ($message !== null) { |
|
1539 | + fputs($socket, $message . "\r\n"); |
|
1540 | + } |
|
1460 | 1541 | |
1461 | 1542 | // No response yet. |
1462 | 1543 | $server_response = ''; |
@@ -1472,8 +1553,9 @@ discard block |
||
1472 | 1553 | $response .= $server_response; |
1473 | 1554 | } |
1474 | 1555 | |
1475 | - if ($code === null) |
|
1476 | - return substr($server_response, 0, 3); |
|
1556 | + if ($code === null) { |
|
1557 | + return substr($server_response, 0, 3); |
|
1558 | + } |
|
1477 | 1559 | |
1478 | 1560 | if (substr($server_response, 0, 3) != $code) |
1479 | 1561 | { |
@@ -1503,8 +1585,9 @@ discard block |
||
1503 | 1585 | // Create a pspell or enchant dictionary resource |
1504 | 1586 | $dict = spell_init(); |
1505 | 1587 | |
1506 | - if (!isset($_POST['spellstring']) || !$dict) |
|
1507 | - die; |
|
1588 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
1589 | + die; |
|
1590 | + } |
|
1508 | 1591 | |
1509 | 1592 | // Construct a bit of Javascript code. |
1510 | 1593 | $context['spell_js'] = ' |
@@ -1522,8 +1605,9 @@ discard block |
||
1522 | 1605 | $check_word = explode('|', $alphas[$i]); |
1523 | 1606 | |
1524 | 1607 | // If the word is a known word, or spelled right... |
1525 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
1526 | - continue; |
|
1608 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
1609 | + continue; |
|
1610 | + } |
|
1527 | 1611 | |
1528 | 1612 | // Find the word, and move up the "last occurrence" to here. |
1529 | 1613 | $found_words = true; |
@@ -1537,20 +1621,23 @@ discard block |
||
1537 | 1621 | if (!empty($suggestions)) |
1538 | 1622 | { |
1539 | 1623 | // But first check they aren't going to be censored - no naughty words! |
1540 | - foreach ($suggestions as $k => $word) |
|
1541 | - if ($suggestions[$k] != censorText($word)) |
|
1624 | + foreach ($suggestions as $k => $word) { |
|
1625 | + if ($suggestions[$k] != censorText($word)) |
|
1542 | 1626 | unset($suggestions[$k]); |
1627 | + } |
|
1543 | 1628 | |
1544 | - if (!empty($suggestions)) |
|
1545 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1629 | + if (!empty($suggestions)) { |
|
1630 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1631 | + } |
|
1546 | 1632 | } |
1547 | 1633 | |
1548 | 1634 | $context['spell_js'] .= ']),'; |
1549 | 1635 | } |
1550 | 1636 | |
1551 | 1637 | // If words were found, take off the last comma. |
1552 | - if ($found_words) |
|
1553 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1638 | + if ($found_words) { |
|
1639 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1640 | + } |
|
1554 | 1641 | |
1555 | 1642 | $context['spell_js'] .= ' |
1556 | 1643 | );'; |
@@ -1585,11 +1672,13 @@ discard block |
||
1585 | 1672 | global $user_info, $smcFunc; |
1586 | 1673 | |
1587 | 1674 | // Can't do it if there's no topics. |
1588 | - if (empty($topics)) |
|
1589 | - return; |
|
1675 | + if (empty($topics)) { |
|
1676 | + return; |
|
1677 | + } |
|
1590 | 1678 | // It must be an array - it must! |
1591 | - if (!is_array($topics)) |
|
1592 | - $topics = array($topics); |
|
1679 | + if (!is_array($topics)) { |
|
1680 | + $topics = array($topics); |
|
1681 | + } |
|
1593 | 1682 | |
1594 | 1683 | // Get the subject and body... |
1595 | 1684 | $result = $smcFunc['db_query']('', ' |
@@ -1637,14 +1726,15 @@ discard block |
||
1637 | 1726 | } |
1638 | 1727 | $smcFunc['db_free_result']($result); |
1639 | 1728 | |
1640 | - if (!empty($task_rows)) |
|
1641 | - $smcFunc['db_insert']('', |
|
1729 | + if (!empty($task_rows)) { |
|
1730 | + $smcFunc['db_insert']('', |
|
1642 | 1731 | '{db_prefix}background_tasks', |
1643 | 1732 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1644 | 1733 | $task_rows, |
1645 | 1734 | array('id_task') |
1646 | 1735 | ); |
1647 | -} |
|
1736 | + } |
|
1737 | + } |
|
1648 | 1738 | |
1649 | 1739 | /** |
1650 | 1740 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1682,9 +1772,9 @@ discard block |
||
1682 | 1772 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
1683 | 1773 | |
1684 | 1774 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
1685 | - if (!$modSettings['postmod_active']) |
|
1686 | - $topicOptions['is_approved'] = true; |
|
1687 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1775 | + if (!$modSettings['postmod_active']) { |
|
1776 | + $topicOptions['is_approved'] = true; |
|
1777 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1688 | 1778 | { |
1689 | 1779 | $request = $smcFunc['db_query']('', ' |
1690 | 1780 | SELECT approved |
@@ -1707,8 +1797,7 @@ discard block |
||
1707 | 1797 | $posterOptions['id'] = 0; |
1708 | 1798 | $posterOptions['name'] = $txt['guest_title']; |
1709 | 1799 | $posterOptions['email'] = ''; |
1710 | - } |
|
1711 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
1800 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
1712 | 1801 | { |
1713 | 1802 | $request = $smcFunc['db_query']('', ' |
1714 | 1803 | SELECT member_name, email_address |
@@ -1726,12 +1815,11 @@ discard block |
||
1726 | 1815 | $posterOptions['id'] = 0; |
1727 | 1816 | $posterOptions['name'] = $txt['guest_title']; |
1728 | 1817 | $posterOptions['email'] = ''; |
1818 | + } else { |
|
1819 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1729 | 1820 | } |
1730 | - else |
|
1731 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1732 | 1821 | $smcFunc['db_free_result']($request); |
1733 | - } |
|
1734 | - else |
|
1822 | + } else |
|
1735 | 1823 | { |
1736 | 1824 | $posterOptions['name'] = $user_info['name']; |
1737 | 1825 | $posterOptions['email'] = $user_info['email']; |
@@ -1741,8 +1829,9 @@ discard block |
||
1741 | 1829 | if (!empty($modSettings['enable_mentions'])) |
1742 | 1830 | { |
1743 | 1831 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
1744 | - if (!empty($msgOptions['mentioned_members'])) |
|
1745 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1832 | + if (!empty($msgOptions['mentioned_members'])) { |
|
1833 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1834 | + } |
|
1746 | 1835 | } |
1747 | 1836 | |
1748 | 1837 | // It's do or die time: forget any user aborts! |
@@ -1775,12 +1864,13 @@ discard block |
||
1775 | 1864 | ); |
1776 | 1865 | |
1777 | 1866 | // Something went wrong creating the message... |
1778 | - if (empty($msgOptions['id'])) |
|
1779 | - return false; |
|
1867 | + if (empty($msgOptions['id'])) { |
|
1868 | + return false; |
|
1869 | + } |
|
1780 | 1870 | |
1781 | 1871 | // Fix the attachments. |
1782 | - if (!empty($msgOptions['attachments'])) |
|
1783 | - $smcFunc['db_query']('', ' |
|
1872 | + if (!empty($msgOptions['attachments'])) { |
|
1873 | + $smcFunc['db_query']('', ' |
|
1784 | 1874 | UPDATE {db_prefix}attachments |
1785 | 1875 | SET id_msg = {int:id_msg} |
1786 | 1876 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1789,6 +1879,7 @@ discard block |
||
1789 | 1879 | 'id_msg' => $msgOptions['id'], |
1790 | 1880 | ) |
1791 | 1881 | ); |
1882 | + } |
|
1792 | 1883 | |
1793 | 1884 | // What if we want to export new posts out to a CMS? |
1794 | 1885 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1865,20 +1956,23 @@ discard block |
||
1865 | 1956 | 'id_topic' => $topicOptions['id'], |
1866 | 1957 | 'counter_increment' => 1, |
1867 | 1958 | ); |
1868 | - if ($msgOptions['approved']) |
|
1869 | - $topics_columns = array( |
|
1959 | + if ($msgOptions['approved']) { |
|
1960 | + $topics_columns = array( |
|
1870 | 1961 | 'id_member_updated = {int:poster_id}', |
1871 | 1962 | 'id_last_msg = {int:id_msg}', |
1872 | 1963 | 'num_replies = num_replies + {int:counter_increment}', |
1873 | 1964 | ); |
1874 | - else |
|
1875 | - $topics_columns = array( |
|
1965 | + } else { |
|
1966 | + $topics_columns = array( |
|
1876 | 1967 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
1877 | 1968 | ); |
1878 | - if ($topicOptions['lock_mode'] !== null) |
|
1879 | - $topics_columns[] = 'locked = {int:locked}'; |
|
1880 | - if ($topicOptions['sticky_mode'] !== null) |
|
1881 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1969 | + } |
|
1970 | + if ($topicOptions['lock_mode'] !== null) { |
|
1971 | + $topics_columns[] = 'locked = {int:locked}'; |
|
1972 | + } |
|
1973 | + if ($topicOptions['sticky_mode'] !== null) { |
|
1974 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1975 | + } |
|
1882 | 1976 | |
1883 | 1977 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
1884 | 1978 | |
@@ -1907,8 +2001,8 @@ discard block |
||
1907 | 2001 | ); |
1908 | 2002 | |
1909 | 2003 | // Increase the number of posts and topics on the board. |
1910 | - if ($msgOptions['approved']) |
|
1911 | - $smcFunc['db_query']('', ' |
|
2004 | + if ($msgOptions['approved']) { |
|
2005 | + $smcFunc['db_query']('', ' |
|
1912 | 2006 | UPDATE {db_prefix}boards |
1913 | 2007 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
1914 | 2008 | WHERE id_board = {int:id_board}', |
@@ -1916,7 +2010,7 @@ discard block |
||
1916 | 2010 | 'id_board' => $topicOptions['board'], |
1917 | 2011 | ) |
1918 | 2012 | ); |
1919 | - else |
|
2013 | + } else |
|
1920 | 2014 | { |
1921 | 2015 | $smcFunc['db_query']('', ' |
1922 | 2016 | UPDATE {db_prefix}boards |
@@ -1986,8 +2080,8 @@ discard block |
||
1986 | 2080 | } |
1987 | 2081 | } |
1988 | 2082 | |
1989 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
1990 | - $smcFunc['db_insert']('', |
|
2083 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
2084 | + $smcFunc['db_insert']('', |
|
1991 | 2085 | '{db_prefix}background_tasks', |
1992 | 2086 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1993 | 2087 | array( |
@@ -1999,19 +2093,22 @@ discard block |
||
1999 | 2093 | ), |
2000 | 2094 | array('id_task') |
2001 | 2095 | ); |
2096 | + } |
|
2002 | 2097 | |
2003 | 2098 | // If there's a custom search index, it may need updating... |
2004 | 2099 | require_once($sourcedir . '/Search.php'); |
2005 | 2100 | $searchAPI = findSearchAPI(); |
2006 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
2007 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2101 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
2102 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2103 | + } |
|
2008 | 2104 | |
2009 | 2105 | // Increase the post counter for the user that created the post. |
2010 | 2106 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
2011 | 2107 | { |
2012 | 2108 | // Are you the one that happened to create this post? |
2013 | - if ($user_info['id'] == $posterOptions['id']) |
|
2014 | - $user_info['posts']++; |
|
2109 | + if ($user_info['id'] == $posterOptions['id']) { |
|
2110 | + $user_info['posts']++; |
|
2111 | + } |
|
2015 | 2112 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
2016 | 2113 | } |
2017 | 2114 | |
@@ -2019,19 +2116,21 @@ discard block |
||
2019 | 2116 | $_SESSION['last_read_topic'] = 0; |
2020 | 2117 | |
2021 | 2118 | // Better safe than sorry. |
2022 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
2023 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2119 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
2120 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2121 | + } |
|
2024 | 2122 | |
2025 | 2123 | // Update all the stats so everyone knows about this new topic and message. |
2026 | 2124 | updateStats('message', true, $msgOptions['id']); |
2027 | 2125 | |
2028 | 2126 | // Update the last message on the board assuming it's approved AND the topic is. |
2029 | - if ($msgOptions['approved']) |
|
2030 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2127 | + if ($msgOptions['approved']) { |
|
2128 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2129 | + } |
|
2031 | 2130 | |
2032 | 2131 | // Queue createPost background notification |
2033 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
2034 | - $smcFunc['db_insert']('', |
|
2132 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
2133 | + $smcFunc['db_insert']('', |
|
2035 | 2134 | '{db_prefix}background_tasks', |
2036 | 2135 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2037 | 2136 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2042,6 +2141,7 @@ discard block |
||
2042 | 2141 | )), 0), |
2043 | 2142 | array('id_task') |
2044 | 2143 | ); |
2144 | + } |
|
2045 | 2145 | |
2046 | 2146 | // Alright, done now... we can abort now, I guess... at least this much is done. |
2047 | 2147 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2068,14 +2168,18 @@ discard block |
||
2068 | 2168 | |
2069 | 2169 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
2070 | 2170 | $messages_columns = array(); |
2071 | - if (isset($posterOptions['name'])) |
|
2072 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
2073 | - if (isset($posterOptions['email'])) |
|
2074 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
2075 | - if (isset($msgOptions['icon'])) |
|
2076 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
2077 | - if (isset($msgOptions['subject'])) |
|
2078 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
2171 | + if (isset($posterOptions['name'])) { |
|
2172 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
2173 | + } |
|
2174 | + if (isset($posterOptions['email'])) { |
|
2175 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
2176 | + } |
|
2177 | + if (isset($msgOptions['icon'])) { |
|
2178 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
2179 | + } |
|
2180 | + if (isset($msgOptions['subject'])) { |
|
2181 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
2182 | + } |
|
2079 | 2183 | if (isset($msgOptions['body'])) |
2080 | 2184 | { |
2081 | 2185 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2102,8 +2206,9 @@ discard block |
||
2102 | 2206 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
2103 | 2207 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
2104 | 2208 | } |
2105 | - if (isset($msgOptions['smileys_enabled'])) |
|
2106 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2209 | + if (isset($msgOptions['smileys_enabled'])) { |
|
2210 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2211 | + } |
|
2107 | 2212 | |
2108 | 2213 | // Which columns need to be ints? |
2109 | 2214 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2121,23 +2226,27 @@ discard block |
||
2121 | 2226 | { |
2122 | 2227 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
2123 | 2228 | |
2124 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
2125 | - foreach ($match[1] as $i => $oldID) |
|
2229 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
2230 | + foreach ($match[1] as $i => $oldID) |
|
2126 | 2231 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
2232 | + } |
|
2127 | 2233 | |
2128 | - if (empty($modSettings['search_custom_index_config'])) |
|
2129 | - unset($msgOptions['old_body']); |
|
2234 | + if (empty($modSettings['search_custom_index_config'])) { |
|
2235 | + unset($msgOptions['old_body']); |
|
2236 | + } |
|
2130 | 2237 | } |
2131 | 2238 | |
2132 | 2239 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
2133 | 2240 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
2134 | 2241 | |
2135 | 2242 | // Remove the poster. |
2136 | - if (isset($mentions[$user_info['id']])) |
|
2137 | - unset($mentions[$user_info['id']]); |
|
2243 | + if (isset($mentions[$user_info['id']])) { |
|
2244 | + unset($mentions[$user_info['id']]); |
|
2245 | + } |
|
2138 | 2246 | |
2139 | - if (isset($oldmentions[$user_info['id']])) |
|
2140 | - unset($oldmentions[$user_info['id']]); |
|
2247 | + if (isset($oldmentions[$user_info['id']])) { |
|
2248 | + unset($oldmentions[$user_info['id']]); |
|
2249 | + } |
|
2141 | 2250 | |
2142 | 2251 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
2143 | 2252 | { |
@@ -2167,8 +2276,9 @@ discard block |
||
2167 | 2276 | } |
2168 | 2277 | |
2169 | 2278 | // Nothing to do? |
2170 | - if (empty($messages_columns)) |
|
2171 | - return true; |
|
2279 | + if (empty($messages_columns)) { |
|
2280 | + return true; |
|
2281 | + } |
|
2172 | 2282 | |
2173 | 2283 | // Change the post. |
2174 | 2284 | $smcFunc['db_query']('', ' |
@@ -2229,8 +2339,9 @@ discard block |
||
2229 | 2339 | // If there's a custom search index, it needs to be modified... |
2230 | 2340 | require_once($sourcedir . '/Search.php'); |
2231 | 2341 | $searchAPI = findSearchAPI(); |
2232 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
2233 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2342 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
2343 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2344 | + } |
|
2234 | 2345 | |
2235 | 2346 | if (isset($msgOptions['subject'])) |
2236 | 2347 | { |
@@ -2244,14 +2355,16 @@ discard block |
||
2244 | 2355 | 'id_first_msg' => $msgOptions['id'], |
2245 | 2356 | ) |
2246 | 2357 | ); |
2247 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
2248 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2358 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
2359 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2360 | + } |
|
2249 | 2361 | $smcFunc['db_free_result']($request); |
2250 | 2362 | } |
2251 | 2363 | |
2252 | 2364 | // Finally, if we are setting the approved state we need to do much more work :( |
2253 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
2254 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2365 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
2366 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2367 | + } |
|
2255 | 2368 | |
2256 | 2369 | return true; |
2257 | 2370 | } |
@@ -2268,11 +2381,13 @@ discard block |
||
2268 | 2381 | { |
2269 | 2382 | global $smcFunc; |
2270 | 2383 | |
2271 | - if (!is_array($msgs)) |
|
2272 | - $msgs = array($msgs); |
|
2384 | + if (!is_array($msgs)) { |
|
2385 | + $msgs = array($msgs); |
|
2386 | + } |
|
2273 | 2387 | |
2274 | - if (empty($msgs)) |
|
2275 | - return false; |
|
2388 | + if (empty($msgs)) { |
|
2389 | + return false; |
|
2390 | + } |
|
2276 | 2391 | |
2277 | 2392 | // May as well start at the beginning, working out *what* we need to change. |
2278 | 2393 | $request = $smcFunc['db_query']('', ' |
@@ -2304,20 +2419,22 @@ discard block |
||
2304 | 2419 | $topics[] = $row['id_topic']; |
2305 | 2420 | |
2306 | 2421 | // Ensure our change array exists already. |
2307 | - if (!isset($topic_changes[$row['id_topic']])) |
|
2308 | - $topic_changes[$row['id_topic']] = array( |
|
2422 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
2423 | + $topic_changes[$row['id_topic']] = array( |
|
2309 | 2424 | 'id_last_msg' => $row['id_last_msg'], |
2310 | 2425 | 'approved' => $row['topic_approved'], |
2311 | 2426 | 'replies' => 0, |
2312 | 2427 | 'unapproved_posts' => 0, |
2313 | 2428 | ); |
2314 | - if (!isset($board_changes[$row['id_board']])) |
|
2315 | - $board_changes[$row['id_board']] = array( |
|
2429 | + } |
|
2430 | + if (!isset($board_changes[$row['id_board']])) { |
|
2431 | + $board_changes[$row['id_board']] = array( |
|
2316 | 2432 | 'posts' => 0, |
2317 | 2433 | 'topics' => 0, |
2318 | 2434 | 'unapproved_posts' => 0, |
2319 | 2435 | 'unapproved_topics' => 0, |
2320 | 2436 | ); |
2437 | + } |
|
2321 | 2438 | |
2322 | 2439 | // If it's the first message then the topic state changes! |
2323 | 2440 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2338,14 +2455,13 @@ discard block |
||
2338 | 2455 | 'poster' => $row['id_member'], |
2339 | 2456 | 'new_topic' => true, |
2340 | 2457 | ); |
2341 | - } |
|
2342 | - else |
|
2458 | + } else |
|
2343 | 2459 | { |
2344 | 2460 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
2345 | 2461 | |
2346 | 2462 | // This will be a post... but don't notify unless it's not followed by approved ones. |
2347 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
2348 | - $notification_posts[$row['id_topic']] = array( |
|
2463 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
2464 | + $notification_posts[$row['id_topic']] = array( |
|
2349 | 2465 | 'id' => $row['id_msg'], |
2350 | 2466 | 'body' => $row['body'], |
2351 | 2467 | 'subject' => $row['subject'], |
@@ -2356,28 +2472,33 @@ discard block |
||
2356 | 2472 | 'new_topic' => false, |
2357 | 2473 | 'msg' => $row['id_msg'], |
2358 | 2474 | ); |
2475 | + } |
|
2359 | 2476 | } |
2360 | 2477 | |
2361 | 2478 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
2362 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
2363 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2479 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
2480 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2481 | + } |
|
2364 | 2482 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
2365 | - elseif (!$approve) |
|
2366 | - // Default to the first message and then we'll override in a bit ;) |
|
2483 | + elseif (!$approve) { |
|
2484 | + // Default to the first message and then we'll override in a bit ;) |
|
2367 | 2485 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
2486 | + } |
|
2368 | 2487 | |
2369 | 2488 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
2370 | 2489 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
2371 | 2490 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
2372 | 2491 | |
2373 | 2492 | // Post count for the user? |
2374 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
2375 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2493 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
2494 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2495 | + } |
|
2376 | 2496 | } |
2377 | 2497 | $smcFunc['db_free_result']($request); |
2378 | 2498 | |
2379 | - if (empty($msgs)) |
|
2380 | - return; |
|
2499 | + if (empty($msgs)) { |
|
2500 | + return; |
|
2501 | + } |
|
2381 | 2502 | |
2382 | 2503 | // Now we have the differences make the changes, first the easy one. |
2383 | 2504 | $smcFunc['db_query']('', ' |
@@ -2404,14 +2525,15 @@ discard block |
||
2404 | 2525 | 'approved' => 1, |
2405 | 2526 | ) |
2406 | 2527 | ); |
2407 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2408 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2528 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2529 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2530 | + } |
|
2409 | 2531 | $smcFunc['db_free_result']($request); |
2410 | 2532 | } |
2411 | 2533 | |
2412 | 2534 | // ... next the topics... |
2413 | - foreach ($topic_changes as $id => $changes) |
|
2414 | - $smcFunc['db_query']('', ' |
|
2535 | + foreach ($topic_changes as $id => $changes) { |
|
2536 | + $smcFunc['db_query']('', ' |
|
2415 | 2537 | UPDATE {db_prefix}topics |
2416 | 2538 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2417 | 2539 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2424,10 +2546,11 @@ discard block |
||
2424 | 2546 | 'id_topic' => $id, |
2425 | 2547 | ) |
2426 | 2548 | ); |
2549 | + } |
|
2427 | 2550 | |
2428 | 2551 | // ... finally the boards... |
2429 | - foreach ($board_changes as $id => $changes) |
|
2430 | - $smcFunc['db_query']('', ' |
|
2552 | + foreach ($board_changes as $id => $changes) { |
|
2553 | + $smcFunc['db_query']('', ' |
|
2431 | 2554 | UPDATE {db_prefix}boards |
2432 | 2555 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2433 | 2556 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2440,13 +2563,14 @@ discard block |
||
2440 | 2563 | 'id_board' => $id, |
2441 | 2564 | ) |
2442 | 2565 | ); |
2566 | + } |
|
2443 | 2567 | |
2444 | 2568 | // Finally, least importantly, notifications! |
2445 | 2569 | if ($approve) |
2446 | 2570 | { |
2447 | 2571 | $task_rows = array(); |
2448 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
2449 | - $task_rows[] = array( |
|
2572 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
2573 | + $task_rows[] = array( |
|
2450 | 2574 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
2451 | 2575 | 'msgOptions' => array( |
2452 | 2576 | 'id' => $topic['msg'], |
@@ -2464,14 +2588,16 @@ discard block |
||
2464 | 2588 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
2465 | 2589 | )), 0 |
2466 | 2590 | ); |
2591 | + } |
|
2467 | 2592 | |
2468 | - if ($notify) |
|
2469 | - $smcFunc['db_insert']('', |
|
2593 | + if ($notify) { |
|
2594 | + $smcFunc['db_insert']('', |
|
2470 | 2595 | '{db_prefix}background_tasks', |
2471 | 2596 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2472 | 2597 | $task_rows, |
2473 | 2598 | array('id_task') |
2474 | 2599 | ); |
2600 | + } |
|
2475 | 2601 | |
2476 | 2602 | $smcFunc['db_query']('', ' |
2477 | 2603 | DELETE FROM {db_prefix}approval_queue |
@@ -2487,8 +2613,9 @@ discard block |
||
2487 | 2613 | else |
2488 | 2614 | { |
2489 | 2615 | $msgInserts = array(); |
2490 | - foreach ($msgs as $msg) |
|
2491 | - $msgInserts[] = array($msg); |
|
2616 | + foreach ($msgs as $msg) { |
|
2617 | + $msgInserts[] = array($msg); |
|
2618 | + } |
|
2492 | 2619 | |
2493 | 2620 | $smcFunc['db_insert']('ignore', |
2494 | 2621 | '{db_prefix}approval_queue', |
@@ -2502,9 +2629,10 @@ discard block |
||
2502 | 2629 | updateLastMessages(array_keys($board_changes)); |
2503 | 2630 | |
2504 | 2631 | // Post count for the members? |
2505 | - if (!empty($member_post_changes)) |
|
2506 | - foreach ($member_post_changes as $id_member => $count_change) |
|
2632 | + if (!empty($member_post_changes)) { |
|
2633 | + foreach ($member_post_changes as $id_member => $count_change) |
|
2507 | 2634 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
2635 | + } |
|
2508 | 2636 | |
2509 | 2637 | return true; |
2510 | 2638 | } |
@@ -2521,11 +2649,13 @@ discard block |
||
2521 | 2649 | { |
2522 | 2650 | global $smcFunc; |
2523 | 2651 | |
2524 | - if (!is_array($topics)) |
|
2525 | - $topics = array($topics); |
|
2652 | + if (!is_array($topics)) { |
|
2653 | + $topics = array($topics); |
|
2654 | + } |
|
2526 | 2655 | |
2527 | - if (empty($topics)) |
|
2528 | - return false; |
|
2656 | + if (empty($topics)) { |
|
2657 | + return false; |
|
2658 | + } |
|
2529 | 2659 | |
2530 | 2660 | $approve_type = $approve ? 0 : 1; |
2531 | 2661 | |
@@ -2541,8 +2671,9 @@ discard block |
||
2541 | 2671 | ) |
2542 | 2672 | ); |
2543 | 2673 | $msgs = array(); |
2544 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2545 | - $msgs[] = $row['id_msg']; |
|
2674 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2675 | + $msgs[] = $row['id_msg']; |
|
2676 | + } |
|
2546 | 2677 | $smcFunc['db_free_result']($request); |
2547 | 2678 | |
2548 | 2679 | return approvePosts($msgs, $approve); |
@@ -2565,11 +2696,13 @@ discard block |
||
2565 | 2696 | global $board_info, $board, $smcFunc; |
2566 | 2697 | |
2567 | 2698 | // Please - let's be sane. |
2568 | - if (empty($setboards)) |
|
2569 | - return false; |
|
2699 | + if (empty($setboards)) { |
|
2700 | + return false; |
|
2701 | + } |
|
2570 | 2702 | |
2571 | - if (!is_array($setboards)) |
|
2572 | - $setboards = array($setboards); |
|
2703 | + if (!is_array($setboards)) { |
|
2704 | + $setboards = array($setboards); |
|
2705 | + } |
|
2573 | 2706 | |
2574 | 2707 | // If we don't know the id_msg we need to find it. |
2575 | 2708 | if (!$id_msg) |
@@ -2587,15 +2720,16 @@ discard block |
||
2587 | 2720 | ) |
2588 | 2721 | ); |
2589 | 2722 | $lastMsg = array(); |
2590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2591 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2723 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2724 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2725 | + } |
|
2592 | 2726 | $smcFunc['db_free_result']($request); |
2593 | - } |
|
2594 | - else |
|
2727 | + } else |
|
2595 | 2728 | { |
2596 | 2729 | // Just to note - there should only be one board passed if we are doing this. |
2597 | - foreach ($setboards as $id_board) |
|
2598 | - $lastMsg[$id_board] = $id_msg; |
|
2730 | + foreach ($setboards as $id_board) { |
|
2731 | + $lastMsg[$id_board] = $id_msg; |
|
2732 | + } |
|
2599 | 2733 | } |
2600 | 2734 | |
2601 | 2735 | $parent_boards = array(); |
@@ -2610,10 +2744,11 @@ discard block |
||
2610 | 2744 | $lastModified[$id_board] = 0; |
2611 | 2745 | } |
2612 | 2746 | |
2613 | - if (!empty($board) && $id_board == $board) |
|
2614 | - $parents = $board_info['parent_boards']; |
|
2615 | - else |
|
2616 | - $parents = getBoardParents($id_board); |
|
2747 | + if (!empty($board) && $id_board == $board) { |
|
2748 | + $parents = $board_info['parent_boards']; |
|
2749 | + } else { |
|
2750 | + $parents = getBoardParents($id_board); |
|
2751 | + } |
|
2617 | 2752 | |
2618 | 2753 | // Ignore any parents on the top child level. |
2619 | 2754 | // @todo Why? |
@@ -2622,10 +2757,11 @@ discard block |
||
2622 | 2757 | if ($parent['level'] != 0) |
2623 | 2758 | { |
2624 | 2759 | // If we're already doing this one as a board, is this a higher last modified? |
2625 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
2626 | - $lastModified[$id] = $lastModified[$id_board]; |
|
2627 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
2628 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
2760 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
2761 | + $lastModified[$id] = $lastModified[$id_board]; |
|
2762 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
2763 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
2764 | + } |
|
2629 | 2765 | } |
2630 | 2766 | } |
2631 | 2767 | } |
@@ -2638,23 +2774,24 @@ discard block |
||
2638 | 2774 | // Finally, to save on queries make the changes... |
2639 | 2775 | foreach ($parent_boards as $id => $msg) |
2640 | 2776 | { |
2641 | - if (!isset($parent_updates[$msg])) |
|
2642 | - $parent_updates[$msg] = array($id); |
|
2643 | - else |
|
2644 | - $parent_updates[$msg][] = $id; |
|
2777 | + if (!isset($parent_updates[$msg])) { |
|
2778 | + $parent_updates[$msg] = array($id); |
|
2779 | + } else { |
|
2780 | + $parent_updates[$msg][] = $id; |
|
2781 | + } |
|
2645 | 2782 | } |
2646 | 2783 | |
2647 | 2784 | foreach ($lastMsg as $id => $msg) |
2648 | 2785 | { |
2649 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
2650 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2786 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
2787 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2651 | 2788 | 'id' => $msg, |
2652 | 2789 | 'updated' => $lastModified[$id], |
2653 | 2790 | 'boards' => array($id) |
2654 | 2791 | ); |
2655 | - |
|
2656 | - else |
|
2657 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2792 | + } else { |
|
2793 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2794 | + } |
|
2658 | 2795 | } |
2659 | 2796 | |
2660 | 2797 | // Now commit the changes! |
@@ -2746,11 +2883,13 @@ discard block |
||
2746 | 2883 | global $txt, $mbname, $scripturl, $settings; |
2747 | 2884 | |
2748 | 2885 | // First things first, load up the email templates language file, if we need to. |
2749 | - if ($loadLang) |
|
2750 | - loadLanguage('EmailTemplates', $lang); |
|
2886 | + if ($loadLang) { |
|
2887 | + loadLanguage('EmailTemplates', $lang); |
|
2888 | + } |
|
2751 | 2889 | |
2752 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
2753 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
2890 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
2891 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
2892 | + } |
|
2754 | 2893 | |
2755 | 2894 | $ret = array( |
2756 | 2895 | 'subject' => $txt[$template . '_subject'], |
@@ -2800,17 +2939,18 @@ discard block |
||
2800 | 2939 | function user_info_callback($matches) |
2801 | 2940 | { |
2802 | 2941 | global $user_info; |
2803 | - if (empty($matches[1])) |
|
2804 | - return ''; |
|
2942 | + if (empty($matches[1])) { |
|
2943 | + return ''; |
|
2944 | + } |
|
2805 | 2945 | |
2806 | 2946 | $use_ref = true; |
2807 | 2947 | $ref = &$user_info; |
2808 | 2948 | |
2809 | 2949 | foreach (explode('.', $matches[1]) as $index) |
2810 | 2950 | { |
2811 | - if ($use_ref && isset($ref[$index])) |
|
2812 | - $ref = &$ref[$index]; |
|
2813 | - else |
|
2951 | + if ($use_ref && isset($ref[$index])) { |
|
2952 | + $ref = &$ref[$index]; |
|
2953 | + } else |
|
2814 | 2954 | { |
2815 | 2955 | $use_ref = false; |
2816 | 2956 | break; |
@@ -2847,8 +2987,7 @@ discard block |
||
2847 | 2987 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
2848 | 2988 | { |
2849 | 2989 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
2850 | - } |
|
2851 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2990 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2852 | 2991 | { |
2853 | 2992 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
2854 | 2993 | } |
@@ -2858,8 +2997,7 @@ discard block |
||
2858 | 2997 | { |
2859 | 2998 | $context['provider'] = 'enchant'; |
2860 | 2999 | return $enchant_link; |
2861 | - } |
|
2862 | - else |
|
3000 | + } else |
|
2863 | 3001 | { |
2864 | 3002 | // Free up any resources used... |
2865 | 3003 | @enchant_broker_free($context['enchant_broker']); |
@@ -2880,8 +3018,9 @@ discard block |
||
2880 | 3018 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
2881 | 3019 | |
2882 | 3020 | // Most people don't have anything but English installed... So we use English as a last resort. |
2883 | - if (!$pspell_link) |
|
2884 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3021 | + if (!$pspell_link) { |
|
3022 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3023 | + } |
|
2885 | 3024 | |
2886 | 3025 | error_reporting($old); |
2887 | 3026 | ob_end_clean(); |
@@ -2921,8 +3060,7 @@ discard block |
||
2921 | 3060 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
2922 | 3061 | } |
2923 | 3062 | return enchant_dict_check($dict, $word); |
2924 | - } |
|
2925 | - elseif ($context['provider'] == 'pspell') |
|
3063 | + } elseif ($context['provider'] == 'pspell') |
|
2926 | 3064 | { |
2927 | 3065 | return pspell_check($dict, $word); |
2928 | 3066 | } |
@@ -2958,13 +3096,11 @@ discard block |
||
2958 | 3096 | } |
2959 | 3097 | |
2960 | 3098 | return $suggestions; |
2961 | - } |
|
2962 | - else |
|
3099 | + } else |
|
2963 | 3100 | { |
2964 | 3101 | return enchant_dict_suggest($dict, $word); |
2965 | 3102 | } |
2966 | - } |
|
2967 | - elseif ($context['provider'] == 'pspell') |
|
3103 | + } elseif ($context['provider'] == 'pspell') |
|
2968 | 3104 | { |
2969 | 3105 | return pspell_suggest($dict, $word); |
2970 | 3106 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * Used by VerificationCode() (Register.php). |
25 | 25 | * |
26 | 26 | * @param string $word |
27 | - * @return boolean false on failure |
|
27 | + * @return null|false false on failure |
|
28 | 28 | */ |
29 | 29 | |
30 | 30 | function createWaveFile($word) |
@@ -38,7 +38,7 @@ |
||
38 | 38 | cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20); |
39 | 39 | |
40 | 40 | // Fixate randomization for this word. |
41 | - $tmp = unpack('n', md5($word . session_id())); |
|
41 | + $tmp = unpack('n', md5($word . session_id())); |
|
42 | 42 | mt_srand(end($tmp)); |
43 | 43 | |
44 | 44 | // Try to see if there's a sound font in the user's language. |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Creates a wave file that spells the letters of $word. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $settings, $user_info; |
33 | 34 | |
34 | 35 | // Allow max 2 requests per 20 seconds. |
35 | - if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) |
|
36 | - die(header('HTTP/1.1 400 Bad Request')); |
|
36 | + if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) { |
|
37 | + die(header('HTTP/1.1 400 Bad Request')); |
|
38 | + } |
|
37 | 39 | cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20); |
38 | 40 | cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20); |
39 | 41 | |
@@ -42,16 +44,19 @@ discard block |
||
42 | 44 | mt_srand(end($tmp)); |
43 | 45 | |
44 | 46 | // Try to see if there's a sound font in the user's language. |
45 | - if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) |
|
46 | - $sound_language = $user_info['language']; |
|
47 | + if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) { |
|
48 | + $sound_language = $user_info['language']; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | // English should be there. |
49 | - elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) |
|
50 | - $sound_language = 'english'; |
|
52 | + elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) { |
|
53 | + $sound_language = 'english'; |
|
54 | + } |
|
51 | 55 | |
52 | 56 | // Guess not... |
53 | - else |
|
54 | - return false; |
|
57 | + else { |
|
58 | + return false; |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // File names are in lower case so lets make sure that we are only using a lower case string |
57 | 62 | $word = strtolower($word); |
@@ -61,20 +66,25 @@ discard block |
||
61 | 66 | for ($i = 0; $i < strlen($word); $i++) |
62 | 67 | { |
63 | 68 | $sound_letter = implode('', file($settings['default_theme_dir'] . '/fonts/sound/' . $word{$i} . '.' . $sound_language . '.wav')); |
64 | - if (strpos($sound_letter, 'data') === false) |
|
65 | - return false; |
|
69 | + if (strpos($sound_letter, 'data') === false) { |
|
70 | + return false; |
|
71 | + } |
|
66 | 72 | |
67 | 73 | $sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8); |
68 | 74 | switch ($word{$i} === 's' ? 0 : mt_rand(0, 2)) |
69 | 75 | { |
70 | - case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
|
71 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
72 | - $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
76 | + case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) { |
|
77 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); |
|
78 | + } |
|
79 | + $k < $m; $k++) { |
|
80 | + $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
81 | + } |
|
73 | 82 | break; |
74 | 83 | |
75 | 84 | case 1: |
76 | - for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) |
|
77 | - $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
85 | + for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) { |
|
86 | + $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
87 | + } |
|
78 | 88 | $sound_word .= str_repeat($sound_letter{$n}, 2); |
79 | 89 | break; |
80 | 90 | |
@@ -82,10 +92,12 @@ discard block |
||
82 | 92 | $shift = 0; |
83 | 93 | for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
84 | 94 | { |
85 | - if (mt_rand(0, 10) === 0) |
|
86 | - $shift += mt_rand(-3, 3); |
|
87 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
88 | - $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
95 | + if (mt_rand(0, 10) === 0) { |
|
96 | + $shift += mt_rand(-3, 3); |
|
97 | + } |
|
98 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) { |
|
99 | + $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
100 | + } |
|
89 | 101 | } |
90 | 102 | break; |
91 | 103 |
@@ -425,7 +425,7 @@ |
||
425 | 425 | * |
426 | 426 | * This is a recursive function, it will call itself if there are subdirs inside the main directory. |
427 | 427 | * @param string $path The absolute path to the directory to be removed |
428 | - * @return bool true when success, false on error. |
|
428 | + * @return false|null true when success, false on error. |
|
429 | 429 | */ |
430 | 430 | function remove_dir($path) |
431 | 431 | { |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Gets a single theme's info. |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | global $smcFunc, $modSettings; |
28 | 29 | |
29 | 30 | // No data, no fun! |
30 | - if (empty($id)) |
|
31 | - return false; |
|
31 | + if (empty($id)) { |
|
32 | + return false; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | // Make sure $id is an int. |
34 | 36 | $id = (int) $id; |
@@ -171,8 +173,9 @@ discard block |
||
171 | 173 | global $smcFunc, $sourcedir, $forum_version, $txt, $scripturl, $context; |
172 | 174 | global $explicit_images; |
173 | 175 | |
174 | - if (empty($path)) |
|
175 | - return false; |
|
176 | + if (empty($path)) { |
|
177 | + return false; |
|
178 | + } |
|
176 | 179 | |
177 | 180 | $xml_data = array(); |
178 | 181 | $explicit_images = false; |
@@ -229,9 +232,10 @@ discard block |
||
229 | 232 | ); |
230 | 233 | |
231 | 234 | // Assign the values to be stored. |
232 | - foreach ($xml_elements as $var => $name) |
|
233 | - if (!empty($theme_info_xml[$name])) |
|
235 | + foreach ($xml_elements as $var => $name) { |
|
236 | + if (!empty($theme_info_xml[$name])) |
|
234 | 237 | $xml_data[$var] = $theme_info_xml[$name]; |
238 | + } |
|
235 | 239 | |
236 | 240 | // Add the supported versions. |
237 | 241 | $xml_data['install_for'] = $install_versions; |
@@ -243,8 +247,9 @@ discard block |
||
243 | 247 | $explicit_images = true; |
244 | 248 | } |
245 | 249 | |
246 | - if (!empty($theme_info_xml['extra'])) |
|
247 | - $xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true); |
|
250 | + if (!empty($theme_info_xml['extra'])) { |
|
251 | + $xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true); |
|
252 | + } |
|
248 | 253 | |
249 | 254 | return $xml_data; |
250 | 255 | } |
@@ -262,12 +267,14 @@ discard block |
||
262 | 267 | global $settings, $explicit_images; |
263 | 268 | |
264 | 269 | // External use? no problem! |
265 | - if ($to_install) |
|
266 | - $context['to_install'] = $to_install; |
|
270 | + if ($to_install) { |
|
271 | + $context['to_install'] = $to_install; |
|
272 | + } |
|
267 | 273 | |
268 | 274 | // One last check. |
269 | - if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') |
|
270 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
275 | + if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') { |
|
276 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
277 | + } |
|
271 | 278 | |
272 | 279 | // OK, is this a newer version of an already installed theme? |
273 | 280 | if (!empty($context['to_install']['version'])) |
@@ -291,8 +298,8 @@ discard block |
||
291 | 298 | $smcFunc['db_free_result']($request); |
292 | 299 | |
293 | 300 | // Got something, lets figure it out what to do next. |
294 | - if (!empty($to_update) && !empty($to_update['version'])) |
|
295 | - switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
301 | + if (!empty($to_update) && !empty($to_update['version'])) { |
|
302 | + switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
296 | 303 | { |
297 | 304 | case 1: // Got a newer version, update the old entry. |
298 | 305 | $smcFunc['db_query']('', ' |
@@ -306,6 +313,7 @@ discard block |
||
306 | 313 | 'id_theme' => $to_update['id_theme'], |
307 | 314 | ) |
308 | 315 | ); |
316 | + } |
|
309 | 317 | |
310 | 318 | // Done with the update, tell the user about it. |
311 | 319 | $context['to_install']['updated'] = true; |
@@ -371,13 +379,15 @@ discard block |
||
371 | 379 | $context['to_install']['base_theme_url'] = $temp['theme_url']; |
372 | 380 | $context['to_install']['base_theme_dir'] = $temp['theme_dir']; |
373 | 381 | |
374 | - if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) |
|
375 | - $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
382 | + if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) { |
|
383 | + $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
384 | + } |
|
376 | 385 | } |
377 | 386 | |
378 | 387 | // Nope, sorry, couldn't find any theme already installed. |
379 | - else |
|
380 | - fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
388 | + else { |
|
389 | + fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
390 | + } |
|
381 | 391 | } |
382 | 392 | |
383 | 393 | unset($context['to_install']['based_on']); |
@@ -400,16 +410,18 @@ discard block |
||
400 | 410 | call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme)); |
401 | 411 | |
402 | 412 | $inserts = array(); |
403 | - foreach ($context['to_install'] as $var => $val) |
|
404 | - $inserts[] = array($id_theme, $var, $val); |
|
413 | + foreach ($context['to_install'] as $var => $val) { |
|
414 | + $inserts[] = array($id_theme, $var, $val); |
|
415 | + } |
|
405 | 416 | |
406 | - if (!empty($inserts)) |
|
407 | - $smcFunc['db_insert']('insert', |
|
417 | + if (!empty($inserts)) { |
|
418 | + $smcFunc['db_insert']('insert', |
|
408 | 419 | '{db_prefix}themes', |
409 | 420 | array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
410 | 421 | $inserts, |
411 | 422 | array('id_theme', 'variable') |
412 | 423 | ); |
424 | + } |
|
413 | 425 | |
414 | 426 | // Update the known and enable Theme's settings. |
415 | 427 | $known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ',')); |
@@ -428,21 +440,24 @@ discard block |
||
428 | 440 | */ |
429 | 441 | function remove_dir($path) |
430 | 442 | { |
431 | - if (empty($path)) |
|
432 | - return false; |
|
443 | + if (empty($path)) { |
|
444 | + return false; |
|
445 | + } |
|
433 | 446 | |
434 | 447 | if (is_dir($path)) |
435 | 448 | { |
436 | 449 | $objects = scandir($path); |
437 | 450 | |
438 | - foreach ($objects as $object) |
|
439 | - if ($object != '.' && $object != '..') |
|
451 | + foreach ($objects as $object) { |
|
452 | + if ($object != '.' && $object != '..') |
|
440 | 453 | { |
441 | 454 | if (filetype($path . '/' . $object) == 'dir') |
442 | 455 | remove_dir($path . '/' . $object); |
456 | + } |
|
443 | 457 | |
444 | - else |
|
445 | - unlink($path . '/' . $object); |
|
458 | + else { |
|
459 | + unlink($path . '/' . $object); |
|
460 | + } |
|
446 | 461 | } |
447 | 462 | } |
448 | 463 | |
@@ -461,8 +476,9 @@ discard block |
||
461 | 476 | global $smcFunc, $modSettings; |
462 | 477 | |
463 | 478 | // Can't delete the default theme, sorry! |
464 | - if (empty($themeID) || $themeID == 1) |
|
465 | - return false; |
|
479 | + if (empty($themeID) || $themeID == 1) { |
|
480 | + return false; |
|
481 | + } |
|
466 | 482 | |
467 | 483 | $known = explode(',', $modSettings['knownThemes']); |
468 | 484 | $enable = explode(',', $modSettings['enableThemes']); |
@@ -512,8 +528,9 @@ discard block |
||
512 | 528 | updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known)); |
513 | 529 | |
514 | 530 | // Fix it if the theme was the overall default theme. |
515 | - if ($modSettings['theme_guests'] == $themeID) |
|
516 | - updateSettings(array('theme_guests' => '1')); |
|
531 | + if ($modSettings['theme_guests'] == $themeID) { |
|
532 | + updateSettings(array('theme_guests' => '1')); |
|
533 | + } |
|
517 | 534 | |
518 | 535 | return true; |
519 | 536 | } |
@@ -530,13 +547,15 @@ discard block |
||
530 | 547 | global $scripturl, $txt, $context; |
531 | 548 | |
532 | 549 | // Is it even a directory? |
533 | - if (!is_dir($path)) |
|
534 | - fatal_lang_error('error_invalid_dir', 'critical'); |
|
550 | + if (!is_dir($path)) { |
|
551 | + fatal_lang_error('error_invalid_dir', 'critical'); |
|
552 | + } |
|
535 | 553 | |
536 | 554 | $dir = dir($path); |
537 | 555 | $entries = array(); |
538 | - while ($entry = $dir->read()) |
|
539 | - $entries[] = $entry; |
|
556 | + while ($entry = $dir->read()) { |
|
557 | + $entries[] = $entry; |
|
558 | + } |
|
540 | 559 | $dir->close(); |
541 | 560 | |
542 | 561 | natcasesort($entries); |
@@ -547,11 +566,12 @@ discard block |
||
547 | 566 | foreach ($entries as $entry) |
548 | 567 | { |
549 | 568 | // Skip all dot files, including .htaccess. |
550 | - if (substr($entry, 0, 1) == '.' || $entry == 'CVS') |
|
551 | - continue; |
|
569 | + if (substr($entry, 0, 1) == '.' || $entry == 'CVS') { |
|
570 | + continue; |
|
571 | + } |
|
552 | 572 | |
553 | - if (is_dir($path . '/' . $entry)) |
|
554 | - $listing1[] = array( |
|
573 | + if (is_dir($path . '/' . $entry)) { |
|
574 | + $listing1[] = array( |
|
555 | 575 | 'filename' => $entry, |
556 | 576 | 'is_writable' => is_writable($path . '/' . $entry), |
557 | 577 | 'is_directory' => true, |
@@ -561,13 +581,14 @@ discard block |
||
561 | 581 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry, |
562 | 582 | 'size' => '', |
563 | 583 | ); |
564 | - else |
|
584 | + } else |
|
565 | 585 | { |
566 | 586 | $size = filesize($path . '/' . $entry); |
567 | - if ($size > 2048 || $size == 1024) |
|
568 | - $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
569 | - else |
|
570 | - $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
587 | + if ($size > 2048 || $size == 1024) { |
|
588 | + $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
589 | + } else { |
|
590 | + $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
591 | + } |
|
571 | 592 | |
572 | 593 | $listing2[] = array( |
573 | 594 | 'filename' => $entry, |
@@ -402,7 +402,7 @@ |
||
402 | 402 | * A private function to find out the subscription details. |
403 | 403 | * |
404 | 404 | * @access private |
405 | - * @return boolean|void False on failure, otherwise just sets $_POST['item_number'] |
|
405 | + * @return false|null False on failure, otherwise just sets $_POST['item_number'] |
|
406 | 406 | */ |
407 | 407 | private function _findSubscription() |
408 | 408 | { |
@@ -236,7 +236,7 @@ |
||
236 | 236 | $header = 'POST /cgi-bin/webscr HTTP/1.1' . "\r\n"; |
237 | 237 | $header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; |
238 | 238 | $header .= 'Host: www.' . (!empty($modSettings['paidsubs_test']) ? 'sandbox.' : '') . 'paypal.com' . "\r\n"; |
239 | - $header .= 'Content-Length: ' . strlen ($requestString) . "\r\n"; |
|
239 | + $header .= 'Content-Length: ' . strlen($requestString) . "\r\n"; |
|
240 | 240 | $header .= 'Connection: close' . "\r\n\r\n"; |
241 | 241 | |
242 | 242 | // Open the connection. |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
15 | 15 | // SMF Payment Gateway: paypal |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
118 | 119 | { |
119 | 120 | $return_data['hidden']['p3'] = 1; |
120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
121 | - } |
|
122 | - else |
|
122 | + } else |
|
123 | 123 | { |
124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // If it's repeatable do some javascript to respect this idea. |
133 | - if (!empty($sub_data['repeatable'])) |
|
134 | - $return_data['javascript'] = ' |
|
133 | + if (!empty($sub_data['repeatable'])) { |
|
134 | + $return_data['javascript'] = ' |
|
135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();">' . $txt['paid_make_recurring'] . '</label><br>\'); |
136 | 136 | |
137 | 137 | function switchPaypalRecur() |
138 | 138 | { |
139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
140 | 140 | }'; |
141 | + } |
|
141 | 142 | |
142 | 143 | return $return_data; |
143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
160 | 161 | global $modSettings; |
161 | 162 | |
162 | 163 | // Has the user set up an email address? |
163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
164 | - return false; |
|
164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
165 | + return false; |
|
166 | + } |
|
165 | 167 | // Check the correct transaction types are even here. |
166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
167 | - return false; |
|
168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
169 | + return false; |
|
170 | + } |
|
168 | 171 | // Correct email address? |
169 | - if (!isset($_POST['business'])) |
|
170 | - $_POST['business'] = $_POST['receiver_email']; |
|
172 | + if (!isset($_POST['business'])) { |
|
173 | + $_POST['business'] = $_POST['receiver_email']; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | // Are we testing? |
173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
174 | - return false; |
|
175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
176 | - return false; |
|
177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
178 | + return false; |
|
179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
180 | + return false; |
|
181 | + } |
|
177 | 182 | return true; |
178 | 183 | } |
179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
192 | 197 | global $modSettings, $txt; |
193 | 198 | |
194 | 199 | // Put this to some default value. |
195 | - if (!isset($_POST['txn_type'])) |
|
196 | - $_POST['txn_type'] = ''; |
|
200 | + if (!isset($_POST['txn_type'])) { |
|
201 | + $_POST['txn_type'] = ''; |
|
202 | + } |
|
197 | 203 | |
198 | 204 | // Build the request string - starting with the minimum requirement. |
199 | 205 | $requestString = 'cmd=_notify-validate'; |
200 | 206 | |
201 | 207 | // Now my dear, add all the posted bits in the order we got them |
202 | - foreach ($_POST as $k => $v) |
|
203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
208 | + foreach ($_POST as $k => $v) { |
|
209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
210 | + } |
|
204 | 211 | |
205 | 212 | // Can we use curl? |
206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'https://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
240 | 247 | $header .= 'Connection: close' . "\r\n\r\n"; |
241 | 248 | |
242 | 249 | // Open the connection. |
243 | - if (!empty($modSettings['paidsubs_test'])) |
|
244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
245 | - else |
|
246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
252 | + } else { |
|
253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
254 | + } |
|
247 | 255 | |
248 | 256 | // Did it work? |
249 | - if (!$fp) |
|
250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
257 | + if (!$fp) { |
|
258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
259 | + } |
|
251 | 260 | |
252 | 261 | // Put the data to the port. |
253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
256 | 265 | while (!feof($fp)) |
257 | 266 | { |
258 | 267 | $this->return_data = fgets($fp, 1024); |
259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
260 | - break; |
|
268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
269 | + break; |
|
270 | + } |
|
261 | 271 | } |
262 | 272 | |
263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
265 | 275 | } |
266 | 276 | |
267 | 277 | // If this isn't verified then give up... |
268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
269 | - exit; |
|
278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
279 | + exit; |
|
280 | + } |
|
270 | 281 | |
271 | 282 | // Check that this is intended for us. |
272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
273 | - exit; |
|
283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
284 | + exit; |
|
285 | + } |
|
274 | 286 | |
275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
280 | - // Calculate the subscription it relates to! |
|
289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
291 | + } |
|
292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
293 | + // Calculate the subscription it relates to! |
|
281 | 294 | $this->_findSubscription(); |
295 | + } |
|
282 | 296 | |
283 | 297 | // Verify the currency! |
284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
285 | - exit; |
|
298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
299 | + exit; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | // Can't exist if it doesn't contain anything. |
288 | - if (empty($_POST['item_number'])) |
|
289 | - exit; |
|
303 | + if (empty($_POST['item_number'])) { |
|
304 | + exit; |
|
305 | + } |
|
290 | 306 | |
291 | 307 | // Return the id_sub and id_member |
292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
299 | 315 | */ |
300 | 316 | public function isRefund() |
301 | 317 | { |
302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
303 | - return true; |
|
304 | - else |
|
305 | - return false; |
|
318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
319 | + return true; |
|
320 | + } else { |
|
321 | + return false; |
|
322 | + } |
|
306 | 323 | } |
307 | 324 | |
308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
312 | 329 | */ |
313 | 330 | public function isSubscription() |
314 | 331 | { |
315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
316 | - return true; |
|
317 | - else |
|
318 | - return false; |
|
332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
333 | + return true; |
|
334 | + } else { |
|
335 | + return false; |
|
336 | + } |
|
319 | 337 | } |
320 | 338 | |
321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
325 | 343 | */ |
326 | 344 | public function isPayment() |
327 | 345 | { |
328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
329 | - return true; |
|
330 | - else |
|
331 | - return false; |
|
346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
347 | + return true; |
|
348 | + } else { |
|
349 | + return false; |
|
350 | + } |
|
332 | 351 | } |
333 | 352 | |
334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
342 | 361 | // Neither require us to *do* anything as per performCancel(). |
343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
345 | - return true; |
|
346 | - else |
|
347 | - return false; |
|
363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
364 | + return true; |
|
365 | + } else { |
|
366 | + return false; |
|
367 | + } |
|
348 | 368 | } |
349 | 369 | |
350 | 370 | /** |
@@ -408,8 +428,9 @@ discard block |
||
408 | 428 | global $smcFunc; |
409 | 429 | |
410 | 430 | // Assume we have this? |
411 | - if (empty($_POST['subscr_id'])) |
|
412 | - return false; |
|
431 | + if (empty($_POST['subscr_id'])) { |
|
432 | + return false; |
|
433 | + } |
|
413 | 434 | |
414 | 435 | // Do we have this in the database? |
415 | 436 | $request = $smcFunc['db_query']('', ' |
@@ -438,11 +459,12 @@ discard block |
||
438 | 459 | 'payer_email' => $_POST['payer_email'], |
439 | 460 | ) |
440 | 461 | ); |
441 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
442 | - return false; |
|
462 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
463 | + return false; |
|
464 | + } |
|
465 | + } else { |
|
466 | + return false; |
|
443 | 467 | } |
444 | - else |
|
445 | - return false; |
|
446 | 468 | } |
447 | 469 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
448 | 470 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
24 | - * @return bool Always returns true |
|
24 | + * @return boolean|null Always returns true |
|
25 | 25 | */ |
26 | 26 | public function execute() |
27 | 27 | { |
@@ -32,8 +32,9 @@ discard block |
||
32 | 32 | $members = membersAllowedTo('calendar_view'); |
33 | 33 | |
34 | 34 | // Don't alert the event creator |
35 | - if (!empty($this->_details['sender_id'])) |
|
36 | - $members = array_diff($members, array($this->_details['sender_id'])); |
|
35 | + if (!empty($this->_details['sender_id'])) { |
|
36 | + $members = array_diff($members, array($this->_details['sender_id'])); |
|
37 | + } |
|
37 | 38 | |
38 | 39 | // Having successfully figured this out, now let's get the preferences of everyone. |
39 | 40 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -44,10 +45,11 @@ discard block |
||
44 | 45 | if (!empty($this->_details['sender_id']) && empty($this->_details['sender_name'])) |
45 | 46 | { |
46 | 47 | loadMemberData($this->_details['sender_id'], 'minimal'); |
47 | - if (!empty($user_profile[$this->_details['sender_id']])) |
|
48 | - $this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name']; |
|
49 | - else |
|
50 | - $this->_details['sender_id'] = 0; |
|
48 | + if (!empty($user_profile[$this->_details['sender_id']])) { |
|
49 | + $this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name']; |
|
50 | + } else { |
|
51 | + $this->_details['sender_id'] = 0; |
|
52 | + } |
|
51 | 53 | } |
52 | 54 | |
53 | 55 | // So now we find out who wants what. |
@@ -59,9 +61,10 @@ discard block |
||
59 | 61 | |
60 | 62 | foreach ($prefs as $member => $pref_option) |
61 | 63 | { |
62 | - foreach ($alert_bits as $type => $bitvalue) |
|
63 | - if ($pref_option['event_new'] & $bitvalue) |
|
64 | + foreach ($alert_bits as $type => $bitvalue) { |
|
65 | + if ($pref_option['event_new'] & $bitvalue) |
|
64 | 66 | $notifies[$type][] = $member; |
67 | + } |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | // Firstly, anyone who wants alerts. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | class EventNew_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | 24 | * @return bool Always returns true |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'content_action' => empty($this->_details['sender_id']) ? 'new_guest' : 'new', |
82 | 82 | 'is_read' => 0, |
83 | 83 | 'extra' => $smcFunc['json_encode']( |
84 | - array( |
|
85 | - "event_id" => $this->_details['event_id'], |
|
84 | + array( |
|
85 | + "event_id" => $this->_details['event_id'], |
|
86 | 86 | "event_title" => $this->_details['event_title'] |
87 | 87 | ) |
88 | 88 | ), |
@@ -80,7 +80,7 @@ |
||
80 | 80 | /** |
81 | 81 | * Handles retrieving previews of news items, newsletters, signatures and warnings. |
82 | 82 | * Calls the appropriate function based on $_POST['item'] |
83 | - * @return void|bool Returns false if $_POST['item'] isn't set or isn't valid |
|
83 | + * @return false|null Returns false if $_POST['item'] isn't set or isn't valid |
|
84 | 84 | */ |
85 | 85 | function RetrievePreview() |
86 | 86 | { |
@@ -272,13 +272,13 @@ |
||
272 | 272 | $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
273 | 273 | // Add in few replacements. |
274 | 274 | /** |
275 | - * These are the defaults: |
|
276 | - * - {MEMBER} - Member Name. => current user for review |
|
277 | - * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced |
|
278 | - * - {FORUMNAME} - Forum Name. |
|
279 | - * - {SCRIPTURL} - Web address of forum. |
|
280 | - * - {REGARDS} - Standard email sign-off. |
|
281 | - */ |
|
275 | + * These are the defaults: |
|
276 | + * - {MEMBER} - Member Name. => current user for review |
|
277 | + * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced |
|
278 | + * - {FORUMNAME} - Forum Name. |
|
279 | + * - {SCRIPTURL} - Web address of forum. |
|
280 | + * - {REGARDS} - Standard email sign-off. |
|
281 | + */ |
|
282 | 282 | $find = array( |
283 | 283 | '{MEMBER}', |
284 | 284 | '{FORUMNAME}', |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main handler and designator for AJAX stuff - jumpto, message icons and previews |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | // Easy adding of sub actions. |
33 | 34 | call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions)); |
34 | 35 | |
35 | - if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | call_helper($subActions[$_REQUEST['sa']]); |
39 | 41 | } |
@@ -57,8 +59,9 @@ discard block |
||
57 | 59 | foreach ($context['jump_to'] as $id_cat => $cat) |
58 | 60 | { |
59 | 61 | $context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name'])); |
60 | - foreach ($cat['boards'] as $id_board => $board) |
|
61 | - $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
62 | + foreach ($cat['boards'] as $id_board => $board) { |
|
63 | + $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
64 | + } |
|
62 | 65 | } |
63 | 66 | |
64 | 67 | $context['sub_template'] = 'jump_to'; |
@@ -95,8 +98,9 @@ discard block |
||
95 | 98 | |
96 | 99 | $context['sub_template'] = 'generic_xml'; |
97 | 100 | |
98 | - if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) |
|
99 | - return false; |
|
101 | + if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) { |
|
102 | + return false; |
|
103 | + } |
|
100 | 104 | |
101 | 105 | $_POST['item'](); |
102 | 106 | } |
@@ -112,10 +116,11 @@ discard block |
||
112 | 116 | |
113 | 117 | $errors = array(); |
114 | 118 | $news = !isset($_POST['news']) ? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES); |
115 | - if (empty($news)) |
|
116 | - $errors[] = array('value' => 'no_news'); |
|
117 | - else |
|
118 | - preparsecode($news); |
|
119 | + if (empty($news)) { |
|
120 | + $errors[] = array('value' => 'no_news'); |
|
121 | + } else { |
|
122 | + preparsecode($news); |
|
123 | + } |
|
119 | 124 | |
120 | 125 | $context['xml_data'] = array( |
121 | 126 | 'news' => array( |
@@ -148,10 +153,12 @@ discard block |
||
148 | 153 | $context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0; |
149 | 154 | $context['send_html'] = !empty($_POST['send_html']) ? 1 : 0; |
150 | 155 | |
151 | - if (empty($_POST['subject'])) |
|
152 | - $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
153 | - if (empty($_POST['message'])) |
|
154 | - $context['post_error']['messages'][] = $txt['error_no_message']; |
|
156 | + if (empty($_POST['subject'])) { |
|
157 | + $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
158 | + } |
|
159 | + if (empty($_POST['message'])) { |
|
160 | + $context['post_error']['messages'][] = $txt['error_no_message']; |
|
161 | + } |
|
155 | 162 | |
156 | 163 | prepareMailingForPreview(); |
157 | 164 | |
@@ -196,38 +203,41 @@ discard block |
||
196 | 203 | $preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview']; |
197 | 204 | $validation = profileValidateSignature($preview_signature); |
198 | 205 | |
199 | - if ($validation !== true && $validation !== false) |
|
200 | - $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
206 | + if ($validation !== true && $validation !== false) { |
|
207 | + $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
208 | + } |
|
201 | 209 | |
202 | 210 | censorText($preview_signature); |
203 | 211 | $preview_signature = parse_bbc($preview_signature, true, 'sig' . $user); |
204 | - } |
|
205 | - elseif (!$can_change) |
|
212 | + } elseif (!$can_change) |
|
206 | 213 | { |
207 | - if ($is_owner) |
|
208 | - $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
209 | - else |
|
210 | - $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
214 | + if ($is_owner) { |
|
215 | + $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
216 | + } else { |
|
217 | + $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
218 | + } |
|
219 | + } else { |
|
220 | + $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
211 | 221 | } |
212 | - else |
|
213 | - $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
214 | 222 | |
215 | 223 | $context['xml_data']['signatures'] = array( |
216 | 224 | 'identifier' => 'signature', |
217 | 225 | 'children' => array() |
218 | 226 | ); |
219 | - if (isset($current_signature)) |
|
220 | - $context['xml_data']['signatures']['children'][] = array( |
|
227 | + if (isset($current_signature)) { |
|
228 | + $context['xml_data']['signatures']['children'][] = array( |
|
221 | 229 | 'value' => $current_signature, |
222 | 230 | 'attributes' => array('type' => 'current'), |
223 | 231 | ); |
224 | - if (isset($preview_signature)) |
|
225 | - $context['xml_data']['signatures']['children'][] = array( |
|
232 | + } |
|
233 | + if (isset($preview_signature)) { |
|
234 | + $context['xml_data']['signatures']['children'][] = array( |
|
226 | 235 | 'value' => $preview_signature, |
227 | 236 | 'attributes' => array('type' => 'preview'), |
228 | 237 | ); |
229 | - if (!empty($errors)) |
|
230 | - $context['xml_data']['errors'] = array( |
|
238 | + } |
|
239 | + if (!empty($errors)) { |
|
240 | + $context['xml_data']['errors'] = array( |
|
231 | 241 | 'identifier' => 'error', |
232 | 242 | 'children' => array_merge( |
233 | 243 | array( |
@@ -239,7 +249,8 @@ discard block |
||
239 | 249 | $errors |
240 | 250 | ), |
241 | 251 | ); |
242 | -} |
|
252 | + } |
|
253 | + } |
|
243 | 254 | |
244 | 255 | /** |
245 | 256 | * Handles previewing user warnings |
@@ -259,15 +270,17 @@ discard block |
||
259 | 270 | $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : ''; |
260 | 271 | if (isset($_POST['issuing'])) |
261 | 272 | { |
262 | - if (empty($_POST['title']) || empty($_POST['body'])) |
|
263 | - $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
264 | - } |
|
265 | - else |
|
273 | + if (empty($_POST['title']) || empty($_POST['body'])) { |
|
274 | + $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
275 | + } |
|
276 | + } else |
|
266 | 277 | { |
267 | - if (empty($_POST['title'])) |
|
268 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
269 | - if (empty($_POST['body'])) |
|
270 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
278 | + if (empty($_POST['title'])) { |
|
279 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
280 | + } |
|
281 | + if (empty($_POST['body'])) { |
|
282 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
283 | + } |
|
271 | 284 | // Add in few replacements. |
272 | 285 | /** |
273 | 286 | * These are the defaults: |
@@ -298,9 +311,9 @@ discard block |
||
298 | 311 | $warning_body = parse_bbc($warning_body, true); |
299 | 312 | } |
300 | 313 | $context['preview_message'] = $warning_body; |
314 | + } else { |
|
315 | + $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
301 | 316 | } |
302 | - else |
|
303 | - $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
304 | 317 | |
305 | 318 | $context['sub_template'] = 'warning'; |
306 | 319 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | /** |
1718 | 1718 | * Show today's birthdays. |
1719 | 1719 | * @param string $output_method The output method. If 'echo', displays a list of users, otherwise returns an array of info about them. |
1720 | - * @return void|array Displays a list of users or returns an array of info about them depending on output_method. |
|
1720 | + * @return null|string Displays a list of users or returns an array of info about them depending on output_method. |
|
1721 | 1721 | */ |
1722 | 1722 | function ssi_todaysBirthdays($output_method = 'echo') |
1723 | 1723 | { |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | /** |
1747 | 1747 | * Shows today's holidays. |
1748 | 1748 | * @param string $output_method The output method. If 'echo', displays a list of holidays, otherwise returns an array of info about them. |
1749 | - * @return void|array Displays a list of holidays or returns an array of info about them depending on output_method |
|
1749 | + * @return null|string Displays a list of holidays or returns an array of info about them depending on output_method |
|
1750 | 1750 | */ |
1751 | 1751 | function ssi_todaysHolidays($output_method = 'echo') |
1752 | 1752 | { |
@@ -1773,7 +1773,7 @@ discard block |
||
1773 | 1773 | |
1774 | 1774 | /** |
1775 | 1775 | * @param string $output_method The output method. If 'echo', displays a list of events, otherwise returns an array of info about them. |
1776 | - * @return void|array Displays a list of events or returns an array of info about them depending on output_method |
|
1776 | + * @return null|string Displays a list of events or returns an array of info about them depending on output_method |
|
1777 | 1777 | */ |
1778 | 1778 | function ssi_todaysEvents($output_method = 'echo') |
1779 | 1779 | { |
@@ -1807,7 +1807,7 @@ discard block |
||
1807 | 1807 | /** |
1808 | 1808 | * Shows today's calendar items (events, birthdays and holidays) |
1809 | 1809 | * @param string $output_method The output method. If 'echo', displays a list of calendar items, otherwise returns an array of info about them. |
1810 | - * @return void|array Displays a list of calendar items or returns an array of info about them depending on output_method |
|
1810 | + * @return null|string Displays a list of calendar items or returns an array of info about them depending on output_method |
|
1811 | 1811 | */ |
1812 | 1812 | function ssi_todaysCalendar($output_method = 'echo') |
1813 | 1813 | { |
@@ -2198,7 +2198,7 @@ discard block |
||
2198 | 2198 | * @param int|string $id The ID or username of a user |
2199 | 2199 | * @param string $password The password to check |
2200 | 2200 | * @param bool $is_username If true, treats $id as a username rather than a user ID |
2201 | - * @return bool Whether or not the password is correct. |
|
2201 | + * @return null|boolean Whether or not the password is correct. |
|
2202 | 2202 | */ |
2203 | 2203 | function ssi_checkPassword($id = null, $password = null, $is_username = false) |
2204 | 2204 | { |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,34 +83,38 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | // Primarily, this is to fix the URLs... |
103 | 112 | ob_start('ob_sessrewrite'); |
104 | 113 | |
105 | 114 | // Start the session... known to scramble SSI includes in cases... |
106 | -if (!headers_sent()) |
|
115 | +if (!headers_sent()) { |
|
107 | 116 | loadSession(); |
108 | -else |
|
117 | +} else |
|
109 | 118 | { |
110 | 119 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
111 | 120 | { |
@@ -139,12 +148,14 @@ discard block |
||
139 | 148 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
140 | 149 | |
141 | 150 | // @todo: probably not the best place, but somewhere it should be set... |
142 | -if (!headers_sent()) |
|
151 | +if (!headers_sent()) { |
|
143 | 152 | header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
153 | +} |
|
144 | 154 | |
145 | 155 | // Take care of any banning that needs to be done. |
146 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
156 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
147 | 157 | is_not_banned(); |
158 | +} |
|
148 | 159 | |
149 | 160 | // Do we allow guests in here? |
150 | 161 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -159,17 +170,19 @@ discard block |
||
159 | 170 | { |
160 | 171 | $context['template_layers'] = $ssi_layers; |
161 | 172 | template_header(); |
162 | -} |
|
163 | -else |
|
173 | +} else { |
|
164 | 174 | setupThemeContext(); |
175 | +} |
|
165 | 176 | |
166 | 177 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
167 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
178 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
168 | 179 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
180 | +} |
|
169 | 181 | |
170 | 182 | // Without visiting the forum this session variable might not be set on submit. |
171 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
183 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
172 | 184 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
185 | +} |
|
173 | 186 | |
174 | 187 | // Have the ability to easily add functions to SSI. |
175 | 188 | call_integration_hook('integrate_SSI'); |
@@ -178,11 +191,13 @@ discard block |
||
178 | 191 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
179 | 192 | { |
180 | 193 | // You shouldn't just access SSI.php directly by URL!! |
181 | - if (!isset($_GET['ssi_function'])) |
|
182 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
194 | + if (!isset($_GET['ssi_function'])) { |
|
195 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
196 | + } |
|
183 | 197 | // Call a function passed by GET. |
184 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
185 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
198 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
199 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
200 | + } |
|
186 | 201 | exit; |
187 | 202 | } |
188 | 203 | |
@@ -199,9 +214,10 @@ discard block |
||
199 | 214 | */ |
200 | 215 | function ssi_shutdown() |
201 | 216 | { |
202 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
203 | - template_footer(); |
|
204 | -} |
|
217 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
218 | + template_footer(); |
|
219 | + } |
|
220 | + } |
|
205 | 221 | |
206 | 222 | /** |
207 | 223 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -214,15 +230,17 @@ discard block |
||
214 | 230 | |
215 | 231 | if ($output_method == 'echo') |
216 | 232 | { |
217 | - if ($context['user']['is_guest']) |
|
218 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
219 | - else |
|
220 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
233 | + if ($context['user']['is_guest']) { |
|
234 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
235 | + } else { |
|
236 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
237 | + } |
|
221 | 238 | } |
222 | 239 | // Don't echo... then do what?! |
223 | - else |
|
224 | - return $context['user']; |
|
225 | -} |
|
240 | + else { |
|
241 | + return $context['user']; |
|
242 | + } |
|
243 | + } |
|
226 | 244 | |
227 | 245 | /** |
228 | 246 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -233,12 +251,14 @@ discard block |
||
233 | 251 | { |
234 | 252 | global $context; |
235 | 253 | |
236 | - if ($output_method == 'echo') |
|
237 | - template_menu(); |
|
254 | + if ($output_method == 'echo') { |
|
255 | + template_menu(); |
|
256 | + } |
|
238 | 257 | // What else could this do? |
239 | - else |
|
240 | - return $context['menu_buttons']; |
|
241 | -} |
|
258 | + else { |
|
259 | + return $context['menu_buttons']; |
|
260 | + } |
|
261 | + } |
|
242 | 262 | |
243 | 263 | /** |
244 | 264 | * Show a logout link. |
@@ -250,20 +270,23 @@ discard block |
||
250 | 270 | { |
251 | 271 | global $context, $txt, $scripturl; |
252 | 272 | |
253 | - if ($redirect_to != '') |
|
254 | - $_SESSION['logout_url'] = $redirect_to; |
|
273 | + if ($redirect_to != '') { |
|
274 | + $_SESSION['logout_url'] = $redirect_to; |
|
275 | + } |
|
255 | 276 | |
256 | 277 | // Guests can't log out. |
257 | - if ($context['user']['is_guest']) |
|
258 | - return false; |
|
278 | + if ($context['user']['is_guest']) { |
|
279 | + return false; |
|
280 | + } |
|
259 | 281 | |
260 | 282 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
261 | 283 | |
262 | - if ($output_method == 'echo') |
|
263 | - echo $link; |
|
264 | - else |
|
265 | - return $link; |
|
266 | -} |
|
284 | + if ($output_method == 'echo') { |
|
285 | + echo $link; |
|
286 | + } else { |
|
287 | + return $link; |
|
288 | + } |
|
289 | + } |
|
267 | 290 | |
268 | 291 | /** |
269 | 292 | * Recent post list: [board] Subject by Poster Date |
@@ -279,17 +302,17 @@ discard block |
||
279 | 302 | global $modSettings, $context; |
280 | 303 | |
281 | 304 | // Excluding certain boards... |
282 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
283 | - $exclude_boards = array($modSettings['recycle_board']); |
|
284 | - else |
|
285 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
305 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
306 | + $exclude_boards = array($modSettings['recycle_board']); |
|
307 | + } else { |
|
308 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
309 | + } |
|
286 | 310 | |
287 | 311 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
288 | 312 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
289 | 313 | { |
290 | 314 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
291 | - } |
|
292 | - elseif ($include_boards != null) |
|
315 | + } elseif ($include_boards != null) |
|
293 | 316 | { |
294 | 317 | $include_boards = array(); |
295 | 318 | } |
@@ -326,8 +349,9 @@ discard block |
||
326 | 349 | { |
327 | 350 | global $modSettings; |
328 | 351 | |
329 | - if (empty($post_ids)) |
|
330 | - return; |
|
352 | + if (empty($post_ids)) { |
|
353 | + return; |
|
354 | + } |
|
331 | 355 | |
332 | 356 | // Allow the user to request more than one - why not? |
333 | 357 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -362,8 +386,9 @@ discard block |
||
362 | 386 | global $scripturl, $txt, $user_info; |
363 | 387 | global $modSettings, $smcFunc, $context; |
364 | 388 | |
365 | - if (!empty($modSettings['enable_likes'])) |
|
366 | - $context['can_like'] = allowedTo('likes_like'); |
|
389 | + if (!empty($modSettings['enable_likes'])) { |
|
390 | + $context['can_like'] = allowedTo('likes_like'); |
|
391 | + } |
|
367 | 392 | |
368 | 393 | // Find all the posts. Newer ones will have higher IDs. |
369 | 394 | $request = $smcFunc['db_query']('substring', ' |
@@ -429,12 +454,13 @@ discard block |
||
429 | 454 | ); |
430 | 455 | |
431 | 456 | // Get the likes for each message. |
432 | - if (!empty($modSettings['enable_likes'])) |
|
433 | - $posts[$row['id_msg']]['likes'] = array( |
|
457 | + if (!empty($modSettings['enable_likes'])) { |
|
458 | + $posts[$row['id_msg']]['likes'] = array( |
|
434 | 459 | 'count' => $row['likes'], |
435 | 460 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
436 | 461 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
437 | 462 | ); |
463 | + } |
|
438 | 464 | } |
439 | 465 | $smcFunc['db_free_result']($request); |
440 | 466 | |
@@ -442,13 +468,14 @@ discard block |
||
442 | 468 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
443 | 469 | |
444 | 470 | // Just return it. |
445 | - if ($output_method != 'echo' || empty($posts)) |
|
446 | - return $posts; |
|
471 | + if ($output_method != 'echo' || empty($posts)) { |
|
472 | + return $posts; |
|
473 | + } |
|
447 | 474 | |
448 | 475 | echo ' |
449 | 476 | <table style="border: none" class="ssi_table">'; |
450 | - foreach ($posts as $post) |
|
451 | - echo ' |
|
477 | + foreach ($posts as $post) { |
|
478 | + echo ' |
|
452 | 479 | <tr> |
453 | 480 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
454 | 481 | [', $post['board']['link'], '] |
@@ -462,6 +489,7 @@ discard block |
||
462 | 489 | ', $post['time'], ' |
463 | 490 | </td> |
464 | 491 | </tr>'; |
492 | + } |
|
465 | 493 | echo ' |
466 | 494 | </table>'; |
467 | 495 | } |
@@ -479,25 +507,26 @@ discard block |
||
479 | 507 | global $settings, $scripturl, $txt, $user_info; |
480 | 508 | global $modSettings, $smcFunc, $context; |
481 | 509 | |
482 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
483 | - $exclude_boards = array($modSettings['recycle_board']); |
|
484 | - else |
|
485 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
510 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
511 | + $exclude_boards = array($modSettings['recycle_board']); |
|
512 | + } else { |
|
513 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
514 | + } |
|
486 | 515 | |
487 | 516 | // Only some boards?. |
488 | 517 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
489 | 518 | { |
490 | 519 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
491 | - } |
|
492 | - elseif ($include_boards != null) |
|
520 | + } elseif ($include_boards != null) |
|
493 | 521 | { |
494 | 522 | $output_method = $include_boards; |
495 | 523 | $include_boards = array(); |
496 | 524 | } |
497 | 525 | |
498 | 526 | $icon_sources = array(); |
499 | - foreach ($context['stable_icons'] as $icon) |
|
500 | - $icon_sources[$icon] = 'images_url'; |
|
527 | + foreach ($context['stable_icons'] as $icon) { |
|
528 | + $icon_sources[$icon] = 'images_url'; |
|
529 | + } |
|
501 | 530 | |
502 | 531 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
503 | 532 | $request = $smcFunc['db_query']('substring', ' |
@@ -522,13 +551,15 @@ discard block |
||
522 | 551 | ) |
523 | 552 | ); |
524 | 553 | $topics = array(); |
525 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
526 | - $topics[$row['id_topic']] = $row; |
|
554 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
555 | + $topics[$row['id_topic']] = $row; |
|
556 | + } |
|
527 | 557 | $smcFunc['db_free_result']($request); |
528 | 558 | |
529 | 559 | // Did we find anything? If not, bail. |
530 | - if (empty($topics)) |
|
531 | - return array(); |
|
560 | + if (empty($topics)) { |
|
561 | + return array(); |
|
562 | + } |
|
532 | 563 | |
533 | 564 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
534 | 565 | |
@@ -556,19 +587,22 @@ discard block |
||
556 | 587 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
557 | 588 | { |
558 | 589 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
559 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
560 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
590 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
591 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
592 | + } |
|
561 | 593 | |
562 | 594 | // Censor the subject. |
563 | 595 | censorText($row['subject']); |
564 | 596 | censorText($row['body']); |
565 | 597 | |
566 | 598 | // Recycled icon |
567 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
568 | - $row['icon'] = 'recycled'; |
|
599 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
600 | + $row['icon'] = 'recycled'; |
|
601 | + } |
|
569 | 602 | |
570 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
571 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
603 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
604 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
605 | + } |
|
572 | 606 | |
573 | 607 | // Build the array. |
574 | 608 | $posts[] = array( |
@@ -607,13 +641,14 @@ discard block |
||
607 | 641 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
608 | 642 | |
609 | 643 | // Just return it. |
610 | - if ($output_method != 'echo' || empty($posts)) |
|
611 | - return $posts; |
|
644 | + if ($output_method != 'echo' || empty($posts)) { |
|
645 | + return $posts; |
|
646 | + } |
|
612 | 647 | |
613 | 648 | echo ' |
614 | 649 | <table style="border: none" class="ssi_table">'; |
615 | - foreach ($posts as $post) |
|
616 | - echo ' |
|
650 | + foreach ($posts as $post) { |
|
651 | + echo ' |
|
617 | 652 | <tr> |
618 | 653 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
619 | 654 | [', $post['board']['link'], '] |
@@ -627,6 +662,7 @@ discard block |
||
627 | 662 | ', $post['time'], ' |
628 | 663 | </td> |
629 | 664 | </tr>'; |
665 | + } |
|
630 | 666 | echo ' |
631 | 667 | </table>'; |
632 | 668 | } |
@@ -651,27 +687,30 @@ discard block |
||
651 | 687 | ) |
652 | 688 | ); |
653 | 689 | $return = array(); |
654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
655 | - $return[] = array( |
|
690 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
691 | + $return[] = array( |
|
656 | 692 | 'id' => $row['id_member'], |
657 | 693 | 'name' => $row['real_name'], |
658 | 694 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
659 | 695 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
660 | 696 | 'posts' => $row['posts'] |
661 | 697 | ); |
698 | + } |
|
662 | 699 | $smcFunc['db_free_result']($request); |
663 | 700 | |
664 | 701 | // If mods want to do somthing with this list of members, let them do that now. |
665 | 702 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
666 | 703 | |
667 | 704 | // Just return all the top posters. |
668 | - if ($output_method != 'echo') |
|
669 | - return $return; |
|
705 | + if ($output_method != 'echo') { |
|
706 | + return $return; |
|
707 | + } |
|
670 | 708 | |
671 | 709 | // Make a quick array to list the links in. |
672 | 710 | $temp_array = array(); |
673 | - foreach ($return as $member) |
|
674 | - $temp_array[] = $member['link']; |
|
711 | + foreach ($return as $member) { |
|
712 | + $temp_array[] = $member['link']; |
|
713 | + } |
|
675 | 714 | |
676 | 715 | echo implode(', ', $temp_array); |
677 | 716 | } |
@@ -703,8 +742,8 @@ discard block |
||
703 | 742 | ) |
704 | 743 | ); |
705 | 744 | $boards = array(); |
706 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
707 | - $boards[] = array( |
|
745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
746 | + $boards[] = array( |
|
708 | 747 | 'id' => $row['id_board'], |
709 | 748 | 'num_posts' => $row['num_posts'], |
710 | 749 | 'num_topics' => $row['num_topics'], |
@@ -713,14 +752,16 @@ discard block |
||
713 | 752 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
714 | 753 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
715 | 754 | ); |
755 | + } |
|
716 | 756 | $smcFunc['db_free_result']($request); |
717 | 757 | |
718 | 758 | // If mods want to do somthing with this list of boards, let them do that now. |
719 | 759 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
720 | 760 | |
721 | 761 | // If we shouldn't output or have nothing to output, just jump out. |
722 | - if ($output_method != 'echo' || empty($boards)) |
|
723 | - return $boards; |
|
762 | + if ($output_method != 'echo' || empty($boards)) { |
|
763 | + return $boards; |
|
764 | + } |
|
724 | 765 | |
725 | 766 | echo ' |
726 | 767 | <table class="ssi_table"> |
@@ -729,13 +770,14 @@ discard block |
||
729 | 770 | <th style="text-align: left">', $txt['board_topics'], '</th> |
730 | 771 | <th style="text-align: left">', $txt['posts'], '</th> |
731 | 772 | </tr>'; |
732 | - foreach ($boards as $sBoard) |
|
733 | - echo ' |
|
773 | + foreach ($boards as $sBoard) { |
|
774 | + echo ' |
|
734 | 775 | <tr> |
735 | 776 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
736 | 777 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
737 | 778 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
738 | 779 | </tr>'; |
780 | + } |
|
739 | 781 | echo ' |
740 | 782 | </table>'; |
741 | 783 | } |
@@ -768,12 +810,13 @@ discard block |
||
768 | 810 | ) |
769 | 811 | ); |
770 | 812 | $topic_ids = array(); |
771 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
772 | - $topic_ids[] = $row['id_topic']; |
|
813 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
814 | + $topic_ids[] = $row['id_topic']; |
|
815 | + } |
|
773 | 816 | $smcFunc['db_free_result']($request); |
817 | + } else { |
|
818 | + $topic_ids = array(); |
|
774 | 819 | } |
775 | - else |
|
776 | - $topic_ids = array(); |
|
777 | 820 | |
778 | 821 | $request = $smcFunc['db_query']('', ' |
779 | 822 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -812,8 +855,9 @@ discard block |
||
812 | 855 | // If mods want to do somthing with this list of topics, let them do that now. |
813 | 856 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
814 | 857 | |
815 | - if ($output_method != 'echo' || empty($topics)) |
|
816 | - return $topics; |
|
858 | + if ($output_method != 'echo' || empty($topics)) { |
|
859 | + return $topics; |
|
860 | + } |
|
817 | 861 | |
818 | 862 | echo ' |
819 | 863 | <table class="ssi_table"> |
@@ -822,8 +866,8 @@ discard block |
||
822 | 866 | <th style="text-align: left">', $txt['views'], '</th> |
823 | 867 | <th style="text-align: left">', $txt['replies'], '</th> |
824 | 868 | </tr>'; |
825 | - foreach ($topics as $sTopic) |
|
826 | - echo ' |
|
869 | + foreach ($topics as $sTopic) { |
|
870 | + echo ' |
|
827 | 871 | <tr> |
828 | 872 | <td style="text-align: left"> |
829 | 873 | ', $sTopic['link'], ' |
@@ -831,6 +875,7 @@ discard block |
||
831 | 875 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
832 | 876 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
833 | 877 | </tr>'; |
878 | + } |
|
834 | 879 | echo ' |
835 | 880 | </table>'; |
836 | 881 | } |
@@ -866,12 +911,13 @@ discard block |
||
866 | 911 | { |
867 | 912 | global $txt, $context; |
868 | 913 | |
869 | - if ($output_method == 'echo') |
|
870 | - echo ' |
|
914 | + if ($output_method == 'echo') { |
|
915 | + echo ' |
|
871 | 916 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
872 | - else |
|
873 | - return $context['common_stats']['latest_member']; |
|
874 | -} |
|
917 | + } else { |
|
918 | + return $context['common_stats']['latest_member']; |
|
919 | + } |
|
920 | + } |
|
875 | 921 | |
876 | 922 | /** |
877 | 923 | * Fetches a random member. |
@@ -920,8 +966,9 @@ discard block |
||
920 | 966 | } |
921 | 967 | |
922 | 968 | // Just to be sure put the random generator back to something... random. |
923 | - if ($random_type != '') |
|
924 | - mt_srand(time()); |
|
969 | + if ($random_type != '') { |
|
970 | + mt_srand(time()); |
|
971 | + } |
|
925 | 972 | |
926 | 973 | return $result; |
927 | 974 | } |
@@ -934,8 +981,9 @@ discard block |
||
934 | 981 | */ |
935 | 982 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
936 | 983 | { |
937 | - if (empty($member_ids)) |
|
938 | - return; |
|
984 | + if (empty($member_ids)) { |
|
985 | + return; |
|
986 | + } |
|
939 | 987 | |
940 | 988 | // Can have more than one member if you really want... |
941 | 989 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -960,8 +1008,9 @@ discard block |
||
960 | 1008 | */ |
961 | 1009 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
962 | 1010 | { |
963 | - if ($group_id === null) |
|
964 | - return; |
|
1011 | + if ($group_id === null) { |
|
1012 | + return; |
|
1013 | + } |
|
965 | 1014 | |
966 | 1015 | $query_where = ' |
967 | 1016 | id_group = {int:id_group} |
@@ -988,8 +1037,9 @@ discard block |
||
988 | 1037 | { |
989 | 1038 | global $smcFunc, $memberContext; |
990 | 1039 | |
991 | - if ($query_where === null) |
|
992 | - return; |
|
1040 | + if ($query_where === null) { |
|
1041 | + return; |
|
1042 | + } |
|
993 | 1043 | |
994 | 1044 | // Fetch the members in question. |
995 | 1045 | $request = $smcFunc['db_query']('', ' |
@@ -1002,12 +1052,14 @@ discard block |
||
1002 | 1052 | )) |
1003 | 1053 | ); |
1004 | 1054 | $members = array(); |
1005 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1006 | - $members[] = $row['id_member']; |
|
1055 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1056 | + $members[] = $row['id_member']; |
|
1057 | + } |
|
1007 | 1058 | $smcFunc['db_free_result']($request); |
1008 | 1059 | |
1009 | - if (empty($members)) |
|
1010 | - return array(); |
|
1060 | + if (empty($members)) { |
|
1061 | + return array(); |
|
1062 | + } |
|
1011 | 1063 | |
1012 | 1064 | // If mods want to do somthing with this list of members, let them do that now. |
1013 | 1065 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1016,23 +1068,25 @@ discard block |
||
1016 | 1068 | loadMemberData($members); |
1017 | 1069 | |
1018 | 1070 | // Draw the table! |
1019 | - if ($output_method == 'echo') |
|
1020 | - echo ' |
|
1071 | + if ($output_method == 'echo') { |
|
1072 | + echo ' |
|
1021 | 1073 | <table style="border: none" class="ssi_table">'; |
1074 | + } |
|
1022 | 1075 | |
1023 | 1076 | $query_members = array(); |
1024 | 1077 | foreach ($members as $member) |
1025 | 1078 | { |
1026 | 1079 | // Load their context data. |
1027 | - if (!loadMemberContext($member)) |
|
1028 | - continue; |
|
1080 | + if (!loadMemberContext($member)) { |
|
1081 | + continue; |
|
1082 | + } |
|
1029 | 1083 | |
1030 | 1084 | // Store this member's information. |
1031 | 1085 | $query_members[$member] = $memberContext[$member]; |
1032 | 1086 | |
1033 | 1087 | // Only do something if we're echo'ing. |
1034 | - if ($output_method == 'echo') |
|
1035 | - echo ' |
|
1088 | + if ($output_method == 'echo') { |
|
1089 | + echo ' |
|
1036 | 1090 | <tr> |
1037 | 1091 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1038 | 1092 | ', $query_members[$member]['link'], ' |
@@ -1040,12 +1094,14 @@ discard block |
||
1040 | 1094 | <br>', $query_members[$member]['avatar']['image'], ' |
1041 | 1095 | </td> |
1042 | 1096 | </tr>'; |
1097 | + } |
|
1043 | 1098 | } |
1044 | 1099 | |
1045 | 1100 | // End the table if appropriate. |
1046 | - if ($output_method == 'echo') |
|
1047 | - echo ' |
|
1101 | + if ($output_method == 'echo') { |
|
1102 | + echo ' |
|
1048 | 1103 | </table>'; |
1104 | + } |
|
1049 | 1105 | |
1050 | 1106 | // Send back the data. |
1051 | 1107 | return $query_members; |
@@ -1060,8 +1116,9 @@ discard block |
||
1060 | 1116 | { |
1061 | 1117 | global $txt, $scripturl, $modSettings, $smcFunc; |
1062 | 1118 | |
1063 | - if (!allowedTo('view_stats')) |
|
1064 | - return; |
|
1119 | + if (!allowedTo('view_stats')) { |
|
1120 | + return; |
|
1121 | + } |
|
1065 | 1122 | |
1066 | 1123 | $totals = array( |
1067 | 1124 | 'members' => $modSettings['totalMembers'], |
@@ -1090,8 +1147,9 @@ discard block |
||
1090 | 1147 | // If mods want to do somthing with the board stats, let them do that now. |
1091 | 1148 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1092 | 1149 | |
1093 | - if ($output_method != 'echo') |
|
1094 | - return $totals; |
|
1150 | + if ($output_method != 'echo') { |
|
1151 | + return $totals; |
|
1152 | + } |
|
1095 | 1153 | |
1096 | 1154 | echo ' |
1097 | 1155 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1120,8 +1178,8 @@ discard block |
||
1120 | 1178 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1121 | 1179 | |
1122 | 1180 | // Add some redundancy for backwards compatibility reasons. |
1123 | - if ($output_method != 'echo') |
|
1124 | - return $return + array( |
|
1181 | + if ($output_method != 'echo') { |
|
1182 | + return $return + array( |
|
1125 | 1183 | 'users' => $return['users_online'], |
1126 | 1184 | 'guests' => $return['num_guests'], |
1127 | 1185 | 'hidden' => $return['num_users_hidden'], |
@@ -1129,29 +1187,35 @@ discard block |
||
1129 | 1187 | 'num_users' => $return['num_users_online'], |
1130 | 1188 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1131 | 1189 | ); |
1190 | + } |
|
1132 | 1191 | |
1133 | 1192 | echo ' |
1134 | 1193 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1135 | 1194 | |
1136 | 1195 | $bracketList = array(); |
1137 | - if (!empty($user_info['buddies'])) |
|
1138 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1139 | - if (!empty($return['num_spiders'])) |
|
1140 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1141 | - if (!empty($return['num_users_hidden'])) |
|
1142 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1196 | + if (!empty($user_info['buddies'])) { |
|
1197 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1198 | + } |
|
1199 | + if (!empty($return['num_spiders'])) { |
|
1200 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1201 | + } |
|
1202 | + if (!empty($return['num_users_hidden'])) { |
|
1203 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1204 | + } |
|
1143 | 1205 | |
1144 | - if (!empty($bracketList)) |
|
1145 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1206 | + if (!empty($bracketList)) { |
|
1207 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1208 | + } |
|
1146 | 1209 | |
1147 | 1210 | echo '<br> |
1148 | 1211 | ', implode(', ', $return['list_users_online']); |
1149 | 1212 | |
1150 | 1213 | // Showing membergroups? |
1151 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1152 | - echo '<br> |
|
1214 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1215 | + echo '<br> |
|
1153 | 1216 | [' . implode('] [', $return['membergroups']) . ']'; |
1154 | -} |
|
1217 | + } |
|
1218 | + } |
|
1155 | 1219 | |
1156 | 1220 | /** |
1157 | 1221 | * Just like whosOnline except it also logs the online presence. |
@@ -1162,11 +1226,12 @@ discard block |
||
1162 | 1226 | { |
1163 | 1227 | writeLog(); |
1164 | 1228 | |
1165 | - if ($output_method != 'echo') |
|
1166 | - return ssi_whosOnline($output_method); |
|
1167 | - else |
|
1168 | - ssi_whosOnline($output_method); |
|
1169 | -} |
|
1229 | + if ($output_method != 'echo') { |
|
1230 | + return ssi_whosOnline($output_method); |
|
1231 | + } else { |
|
1232 | + ssi_whosOnline($output_method); |
|
1233 | + } |
|
1234 | + } |
|
1170 | 1235 | |
1171 | 1236 | // Shows a login box. |
1172 | 1237 | /** |
@@ -1179,11 +1244,13 @@ discard block |
||
1179 | 1244 | { |
1180 | 1245 | global $scripturl, $txt, $user_info, $context; |
1181 | 1246 | |
1182 | - if ($redirect_to != '') |
|
1183 | - $_SESSION['login_url'] = $redirect_to; |
|
1247 | + if ($redirect_to != '') { |
|
1248 | + $_SESSION['login_url'] = $redirect_to; |
|
1249 | + } |
|
1184 | 1250 | |
1185 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1186 | - return $user_info['is_guest']; |
|
1251 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1252 | + return $user_info['is_guest']; |
|
1253 | + } |
|
1187 | 1254 | |
1188 | 1255 | // Create a login token |
1189 | 1256 | createToken('login'); |
@@ -1235,8 +1302,9 @@ discard block |
||
1235 | 1302 | |
1236 | 1303 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1237 | 1304 | |
1238 | - if (empty($boardsAllowed)) |
|
1239 | - return array(); |
|
1305 | + if (empty($boardsAllowed)) { |
|
1306 | + return array(); |
|
1307 | + } |
|
1240 | 1308 | |
1241 | 1309 | $request = $smcFunc['db_query']('', ' |
1242 | 1310 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1269,12 +1337,14 @@ discard block |
||
1269 | 1337 | $smcFunc['db_free_result']($request); |
1270 | 1338 | |
1271 | 1339 | // This user has voted on all the polls. |
1272 | - if (empty($row) || !is_array($row)) |
|
1273 | - return array(); |
|
1340 | + if (empty($row) || !is_array($row)) { |
|
1341 | + return array(); |
|
1342 | + } |
|
1274 | 1343 | |
1275 | 1344 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1276 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1277 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1345 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1346 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1347 | + } |
|
1278 | 1348 | |
1279 | 1349 | $request = $smcFunc['db_query']('', ' |
1280 | 1350 | SELECT COUNT(DISTINCT id_member) |
@@ -1338,8 +1408,9 @@ discard block |
||
1338 | 1408 | // If mods want to do somthing with this list of polls, let them do that now. |
1339 | 1409 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1340 | 1410 | |
1341 | - if ($output_method != 'echo') |
|
1342 | - return $return; |
|
1411 | + if ($output_method != 'echo') { |
|
1412 | + return $return; |
|
1413 | + } |
|
1343 | 1414 | |
1344 | 1415 | if ($allow_view_results) |
1345 | 1416 | { |
@@ -1348,19 +1419,20 @@ discard block |
||
1348 | 1419 | <strong>', $return['question'], '</strong><br> |
1349 | 1420 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1350 | 1421 | |
1351 | - foreach ($return['options'] as $option) |
|
1352 | - echo ' |
|
1422 | + foreach ($return['options'] as $option) { |
|
1423 | + echo ' |
|
1353 | 1424 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1425 | + } |
|
1354 | 1426 | |
1355 | 1427 | echo ' |
1356 | 1428 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1357 | 1429 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1358 | 1430 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1359 | 1431 | </form>'; |
1432 | + } else { |
|
1433 | + echo $txt['poll_cannot_see']; |
|
1434 | + } |
|
1360 | 1435 | } |
1361 | - else |
|
1362 | - echo $txt['poll_cannot_see']; |
|
1363 | -} |
|
1364 | 1436 | |
1365 | 1437 | /** |
1366 | 1438 | * Shows the poll from the specified topic |
@@ -1374,13 +1446,15 @@ discard block |
||
1374 | 1446 | |
1375 | 1447 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1376 | 1448 | |
1377 | - if (empty($boardsAllowed)) |
|
1378 | - return array(); |
|
1449 | + if (empty($boardsAllowed)) { |
|
1450 | + return array(); |
|
1451 | + } |
|
1379 | 1452 | |
1380 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1381 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1382 | - else |
|
1383 | - $topic = (int) $topic; |
|
1453 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1454 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1455 | + } else { |
|
1456 | + $topic = (int) $topic; |
|
1457 | + } |
|
1384 | 1458 | |
1385 | 1459 | $request = $smcFunc['db_query']('', ' |
1386 | 1460 | SELECT |
@@ -1401,17 +1475,18 @@ discard block |
||
1401 | 1475 | ); |
1402 | 1476 | |
1403 | 1477 | // Either this topic has no poll, or the user cannot view it. |
1404 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1405 | - return array(); |
|
1478 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1479 | + return array(); |
|
1480 | + } |
|
1406 | 1481 | |
1407 | 1482 | $row = $smcFunc['db_fetch_assoc']($request); |
1408 | 1483 | $smcFunc['db_free_result']($request); |
1409 | 1484 | |
1410 | 1485 | // Check if they can vote. |
1411 | 1486 | $already_voted = false; |
1412 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1413 | - $allow_vote = false; |
|
1414 | - elseif ($user_info['is_guest']) |
|
1487 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1488 | + $allow_vote = false; |
|
1489 | + } elseif ($user_info['is_guest']) |
|
1415 | 1490 | { |
1416 | 1491 | // There's a difference between "allowed to vote" and "already voted"... |
1417 | 1492 | $allow_vote = $row['guest_vote']; |
@@ -1421,10 +1496,9 @@ discard block |
||
1421 | 1496 | { |
1422 | 1497 | $already_voted = true; |
1423 | 1498 | } |
1424 | - } |
|
1425 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1426 | - $allow_vote = false; |
|
1427 | - else |
|
1499 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1500 | + $allow_vote = false; |
|
1501 | + } else |
|
1428 | 1502 | { |
1429 | 1503 | $request = $smcFunc['db_query']('', ' |
1430 | 1504 | SELECT id_member |
@@ -1506,8 +1580,9 @@ discard block |
||
1506 | 1580 | // If mods want to do somthing with this poll, let them do that now. |
1507 | 1581 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1508 | 1582 | |
1509 | - if ($output_method != 'echo') |
|
1510 | - return $return; |
|
1583 | + if ($output_method != 'echo') { |
|
1584 | + return $return; |
|
1585 | + } |
|
1511 | 1586 | |
1512 | 1587 | if ($return['allow_vote']) |
1513 | 1588 | { |
@@ -1516,17 +1591,17 @@ discard block |
||
1516 | 1591 | <strong>', $return['question'], '</strong><br> |
1517 | 1592 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1518 | 1593 | |
1519 | - foreach ($return['options'] as $option) |
|
1520 | - echo ' |
|
1594 | + foreach ($return['options'] as $option) { |
|
1595 | + echo ' |
|
1521 | 1596 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1597 | + } |
|
1522 | 1598 | |
1523 | 1599 | echo ' |
1524 | 1600 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1525 | 1601 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1526 | 1602 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1527 | 1603 | </form>'; |
1528 | - } |
|
1529 | - else |
|
1604 | + } else |
|
1530 | 1605 | { |
1531 | 1606 | echo ' |
1532 | 1607 | <div class="ssi_poll"> |
@@ -1606,27 +1681,32 @@ discard block |
||
1606 | 1681 | 'is_approved' => 1, |
1607 | 1682 | ) |
1608 | 1683 | ); |
1609 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1610 | - die; |
|
1684 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1685 | + die; |
|
1686 | + } |
|
1611 | 1687 | $row = $smcFunc['db_fetch_assoc']($request); |
1612 | 1688 | $smcFunc['db_free_result']($request); |
1613 | 1689 | |
1614 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1615 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1690 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1691 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1692 | + } |
|
1616 | 1693 | |
1617 | 1694 | // Too many options checked? |
1618 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1619 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1695 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1696 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1697 | + } |
|
1620 | 1698 | |
1621 | 1699 | // It's a guest who has already voted? |
1622 | 1700 | if ($user_info['is_guest']) |
1623 | 1701 | { |
1624 | 1702 | // Guest voting disabled? |
1625 | - if (!$row['guest_vote']) |
|
1626 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1703 | + if (!$row['guest_vote']) { |
|
1704 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1705 | + } |
|
1627 | 1706 | // Already voted? |
1628 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1629 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1707 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1708 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1709 | + } |
|
1630 | 1710 | } |
1631 | 1711 | |
1632 | 1712 | $sOptions = array(); |
@@ -1680,11 +1760,13 @@ discard block |
||
1680 | 1760 | { |
1681 | 1761 | global $scripturl, $txt, $context; |
1682 | 1762 | |
1683 | - if (!allowedTo('search_posts')) |
|
1684 | - return; |
|
1763 | + if (!allowedTo('search_posts')) { |
|
1764 | + return; |
|
1765 | + } |
|
1685 | 1766 | |
1686 | - if ($output_method != 'echo') |
|
1687 | - return $scripturl . '?action=search'; |
|
1767 | + if ($output_method != 'echo') { |
|
1768 | + return $scripturl . '?action=search'; |
|
1769 | + } |
|
1688 | 1770 | |
1689 | 1771 | echo ' |
1690 | 1772 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1706,8 +1788,9 @@ discard block |
||
1706 | 1788 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1707 | 1789 | call_integration_hook('integrate_ssi_news'); |
1708 | 1790 | |
1709 | - if ($output_method != 'echo') |
|
1710 | - return $context['random_news_line']; |
|
1791 | + if ($output_method != 'echo') { |
|
1792 | + return $context['random_news_line']; |
|
1793 | + } |
|
1711 | 1794 | |
1712 | 1795 | echo $context['random_news_line']; |
1713 | 1796 | } |
@@ -1721,8 +1804,9 @@ discard block |
||
1721 | 1804 | { |
1722 | 1805 | global $scripturl, $modSettings, $user_info; |
1723 | 1806 | |
1724 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1725 | - return; |
|
1807 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1808 | + return; |
|
1809 | + } |
|
1726 | 1810 | |
1727 | 1811 | $eventOptions = array( |
1728 | 1812 | 'include_birthdays' => true, |
@@ -1733,13 +1817,15 @@ discard block |
||
1733 | 1817 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1734 | 1818 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1735 | 1819 | |
1736 | - if ($output_method != 'echo') |
|
1737 | - return $return['calendar_birthdays']; |
|
1820 | + if ($output_method != 'echo') { |
|
1821 | + return $return['calendar_birthdays']; |
|
1822 | + } |
|
1738 | 1823 | |
1739 | - foreach ($return['calendar_birthdays'] as $member) |
|
1740 | - echo ' |
|
1824 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1825 | + echo ' |
|
1741 | 1826 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
1742 | -} |
|
1827 | + } |
|
1828 | + } |
|
1743 | 1829 | |
1744 | 1830 | /** |
1745 | 1831 | * Shows today's holidays. |
@@ -1750,8 +1836,9 @@ discard block |
||
1750 | 1836 | { |
1751 | 1837 | global $modSettings, $user_info; |
1752 | 1838 | |
1753 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1754 | - return; |
|
1839 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1840 | + return; |
|
1841 | + } |
|
1755 | 1842 | |
1756 | 1843 | $eventOptions = array( |
1757 | 1844 | 'include_holidays' => true, |
@@ -1762,8 +1849,9 @@ discard block |
||
1762 | 1849 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1763 | 1850 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1764 | 1851 | |
1765 | - if ($output_method != 'echo') |
|
1766 | - return $return['calendar_holidays']; |
|
1852 | + if ($output_method != 'echo') { |
|
1853 | + return $return['calendar_holidays']; |
|
1854 | + } |
|
1767 | 1855 | |
1768 | 1856 | echo ' |
1769 | 1857 | ', implode(', ', $return['calendar_holidays']); |
@@ -1777,8 +1865,9 @@ discard block |
||
1777 | 1865 | { |
1778 | 1866 | global $modSettings, $user_info; |
1779 | 1867 | |
1780 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1781 | - return; |
|
1868 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1869 | + return; |
|
1870 | + } |
|
1782 | 1871 | |
1783 | 1872 | $eventOptions = array( |
1784 | 1873 | 'include_events' => true, |
@@ -1789,14 +1878,16 @@ discard block |
||
1789 | 1878 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1790 | 1879 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1791 | 1880 | |
1792 | - if ($output_method != 'echo') |
|
1793 | - return $return['calendar_events']; |
|
1881 | + if ($output_method != 'echo') { |
|
1882 | + return $return['calendar_events']; |
|
1883 | + } |
|
1794 | 1884 | |
1795 | 1885 | foreach ($return['calendar_events'] as $event) |
1796 | 1886 | { |
1797 | - if ($event['can_edit']) |
|
1798 | - echo ' |
|
1887 | + if ($event['can_edit']) { |
|
1888 | + echo ' |
|
1799 | 1889 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1890 | + } |
|
1800 | 1891 | echo ' |
1801 | 1892 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1802 | 1893 | } |
@@ -1811,8 +1902,9 @@ discard block |
||
1811 | 1902 | { |
1812 | 1903 | global $modSettings, $txt, $scripturl, $user_info; |
1813 | 1904 | |
1814 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1815 | - return; |
|
1905 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1906 | + return; |
|
1907 | + } |
|
1816 | 1908 | |
1817 | 1909 | $eventOptions = array( |
1818 | 1910 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1825,19 +1917,22 @@ discard block |
||
1825 | 1917 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1826 | 1918 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1827 | 1919 | |
1828 | - if ($output_method != 'echo') |
|
1829 | - return $return; |
|
1920 | + if ($output_method != 'echo') { |
|
1921 | + return $return; |
|
1922 | + } |
|
1830 | 1923 | |
1831 | - if (!empty($return['calendar_holidays'])) |
|
1832 | - echo ' |
|
1924 | + if (!empty($return['calendar_holidays'])) { |
|
1925 | + echo ' |
|
1833 | 1926 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1927 | + } |
|
1834 | 1928 | if (!empty($return['calendar_birthdays'])) |
1835 | 1929 | { |
1836 | 1930 | echo ' |
1837 | 1931 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1838 | - foreach ($return['calendar_birthdays'] as $member) |
|
1839 | - echo ' |
|
1932 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1933 | + echo ' |
|
1840 | 1934 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
1935 | + } |
|
1841 | 1936 | echo ' |
1842 | 1937 | <br>'; |
1843 | 1938 | } |
@@ -1847,9 +1942,10 @@ discard block |
||
1847 | 1942 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1848 | 1943 | foreach ($return['calendar_events'] as $event) |
1849 | 1944 | { |
1850 | - if ($event['can_edit']) |
|
1851 | - echo ' |
|
1945 | + if ($event['can_edit']) { |
|
1946 | + echo ' |
|
1852 | 1947 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1948 | + } |
|
1853 | 1949 | echo ' |
1854 | 1950 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1855 | 1951 | } |
@@ -1873,25 +1969,29 @@ discard block |
||
1873 | 1969 | loadLanguage('Stats'); |
1874 | 1970 | |
1875 | 1971 | // Must be integers.... |
1876 | - if ($limit === null) |
|
1877 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1878 | - else |
|
1879 | - $limit = (int) $limit; |
|
1880 | - |
|
1881 | - if ($start === null) |
|
1882 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1883 | - else |
|
1884 | - $start = (int) $start; |
|
1885 | - |
|
1886 | - if ($board !== null) |
|
1887 | - $board = (int) $board; |
|
1888 | - elseif (isset($_GET['board'])) |
|
1889 | - $board = (int) $_GET['board']; |
|
1890 | - |
|
1891 | - if ($length === null) |
|
1892 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1893 | - else |
|
1894 | - $length = (int) $length; |
|
1972 | + if ($limit === null) { |
|
1973 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1974 | + } else { |
|
1975 | + $limit = (int) $limit; |
|
1976 | + } |
|
1977 | + |
|
1978 | + if ($start === null) { |
|
1979 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1980 | + } else { |
|
1981 | + $start = (int) $start; |
|
1982 | + } |
|
1983 | + |
|
1984 | + if ($board !== null) { |
|
1985 | + $board = (int) $board; |
|
1986 | + } elseif (isset($_GET['board'])) { |
|
1987 | + $board = (int) $_GET['board']; |
|
1988 | + } |
|
1989 | + |
|
1990 | + if ($length === null) { |
|
1991 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1992 | + } else { |
|
1993 | + $length = (int) $length; |
|
1994 | + } |
|
1895 | 1995 | |
1896 | 1996 | $limit = max(0, $limit); |
1897 | 1997 | $start = max(0, $start); |
@@ -1909,17 +2009,19 @@ discard block |
||
1909 | 2009 | ); |
1910 | 2010 | if ($smcFunc['db_num_rows']($request) == 0) |
1911 | 2011 | { |
1912 | - if ($output_method == 'echo') |
|
1913 | - die($txt['ssi_no_guests']); |
|
1914 | - else |
|
1915 | - return array(); |
|
2012 | + if ($output_method == 'echo') { |
|
2013 | + die($txt['ssi_no_guests']); |
|
2014 | + } else { |
|
2015 | + return array(); |
|
2016 | + } |
|
1916 | 2017 | } |
1917 | 2018 | list ($board) = $smcFunc['db_fetch_row']($request); |
1918 | 2019 | $smcFunc['db_free_result']($request); |
1919 | 2020 | |
1920 | 2021 | $icon_sources = array(); |
1921 | - foreach ($context['stable_icons'] as $icon) |
|
1922 | - $icon_sources[$icon] = 'images_url'; |
|
2022 | + foreach ($context['stable_icons'] as $icon) { |
|
2023 | + $icon_sources[$icon] = 'images_url'; |
|
2024 | + } |
|
1923 | 2025 | |
1924 | 2026 | if (!empty($modSettings['enable_likes'])) |
1925 | 2027 | { |
@@ -1942,12 +2044,14 @@ discard block |
||
1942 | 2044 | ) |
1943 | 2045 | ); |
1944 | 2046 | $posts = array(); |
1945 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1946 | - $posts[] = $row['id_first_msg']; |
|
2047 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2048 | + $posts[] = $row['id_first_msg']; |
|
2049 | + } |
|
1947 | 2050 | $smcFunc['db_free_result']($request); |
1948 | 2051 | |
1949 | - if (empty($posts)) |
|
1950 | - return array(); |
|
2052 | + if (empty($posts)) { |
|
2053 | + return array(); |
|
2054 | + } |
|
1951 | 2055 | |
1952 | 2056 | // Find the posts. |
1953 | 2057 | $request = $smcFunc['db_query']('', ' |
@@ -1977,24 +2081,28 @@ discard block |
||
1977 | 2081 | $last_space = strrpos($row['body'], ' '); |
1978 | 2082 | $last_open = strrpos($row['body'], '<'); |
1979 | 2083 | $last_close = strrpos($row['body'], '>'); |
1980 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
1981 | - $cutoff = $last_open; |
|
1982 | - elseif (empty($last_close) || $last_close < $last_open) |
|
1983 | - $cutoff = $last_space; |
|
2084 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2085 | + $cutoff = $last_open; |
|
2086 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2087 | + $cutoff = $last_space; |
|
2088 | + } |
|
1984 | 2089 | |
1985 | - if ($cutoff !== false) |
|
1986 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2090 | + if ($cutoff !== false) { |
|
2091 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2092 | + } |
|
1987 | 2093 | $row['body'] .= '...'; |
1988 | 2094 | } |
1989 | 2095 | |
1990 | 2096 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
1991 | 2097 | |
1992 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
1993 | - $row['icon'] = 'recycled'; |
|
2098 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2099 | + $row['icon'] = 'recycled'; |
|
2100 | + } |
|
1994 | 2101 | |
1995 | 2102 | // Check that this message icon is there... |
1996 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
1997 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2103 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2104 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2105 | + } |
|
1998 | 2106 | |
1999 | 2107 | censorText($row['subject']); |
2000 | 2108 | censorText($row['body']); |
@@ -2031,16 +2139,18 @@ discard block |
||
2031 | 2139 | } |
2032 | 2140 | $smcFunc['db_free_result']($request); |
2033 | 2141 | |
2034 | - if (empty($return)) |
|
2035 | - return $return; |
|
2142 | + if (empty($return)) { |
|
2143 | + return $return; |
|
2144 | + } |
|
2036 | 2145 | |
2037 | 2146 | $return[count($return) - 1]['is_last'] = true; |
2038 | 2147 | |
2039 | 2148 | // If mods want to do somthing with this list of posts, let them do that now. |
2040 | 2149 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2041 | 2150 | |
2042 | - if ($output_method != 'echo') |
|
2043 | - return $return; |
|
2151 | + if ($output_method != 'echo') { |
|
2152 | + return $return; |
|
2153 | + } |
|
2044 | 2154 | |
2045 | 2155 | foreach ($return as $news) |
2046 | 2156 | { |
@@ -2092,9 +2202,10 @@ discard block |
||
2092 | 2202 | echo ' |
2093 | 2203 | </div>'; |
2094 | 2204 | |
2095 | - if (!$news['is_last']) |
|
2096 | - echo ' |
|
2205 | + if (!$news['is_last']) { |
|
2206 | + echo ' |
|
2097 | 2207 | <hr>'; |
2208 | + } |
|
2098 | 2209 | } |
2099 | 2210 | } |
2100 | 2211 | |
@@ -2108,8 +2219,9 @@ discard block |
||
2108 | 2219 | { |
2109 | 2220 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2110 | 2221 | |
2111 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2112 | - return; |
|
2222 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2223 | + return; |
|
2224 | + } |
|
2113 | 2225 | |
2114 | 2226 | // Find all events which are happening in the near future that the member can see. |
2115 | 2227 | $request = $smcFunc['db_query']('', ' |
@@ -2135,20 +2247,23 @@ discard block |
||
2135 | 2247 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2136 | 2248 | { |
2137 | 2249 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2138 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2139 | - continue; |
|
2250 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2251 | + continue; |
|
2252 | + } |
|
2140 | 2253 | |
2141 | 2254 | // Censor the title. |
2142 | 2255 | censorText($row['title']); |
2143 | 2256 | |
2144 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2145 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2146 | - else |
|
2147 | - $date = $row['start_date']; |
|
2257 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2258 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2259 | + } else { |
|
2260 | + $date = $row['start_date']; |
|
2261 | + } |
|
2148 | 2262 | |
2149 | 2263 | // If the topic it is attached to is not approved then don't link it. |
2150 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2151 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2264 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2265 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2266 | + } |
|
2152 | 2267 | |
2153 | 2268 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2154 | 2269 | |
@@ -2174,24 +2289,27 @@ discard block |
||
2174 | 2289 | } |
2175 | 2290 | $smcFunc['db_free_result']($request); |
2176 | 2291 | |
2177 | - foreach ($return as $mday => $array) |
|
2178 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2292 | + foreach ($return as $mday => $array) { |
|
2293 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2294 | + } |
|
2179 | 2295 | |
2180 | 2296 | // If mods want to do somthing with this list of events, let them do that now. |
2181 | 2297 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2182 | 2298 | |
2183 | - if ($output_method != 'echo' || empty($return)) |
|
2184 | - return $return; |
|
2299 | + if ($output_method != 'echo' || empty($return)) { |
|
2300 | + return $return; |
|
2301 | + } |
|
2185 | 2302 | |
2186 | 2303 | // Well the output method is echo. |
2187 | 2304 | echo ' |
2188 | 2305 | <span class="event">' . $txt['events'] . '</span> '; |
2189 | - foreach ($return as $mday => $array) |
|
2190 | - foreach ($array as $event) |
|
2306 | + foreach ($return as $mday => $array) { |
|
2307 | + foreach ($array as $event) |
|
2191 | 2308 | { |
2192 | 2309 | if ($event['can_edit']) |
2193 | 2310 | echo ' |
2194 | 2311 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2312 | + } |
|
2195 | 2313 | |
2196 | 2314 | echo ' |
2197 | 2315 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2210,8 +2328,9 @@ discard block |
||
2210 | 2328 | global $smcFunc; |
2211 | 2329 | |
2212 | 2330 | // If $id is null, this was most likely called from a query string and should do nothing. |
2213 | - if ($id === null) |
|
2214 | - return; |
|
2331 | + if ($id === null) { |
|
2332 | + return; |
|
2333 | + } |
|
2215 | 2334 | |
2216 | 2335 | $request = $smcFunc['db_query']('', ' |
2217 | 2336 | SELECT passwd, member_name, is_activated |
@@ -2243,8 +2362,9 @@ discard block |
||
2243 | 2362 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2244 | 2363 | |
2245 | 2364 | // No boards? Adios amigo. |
2246 | - if (empty($attachments_boards)) |
|
2247 | - return array(); |
|
2365 | + if (empty($attachments_boards)) { |
|
2366 | + return array(); |
|
2367 | + } |
|
2248 | 2368 | |
2249 | 2369 | // Is it an array? |
2250 | 2370 | $attachment_ext = (array) $attachment_ext; |
@@ -2328,8 +2448,9 @@ discard block |
||
2328 | 2448 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2329 | 2449 | |
2330 | 2450 | // So you just want an array? Here you can have it. |
2331 | - if ($output_method == 'array' || empty($attachments)) |
|
2332 | - return $attachments; |
|
2451 | + if ($output_method == 'array' || empty($attachments)) { |
|
2452 | + return $attachments; |
|
2453 | + } |
|
2333 | 2454 | |
2334 | 2455 | // Give them the default. |
2335 | 2456 | echo ' |
@@ -2340,14 +2461,15 @@ discard block |
||
2340 | 2461 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2341 | 2462 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2342 | 2463 | </tr>'; |
2343 | - foreach ($attachments as $attach) |
|
2344 | - echo ' |
|
2464 | + foreach ($attachments as $attach) { |
|
2465 | + echo ' |
|
2345 | 2466 | <tr> |
2346 | 2467 | <td>', $attach['file']['link'], '</td> |
2347 | 2468 | <td>', $attach['member']['link'], '</td> |
2348 | 2469 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2349 | 2470 | <td>', $attach['file']['filesize'], '</td> |
2350 | 2471 | </tr>'; |
2472 | + } |
|
2351 | 2473 | echo ' |
2352 | 2474 | </table>'; |
2353 | 2475 | } |
@@ -227,7 +227,7 @@ |
||
227 | 227 | * @param int|string $verify_id The verification control ID |
228 | 228 | * @param string $display_type What type to display. Can be 'single' to only show one verification option or 'all' to show all of them |
229 | 229 | * @param bool $reset Whether to reset the internal tracking counter |
230 | - * @return bool False if there's nothing else to show, true if $display_type is 'single', nothing otherwise |
|
230 | + * @return boolean|null False if there's nothing else to show, true if $display_type is 'single', nothing otherwise |
|
231 | 231 | */ |
232 | 232 | function template_control_verification($verify_id, $display_type = 'all', $reset = false) |
233 | 233 | { |
@@ -53,14 +53,15 @@ discard block |
||
53 | 53 | foreach ($context['smileys'] as $location => $smileyRows) |
54 | 54 | { |
55 | 55 | $countLocations--; |
56 | - if ($location == 'postform') |
|
57 | - echo ' |
|
56 | + if ($location == 'postform') { |
|
57 | + echo ' |
|
58 | 58 | dropdown: |
59 | 59 | {'; |
60 | - elseif ($location == 'popup') |
|
61 | - echo ' |
|
60 | + } elseif ($location == 'popup') { |
|
61 | + echo ' |
|
62 | 62 | popup: |
63 | 63 | {'; |
64 | + } |
|
64 | 65 | |
65 | 66 | $numRows = count($smileyRows); |
66 | 67 | |
@@ -68,25 +69,27 @@ discard block |
||
68 | 69 | $emptyPlaceholder = 0; |
69 | 70 | foreach ($smileyRows as $smileyRow) |
70 | 71 | { |
71 | - foreach ($smileyRow['smileys'] as $smiley) |
|
72 | - echo ' |
|
72 | + foreach ($smileyRow['smileys'] as $smiley) { |
|
73 | + echo ' |
|
73 | 74 | ', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : ''; |
75 | + } |
|
74 | 76 | |
75 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
76 | - echo ', |
|
77 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
78 | + echo ', |
|
77 | 79 | \'-', $emptyPlaceholder++, '\': \'\','; |
80 | + } |
|
78 | 81 | } |
79 | 82 | echo ' |
80 | 83 | }', $countLocations != 0 ? ',' : ''; |
81 | 84 | } |
82 | 85 | echo ' |
83 | 86 | }'; |
84 | - } |
|
85 | - else |
|
86 | - echo ', |
|
87 | + } else { |
|
88 | + echo ', |
|
87 | 89 | emoticons: |
88 | 90 | {}, |
89 | 91 | emoticonsEnabled:false'; |
92 | + } |
|
90 | 93 | |
91 | 94 | if ($context['show_bbc'] && $bbcContainer !== null) |
92 | 95 | { |
@@ -100,15 +103,16 @@ discard block |
||
100 | 103 | |
101 | 104 | $count_tags--; |
102 | 105 | |
103 | - if (!empty($count_tags)) |
|
104 | - echo '||'; |
|
106 | + if (!empty($count_tags)) { |
|
107 | + echo '||'; |
|
108 | + } |
|
105 | 109 | } |
106 | 110 | |
107 | 111 | echo '",'; |
108 | - } |
|
109 | - else |
|
110 | - echo ', |
|
112 | + } else { |
|
113 | + echo ', |
|
111 | 114 | toolbar: "",'; |
115 | + } |
|
112 | 116 | |
113 | 117 | echo ' |
114 | 118 | }); |
@@ -150,42 +154,47 @@ discard block |
||
150 | 154 | |
151 | 155 | $tempTab = $context['tabindex']; |
152 | 156 | |
153 | - if (!empty($context['drafts_pm_save'])) |
|
154 | - $tempTab++; |
|
155 | - elseif (!empty($context['drafts_save'])) |
|
156 | - $tempTab++; |
|
157 | - elseif ($editor_context['preview_type']) |
|
158 | - $tempTab++; |
|
159 | - elseif ($context['show_spellchecking']) |
|
160 | - $tempTab++; |
|
157 | + if (!empty($context['drafts_pm_save'])) { |
|
158 | + $tempTab++; |
|
159 | + } elseif (!empty($context['drafts_save'])) { |
|
160 | + $tempTab++; |
|
161 | + } elseif ($editor_context['preview_type']) { |
|
162 | + $tempTab++; |
|
163 | + } elseif ($context['show_spellchecking']) { |
|
164 | + $tempTab++; |
|
165 | + } |
|
161 | 166 | |
162 | 167 | $tempTab++; |
163 | 168 | $context['tabindex'] = $tempTab; |
164 | 169 | |
165 | - if (!empty($context['drafts_pm_save'])) |
|
166 | - echo ' |
|
170 | + if (!empty($context['drafts_pm_save'])) { |
|
171 | + echo ' |
|
167 | 172 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
168 | 173 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
174 | + } |
|
169 | 175 | |
170 | - if (!empty($context['drafts_save'])) |
|
171 | - echo ' |
|
176 | + if (!empty($context['drafts_save'])) { |
|
177 | + echo ' |
|
172 | 178 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button"> |
173 | 179 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
180 | + } |
|
174 | 181 | |
175 | - if ($context['show_spellchecking']) |
|
176 | - echo ' |
|
182 | + if ($context['show_spellchecking']) { |
|
183 | + echo ' |
|
177 | 184 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
185 | + } |
|
178 | 186 | |
179 | - if ($editor_context['preview_type']) |
|
180 | - echo ' |
|
187 | + if ($editor_context['preview_type']) { |
|
188 | + echo ' |
|
181 | 189 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button">'; |
190 | + } |
|
182 | 191 | |
183 | 192 | echo ' |
184 | 193 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">'; |
185 | 194 | |
186 | 195 | // Load in the PM autosaver if it's enabled |
187 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
188 | - echo ' |
|
196 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
197 | + echo ' |
|
189 | 198 | <span class="righttext padding" style="display: block"> |
190 | 199 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
191 | 200 | <span id="draft_lastautosave" ></span> |
@@ -203,10 +212,11 @@ discard block |
||
203 | 212 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
204 | 213 | }); |
205 | 214 | </script>'; |
215 | + } |
|
206 | 216 | |
207 | 217 | // Start an instance of the auto saver if its enabled |
208 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
209 | - echo ' |
|
218 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
219 | + echo ' |
|
210 | 220 | <span class="righttext padding" style="display: block"> |
211 | 221 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
212 | 222 | <span id="draft_lastautosave" ></span> |
@@ -223,7 +233,8 @@ discard block |
||
223 | 233 | iFreq: ', $context['drafts_autosave_frequency'], ' |
224 | 234 | }); |
225 | 235 | </script>'; |
226 | -} |
|
236 | + } |
|
237 | + } |
|
227 | 238 | |
228 | 239 | /** |
229 | 240 | * This template displays a verification form |
@@ -240,51 +251,57 @@ discard block |
||
240 | 251 | $verify_context = &$context['controls']['verification'][$verify_id]; |
241 | 252 | |
242 | 253 | // Keep track of where we are. |
243 | - if (empty($verify_context['tracking']) || $reset) |
|
244 | - $verify_context['tracking'] = 0; |
|
254 | + if (empty($verify_context['tracking']) || $reset) { |
|
255 | + $verify_context['tracking'] = 0; |
|
256 | + } |
|
245 | 257 | |
246 | 258 | // How many items are there to display in total. |
247 | 259 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
248 | 260 | |
249 | 261 | // If we've gone too far, stop. |
250 | - if ($verify_context['tracking'] > $total_items) |
|
251 | - return false; |
|
262 | + if ($verify_context['tracking'] > $total_items) { |
|
263 | + return false; |
|
264 | + } |
|
252 | 265 | |
253 | 266 | // Loop through each item to show them. |
254 | 267 | for ($i = 0; $i < $total_items; $i++) |
255 | 268 | { |
256 | 269 | // If we're after a single item only show it if we're in the right place. |
257 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
258 | - continue; |
|
270 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
271 | + continue; |
|
272 | + } |
|
259 | 273 | |
260 | - if ($display_type != 'single') |
|
261 | - echo ' |
|
274 | + if ($display_type != 'single') { |
|
275 | + echo ' |
|
262 | 276 | <div id="verification_control_', $i, '" class="verification_control">'; |
277 | + } |
|
263 | 278 | |
264 | 279 | // Display empty field, but only if we have one, and it's the first time. |
265 | - if ($verify_context['empty_field'] && empty($i)) |
|
266 | - echo ' |
|
280 | + if ($verify_context['empty_field'] && empty($i)) { |
|
281 | + echo ' |
|
267 | 282 | <div class="smalltext vv_special"> |
268 | 283 | ', $txt['visual_verification_hidden'], ': |
269 | 284 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
270 | 285 | </div>'; |
286 | + } |
|
271 | 287 | |
272 | 288 | // Do the actual stuff |
273 | 289 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
274 | 290 | { |
275 | 291 | if ($verify_context['show_visual']) |
276 | 292 | { |
277 | - if ($context['use_graphic_library']) |
|
278 | - echo ' |
|
293 | + if ($context['use_graphic_library']) { |
|
294 | + echo ' |
|
279 | 295 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
280 | - else |
|
281 | - echo ' |
|
296 | + } else { |
|
297 | + echo ' |
|
282 | 298 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
283 | 299 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
284 | 300 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
285 | 301 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
286 | 302 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
287 | 303 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
304 | + } |
|
288 | 305 | |
289 | 306 | echo ' |
290 | 307 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -294,13 +311,13 @@ discard block |
||
294 | 311 | </div>'; |
295 | 312 | } |
296 | 313 | |
297 | - if ($verify_context['can_recaptcha']) |
|
298 | - echo ' |
|
314 | + if ($verify_context['can_recaptcha']) { |
|
315 | + echo ' |
|
299 | 316 | <div class="g-recaptcha centertext" data-sitekey="' . $verify_context['recaptcha_site_key'] . '" data-theme="' . $verify_context['recaptcha_theme'] . '"></div> |
300 | 317 | <br> |
301 | 318 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>'; |
302 | - } |
|
303 | - else |
|
319 | + } |
|
320 | + } else |
|
304 | 321 | { |
305 | 322 | // Where in the question array is this question? |
306 | 323 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -312,21 +329,24 @@ discard block |
||
312 | 329 | </div>'; |
313 | 330 | } |
314 | 331 | |
315 | - if ($display_type != 'single') |
|
316 | - echo ' |
|
332 | + if ($display_type != 'single') { |
|
333 | + echo ' |
|
317 | 334 | </div><!-- #verification_control_[i] -->'; |
335 | + } |
|
318 | 336 | |
319 | 337 | // If we were displaying just one and we did it, break. |
320 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
321 | - break; |
|
338 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
339 | + break; |
|
340 | + } |
|
322 | 341 | } |
323 | 342 | |
324 | 343 | // Assume we found something, always. |
325 | 344 | $verify_context['tracking']++; |
326 | 345 | |
327 | 346 | // Tell something displaying piecemeal to keep going. |
328 | - if ($display_type == 'single') |
|
329 | - return true; |
|
330 | -} |
|
347 | + if ($display_type == 'single') { |
|
348 | + return true; |
|
349 | + } |
|
350 | + } |
|
331 | 351 | |
332 | 352 | ?> |
333 | 353 | \ No newline at end of file |
@@ -1096,7 +1096,7 @@ |
||
1096 | 1096 | /** |
1097 | 1097 | * CHMOD control form |
1098 | 1098 | * |
1099 | - * @return bool False if nothing to do. |
|
1099 | + * @return false|null False if nothing to do. |
|
1100 | 1100 | */ |
1101 | 1101 | function template_control_chmod() |
1102 | 1102 | { |
@@ -31,25 +31,27 @@ discard block |
||
31 | 31 | </div> |
32 | 32 | <div class="information">'; |
33 | 33 | |
34 | - if ($context['is_installed']) |
|
35 | - echo ' |
|
34 | + if ($context['is_installed']) { |
|
35 | + echo ' |
|
36 | 36 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
37 | 37 | <br> |
38 | 38 | ', $txt['package_installed_warning2'], '<br> |
39 | 39 | <br>'; |
40 | + } |
|
40 | 41 | |
41 | 42 | echo $txt['package_installed_warning3'], ' |
42 | 43 | </div> |
43 | 44 | <br>'; |
44 | 45 | |
45 | 46 | // Do errors exist in the install? If so light them up like a christmas tree. |
46 | - if ($context['has_failure']) |
|
47 | - echo ' |
|
47 | + if ($context['has_failure']) { |
|
48 | + echo ' |
|
48 | 49 | <div class="errorbox"> |
49 | 50 | ', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br> |
50 | 51 | ', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), |
51 | 52 | !empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', ' |
52 | 53 | </div>'; |
54 | + } |
|
53 | 55 | |
54 | 56 | // Display the package readme if one exists |
55 | 57 | if (isset($context['package_readme'])) |
@@ -63,9 +65,10 @@ discard block |
||
63 | 65 | <span class="floatright">', $txt['package_available_readme_language'], ' |
64 | 66 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
65 | 67 | |
66 | - foreach ($context['readmes'] as $a => $b) |
|
67 | - echo ' |
|
68 | + foreach ($context['readmes'] as $a => $b) { |
|
69 | + echo ' |
|
68 | 70 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
71 | + } |
|
69 | 72 | |
70 | 73 | echo ' |
71 | 74 | </select> |
@@ -86,9 +89,10 @@ discard block |
||
86 | 89 | <span class="floatright">', $txt['package_available_license_language'], ' |
87 | 90 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
88 | 91 | |
89 | - foreach ($context['licenses'] as $a => $b) |
|
90 | - echo ' |
|
92 | + foreach ($context['licenses'] as $a => $b) { |
|
93 | + echo ' |
|
91 | 94 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
95 | + } |
|
92 | 96 | echo ' |
93 | 97 | </select> |
94 | 98 | </span> |
@@ -115,9 +119,10 @@ discard block |
||
115 | 119 | ', $txt['package_db_uninstall_actions'], ': |
116 | 120 | <ul>'; |
117 | 121 | |
118 | - foreach ($context['database_changes'] as $change) |
|
119 | - echo ' |
|
122 | + foreach ($context['database_changes'] as $change) { |
|
123 | + echo ' |
|
120 | 124 | <li>', $change, '</li>'; |
125 | + } |
|
121 | 126 | |
122 | 127 | echo ' |
123 | 128 | </ul> |
@@ -128,14 +133,14 @@ discard block |
||
128 | 133 | echo ' |
129 | 134 | <div class="information">'; |
130 | 135 | |
131 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
132 | - echo ' |
|
136 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
137 | + echo ' |
|
133 | 138 | <br> |
134 | 139 | <div class="errorbox"> |
135 | 140 | ', $txt['corrupt_compatible'], ' |
136 | 141 | </div> |
137 | 142 | </div><!-- .information -->'; |
138 | - else |
|
143 | + } else |
|
139 | 144 | { |
140 | 145 | echo ' |
141 | 146 | ', $txt['perform_actions'], ' |
@@ -239,9 +244,10 @@ discard block |
||
239 | 244 | <td></td> |
240 | 245 | <td>'; |
241 | 246 | |
242 | - if (!empty($context['themes_locked'])) |
|
243 | - echo ' |
|
247 | + if (!empty($context['themes_locked'])) { |
|
248 | + echo ' |
|
244 | 249 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
250 | + } |
|
245 | 251 | echo ' |
246 | 252 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
247 | 253 | </td> |
@@ -307,21 +313,23 @@ discard block |
||
307 | 313 | } |
308 | 314 | |
309 | 315 | // Are we effectively ready to install? |
310 | - if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) |
|
311 | - echo ' |
|
316 | + if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) { |
|
317 | + echo ' |
|
312 | 318 | <div class="righttext padding"> |
313 | 319 | <input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) && confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button"> |
314 | 320 | </div>'; |
321 | + } |
|
315 | 322 | |
316 | 323 | // If we need ftp information then demand it! |
317 | - elseif ($context['ftp_needed']) |
|
318 | - echo ' |
|
324 | + elseif ($context['ftp_needed']) { |
|
325 | + echo ' |
|
319 | 326 | <div class="cat_bar"> |
320 | 327 | <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3> |
321 | 328 | </div> |
322 | 329 | <div> |
323 | 330 | ', template_control_chmod(), ' |
324 | 331 | </div>'; |
332 | + } |
|
325 | 333 | |
326 | 334 | echo ' |
327 | 335 | |
@@ -338,8 +346,8 @@ discard block |
||
338 | 346 | // Operations. |
339 | 347 | if (!empty($js_operations)) |
340 | 348 | { |
341 | - foreach ($js_operations as $key => $operation) |
|
342 | - echo ' |
|
349 | + foreach ($js_operations as $key => $operation) { |
|
350 | + echo ' |
|
343 | 351 | aOperationElements[', $key, '] = new smc_Toggle({ |
344 | 352 | bToggleEnabled: true, |
345 | 353 | bNoAnimate: true, |
@@ -357,6 +365,7 @@ discard block |
||
357 | 365 | } |
358 | 366 | ] |
359 | 367 | });'; |
368 | + } |
|
360 | 369 | } |
361 | 370 | |
362 | 371 | echo ' |
@@ -378,14 +387,15 @@ discard block |
||
378 | 387 | </script>'; |
379 | 388 | |
380 | 389 | // And a bit more for database changes. |
381 | - if (!empty($context['database_changes'])) |
|
382 | - echo ' |
|
390 | + if (!empty($context['database_changes'])) { |
|
391 | + echo ' |
|
383 | 392 | <script> |
384 | 393 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
385 | 394 | var db_vis = false; |
386 | 395 | database_changes_area.style.display = "none"; |
387 | 396 | </script>'; |
388 | -} |
|
397 | + } |
|
398 | + } |
|
389 | 399 | |
390 | 400 | /** |
391 | 401 | * Extract package contents |
@@ -394,8 +404,8 @@ discard block |
||
394 | 404 | { |
395 | 405 | global $context, $txt, $scripturl; |
396 | 406 | |
397 | - if (!empty($context['redirect_url'])) |
|
398 | - echo ' |
|
407 | + if (!empty($context['redirect_url'])) { |
|
408 | + echo ' |
|
399 | 409 | <script> |
400 | 410 | setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], '); |
401 | 411 | |
@@ -404,52 +414,51 @@ discard block |
||
404 | 414 | window.location = "', $context['redirect_url'], '"; |
405 | 415 | } |
406 | 416 | </script>'; |
417 | + } |
|
407 | 418 | |
408 | 419 | echo ' |
409 | 420 | <div id="admincenter">'; |
410 | 421 | |
411 | - if (empty($context['redirect_url'])) |
|
412 | - echo ' |
|
422 | + if (empty($context['redirect_url'])) { |
|
423 | + echo ' |
|
413 | 424 | <div class="cat_bar"> |
414 | 425 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
415 | 426 | </div> |
416 | 427 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
417 | - else |
|
418 | - echo ' |
|
428 | + } else { |
|
429 | + echo ' |
|
419 | 430 | <div class="cat_bar"> |
420 | 431 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
421 | 432 | </div>'; |
433 | + } |
|
422 | 434 | |
423 | 435 | echo ' |
424 | 436 | <div class="windowbg">'; |
425 | 437 | |
426 | 438 | // If we are going to redirect we have a slightly different agenda. |
427 | - if (!empty($context['redirect_url'])) |
|
428 | - echo ' |
|
439 | + if (!empty($context['redirect_url'])) { |
|
440 | + echo ' |
|
429 | 441 | ', $context['redirect_text'], '<br><br> |
430 | 442 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>'; |
431 | - |
|
432 | - elseif ($context['uninstalling']) |
|
433 | - echo ' |
|
443 | + } elseif ($context['uninstalling']) { |
|
444 | + echo ' |
|
434 | 445 | ', $txt['package_uninstall_done']; |
435 | - |
|
436 | - elseif ($context['install_finished']) |
|
446 | + } elseif ($context['install_finished']) |
|
437 | 447 | { |
438 | - if ($context['extract_type'] == 'avatar') |
|
439 | - echo ' |
|
448 | + if ($context['extract_type'] == 'avatar') { |
|
449 | + echo ' |
|
440 | 450 | ', $txt['avatars_extracted']; |
441 | - |
|
442 | - elseif ($context['extract_type'] == 'language') |
|
443 | - echo ' |
|
451 | + } elseif ($context['extract_type'] == 'language') { |
|
452 | + echo ' |
|
444 | 453 | ', $txt['language_extracted']; |
445 | - |
|
446 | - else |
|
447 | - echo ' |
|
454 | + } else { |
|
455 | + echo ' |
|
448 | 456 | ', $txt['package_installed_done']; |
449 | - } |
|
450 | - else |
|
451 | - echo ' |
|
457 | + } |
|
458 | + } else { |
|
459 | + echo ' |
|
452 | 460 | ', $txt['corrupt_compatible']; |
461 | + } |
|
453 | 462 | |
454 | 463 | echo ' |
455 | 464 | </div><!-- .windowbg -->'; |
@@ -483,9 +492,10 @@ discard block |
||
483 | 492 | <div class="windowbg"> |
484 | 493 | <ol>'; |
485 | 494 | |
486 | - foreach ($context['files'] as $fileinfo) |
|
487 | - echo ' |
|
495 | + foreach ($context['files'] as $fileinfo) { |
|
496 | + echo ' |
|
488 | 497 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
498 | + } |
|
489 | 499 | |
490 | 500 | echo ' |
491 | 501 | </ol> |
@@ -549,9 +559,10 @@ discard block |
||
549 | 559 | </script> |
550 | 560 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
551 | 561 | |
552 | - if (empty($modSettings['disable_smf_js'])) |
|
553 | - echo ' |
|
562 | + if (empty($modSettings['disable_smf_js'])) { |
|
563 | + echo ' |
|
554 | 564 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
565 | + } |
|
555 | 566 | |
556 | 567 | // This sets the announcements and current versions themselves ;). |
557 | 568 | echo ' |
@@ -590,12 +601,13 @@ discard block |
||
590 | 601 | } |
591 | 602 | } |
592 | 603 | |
593 | - if (!$mods_available) |
|
594 | - echo ' |
|
604 | + if (!$mods_available) { |
|
605 | + echo ' |
|
595 | 606 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
596 | - else |
|
597 | - echo ' |
|
607 | + } else { |
|
608 | + echo ' |
|
598 | 609 | <br>'; |
610 | + } |
|
599 | 611 | |
600 | 612 | // The advanced (emulation) box, collapsed by default |
601 | 613 | echo ' |
@@ -622,9 +634,10 @@ discard block |
||
622 | 634 | <a id="revert" name="revert"></a> |
623 | 635 | <select name="version_emulate" id="ve">'; |
624 | 636 | |
625 | - foreach ($context['emulation_versions'] as $version) |
|
626 | - echo ' |
|
637 | + foreach ($context['emulation_versions'] as $version) { |
|
638 | + echo ' |
|
627 | 639 | <option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>'; |
640 | + } |
|
628 | 641 | |
629 | 642 | echo ' |
630 | 643 | </select> |
@@ -680,11 +693,12 @@ discard block |
||
680 | 693 | { |
681 | 694 | global $context, $txt, $scripturl; |
682 | 695 | |
683 | - if (!empty($context['package_ftp']['error'])) |
|
684 | - echo ' |
|
696 | + if (!empty($context['package_ftp']['error'])) { |
|
697 | + echo ' |
|
685 | 698 | <div class="errorbox"> |
686 | 699 | <pre>', $context['package_ftp']['error'], '</pre> |
687 | 700 | </div>'; |
701 | + } |
|
688 | 702 | |
689 | 703 | echo ' |
690 | 704 | <div id="admin_form_wrapper"> |
@@ -766,13 +780,14 @@ discard block |
||
766 | 780 | <legend>' . $txt['package_servers'] . '</legend> |
767 | 781 | <ul class="package_servers">'; |
768 | 782 | |
769 | - foreach ($context['servers'] as $server) |
|
770 | - echo ' |
|
783 | + foreach ($context['servers'] as $server) { |
|
784 | + echo ' |
|
771 | 785 | <li class="flow_auto"> |
772 | 786 | <span class="floatleft">' . $server['name'] . '</span> |
773 | 787 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
774 | 788 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
775 | 789 | </li>'; |
790 | + } |
|
776 | 791 | echo ' |
777 | 792 | </ul> |
778 | 793 | </fieldset> |
@@ -859,11 +874,12 @@ discard block |
||
859 | 874 | <div class="windowbg2">'; |
860 | 875 | |
861 | 876 | // No packages, as yet. |
862 | - if (empty($context['package_list'])) |
|
863 | - echo ' |
|
877 | + if (empty($context['package_list'])) { |
|
878 | + echo ' |
|
864 | 879 | <ul> |
865 | 880 | <li>', $txt['no_packages'], '</li> |
866 | 881 | </ul>'; |
882 | + } |
|
867 | 883 | |
868 | 884 | // List out the packages... |
869 | 885 | else |
@@ -877,11 +893,12 @@ discard block |
||
877 | 893 | <li> |
878 | 894 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
879 | 895 | |
880 | - if (!empty($packageSection['text'])) |
|
881 | - echo ' |
|
896 | + if (!empty($packageSection['text'])) { |
|
897 | + echo ' |
|
882 | 898 | <div class="sub_bar"> |
883 | 899 | <h3 class="subbg">', $packageSection['text'], '</h3> |
884 | 900 | </div>'; |
901 | + } |
|
885 | 902 | |
886 | 903 | echo ' |
887 | 904 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -892,24 +909,28 @@ discard block |
||
892 | 909 | <li>'; |
893 | 910 | |
894 | 911 | // Textual message. Could be empty just for a blank line... |
895 | - if ($package['is_text']) |
|
896 | - echo ' |
|
912 | + if ($package['is_text']) { |
|
913 | + echo ' |
|
897 | 914 | ', empty($package['name']) ? ' ' : $package['name']; |
915 | + } |
|
898 | 916 | |
899 | 917 | // This is supposed to be a rule.. |
900 | - elseif ($package['is_line']) |
|
901 | - echo ' |
|
918 | + elseif ($package['is_line']) { |
|
919 | + echo ' |
|
902 | 920 | <hr>'; |
921 | + } |
|
903 | 922 | |
904 | 923 | // A remote link. |
905 | - elseif ($package['is_remote']) |
|
906 | - echo ' |
|
924 | + elseif ($package['is_remote']) { |
|
925 | + echo ' |
|
907 | 926 | <strong>', $package['link'], '</strong>'; |
927 | + } |
|
908 | 928 | |
909 | 929 | // A title? |
910 | - elseif ($package['is_heading'] || $package['is_title']) |
|
911 | - echo ' |
|
930 | + elseif ($package['is_heading'] || $package['is_title']) { |
|
931 | + echo ' |
|
912 | 932 | <strong>', $package['name'], '</strong>'; |
933 | + } |
|
913 | 934 | |
914 | 935 | // Otherwise, it's a package. |
915 | 936 | else |
@@ -920,32 +941,36 @@ discard block |
||
920 | 941 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
921 | 942 | |
922 | 943 | // Show the mod type? |
923 | - if ($package['type'] != '') |
|
924 | - echo ' |
|
944 | + if ($package['type'] != '') { |
|
945 | + echo ' |
|
925 | 946 | <li class="package_section"> |
926 | 947 | ', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), ' |
927 | 948 | </li>'; |
949 | + } |
|
928 | 950 | |
929 | 951 | // Show the version number? |
930 | - if ($package['version'] != '') |
|
931 | - echo ' |
|
952 | + if ($package['version'] != '') { |
|
953 | + echo ' |
|
932 | 954 | <li class="package_section"> |
933 | 955 | ', $txt['mod_version'], ': ', $package['version'], ' |
934 | 956 | </li>'; |
957 | + } |
|
935 | 958 | |
936 | 959 | // How 'bout the author? |
937 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
938 | - echo ' |
|
960 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
961 | + echo ' |
|
939 | 962 | <li class="package_section"> |
940 | 963 | ', $txt['mod_author'], ': ', $package['author']['link'], ' |
941 | 964 | </li>'; |
965 | + } |
|
942 | 966 | |
943 | 967 | // The homepage... |
944 | - if ($package['author']['website']['link'] != '') |
|
945 | - echo ' |
|
968 | + if ($package['author']['website']['link'] != '') { |
|
969 | + echo ' |
|
946 | 970 | <li class="package_section"> |
947 | 971 | ', $txt['author_website'], ': ', $package['author']['website']['link'], ' |
948 | 972 | </li>'; |
973 | + } |
|
949 | 974 | |
950 | 975 | // Description: bleh bleh! |
951 | 976 | // Location of file: http://someplace/. |
@@ -1004,8 +1029,8 @@ discard block |
||
1004 | 1029 | |
1005 | 1030 | foreach ($ps['items'] as $id => $package) |
1006 | 1031 | { |
1007 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
1008 | - echo ' |
|
1032 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
1033 | + echo ' |
|
1009 | 1034 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
1010 | 1035 | bToggleEnabled: true, |
1011 | 1036 | bCurrentlyCollapsed: true, |
@@ -1020,6 +1045,7 @@ discard block |
||
1020 | 1045 | } |
1021 | 1046 | ] |
1022 | 1047 | });'; |
1048 | + } |
|
1023 | 1049 | } |
1024 | 1050 | } |
1025 | 1051 | |
@@ -1064,9 +1090,10 @@ discard block |
||
1064 | 1090 | { |
1065 | 1091 | global $context, $txt, $scripturl; |
1066 | 1092 | |
1067 | - if (!empty($context['saved_successful'])) |
|
1068 | - echo ' |
|
1093 | + if (!empty($context['saved_successful'])) { |
|
1094 | + echo ' |
|
1069 | 1095 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1096 | + } |
|
1070 | 1097 | |
1071 | 1098 | echo ' |
1072 | 1099 | <div id="admincenter"> |
@@ -1128,8 +1155,9 @@ discard block |
||
1128 | 1155 | global $context, $txt; |
1129 | 1156 | |
1130 | 1157 | // Nothing to do? Brilliant! |
1131 | - if (empty($context['package_ftp'])) |
|
1132 | - return false; |
|
1158 | + if (empty($context['package_ftp'])) { |
|
1159 | + return false; |
|
1160 | + } |
|
1133 | 1161 | |
1134 | 1162 | if (empty($context['package_ftp']['form_elements_only'])) |
1135 | 1163 | { |
@@ -1139,19 +1167,21 @@ discard block |
||
1139 | 1167 | ', $txt['package_ftp_why_file_list'], ' |
1140 | 1168 | <ul style="display: inline;">'; |
1141 | 1169 | |
1142 | - if (!empty($context['notwritable_files'])) |
|
1143 | - foreach ($context['notwritable_files'] as $file) |
|
1170 | + if (!empty($context['notwritable_files'])) { |
|
1171 | + foreach ($context['notwritable_files'] as $file) |
|
1144 | 1172 | echo ' |
1145 | 1173 | <li>', $file, '</li>'; |
1174 | + } |
|
1146 | 1175 | |
1147 | 1176 | echo ' |
1148 | 1177 | </ul>'; |
1149 | 1178 | |
1150 | - if (!$context['server']['is_windows']) |
|
1151 | - echo ' |
|
1179 | + if (!$context['server']['is_windows']) { |
|
1180 | + echo ' |
|
1152 | 1181 | <hr> |
1153 | 1182 | ', $txt['package_chmod_linux'], '<br> |
1154 | 1183 | <tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>'; |
1184 | + } |
|
1155 | 1185 | |
1156 | 1186 | echo ' |
1157 | 1187 | </div><!-- #need_writable_list -->'; |
@@ -1164,9 +1194,10 @@ discard block |
||
1164 | 1194 | </div> |
1165 | 1195 | </div>'; |
1166 | 1196 | |
1167 | - if (!empty($context['package_ftp']['destination'])) |
|
1168 | - echo ' |
|
1197 | + if (!empty($context['package_ftp']['destination'])) { |
|
1198 | + echo ' |
|
1169 | 1199 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">'; |
1200 | + } |
|
1170 | 1201 | |
1171 | 1202 | echo ' |
1172 | 1203 | <fieldset> |
@@ -1199,24 +1230,27 @@ discard block |
||
1199 | 1230 | </dl> |
1200 | 1231 | </fieldset>'; |
1201 | 1232 | |
1202 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1203 | - echo ' |
|
1233 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1234 | + echo ' |
|
1204 | 1235 | <div class="righttext" style="margin: 1ex;"> |
1205 | 1236 | <span id="test_ftp_placeholder_full"></span> |
1206 | 1237 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
1207 | 1238 | </div>'; |
1239 | + } |
|
1208 | 1240 | |
1209 | - if (!empty($context['package_ftp']['destination'])) |
|
1210 | - echo ' |
|
1241 | + if (!empty($context['package_ftp']['destination'])) { |
|
1242 | + echo ' |
|
1211 | 1243 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1212 | 1244 | </form>'; |
1245 | + } |
|
1213 | 1246 | |
1214 | 1247 | // Hide the details of the list. |
1215 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1216 | - echo ' |
|
1248 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1249 | + echo ' |
|
1217 | 1250 | <script> |
1218 | 1251 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
1219 | 1252 | </script>'; |
1253 | + } |
|
1220 | 1254 | |
1221 | 1255 | // Quick generate the test button. |
1222 | 1256 | echo ' |
@@ -1573,9 +1607,10 @@ discard block |
||
1573 | 1607 | <td width="30%"> |
1574 | 1608 | <strong>'; |
1575 | 1609 | |
1576 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1577 | - echo ' |
|
1610 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1611 | + echo ' |
|
1578 | 1612 | <span class="generic_icons folder"></span>'; |
1613 | + } |
|
1579 | 1614 | |
1580 | 1615 | echo ' |
1581 | 1616 | ', $name, ' |
@@ -1602,8 +1637,9 @@ discard block |
||
1602 | 1637 | </td> |
1603 | 1638 | </tr>'; |
1604 | 1639 | |
1605 | - if (!empty($dir['contents'])) |
|
1606 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
1640 | + if (!empty($dir['contents'])) { |
|
1641 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
1642 | + } |
|
1607 | 1643 | } |
1608 | 1644 | |
1609 | 1645 | echo ' |
@@ -1639,13 +1675,14 @@ discard block |
||
1639 | 1675 | </fieldset>'; |
1640 | 1676 | |
1641 | 1677 | // Likely to need FTP? |
1642 | - if (empty($context['ftp_connected'])) |
|
1643 | - echo ' |
|
1678 | + if (empty($context['ftp_connected'])) { |
|
1679 | + echo ' |
|
1644 | 1680 | <p> |
1645 | 1681 | ', $txt['package_file_perms_ftp_details'], ': |
1646 | 1682 | </p> |
1647 | 1683 | ', template_control_chmod(), ' |
1648 | 1684 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
1685 | + } |
|
1649 | 1686 | |
1650 | 1687 | echo ' |
1651 | 1688 | <span id="test_ftp_placeholder_full"></span> |
@@ -1654,9 +1691,10 @@ discard block |
||
1654 | 1691 | </div><!-- .windowbg2 -->'; |
1655 | 1692 | |
1656 | 1693 | // Any looks fors we've already done? |
1657 | - foreach ($context['look_for'] as $path) |
|
1658 | - echo ' |
|
1694 | + foreach ($context['look_for'] as $path) { |
|
1695 | + echo ' |
|
1659 | 1696 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1697 | + } |
|
1660 | 1698 | |
1661 | 1699 | echo ' |
1662 | 1700 | </form> |
@@ -1698,9 +1736,10 @@ discard block |
||
1698 | 1736 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
1699 | 1737 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
1700 | 1738 | |
1701 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1702 | - echo ' |
|
1739 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1740 | + echo ' |
|
1703 | 1741 | <span class="generic_icons folder"></span>'; |
1742 | + } |
|
1704 | 1743 | |
1705 | 1744 | echo ' |
1706 | 1745 | ', $name, ' |
@@ -1718,34 +1757,38 @@ discard block |
||
1718 | 1757 | </tr> |
1719 | 1758 | <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>'; |
1720 | 1759 | |
1721 | - if (!empty($dir['contents'])) |
|
1722 | - template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
1760 | + if (!empty($dir['contents'])) { |
|
1761 | + template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
1762 | + } |
|
1723 | 1763 | } |
1724 | 1764 | } |
1725 | 1765 | |
1726 | 1766 | // We have more files to show? |
1727 | - if ($has_more) |
|
1728 | - echo ' |
|
1767 | + if ($has_more) { |
|
1768 | + echo ' |
|
1729 | 1769 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
1730 | 1770 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
1731 | 1771 | « <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> » |
1732 | 1772 | </td> |
1733 | 1773 | <td colspan="6"></td> |
1734 | 1774 | </tr>'; |
1775 | + } |
|
1735 | 1776 | |
1736 | 1777 | if ($drawn_div) |
1737 | 1778 | { |
1738 | 1779 | // Hide anything too far down the tree. |
1739 | 1780 | $isFound = false; |
1740 | - foreach ($context['look_for'] as $tree) |
|
1741 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
1781 | + foreach ($context['look_for'] as $tree) { |
|
1782 | + if (substr($tree, 0, strlen($ident)) == $ident) |
|
1742 | 1783 | $isFound = true; |
1784 | + } |
|
1743 | 1785 | |
1744 | - if ($level > 1 && !$isFound) |
|
1745 | - echo ' |
|
1786 | + if ($level > 1 && !$isFound) { |
|
1787 | + echo ' |
|
1746 | 1788 | <script> |
1747 | 1789 | expandFolder(\'', $js_ident, '\', \'\'); |
1748 | 1790 | </script>'; |
1791 | + } |
|
1749 | 1792 | } |
1750 | 1793 | } |
1751 | 1794 | |
@@ -1765,11 +1808,12 @@ discard block |
||
1765 | 1808 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
1766 | 1809 | </div>'; |
1767 | 1810 | |
1768 | - if (!empty($context['skip_ftp'])) |
|
1769 | - echo ' |
|
1811 | + if (!empty($context['skip_ftp'])) { |
|
1812 | + echo ' |
|
1770 | 1813 | <div class="errorbox"> |
1771 | 1814 | ', $txt['package_file_perms_skipping_ftp'], ' |
1772 | 1815 | </div>'; |
1816 | + } |
|
1773 | 1817 | |
1774 | 1818 | // How many have we done? |
1775 | 1819 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1808,28 +1852,31 @@ discard block |
||
1808 | 1852 | <br>'; |
1809 | 1853 | |
1810 | 1854 | // Put out the right hidden data. |
1811 | - if ($context['method'] == 'individual') |
|
1812 | - echo ' |
|
1855 | + if ($context['method'] == 'individual') { |
|
1856 | + echo ' |
|
1813 | 1857 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
1814 | 1858 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1815 | 1859 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
1816 | - else |
|
1817 | - echo ' |
|
1860 | + } else { |
|
1861 | + echo ' |
|
1818 | 1862 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
1819 | 1863 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
1820 | 1864 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1821 | 1865 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
1822 | 1866 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
1867 | + } |
|
1823 | 1868 | |
1824 | 1869 | // Are we not using FTP for whatever reason. |
1825 | - if (!empty($context['skip_ftp'])) |
|
1826 | - echo ' |
|
1870 | + if (!empty($context['skip_ftp'])) { |
|
1871 | + echo ' |
|
1827 | 1872 | <input type="hidden" name="skip_ftp" value="1">'; |
1873 | + } |
|
1828 | 1874 | |
1829 | 1875 | // Retain state. |
1830 | - foreach ($context['back_look_data'] as $path) |
|
1831 | - echo ' |
|
1876 | + foreach ($context['back_look_data'] as $path) { |
|
1877 | + echo ' |
|
1832 | 1878 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1879 | + } |
|
1833 | 1880 | |
1834 | 1881 | echo ' |
1835 | 1882 | <input type="hidden" name="method" value="', $context['method'], '"> |