@@ -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(defined('E_STRICT') ? E_ALL | E_STRICT : 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 | |
@@ -74,21 +75,22 @@ discard block |
||
| 74 | 75 | echo ' |
| 75 | 76 | ', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : ''; |
| 76 | 77 | } |
| 77 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
| 78 | - echo ', |
|
| 78 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
| 79 | + echo ', |
|
| 79 | 80 | \'-', $emptyPlaceholder++, '\': \'\','; |
| 81 | + } |
|
| 80 | 82 | } |
| 81 | 83 | echo ' |
| 82 | 84 | }', $countLocations != 0 ? ',' : ''; |
| 83 | 85 | } |
| 84 | 86 | echo ' |
| 85 | 87 | }'; |
| 86 | - } |
|
| 87 | - else |
|
| 88 | - echo ', |
|
| 88 | + } else { |
|
| 89 | + echo ', |
|
| 89 | 90 | emoticons: |
| 90 | 91 | {}, |
| 91 | 92 | emoticonsEnabled:false'; |
| 93 | + } |
|
| 92 | 94 | |
| 93 | 95 | if ($context['show_bbc'] && $bbcContainer !== null) |
| 94 | 96 | { |
@@ -101,15 +103,16 @@ discard block |
||
| 101 | 103 | |
| 102 | 104 | $count_tags--; |
| 103 | 105 | |
| 104 | - if (!empty($count_tags)) |
|
| 105 | - echo '||'; |
|
| 106 | + if (!empty($count_tags)) { |
|
| 107 | + echo '||'; |
|
| 108 | + } |
|
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | echo '",'; |
| 109 | - } |
|
| 110 | - else |
|
| 111 | - echo ', |
|
| 112 | + } else { |
|
| 113 | + echo ', |
|
| 112 | 114 | toolbar: "",'; |
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | echo ' |
| 115 | 118 | }); |
@@ -151,43 +154,48 @@ discard block |
||
| 151 | 154 | |
| 152 | 155 | $tempTab = $context['tabindex']; |
| 153 | 156 | |
| 154 | - if (!empty($context['drafts_pm_save'])) |
|
| 155 | - $tempTab++; |
|
| 156 | - elseif (!empty($context['drafts_save'])) |
|
| 157 | - $tempTab++; |
|
| 158 | - elseif ($editor_context['preview_type']) |
|
| 159 | - $tempTab++; |
|
| 160 | - elseif ($context['show_spellchecking']) |
|
| 161 | - $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 | + } |
|
| 162 | 166 | |
| 163 | 167 | $tempTab++; |
| 164 | 168 | $context['tabindex'] = $tempTab; |
| 165 | 169 | |
| 166 | - if (!empty($context['drafts_pm_save'])) |
|
| 167 | - echo ' |
|
| 170 | + if (!empty($context['drafts_pm_save'])) { |
|
| 171 | + echo ' |
|
| 168 | 172 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
| 169 | 173 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
| 174 | + } |
|
| 170 | 175 | |
| 171 | - if (!empty($context['drafts_save'])) |
|
| 172 | - echo ' |
|
| 176 | + if (!empty($context['drafts_save'])) { |
|
| 177 | + echo ' |
|
| 173 | 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"> |
| 174 | 179 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
| 180 | + } |
|
| 175 | 181 | |
| 176 | - if ($context['show_spellchecking']) |
|
| 177 | - echo ' |
|
| 182 | + if ($context['show_spellchecking']) { |
|
| 183 | + echo ' |
|
| 178 | 184 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
| 185 | + } |
|
| 179 | 186 | |
| 180 | - if ($editor_context['preview_type']) |
|
| 181 | - echo ' |
|
| 187 | + if ($editor_context['preview_type']) { |
|
| 188 | + echo ' |
|
| 182 | 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 | + } |
|
| 183 | 191 | |
| 184 | 192 | |
| 185 | 193 | echo ' |
| 186 | 194 | <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">'; |
| 187 | 195 | |
| 188 | 196 | // Load in the PM autosaver if it's enabled |
| 189 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
| 190 | - echo ' |
|
| 197 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
| 198 | + echo ' |
|
| 191 | 199 | <span class="righttext padding" style="display: block"> |
| 192 | 200 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"> </span> |
| 193 | 201 | <span id="draft_lastautosave" ></span> |
@@ -205,10 +213,11 @@ discard block |
||
| 205 | 213 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
| 206 | 214 | }); |
| 207 | 215 | </script>'; |
| 216 | + } |
|
| 208 | 217 | |
| 209 | 218 | // Start an instance of the auto saver if its enabled |
| 210 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
| 211 | - echo ' |
|
| 219 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
| 220 | + echo ' |
|
| 212 | 221 | <span class="righttext padding" style="display: block"> |
| 213 | 222 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"> </span> |
| 214 | 223 | <span id="draft_lastautosave" ></span> |
@@ -225,7 +234,8 @@ discard block |
||
| 225 | 234 | iFreq: ', $context['drafts_autosave_frequency'], ' |
| 226 | 235 | }); |
| 227 | 236 | </script>'; |
| 228 | -} |
|
| 237 | + } |
|
| 238 | + } |
|
| 229 | 239 | |
| 230 | 240 | /** |
| 231 | 241 | * This template displays a verification form |
@@ -242,51 +252,57 @@ discard block |
||
| 242 | 252 | $verify_context = &$context['controls']['verification'][$verify_id]; |
| 243 | 253 | |
| 244 | 254 | // Keep track of where we are. |
| 245 | - if (empty($verify_context['tracking']) || $reset) |
|
| 246 | - $verify_context['tracking'] = 0; |
|
| 255 | + if (empty($verify_context['tracking']) || $reset) { |
|
| 256 | + $verify_context['tracking'] = 0; |
|
| 257 | + } |
|
| 247 | 258 | |
| 248 | 259 | // How many items are there to display in total. |
| 249 | 260 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
| 250 | 261 | |
| 251 | 262 | // If we've gone too far, stop. |
| 252 | - if ($verify_context['tracking'] > $total_items) |
|
| 253 | - return false; |
|
| 263 | + if ($verify_context['tracking'] > $total_items) { |
|
| 264 | + return false; |
|
| 265 | + } |
|
| 254 | 266 | |
| 255 | 267 | // Loop through each item to show them. |
| 256 | 268 | for ($i = 0; $i < $total_items; $i++) |
| 257 | 269 | { |
| 258 | 270 | // If we're after a single item only show it if we're in the right place. |
| 259 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
| 260 | - continue; |
|
| 271 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
| 272 | + continue; |
|
| 273 | + } |
|
| 261 | 274 | |
| 262 | - if ($display_type != 'single') |
|
| 263 | - echo ' |
|
| 275 | + if ($display_type != 'single') { |
|
| 276 | + echo ' |
|
| 264 | 277 | <div id="verification_control_', $i, '" class="verification_control">'; |
| 278 | + } |
|
| 265 | 279 | |
| 266 | 280 | // Display empty field, but only if we have one, and it's the first time. |
| 267 | - if ($verify_context['empty_field'] && empty($i)) |
|
| 268 | - echo ' |
|
| 281 | + if ($verify_context['empty_field'] && empty($i)) { |
|
| 282 | + echo ' |
|
| 269 | 283 | <div class="smalltext vv_special"> |
| 270 | 284 | ', $txt['visual_verification_hidden'], ': |
| 271 | 285 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
| 272 | 286 | </div>'; |
| 287 | + } |
|
| 273 | 288 | |
| 274 | 289 | // Do the actual stuff |
| 275 | 290 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
| 276 | 291 | { |
| 277 | 292 | if ($verify_context['show_visual']) |
| 278 | 293 | { |
| 279 | - if ($context['use_graphic_library']) |
|
| 280 | - echo ' |
|
| 294 | + if ($context['use_graphic_library']) { |
|
| 295 | + echo ' |
|
| 281 | 296 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
| 282 | - else |
|
| 283 | - echo ' |
|
| 297 | + } else { |
|
| 298 | + echo ' |
|
| 284 | 299 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
| 285 | 300 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
| 286 | 301 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
| 287 | 302 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
| 288 | 303 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
| 289 | 304 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
| 305 | + } |
|
| 290 | 306 | |
| 291 | 307 | echo ' |
| 292 | 308 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -303,8 +319,7 @@ discard block |
||
| 303 | 319 | <br> |
| 304 | 320 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>'; |
| 305 | 321 | } |
| 306 | - } |
|
| 307 | - else |
|
| 322 | + } else |
|
| 308 | 323 | { |
| 309 | 324 | // Where in the question array is this question? |
| 310 | 325 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -316,21 +331,24 @@ discard block |
||
| 316 | 331 | </div>'; |
| 317 | 332 | } |
| 318 | 333 | |
| 319 | - if ($display_type != 'single') |
|
| 320 | - echo ' |
|
| 334 | + if ($display_type != 'single') { |
|
| 335 | + echo ' |
|
| 321 | 336 | </div><!-- #verification_control_[i] -->'; |
| 337 | + } |
|
| 322 | 338 | |
| 323 | 339 | // If we were displaying just one and we did it, break. |
| 324 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
| 325 | - break; |
|
| 340 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
| 341 | + break; |
|
| 342 | + } |
|
| 326 | 343 | } |
| 327 | 344 | |
| 328 | 345 | // Assume we found something, always, |
| 329 | 346 | $verify_context['tracking']++; |
| 330 | 347 | |
| 331 | 348 | // Tell something displaying piecemeal to keep going. |
| 332 | - if ($display_type == 'single') |
|
| 333 | - return true; |
|
| 334 | -} |
|
| 349 | + if ($display_type == 'single') { |
|
| 350 | + return true; |
|
| 351 | + } |
|
| 352 | + } |
|
| 335 | 353 | |
| 336 | 354 | ?> |
| 337 | 355 | \ 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,12 +31,13 @@ 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> |
@@ -65,9 +66,10 @@ discard block |
||
| 65 | 66 | <span class="floatright">', $txt['package_available_readme_language'], ' |
| 66 | 67 | <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\'));">'; |
| 67 | 68 | |
| 68 | - foreach ($context['readmes'] as $a => $b) |
|
| 69 | - echo ' |
|
| 69 | + foreach ($context['readmes'] as $a => $b) { |
|
| 70 | + echo ' |
|
| 70 | 71 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
| 72 | + } |
|
| 71 | 73 | |
| 72 | 74 | echo ' |
| 73 | 75 | </select> |
@@ -88,9 +90,10 @@ discard block |
||
| 88 | 90 | <span class="floatright">', $txt['package_available_license_language'], ' |
| 89 | 91 | <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\'));">'; |
| 90 | 92 | |
| 91 | - foreach ($context['licenses'] as $a => $b) |
|
| 92 | - echo ' |
|
| 93 | + foreach ($context['licenses'] as $a => $b) { |
|
| 94 | + echo ' |
|
| 93 | 95 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
| 96 | + } |
|
| 94 | 97 | echo ' |
| 95 | 98 | </select> |
| 96 | 99 | </span> |
@@ -117,9 +120,10 @@ discard block |
||
| 117 | 120 | ', $txt['package_db_uninstall_actions'], ': |
| 118 | 121 | <ul>'; |
| 119 | 122 | |
| 120 | - foreach ($context['database_changes'] as $change) |
|
| 121 | - echo ' |
|
| 123 | + foreach ($context['database_changes'] as $change) { |
|
| 124 | + echo ' |
|
| 122 | 125 | <li>', $change, '</li>'; |
| 126 | + } |
|
| 123 | 127 | echo ' |
| 124 | 128 | </ul> |
| 125 | 129 | </div> |
@@ -129,14 +133,14 @@ discard block |
||
| 129 | 133 | echo ' |
| 130 | 134 | <div class="information">'; |
| 131 | 135 | |
| 132 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
| 133 | - echo ' |
|
| 136 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
| 137 | + echo ' |
|
| 134 | 138 | <br> |
| 135 | 139 | <div class="errorbox"> |
| 136 | 140 | ', $txt['corrupt_compatible'], ' |
| 137 | 141 | </div> |
| 138 | 142 | </div><!-- .information -->'; |
| 139 | - else |
|
| 143 | + } else |
|
| 140 | 144 | { |
| 141 | 145 | echo ' |
| 142 | 146 | ', $txt['perform_actions'], ' |
@@ -241,9 +245,10 @@ discard block |
||
| 241 | 245 | <td></td> |
| 242 | 246 | <td>'; |
| 243 | 247 | |
| 244 | - if (!empty($context['themes_locked'])) |
|
| 245 | - echo ' |
|
| 248 | + if (!empty($context['themes_locked'])) { |
|
| 249 | + echo ' |
|
| 246 | 250 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
| 251 | + } |
|
| 247 | 252 | echo ' |
| 248 | 253 | <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' : '', '> |
| 249 | 254 | </td> |
@@ -385,14 +390,15 @@ discard block |
||
| 385 | 390 | </script>'; |
| 386 | 391 | |
| 387 | 392 | // And a bit more for database changes. |
| 388 | - if (!empty($context['database_changes'])) |
|
| 389 | - echo ' |
|
| 393 | + if (!empty($context['database_changes'])) { |
|
| 394 | + echo ' |
|
| 390 | 395 | <script> |
| 391 | 396 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
| 392 | 397 | var db_vis = false; |
| 393 | 398 | database_changes_area.style.display = "none"; |
| 394 | 399 | </script>'; |
| 395 | -} |
|
| 400 | + } |
|
| 401 | + } |
|
| 396 | 402 | |
| 397 | 403 | /** |
| 398 | 404 | * Extract package contents |
@@ -424,12 +430,12 @@ discard block |
||
| 424 | 430 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
| 425 | 431 | </div> |
| 426 | 432 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
| 427 | - } |
|
| 428 | - else |
|
| 429 | - echo ' |
|
| 433 | + } else { |
|
| 434 | + echo ' |
|
| 430 | 435 | <div class="cat_bar"> |
| 431 | 436 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
| 432 | 437 | </div>'; |
| 438 | + } |
|
| 433 | 439 | |
| 434 | 440 | echo ' |
| 435 | 441 | <div class="windowbg">'; |
@@ -440,28 +446,25 @@ discard block |
||
| 440 | 446 | echo ' |
| 441 | 447 | ', $context['redirect_text'], '<br><br> |
| 442 | 448 | <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>'; |
| 443 | - } |
|
| 444 | - elseif ($context['uninstalling']) |
|
| 445 | - echo ' |
|
| 449 | + } elseif ($context['uninstalling']) { |
|
| 450 | + echo ' |
|
| 446 | 451 | ', $txt['package_uninstall_done']; |
| 447 | - |
|
| 448 | - elseif ($context['install_finished']) |
|
| 452 | + } elseif ($context['install_finished']) |
|
| 449 | 453 | { |
| 450 | - if ($context['extract_type'] == 'avatar') |
|
| 451 | - echo ' |
|
| 454 | + if ($context['extract_type'] == 'avatar') { |
|
| 455 | + echo ' |
|
| 452 | 456 | ', $txt['avatars_extracted']; |
| 453 | - |
|
| 454 | - elseif ($context['extract_type'] == 'language') |
|
| 455 | - echo ' |
|
| 457 | + } elseif ($context['extract_type'] == 'language') { |
|
| 458 | + echo ' |
|
| 456 | 459 | ', $txt['language_extracted']; |
| 457 | - |
|
| 458 | - else |
|
| 459 | - echo ' |
|
| 460 | + } else { |
|
| 461 | + echo ' |
|
| 460 | 462 | ', $txt['package_installed_done']; |
| 461 | - } |
|
| 462 | - else |
|
| 463 | - echo ' |
|
| 463 | + } |
|
| 464 | + } else { |
|
| 465 | + echo ' |
|
| 464 | 466 | ', $txt['corrupt_compatible']; |
| 467 | + } |
|
| 465 | 468 | |
| 466 | 469 | echo ' |
| 467 | 470 | </div><!-- .windowbg -->'; |
@@ -495,9 +498,10 @@ discard block |
||
| 495 | 498 | <div class="windowbg"> |
| 496 | 499 | <ol>'; |
| 497 | 500 | |
| 498 | - foreach ($context['files'] as $fileinfo) |
|
| 499 | - echo ' |
|
| 501 | + foreach ($context['files'] as $fileinfo) { |
|
| 502 | + echo ' |
|
| 500 | 503 | <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>'; |
| 504 | + } |
|
| 501 | 505 | |
| 502 | 506 | echo ' |
| 503 | 507 | </ol> |
@@ -561,9 +565,10 @@ discard block |
||
| 561 | 565 | </script> |
| 562 | 566 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
| 563 | 567 | |
| 564 | - if (empty($modSettings['disable_smf_js'])) |
|
| 565 | - echo ' |
|
| 568 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 569 | + echo ' |
|
| 566 | 570 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 571 | + } |
|
| 567 | 572 | |
| 568 | 573 | // This sets the announcements and current versions themselves ;). |
| 569 | 574 | echo ' |
@@ -602,12 +607,13 @@ discard block |
||
| 602 | 607 | } |
| 603 | 608 | } |
| 604 | 609 | |
| 605 | - if (!$mods_available) |
|
| 606 | - echo ' |
|
| 610 | + if (!$mods_available) { |
|
| 611 | + echo ' |
|
| 607 | 612 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
| 608 | - else |
|
| 609 | - echo ' |
|
| 613 | + } else { |
|
| 614 | + echo ' |
|
| 610 | 615 | <br>'; |
| 616 | + } |
|
| 611 | 617 | |
| 612 | 618 | // the advanced (emulation) box, collapsed by default |
| 613 | 619 | echo ' |
@@ -694,11 +700,12 @@ discard block |
||
| 694 | 700 | { |
| 695 | 701 | global $context, $txt, $scripturl; |
| 696 | 702 | |
| 697 | - if (!empty($context['package_ftp']['error'])) |
|
| 698 | - echo ' |
|
| 703 | + if (!empty($context['package_ftp']['error'])) { |
|
| 704 | + echo ' |
|
| 699 | 705 | <div class="errorbox"> |
| 700 | 706 | <pre>', $context['package_ftp']['error'], '</pre> |
| 701 | 707 | </div>'; |
| 708 | + } |
|
| 702 | 709 | |
| 703 | 710 | echo ' |
| 704 | 711 | <div id="admin_form_wrapper"> |
@@ -780,13 +787,14 @@ discard block |
||
| 780 | 787 | <legend>' . $txt['package_servers'] . '</legend> |
| 781 | 788 | <ul class="package_servers">'; |
| 782 | 789 | |
| 783 | - foreach ($context['servers'] as $server) |
|
| 784 | - echo ' |
|
| 790 | + foreach ($context['servers'] as $server) { |
|
| 791 | + echo ' |
|
| 785 | 792 | <li class="flow_auto"> |
| 786 | 793 | <span class="floatleft">' . $server['name'] . '</span> |
| 787 | 794 | <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> |
| 788 | 795 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
| 789 | 796 | </li>'; |
| 797 | + } |
|
| 790 | 798 | echo ' |
| 791 | 799 | </ul> |
| 792 | 800 | </fieldset> |
@@ -873,11 +881,12 @@ discard block |
||
| 873 | 881 | <div class="windowbg2">'; |
| 874 | 882 | |
| 875 | 883 | // No packages, as yet. |
| 876 | - if (empty($context['package_list'])) |
|
| 877 | - echo ' |
|
| 884 | + if (empty($context['package_list'])) { |
|
| 885 | + echo ' |
|
| 878 | 886 | <ul> |
| 879 | 887 | <li>', $txt['no_packages'], '</li> |
| 880 | 888 | </ul>'; |
| 889 | + } |
|
| 881 | 890 | |
| 882 | 891 | // List out the packages... |
| 883 | 892 | else |
@@ -890,11 +899,12 @@ discard block |
||
| 890 | 899 | <li> |
| 891 | 900 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
| 892 | 901 | |
| 893 | - if (!empty($packageSection['text'])) |
|
| 894 | - echo ' |
|
| 902 | + if (!empty($packageSection['text'])) { |
|
| 903 | + echo ' |
|
| 895 | 904 | <div class="sub_bar"> |
| 896 | 905 | <h3 class="subbg">', $packageSection['text'], '</h3> |
| 897 | 906 | </div>'; |
| 907 | + } |
|
| 898 | 908 | |
| 899 | 909 | echo ' |
| 900 | 910 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -904,13 +914,15 @@ discard block |
||
| 904 | 914 | echo ' |
| 905 | 915 | <li>'; |
| 906 | 916 | // Textual message. Could be empty just for a blank line... |
| 907 | - if ($package['is_text']) |
|
| 908 | - echo ' |
|
| 917 | + if ($package['is_text']) { |
|
| 918 | + echo ' |
|
| 909 | 919 | ', empty($package['name']) ? ' ' : $package['name']; |
| 920 | + } |
|
| 910 | 921 | // This is supposed to be a rule.. |
| 911 | - elseif ($package['is_line']) |
|
| 912 | - echo ' |
|
| 922 | + elseif ($package['is_line']) { |
|
| 923 | + echo ' |
|
| 913 | 924 | <hr>'; |
| 925 | + } |
|
| 914 | 926 | // A remote link. |
| 915 | 927 | elseif ($package['is_remote']) |
| 916 | 928 | { |
@@ -932,24 +944,28 @@ discard block |
||
| 932 | 944 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
| 933 | 945 | |
| 934 | 946 | // Show the mod type? |
| 935 | - if ($package['type'] != '') |
|
| 936 | - echo ' |
|
| 947 | + if ($package['type'] != '') { |
|
| 948 | + echo ' |
|
| 937 | 949 | <li class="package_section">', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>'; |
| 950 | + } |
|
| 938 | 951 | |
| 939 | 952 | // Show the version number? |
| 940 | - if ($package['version'] != '') |
|
| 941 | - echo ' |
|
| 953 | + if ($package['version'] != '') { |
|
| 954 | + echo ' |
|
| 942 | 955 | <li class="package_section">', $txt['mod_version'], ': ', $package['version'], '</li>'; |
| 956 | + } |
|
| 943 | 957 | |
| 944 | 958 | // How 'bout the author? |
| 945 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
| 946 | - echo ' |
|
| 959 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
| 960 | + echo ' |
|
| 947 | 961 | <li class="package_section">', $txt['mod_author'], ': ', $package['author']['link'], '</li>'; |
| 962 | + } |
|
| 948 | 963 | |
| 949 | 964 | // The homepage.... |
| 950 | - if ($package['author']['website']['link'] != '') |
|
| 951 | - echo ' |
|
| 965 | + if ($package['author']['website']['link'] != '') { |
|
| 966 | + echo ' |
|
| 952 | 967 | <li class="package_section">', $txt['author_website'], ': ', $package['author']['website']['link'], '</li>'; |
| 968 | + } |
|
| 953 | 969 | |
| 954 | 970 | // Description: bleh bleh! |
| 955 | 971 | // Location of file: http://someplace/. |
@@ -1003,8 +1019,8 @@ discard block |
||
| 1003 | 1019 | |
| 1004 | 1020 | foreach ($ps['items'] as $id => $package) |
| 1005 | 1021 | { |
| 1006 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
| 1007 | - echo ' |
|
| 1022 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
| 1023 | + echo ' |
|
| 1008 | 1024 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
| 1009 | 1025 | bToggleEnabled: true, |
| 1010 | 1026 | bCurrentlyCollapsed: true, |
@@ -1019,6 +1035,7 @@ discard block |
||
| 1019 | 1035 | } |
| 1020 | 1036 | ] |
| 1021 | 1037 | });'; |
| 1038 | + } |
|
| 1022 | 1039 | } |
| 1023 | 1040 | } |
| 1024 | 1041 | |
@@ -1064,9 +1081,10 @@ discard block |
||
| 1064 | 1081 | { |
| 1065 | 1082 | global $context, $txt, $scripturl; |
| 1066 | 1083 | |
| 1067 | - if (!empty($context['saved_successful'])) |
|
| 1068 | - echo ' |
|
| 1084 | + if (!empty($context['saved_successful'])) { |
|
| 1085 | + echo ' |
|
| 1069 | 1086 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1087 | + } |
|
| 1070 | 1088 | |
| 1071 | 1089 | echo ' |
| 1072 | 1090 | <div id="admincenter"> |
@@ -1128,8 +1146,9 @@ discard block |
||
| 1128 | 1146 | global $context, $txt; |
| 1129 | 1147 | |
| 1130 | 1148 | // Nothing to do? Brilliant! |
| 1131 | - if (empty($context['package_ftp'])) |
|
| 1132 | - return false; |
|
| 1149 | + if (empty($context['package_ftp'])) { |
|
| 1150 | + return false; |
|
| 1151 | + } |
|
| 1133 | 1152 | |
| 1134 | 1153 | if (empty($context['package_ftp']['form_elements_only'])) |
| 1135 | 1154 | { |
@@ -1139,19 +1158,21 @@ discard block |
||
| 1139 | 1158 | ', $txt['package_ftp_why_file_list'], ' |
| 1140 | 1159 | <ul style="display: inline;">'; |
| 1141 | 1160 | |
| 1142 | - if (!empty($context['notwritable_files'])) |
|
| 1143 | - foreach ($context['notwritable_files'] as $file) |
|
| 1161 | + if (!empty($context['notwritable_files'])) { |
|
| 1162 | + foreach ($context['notwritable_files'] as $file) |
|
| 1144 | 1163 | echo ' |
| 1145 | 1164 | <li>', $file, '</li>'; |
| 1165 | + } |
|
| 1146 | 1166 | |
| 1147 | 1167 | echo ' |
| 1148 | 1168 | </ul>'; |
| 1149 | 1169 | |
| 1150 | - if (!$context['server']['is_windows']) |
|
| 1151 | - echo ' |
|
| 1170 | + if (!$context['server']['is_windows']) { |
|
| 1171 | + echo ' |
|
| 1152 | 1172 | <hr> |
| 1153 | 1173 | ', $txt['package_chmod_linux'], '<br> |
| 1154 | 1174 | <tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>'; |
| 1175 | + } |
|
| 1155 | 1176 | |
| 1156 | 1177 | echo ' |
| 1157 | 1178 | </div><!-- #need_writable_list -->'; |
@@ -1164,9 +1185,10 @@ discard block |
||
| 1164 | 1185 | </div> |
| 1165 | 1186 | </div>'; |
| 1166 | 1187 | |
| 1167 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1168 | - echo ' |
|
| 1188 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1189 | + echo ' |
|
| 1169 | 1190 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">'; |
| 1191 | + } |
|
| 1170 | 1192 | |
| 1171 | 1193 | echo ' |
| 1172 | 1194 | <fieldset> |
@@ -1199,24 +1221,27 @@ discard block |
||
| 1199 | 1221 | </dl> |
| 1200 | 1222 | </fieldset>'; |
| 1201 | 1223 | |
| 1202 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1203 | - echo ' |
|
| 1224 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1225 | + echo ' |
|
| 1204 | 1226 | <div class="righttext" style="margin: 1ex;"> |
| 1205 | 1227 | <span id="test_ftp_placeholder_full"></span> |
| 1206 | 1228 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
| 1207 | 1229 | </div>'; |
| 1230 | + } |
|
| 1208 | 1231 | |
| 1209 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1210 | - echo ' |
|
| 1232 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1233 | + echo ' |
|
| 1211 | 1234 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1212 | 1235 | </form>'; |
| 1236 | + } |
|
| 1213 | 1237 | |
| 1214 | 1238 | // Hide the details of the list. |
| 1215 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1216 | - echo ' |
|
| 1239 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1240 | + echo ' |
|
| 1217 | 1241 | <script> |
| 1218 | 1242 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
| 1219 | 1243 | </script>'; |
| 1244 | + } |
|
| 1220 | 1245 | |
| 1221 | 1246 | // Quick generate the test button. |
| 1222 | 1247 | echo ' |
@@ -1572,9 +1597,10 @@ discard block |
||
| 1572 | 1597 | <tr class="windowbg"> |
| 1573 | 1598 | <td width="30%"><strong>'; |
| 1574 | 1599 | |
| 1575 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1576 | - echo ' |
|
| 1600 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1601 | + echo ' |
|
| 1577 | 1602 | <span class="generic_icons folder"></span>'; |
| 1603 | + } |
|
| 1578 | 1604 | |
| 1579 | 1605 | echo ' |
| 1580 | 1606 | ', $name, ' |
@@ -1590,8 +1616,9 @@ discard block |
||
| 1590 | 1616 | <td class="centertext perm_no_change"><input type="radio" name="permStatus[', $name, ']" value="no_change" checked class="centertext"></td> |
| 1591 | 1617 | </tr>'; |
| 1592 | 1618 | |
| 1593 | - if (!empty($dir['contents'])) |
|
| 1594 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1619 | + if (!empty($dir['contents'])) { |
|
| 1620 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1621 | + } |
|
| 1595 | 1622 | } |
| 1596 | 1623 | |
| 1597 | 1624 | echo ' |
@@ -1627,13 +1654,14 @@ discard block |
||
| 1627 | 1654 | </fieldset>'; |
| 1628 | 1655 | |
| 1629 | 1656 | // Likely to need FTP? |
| 1630 | - if (empty($context['ftp_connected'])) |
|
| 1631 | - echo ' |
|
| 1657 | + if (empty($context['ftp_connected'])) { |
|
| 1658 | + echo ' |
|
| 1632 | 1659 | <p> |
| 1633 | 1660 | ', $txt['package_file_perms_ftp_details'], ': |
| 1634 | 1661 | </p> |
| 1635 | 1662 | ', template_control_chmod(), ' |
| 1636 | 1663 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
| 1664 | + } |
|
| 1637 | 1665 | |
| 1638 | 1666 | echo ' |
| 1639 | 1667 | <span id="test_ftp_placeholder_full"></span> |
@@ -1642,9 +1670,10 @@ discard block |
||
| 1642 | 1670 | </div><!-- .windowbg2 -->'; |
| 1643 | 1671 | |
| 1644 | 1672 | // Any looks fors we've already done? |
| 1645 | - foreach ($context['look_for'] as $path) |
|
| 1646 | - echo ' |
|
| 1673 | + foreach ($context['look_for'] as $path) { |
|
| 1674 | + echo ' |
|
| 1647 | 1675 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1676 | + } |
|
| 1648 | 1677 | |
| 1649 | 1678 | echo ' |
| 1650 | 1679 | </form> |
@@ -1686,9 +1715,10 @@ discard block |
||
| 1686 | 1715 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
| 1687 | 1716 | ', (!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, "'\\") . '\');">' : ''; |
| 1688 | 1717 | |
| 1689 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1690 | - echo ' |
|
| 1718 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1719 | + echo ' |
|
| 1691 | 1720 | <span class="generic_icons folder"></span>'; |
| 1721 | + } |
|
| 1692 | 1722 | |
| 1693 | 1723 | echo ' |
| 1694 | 1724 | ', $name, ' |
@@ -1714,14 +1744,15 @@ discard block |
||
| 1714 | 1744 | } |
| 1715 | 1745 | |
| 1716 | 1746 | // We have more files to show? |
| 1717 | - if ($has_more) |
|
| 1718 | - echo ' |
|
| 1747 | + if ($has_more) { |
|
| 1748 | + echo ' |
|
| 1719 | 1749 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
| 1720 | 1750 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
| 1721 | 1751 | « <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> » |
| 1722 | 1752 | </td> |
| 1723 | 1753 | <td colspan="6"></td> |
| 1724 | 1754 | </tr>'; |
| 1755 | + } |
|
| 1725 | 1756 | |
| 1726 | 1757 | if ($drawn_div) |
| 1727 | 1758 | { |
@@ -1729,15 +1760,17 @@ discard block |
||
| 1729 | 1760 | $isFound = false; |
| 1730 | 1761 | foreach ($context['look_for'] as $tree) |
| 1731 | 1762 | { |
| 1732 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
| 1733 | - $isFound = true; |
|
| 1763 | + if (substr($tree, 0, strlen($ident)) == $ident) { |
|
| 1764 | + $isFound = true; |
|
| 1765 | + } |
|
| 1734 | 1766 | } |
| 1735 | 1767 | |
| 1736 | - if ($level > 1 && !$isFound) |
|
| 1737 | - echo ' |
|
| 1768 | + if ($level > 1 && !$isFound) { |
|
| 1769 | + echo ' |
|
| 1738 | 1770 | <script> |
| 1739 | 1771 | expandFolder(\'', $js_ident, '\', \'\'); |
| 1740 | 1772 | </script>'; |
| 1773 | + } |
|
| 1741 | 1774 | } |
| 1742 | 1775 | } |
| 1743 | 1776 | |
@@ -1757,11 +1790,12 @@ discard block |
||
| 1757 | 1790 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
| 1758 | 1791 | </div>'; |
| 1759 | 1792 | |
| 1760 | - if (!empty($context['skip_ftp'])) |
|
| 1761 | - echo ' |
|
| 1793 | + if (!empty($context['skip_ftp'])) { |
|
| 1794 | + echo ' |
|
| 1762 | 1795 | <div class="errorbox"> |
| 1763 | 1796 | ', $txt['package_file_perms_skipping_ftp'], ' |
| 1764 | 1797 | </div>'; |
| 1798 | + } |
|
| 1765 | 1799 | |
| 1766 | 1800 | // How many have we done? |
| 1767 | 1801 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1800,28 +1834,31 @@ discard block |
||
| 1800 | 1834 | <br>'; |
| 1801 | 1835 | |
| 1802 | 1836 | // Put out the right hidden data. |
| 1803 | - if ($context['method'] == 'individual') |
|
| 1804 | - echo ' |
|
| 1837 | + if ($context['method'] == 'individual') { |
|
| 1838 | + echo ' |
|
| 1805 | 1839 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
| 1806 | 1840 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1807 | 1841 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
| 1808 | - else |
|
| 1809 | - echo ' |
|
| 1842 | + } else { |
|
| 1843 | + echo ' |
|
| 1810 | 1844 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
| 1811 | 1845 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
| 1812 | 1846 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1813 | 1847 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
| 1814 | 1848 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
| 1849 | + } |
|
| 1815 | 1850 | |
| 1816 | 1851 | // Are we not using FTP for whatever reason. |
| 1817 | - if (!empty($context['skip_ftp'])) |
|
| 1818 | - echo ' |
|
| 1852 | + if (!empty($context['skip_ftp'])) { |
|
| 1853 | + echo ' |
|
| 1819 | 1854 | <input type="hidden" name="skip_ftp" value="1">'; |
| 1855 | + } |
|
| 1820 | 1856 | |
| 1821 | 1857 | // Retain state. |
| 1822 | - foreach ($context['back_look_data'] as $path) |
|
| 1823 | - echo ' |
|
| 1858 | + foreach ($context['back_look_data'] as $path) { |
|
| 1859 | + echo ' |
|
| 1824 | 1860 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1861 | + } |
|
| 1825 | 1862 | |
| 1826 | 1863 | echo ' |
| 1827 | 1864 | <input type="hidden" name="method" value="', $context['method'], '"> |