@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $board_info, $smcFunc, $modSettings; |
| 33 | 34 | |
| 34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
| 35 | - if (empty($topic)) |
|
| 36 | - redirectexit(); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + redirectexit(); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
| 39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | ) |
| 60 | 62 | ); |
| 61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
| 62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 63 | - redirectexit(); |
|
| 64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 65 | + redirectexit(); |
|
| 66 | + } |
|
| 64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
| 65 | 68 | $smcFunc['db_free_result']($request); |
| 66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
| 134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
| 135 | 138 | { |
| 136 | 139 | $guestvoted = explode(',', $guestvoted); |
| 137 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 138 | - break; |
|
| 140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 139 | 143 | } |
| 140 | 144 | // Has the poll been reset since guest voted? |
| 141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 142 | 146 | { |
| 143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
| 144 | 148 | unset($guestinfo[$i]); |
| 145 | - if (!empty($guestinfo)) |
|
| 146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 147 | - else |
|
| 148 | - unset($_COOKIE['guest_poll_vote']); |
|
| 149 | - } |
|
| 150 | - else |
|
| 149 | + if (!empty($guestinfo)) { |
|
| 150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 151 | + } else { |
|
| 152 | + unset($_COOKIE['guest_poll_vote']); |
|
| 153 | + } |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | // What did they vote for? |
| 153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
| 233 | 237 | $context['poster_name'] = $row['poster_name']; |
| 234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
| 235 | 239 | $context['parent_boards'] = array(); |
| 236 | - foreach ($board_info['parent_boards'] as $parent) |
|
| 237 | - $context['parent_boards'][] = $parent['name']; |
|
| 240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
| 241 | + $context['parent_boards'][] = $parent['name']; |
|
| 242 | + } |
|
| 238 | 243 | |
| 239 | 244 | // Split the topics up so we can print them. |
| 240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
| 266 | 271 | 'id_msg' => $row['id_msg'], |
| 267 | 272 | ); |
| 268 | 273 | |
| 269 | - if (!isset($context['topic_subject'])) |
|
| 270 | - $context['topic_subject'] = $row['subject']; |
|
| 274 | + if (!isset($context['topic_subject'])) { |
|
| 275 | + $context['topic_subject'] = $row['subject']; |
|
| 276 | + } |
|
| 271 | 277 | } |
| 272 | 278 | $smcFunc['db_free_result']($request); |
| 273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
| 275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
| 276 | 282 | { |
| 277 | 283 | $messages = array(); |
| 278 | - foreach ($context['posts'] as $temp) |
|
| 279 | - $messages[] = $temp['id_msg']; |
|
| 284 | + foreach ($context['posts'] as $temp) { |
|
| 285 | + $messages[] = $temp['id_msg']; |
|
| 286 | + } |
|
| 280 | 287 | |
| 281 | 288 | // build the request |
| 282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 296 | 303 | { |
| 297 | 304 | $temp[$row['id_attach']] = $row; |
| 298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
| 299 | - $context['printattach'][$row['id_msg']] = array(); |
|
| 305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
| 306 | + $context['printattach'][$row['id_msg']] = array(); |
|
| 307 | + } |
|
| 300 | 308 | } |
| 301 | 309 | $smcFunc['db_free_result']($request); |
| 302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
| 313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
| 314 | 322 | $row['width'] = $modSettings['max_image_width']; |
| 315 | 323 | } |
| 316 | - } |
|
| 317 | - elseif (!empty($modSettings['max_image_width'])) |
|
| 324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
| 318 | 325 | { |
| 319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
| 320 | 327 | { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_engine'](); |
@@ -74,24 +74,31 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | - if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') |
|
| 78 | - get_memcached_server(); |
|
| 77 | + if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { |
|
| 78 | + get_memcached_server(); |
|
| 79 | + } |
|
| 79 | 80 | |
| 80 | 81 | // Check to see if we have any accelerators installed... |
| 81 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 82 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 83 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 84 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 85 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 86 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
| 87 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 88 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 82 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 83 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | + } |
|
| 85 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 86 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 87 | + } |
|
| 88 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 89 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
| 90 | + } |
|
| 91 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 92 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | - if (in_array('php', $checkFor)) |
|
| 91 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 95 | + if (in_array('php', $checkFor)) { |
|
| 96 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | - if (in_array('server', $checkFor)) |
|
| 94 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 99 | + if (in_array('server', $checkFor)) { |
|
| 100 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | return $versions; |
| 97 | 104 | } |
@@ -131,11 +138,13 @@ discard block |
||
| 131 | 138 | fclose($fp); |
| 132 | 139 | |
| 133 | 140 | // The comment looks rougly like... that. |
| 134 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 135 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 141 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 142 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 143 | + } |
|
| 136 | 144 | // Not found! This is bad. |
| 137 | - else |
|
| 138 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 145 | + else { |
|
| 146 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 147 | + } |
|
| 139 | 148 | } |
| 140 | 149 | |
| 141 | 150 | // Do the paid subscriptions handler? |
@@ -146,11 +155,13 @@ discard block |
||
| 146 | 155 | fclose($fp); |
| 147 | 156 | |
| 148 | 157 | // Found it? |
| 149 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 150 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 158 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 159 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 160 | + } |
|
| 151 | 161 | // If we haven't how do we all get paid? |
| 152 | - else |
|
| 153 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 162 | + else { |
|
| 163 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 164 | + } |
|
| 154 | 165 | } |
| 155 | 166 | |
| 156 | 167 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -165,11 +176,13 @@ discard block |
||
| 165 | 176 | fclose($fp); |
| 166 | 177 | |
| 167 | 178 | // Look for the version comment in the file header. |
| 168 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 169 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 179 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 180 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 181 | + } |
|
| 170 | 182 | // It wasn't found, but the file was... show a '??'. |
| 171 | - else |
|
| 172 | - $version_info['file_versions'][$entry] = '??'; |
|
| 183 | + else { |
|
| 184 | + $version_info['file_versions'][$entry] = '??'; |
|
| 185 | + } |
|
| 173 | 186 | } |
| 174 | 187 | } |
| 175 | 188 | $sources_dir->close(); |
@@ -188,11 +201,13 @@ discard block |
||
| 188 | 201 | fclose($fp); |
| 189 | 202 | |
| 190 | 203 | // Look for the version comment in the file header. |
| 191 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 192 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 204 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 205 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 206 | + } |
|
| 193 | 207 | // It wasn't found, but the file was... show a '??'. |
| 194 | - else |
|
| 195 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 208 | + else { |
|
| 209 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 210 | + } |
|
| 196 | 211 | } |
| 197 | 212 | } |
| 198 | 213 | $tasks_dir->close(); |
@@ -200,8 +215,9 @@ discard block |
||
| 200 | 215 | |
| 201 | 216 | // Load all the files in the default template directory - and the current theme if applicable. |
| 202 | 217 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 203 | - if ($settings['theme_id'] != 1) |
|
| 204 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 218 | + if ($settings['theme_id'] != 1) { |
|
| 219 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 220 | + } |
|
| 205 | 221 | |
| 206 | 222 | foreach ($directories as $type => $dirname) |
| 207 | 223 | { |
@@ -216,11 +232,13 @@ discard block |
||
| 216 | 232 | fclose($fp); |
| 217 | 233 | |
| 218 | 234 | // Look for the version comment in the file header. |
| 219 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 220 | - $version_info[$type][$entry] = $match[1]; |
|
| 235 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 236 | + $version_info[$type][$entry] = $match[1]; |
|
| 237 | + } |
|
| 221 | 238 | // It wasn't found, but the file was... show a '??'. |
| 222 | - else |
|
| 223 | - $version_info[$type][$entry] = '??'; |
|
| 239 | + else { |
|
| 240 | + $version_info[$type][$entry] = '??'; |
|
| 241 | + } |
|
| 224 | 242 | } |
| 225 | 243 | } |
| 226 | 244 | $this_dir->close(); |
@@ -241,11 +259,13 @@ discard block |
||
| 241 | 259 | list ($name, $language) = explode('.', $entry); |
| 242 | 260 | |
| 243 | 261 | // Look for the version comment in the file header. |
| 244 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 245 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 262 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 263 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 264 | + } |
|
| 246 | 265 | // It wasn't found, but the file was... show a '??'. |
| 247 | - else |
|
| 248 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 266 | + else { |
|
| 267 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 268 | + } |
|
| 249 | 269 | } |
| 250 | 270 | } |
| 251 | 271 | $this_dir->close(); |
@@ -260,8 +280,9 @@ discard block |
||
| 260 | 280 | ksort($version_info['tasks_versions']); |
| 261 | 281 | |
| 262 | 282 | // For languages sort each language too. |
| 263 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 264 | - ksort($version_info['default_language_versions'][$language]); |
|
| 283 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 284 | + ksort($version_info['default_language_versions'][$language]); |
|
| 285 | + } |
|
| 265 | 286 | } |
| 266 | 287 | return $version_info; |
| 267 | 288 | } |
@@ -303,27 +324,31 @@ discard block |
||
| 303 | 324 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 304 | 325 | |
| 305 | 326 | // Break it up based on \r or \n, and then clean out extra characters. |
| 306 | - if (strpos($settingsArray, "\n") !== false) |
|
| 307 | - $settingsArray = explode("\n", $settingsArray); |
|
| 308 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 309 | - $settingsArray = explode("\r", $settingsArray); |
|
| 310 | - else |
|
| 311 | - return; |
|
| 327 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 328 | + $settingsArray = explode("\n", $settingsArray); |
|
| 329 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 330 | + $settingsArray = explode("\r", $settingsArray); |
|
| 331 | + } else { |
|
| 332 | + return; |
|
| 333 | + } |
|
| 312 | 334 | |
| 313 | 335 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 314 | - if (count($settingsArray) < 10) |
|
| 315 | - return; |
|
| 336 | + if (count($settingsArray) < 10) { |
|
| 337 | + return; |
|
| 338 | + } |
|
| 316 | 339 | |
| 317 | 340 | // remove any /r's that made there way in here |
| 318 | - foreach ($settingsArray as $k => $dummy) |
|
| 319 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 341 | + foreach ($settingsArray as $k => $dummy) { |
|
| 342 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 343 | + } |
|
| 320 | 344 | |
| 321 | 345 | // go line by line and see whats changing |
| 322 | 346 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 323 | 347 | { |
| 324 | 348 | // Don't trim or bother with it if it's not a variable. |
| 325 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 326 | - continue; |
|
| 349 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 350 | + continue; |
|
| 351 | + } |
|
| 327 | 352 | |
| 328 | 353 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 329 | 354 | |
@@ -335,8 +360,7 @@ discard block |
||
| 335 | 360 | { |
| 336 | 361 | updateDbLastError($val); |
| 337 | 362 | unset($config_vars[$var]); |
| 338 | - } |
|
| 339 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 363 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 340 | 364 | { |
| 341 | 365 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 342 | 366 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -347,34 +371,39 @@ discard block |
||
| 347 | 371 | } |
| 348 | 372 | |
| 349 | 373 | // End of the file ... maybe |
| 350 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 351 | - $end = $i; |
|
| 374 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 375 | + $end = $i; |
|
| 376 | + } |
|
| 352 | 377 | } |
| 353 | 378 | |
| 354 | 379 | // This should never happen, but apparently it is happening. |
| 355 | - if (empty($end) || $end < 10) |
|
| 356 | - $end = count($settingsArray) - 1; |
|
| 380 | + if (empty($end) || $end < 10) { |
|
| 381 | + $end = count($settingsArray) - 1; |
|
| 382 | + } |
|
| 357 | 383 | |
| 358 | 384 | // Still more variables to go? Then lets add them at the end. |
| 359 | 385 | if (!empty($config_vars)) |
| 360 | 386 | { |
| 361 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 362 | - $settingsArray[$end++] = ''; |
|
| 363 | - else |
|
| 364 | - $end++; |
|
| 387 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 388 | + $settingsArray[$end++] = ''; |
|
| 389 | + } else { |
|
| 390 | + $end++; |
|
| 391 | + } |
|
| 365 | 392 | |
| 366 | 393 | // Add in any newly defined vars that were passed |
| 367 | - foreach ($config_vars as $var => $val) |
|
| 368 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 394 | + foreach ($config_vars as $var => $val) { |
|
| 395 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 396 | + } |
|
| 369 | 397 | |
| 370 | 398 | $settingsArray[$end] = '?' . '>'; |
| 399 | + } else { |
|
| 400 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 371 | 401 | } |
| 372 | - else |
|
| 373 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 374 | 402 | |
| 375 | 403 | // Sanity error checking: the file needs to be at least 12 lines. |
| 376 | - if (count($settingsArray) < 12) |
|
| 377 | - return; |
|
| 404 | + if (count($settingsArray) < 12) { |
|
| 405 | + return; |
|
| 406 | + } |
|
| 378 | 407 | |
| 379 | 408 | // Try to avoid a few pitfalls: |
| 380 | 409 | // - like a possible race condition, |
@@ -382,8 +411,9 @@ discard block |
||
| 382 | 411 | // |
| 383 | 412 | // Check before you act: if cache is enabled, we can do a simple write test |
| 384 | 413 | // to validate that we even write things on this filesystem. |
| 385 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 386 | - $cachedir = $boarddir . '/cache'; |
|
| 414 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 415 | + $cachedir = $boarddir . '/cache'; |
|
| 416 | + } |
|
| 387 | 417 | |
| 388 | 418 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 389 | 419 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
| 419 | 449 | // Well this is not good at all, lets see if we can save this |
| 420 | 450 | $context['settings_message'] = 'settings_error'; |
| 421 | 451 | |
| 422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 454 | + } |
|
| 424 | 455 | } |
| 425 | 456 | } |
| 426 | 457 | |
| 427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 429 | - if (function_exists('opcache_invalidate')) |
|
| 430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 431 | -} |
|
| 460 | + if (function_exists('opcache_invalidate')) { |
|
| 461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 462 | + } |
|
| 463 | + } |
|
| 432 | 464 | |
| 433 | 465 | /** |
| 434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
| 454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
| 455 | 487 | |
| 456 | 488 | // This must exist! |
| 457 | - if (!isset($context['admin_preferences'])) |
|
| 458 | - return false; |
|
| 489 | + if (!isset($context['admin_preferences'])) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 459 | 492 | |
| 460 | 493 | // This is what we'll be saving. |
| 461 | 494 | $options['admin_preferences'] = json_encode($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
| 519 | 552 | $emails_sent = array(); |
| 520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 521 | 554 | { |
| 522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 523 | - continue; |
|
| 555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 524 | 558 | |
| 525 | 559 | // Stick their particulars in the replacement data. |
| 526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
| 539 | 573 | $smcFunc['db_free_result']($request); |
| 540 | 574 | |
| 541 | 575 | // Any additional users we must email this to? |
| 542 | - if (!empty($additional_recipients)) |
|
| 543 | - foreach ($additional_recipients as $recipient) |
|
| 576 | + if (!empty($additional_recipients)) { |
|
| 577 | + foreach ($additional_recipients as $recipient) |
|
| 544 | 578 | { |
| 545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
| 546 | 580 | continue; |
| 581 | + } |
|
| 547 | 582 | |
| 548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
| 549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get all birthdays within the given time range. |
@@ -61,10 +62,11 @@ discard block |
||
| 61 | 62 | $bday = array(); |
| 62 | 63 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 63 | 64 | { |
| 64 | - if ($year_low != $year_high) |
|
| 65 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 66 | - else |
|
| 67 | - $age_year = $year_low; |
|
| 65 | + if ($year_low != $year_high) { |
|
| 66 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 67 | + } else { |
|
| 68 | + $age_year = $year_low; |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 70 | 72 | 'id' => $row['id_member'], |
@@ -76,8 +78,9 @@ discard block |
||
| 76 | 78 | $smcFunc['db_free_result']($result); |
| 77 | 79 | |
| 78 | 80 | // Set is_last, so the themes know when to stop placing separators. |
| 79 | - foreach ($bday as $mday => $array) |
|
| 80 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 81 | + foreach ($bday as $mday => $array) { |
|
| 82 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | return $bday; |
| 83 | 86 | } |
@@ -125,8 +128,9 @@ discard block |
||
| 125 | 128 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 126 | 129 | { |
| 127 | 130 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 128 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 129 | - continue; |
|
| 131 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 132 | + continue; |
|
| 133 | + } |
|
| 130 | 134 | |
| 131 | 135 | // Force a censor of the title - as often these are used by others. |
| 132 | 136 | censorText($row['title'], $use_permissions ? false : true); |
@@ -141,13 +145,14 @@ discard block |
||
| 141 | 145 | { |
| 142 | 146 | // Attempt to avoid DST problems. |
| 143 | 147 | // @todo Resolve this properly at some point. |
| 144 | - if (strftime('%Y-%m-%d', $date) == $lastDate) |
|
| 145 | - $date += 3601; |
|
| 148 | + if (strftime('%Y-%m-%d', $date) == $lastDate) { |
|
| 149 | + $date += 3601; |
|
| 150 | + } |
|
| 146 | 151 | $lastDate = strftime('%Y-%m-%d', $date); |
| 147 | 152 | |
| 148 | 153 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 149 | - if ($use_permissions) |
|
| 150 | - $events[strftime('%Y-%m-%d', $date)][] = array( |
|
| 154 | + if ($use_permissions) { |
|
| 155 | + $events[strftime('%Y-%m-%d', $date)][] = array( |
|
| 151 | 156 | 'id' => $row['id_event'], |
| 152 | 157 | 'title' => $row['title'], |
| 153 | 158 | 'start_date' => $row['start_date'], |
@@ -162,9 +167,10 @@ discard block |
||
| 162 | 167 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 163 | 168 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 164 | 169 | ); |
| 170 | + } |
|
| 165 | 171 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 166 | - else |
|
| 167 | - $events[strftime('%Y-%m-%d', $date)][] = array( |
|
| 172 | + else { |
|
| 173 | + $events[strftime('%Y-%m-%d', $date)][] = array( |
|
| 168 | 174 | 'id' => $row['id_event'], |
| 169 | 175 | 'title' => $row['title'], |
| 170 | 176 | 'start_date' => $row['start_date'], |
@@ -181,6 +187,7 @@ discard block |
||
| 181 | 187 | 'poster' => $row['id_member'], |
| 182 | 188 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 183 | 189 | ); |
| 190 | + } |
|
| 184 | 191 | } |
| 185 | 192 | } |
| 186 | 193 | $smcFunc['db_free_result']($result); |
@@ -188,8 +195,9 @@ discard block |
||
| 188 | 195 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 189 | 196 | if ($use_permissions) |
| 190 | 197 | { |
| 191 | - foreach ($events as $mday => $array) |
|
| 192 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 198 | + foreach ($events as $mday => $array) { |
|
| 199 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 200 | + } |
|
| 193 | 201 | } |
| 194 | 202 | |
| 195 | 203 | return $events; |
@@ -207,11 +215,12 @@ discard block |
||
| 207 | 215 | global $smcFunc; |
| 208 | 216 | |
| 209 | 217 | // Get the lowest and highest dates for "all years". |
| 210 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 211 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 218 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 219 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 212 | 220 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 213 | - else |
|
| 214 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 221 | + } else { |
|
| 222 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 223 | + } |
|
| 215 | 224 | |
| 216 | 225 | // Find some holidays... ;). |
| 217 | 226 | $result = $smcFunc['db_query']('', ' |
@@ -231,10 +240,11 @@ discard block |
||
| 231 | 240 | $holidays = array(); |
| 232 | 241 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 233 | 242 | { |
| 234 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 235 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 236 | - else |
|
| 237 | - $event_year = substr($low_date, 0, 4); |
|
| 243 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 244 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 245 | + } else { |
|
| 246 | + $event_year = substr($low_date, 0, 4); |
|
| 247 | + } |
|
| 238 | 248 | |
| 239 | 249 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 240 | 250 | } |
@@ -258,10 +268,12 @@ discard block |
||
| 258 | 268 | isAllowedTo('calendar_post'); |
| 259 | 269 | |
| 260 | 270 | // No board? No topic?!? |
| 261 | - if (empty($board)) |
|
| 262 | - fatal_lang_error('missing_board_id', false); |
|
| 263 | - if (empty($topic)) |
|
| 264 | - fatal_lang_error('missing_topic_id', false); |
|
| 271 | + if (empty($board)) { |
|
| 272 | + fatal_lang_error('missing_board_id', false); |
|
| 273 | + } |
|
| 274 | + if (empty($topic)) { |
|
| 275 | + fatal_lang_error('missing_topic_id', false); |
|
| 276 | + } |
|
| 265 | 277 | |
| 266 | 278 | // Administrator, Moderator, or owner. Period. |
| 267 | 279 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -279,12 +291,14 @@ discard block |
||
| 279 | 291 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 280 | 292 | { |
| 281 | 293 | // Not the owner of the topic. |
| 282 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 283 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 294 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 295 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 296 | + } |
|
| 284 | 297 | } |
| 285 | 298 | // Topic/Board doesn't exist..... |
| 286 | - else |
|
| 287 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 299 | + else { |
|
| 300 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 301 | + } |
|
| 288 | 302 | $smcFunc['db_free_result']($result); |
| 289 | 303 | } |
| 290 | 304 | } |
@@ -372,14 +386,16 @@ discard block |
||
| 372 | 386 | if (!empty($calendarOptions['start_day'])) |
| 373 | 387 | { |
| 374 | 388 | $nShift -= $calendarOptions['start_day']; |
| 375 | - if ($nShift < 0) |
|
| 376 | - $nShift = 7 + $nShift; |
|
| 389 | + if ($nShift < 0) { |
|
| 390 | + $nShift = 7 + $nShift; |
|
| 391 | + } |
|
| 377 | 392 | } |
| 378 | 393 | |
| 379 | 394 | // Number of rows required to fit the month. |
| 380 | 395 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 381 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 382 | - $nRows++; |
|
| 396 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 397 | + $nRows++; |
|
| 398 | + } |
|
| 383 | 399 | |
| 384 | 400 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 385 | 401 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -392,8 +408,9 @@ discard block |
||
| 392 | 408 | { |
| 393 | 409 | $calendarGrid['week_days'][] = $count; |
| 394 | 410 | $count++; |
| 395 | - if ($count == 7) |
|
| 396 | - $count = 0; |
|
| 411 | + if ($count == 7) { |
|
| 412 | + $count = 0; |
|
| 413 | + } |
|
| 397 | 414 | } |
| 398 | 415 | |
| 399 | 416 | // Iterate through each week. |
@@ -410,8 +427,9 @@ discard block |
||
| 410 | 427 | { |
| 411 | 428 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 412 | 429 | |
| 413 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 414 | - $nDay = 0; |
|
| 430 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 431 | + $nDay = 0; |
|
| 432 | + } |
|
| 415 | 433 | |
| 416 | 434 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 417 | 435 | |
@@ -429,8 +447,9 @@ discard block |
||
| 429 | 447 | } |
| 430 | 448 | |
| 431 | 449 | // What is the last day of the month? |
| 432 | - if ($is_previous === true) |
|
| 433 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 450 | + if ($is_previous === true) { |
|
| 451 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 452 | + } |
|
| 434 | 453 | |
| 435 | 454 | // We'll use the shift in the template. |
| 436 | 455 | $calendarGrid['shift'] = $nShift; |
@@ -464,8 +483,9 @@ discard block |
||
| 464 | 483 | { |
| 465 | 484 | // Here we offset accordingly to get things to the real start of a week. |
| 466 | 485 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 467 | - if ($date_diff < 0) |
|
| 468 | - $date_diff += 7; |
|
| 486 | + if ($date_diff < 0) { |
|
| 487 | + $date_diff += 7; |
|
| 488 | + } |
|
| 469 | 489 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 470 | 490 | $day = (int) strftime('%d', $new_timestamp); |
| 471 | 491 | $month = (int) strftime('%m', $new_timestamp); |
@@ -616,8 +636,9 @@ discard block |
||
| 616 | 636 | // Holidays between now and now + days. |
| 617 | 637 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 618 | 638 | { |
| 619 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 620 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 639 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 640 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 641 | + } |
|
| 621 | 642 | } |
| 622 | 643 | |
| 623 | 644 | // Happy Birthday, guys and gals! |
@@ -626,8 +647,9 @@ discard block |
||
| 626 | 647 | $loop_date = strftime('%Y-%m-%d', $i); |
| 627 | 648 | if (isset($cached_data['birthdays'][$loop_date])) |
| 628 | 649 | { |
| 629 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 630 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 650 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 651 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 652 | + } |
|
| 631 | 653 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 632 | 654 | } |
| 633 | 655 | } |
@@ -639,8 +661,9 @@ discard block |
||
| 639 | 661 | $loop_date = strftime('%Y-%m-%d', $i); |
| 640 | 662 | |
| 641 | 663 | // No events today? Check the next day. |
| 642 | - if (empty($cached_data['events'][$loop_date])) |
|
| 643 | - continue; |
|
| 664 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 665 | + continue; |
|
| 666 | + } |
|
| 644 | 667 | |
| 645 | 668 | // Loop through all events to add a few last-minute values. |
| 646 | 669 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -653,9 +676,9 @@ discard block |
||
| 653 | 676 | { |
| 654 | 677 | unset($cached_data['events'][$loop_date][$ev]); |
| 655 | 678 | continue; |
| 679 | + } else { |
|
| 680 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 656 | 681 | } |
| 657 | - else |
|
| 658 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 659 | 682 | |
| 660 | 683 | // Might be set to true afterwards, depending on the permissions. |
| 661 | 684 | $this_event['can_edit'] = false; |
@@ -663,15 +686,18 @@ discard block |
||
| 663 | 686 | $this_event['date'] = $loop_date; |
| 664 | 687 | } |
| 665 | 688 | |
| 666 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 667 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 689 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 690 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 691 | + } |
|
| 668 | 692 | } |
| 669 | 693 | |
| 670 | 694 | // Mark the last item so that a list separator can be used in the template. |
| 671 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 672 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 673 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 674 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 695 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 696 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 697 | + } |
|
| 698 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 699 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 700 | + } |
|
| 675 | 701 | |
| 676 | 702 | return array( |
| 677 | 703 | 'data' => $return_data, |
@@ -716,16 +742,20 @@ discard block |
||
| 716 | 742 | if (!isset($_POST['deleteevent'])) |
| 717 | 743 | { |
| 718 | 744 | // No month? No year? |
| 719 | - if (!isset($_POST['month'])) |
|
| 720 | - fatal_lang_error('event_month_missing', false); |
|
| 721 | - if (!isset($_POST['year'])) |
|
| 722 | - fatal_lang_error('event_year_missing', false); |
|
| 745 | + if (!isset($_POST['month'])) { |
|
| 746 | + fatal_lang_error('event_month_missing', false); |
|
| 747 | + } |
|
| 748 | + if (!isset($_POST['year'])) { |
|
| 749 | + fatal_lang_error('event_year_missing', false); |
|
| 750 | + } |
|
| 723 | 751 | |
| 724 | 752 | // Check the month and year... |
| 725 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 726 | - fatal_lang_error('invalid_month', false); |
|
| 727 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 728 | - fatal_lang_error('invalid_year', false); |
|
| 753 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 754 | + fatal_lang_error('invalid_month', false); |
|
| 755 | + } |
|
| 756 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 757 | + fatal_lang_error('invalid_year', false); |
|
| 758 | + } |
|
| 729 | 759 | } |
| 730 | 760 | |
| 731 | 761 | // Make sure they're allowed to post... |
@@ -734,32 +764,39 @@ discard block |
||
| 734 | 764 | if (isset($_POST['span'])) |
| 735 | 765 | { |
| 736 | 766 | // Make sure it's turned on and not some fool trying to trick it. |
| 737 | - if (empty($modSettings['cal_allowspan'])) |
|
| 738 | - fatal_lang_error('no_span', false); |
|
| 739 | - if ($_POST['span'] < 1 || $_POST['span'] > $modSettings['cal_maxspan']) |
|
| 740 | - fatal_lang_error('invalid_days_numb', false); |
|
| 767 | + if (empty($modSettings['cal_allowspan'])) { |
|
| 768 | + fatal_lang_error('no_span', false); |
|
| 769 | + } |
|
| 770 | + if ($_POST['span'] < 1 || $_POST['span'] > $modSettings['cal_maxspan']) { |
|
| 771 | + fatal_lang_error('invalid_days_numb', false); |
|
| 772 | + } |
|
| 741 | 773 | } |
| 742 | 774 | |
| 743 | 775 | // There is no need to validate the following values if we are just deleting the event. |
| 744 | 776 | if (!isset($_POST['deleteevent'])) |
| 745 | 777 | { |
| 746 | 778 | // No day? |
| 747 | - if (!isset($_POST['day'])) |
|
| 748 | - fatal_lang_error('event_day_missing', false); |
|
| 749 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 750 | - fatal_lang_error('event_title_missing', false); |
|
| 751 | - elseif (!isset($_POST['evtitle'])) |
|
| 752 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 779 | + if (!isset($_POST['day'])) { |
|
| 780 | + fatal_lang_error('event_day_missing', false); |
|
| 781 | + } |
|
| 782 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 783 | + fatal_lang_error('event_title_missing', false); |
|
| 784 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 785 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // Bad day? |
| 755 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 756 | - fatal_lang_error('invalid_date', false); |
|
| 789 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 790 | + fatal_lang_error('invalid_date', false); |
|
| 791 | + } |
|
| 757 | 792 | |
| 758 | 793 | // No title? |
| 759 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 760 | - fatal_lang_error('no_event_title', false); |
|
| 761 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 762 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 794 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 795 | + fatal_lang_error('no_event_title', false); |
|
| 796 | + } |
|
| 797 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 798 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 799 | + } |
|
| 763 | 800 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 764 | 801 | } |
| 765 | 802 | } |
@@ -786,8 +823,9 @@ discard block |
||
| 786 | 823 | ); |
| 787 | 824 | |
| 788 | 825 | // No results, return false. |
| 789 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 790 | - return false; |
|
| 826 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 827 | + return false; |
|
| 828 | + } |
|
| 791 | 829 | |
| 792 | 830 | // Grab the results and return. |
| 793 | 831 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -815,13 +853,15 @@ discard block |
||
| 815 | 853 | |
| 816 | 854 | // Make sure the start date is in ISO order. |
| 817 | 855 | // @todo $year, $month, and $day are not set |
| 818 | - if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) |
|
| 819 | - trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR); |
|
| 856 | + if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) { |
|
| 857 | + trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR); |
|
| 858 | + } |
|
| 820 | 859 | |
| 821 | 860 | // Set the end date (if not yet given) |
| 822 | 861 | // @todo $year, $month, and $day are not set |
| 823 | - if (!isset($eventOptions['end_date'])) |
|
| 824 | - $eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 862 | + if (!isset($eventOptions['end_date'])) { |
|
| 863 | + $eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 864 | + } |
|
| 825 | 865 | |
| 826 | 866 | // If no topic and board are given, they are not linked to a topic. |
| 827 | 867 | $eventOptions['board'] = isset($eventOptions['board']) ? (int) $eventOptions['board'] : 0; |
@@ -888,15 +928,17 @@ discard block |
||
| 888 | 928 | $eventOptions['title'] = $smcFunc['htmlspecialchars']($eventOptions['title'], ENT_QUOTES); |
| 889 | 929 | |
| 890 | 930 | // Scan the start date for validity and get its components. |
| 891 | - if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) |
|
| 892 | - trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR); |
|
| 931 | + if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) { |
|
| 932 | + trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR); |
|
| 933 | + } |
|
| 893 | 934 | |
| 894 | 935 | // Default span to 0 days. |
| 895 | 936 | $eventOptions['span'] = isset($eventOptions['span']) ? (int) $eventOptions['span'] : 0; |
| 896 | 937 | |
| 897 | 938 | // Set the end date to the start date + span (if the end date wasn't already given). |
| 898 | - if (!isset($eventOptions['end_date'])) |
|
| 899 | - $eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 939 | + if (!isset($eventOptions['end_date'])) { |
|
| 940 | + $eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 941 | + } |
|
| 900 | 942 | |
| 901 | 943 | $event_columns = array( |
| 902 | 944 | 'start_date' => '{date:start_date}', |
@@ -918,8 +960,9 @@ discard block |
||
| 918 | 960 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 919 | 961 | |
| 920 | 962 | $column_clauses = array(); |
| 921 | - foreach ($event_columns as $col => $crit) |
|
| 922 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 963 | + foreach ($event_columns as $col => $crit) { |
|
| 964 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 965 | + } |
|
| 923 | 966 | |
| 924 | 967 | $smcFunc['db_query']('', ' |
| 925 | 968 | UPDATE {db_prefix}calendar |
@@ -993,8 +1036,9 @@ discard block |
||
| 993 | 1036 | ); |
| 994 | 1037 | |
| 995 | 1038 | // If nothing returned, we are in poo, poo. |
| 996 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 997 | - return false; |
|
| 1039 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1040 | + return false; |
|
| 1041 | + } |
|
| 998 | 1042 | |
| 999 | 1043 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1000 | 1044 | $smcFunc['db_free_result']($request); |
@@ -1048,8 +1092,9 @@ discard block |
||
| 1048 | 1092 | ) |
| 1049 | 1093 | ); |
| 1050 | 1094 | $holidays = array(); |
| 1051 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1052 | - $holidays[] = $row; |
|
| 1095 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1096 | + $holidays[] = $row; |
|
| 1097 | + } |
|
| 1053 | 1098 | $smcFunc['db_free_result']($request); |
| 1054 | 1099 | |
| 1055 | 1100 | return $holidays; |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 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. |
@@ -46,17 +47,19 @@ discard block |
||
| 46 | 47 | $message = preg_replace('~\.{100,}~', '...', $message); |
| 47 | 48 | |
| 48 | 49 | // Trim off trailing quotes - these often happen by accident. |
| 49 | - while (substr($message, -7) == '[quote]') |
|
| 50 | - $message = substr($message, 0, -7); |
|
| 51 | - while (substr($message, 0, 8) == '[/quote]') |
|
| 52 | - $message = substr($message, 8); |
|
| 50 | + while (substr($message, -7) == '[quote]') { |
|
| 51 | + $message = substr($message, 0, -7); |
|
| 52 | + } |
|
| 53 | + while (substr($message, 0, 8) == '[/quote]') { |
|
| 54 | + $message = substr($message, 8); |
|
| 55 | + } |
|
| 53 | 56 | |
| 54 | 57 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
| 55 | 58 | $in_tag = false; |
| 56 | 59 | $had_tag = false; |
| 57 | 60 | $codeopen = 0; |
| 58 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
| 59 | - foreach ($matches[0] as $index => $dummy) |
|
| 61 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
| 62 | + foreach ($matches[0] as $index => $dummy) |
|
| 60 | 63 | { |
| 61 | 64 | // Closing? |
| 62 | 65 | if (!empty($matches[2][$index])) |
@@ -64,6 +67,7 @@ discard block |
||
| 64 | 67 | // If it's closing and we're not in a tag we need to open it... |
| 65 | 68 | if (!$in_tag) |
| 66 | 69 | $codeopen = true; |
| 70 | + } |
|
| 67 | 71 | // Either way we ain't in one any more. |
| 68 | 72 | $in_tag = false; |
| 69 | 73 | } |
@@ -72,17 +76,20 @@ discard block |
||
| 72 | 76 | { |
| 73 | 77 | $had_tag = true; |
| 74 | 78 | // If we're in a tag don't do nought! |
| 75 | - if (!$in_tag) |
|
| 76 | - $in_tag = true; |
|
| 79 | + if (!$in_tag) { |
|
| 80 | + $in_tag = true; |
|
| 81 | + } |
|
| 77 | 82 | } |
| 78 | 83 | } |
| 79 | 84 | |
| 80 | 85 | // If we have an open tag, close it. |
| 81 | - if ($in_tag) |
|
| 82 | - $message .= '[/code]'; |
|
| 86 | + if ($in_tag) { |
|
| 87 | + $message .= '[/code]'; |
|
| 88 | + } |
|
| 83 | 89 | // Open any ones that need to be open, only if we've never had a tag. |
| 84 | - if ($codeopen && !$had_tag) |
|
| 85 | - $message = '[code]' . $message; |
|
| 90 | + if ($codeopen && !$had_tag) { |
|
| 91 | + $message = '[code]' . $message; |
|
| 92 | + } |
|
| 86 | 93 | |
| 87 | 94 | // Now that we've fixed all the code tags, let's fix the img and url tags... |
| 88 | 95 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +115,26 @@ discard block |
||
| 108 | 115 | fixTags($message); |
| 109 | 116 | |
| 110 | 117 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
| 111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
| 112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
| 113 | - else |
|
| 114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
| 118 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
| 119 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
| 120 | + } else { |
|
| 121 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
| 122 | + } |
|
| 115 | 123 | |
| 116 | 124 | if (!$previewing && strpos($message, '[html]') !== false) |
| 117 | 125 | { |
| 118 | - if (allowedTo('admin_forum')) |
|
| 119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function ($m) { |
|
| 126 | + if (allowedTo('admin_forum')) { |
|
| 127 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function ($m) { |
|
| 120 | 128 | return '[html]' . strtr(un_htmlspecialchars($m), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
| 129 | + } |
|
| 121 | 130 | }, $message); |
| 122 | 131 | |
| 123 | 132 | // We should edit them out, or else if an admin edits the message they will get shown... |
| 124 | 133 | else |
| 125 | 134 | { |
| 126 | - while (strpos($message, '[html]') !== false) |
|
| 127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
| 135 | + while (strpos($message, '[html]') !== false) { |
|
| 136 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
| 137 | + } |
|
| 128 | 138 | } |
| 129 | 139 | } |
| 130 | 140 | |
@@ -146,10 +156,12 @@ discard block |
||
| 146 | 156 | |
| 147 | 157 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
| 148 | 158 | $list_close = substr_count($message, '[/list]'); |
| 149 | - if ($list_close - $list_open > 0) |
|
| 150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
| 151 | - if ($list_open - $list_close > 0) |
|
| 152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
| 159 | + if ($list_close - $list_open > 0) { |
|
| 160 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
| 161 | + } |
|
| 162 | + if ($list_open - $list_close > 0) { |
|
| 163 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
| 164 | + } |
|
| 153 | 165 | |
| 154 | 166 | $mistake_fixes = array( |
| 155 | 167 | // Find [table]s not followed by [tr]. |
@@ -198,8 +210,9 @@ discard block |
||
| 198 | 210 | ); |
| 199 | 211 | |
| 200 | 212 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
| 201 | - for ($j = 0; $j < 3; $j++) |
|
| 202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
| 213 | + for ($j = 0; $j < 3; $j++) { |
|
| 214 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
| 215 | + } |
|
| 203 | 216 | |
| 204 | 217 | // Remove empty bbc from the sections outside the code tags |
| 205 | 218 | $allowedEmpty = array( |
@@ -209,24 +222,28 @@ discard block |
||
| 209 | 222 | |
| 210 | 223 | require_once($sourcedir . '/Subs.php'); |
| 211 | 224 | |
| 212 | - foreach (($codes = parse_bbc(false)) as $code) |
|
| 213 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
| 225 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
| 226 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
| 214 | 227 | $alltags[] = $code['tag']; |
| 228 | + } |
|
| 215 | 229 | |
| 216 | 230 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
| 217 | 231 | |
| 218 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
| 219 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
| 232 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
| 233 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
| 234 | + } |
|
| 220 | 235 | |
| 221 | 236 | // Restore code blocks |
| 222 | - if (!empty($code_tags)) |
|
| 223 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 237 | + if (!empty($code_tags)) { |
|
| 238 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 239 | + } |
|
| 224 | 240 | |
| 225 | 241 | // Restore white space entities |
| 226 | - if (!$previewing) |
|
| 227 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 228 | - else |
|
| 229 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 242 | + if (!$previewing) { |
|
| 243 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 244 | + } else { |
|
| 245 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 246 | + } |
|
| 230 | 247 | |
| 231 | 248 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
| 232 | 249 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -269,8 +286,9 @@ discard block |
||
| 269 | 286 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
| 270 | 287 | }, $message); |
| 271 | 288 | |
| 272 | - if (!empty($code_tags)) |
|
| 273 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 289 | + if (!empty($code_tags)) { |
|
| 290 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 291 | + } |
|
| 274 | 292 | |
| 275 | 293 | // Change breaks back to \n's and &nsbp; back to spaces. |
| 276 | 294 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -351,8 +369,9 @@ discard block |
||
| 351 | 369 | ); |
| 352 | 370 | |
| 353 | 371 | // Fix each type of tag. |
| 354 | - foreach ($fixArray as $param) |
|
| 355 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
| 372 | + foreach ($fixArray as $param) { |
|
| 373 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
| 374 | + } |
|
| 356 | 375 | |
| 357 | 376 | // Now fix possible security problems with images loading links automatically... |
| 358 | 377 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function ($m) |
@@ -388,16 +407,19 @@ discard block |
||
| 388 | 407 | $desired_height = $height; |
| 389 | 408 | } |
| 390 | 409 | // Scale it to the width... |
| 391 | - elseif (empty($desired_width) && !empty($height)) |
|
| 392 | - $desired_width = (int) (($desired_height * $width) / $height); |
|
| 410 | + elseif (empty($desired_width) && !empty($height)) { |
|
| 411 | + $desired_width = (int) (($desired_height * $width) / $height); |
|
| 412 | + } |
|
| 393 | 413 | // Scale if to the height. |
| 394 | - elseif (!empty($width)) |
|
| 395 | - $desired_height = (int) (($desired_width * $height) / $width); |
|
| 414 | + elseif (!empty($width)) { |
|
| 415 | + $desired_height = (int) (($desired_width * $height) / $width); |
|
| 416 | + } |
|
| 396 | 417 | } |
| 397 | 418 | |
| 398 | 419 | // If the width and height are fine, just continue along... |
| 399 | - if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) |
|
| 400 | - continue; |
|
| 420 | + if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) { |
|
| 421 | + continue; |
|
| 422 | + } |
|
| 401 | 423 | |
| 402 | 424 | // Too bad, it's too wide. Make it as wide as the maximum. |
| 403 | 425 | if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width'])) |
@@ -417,8 +439,9 @@ discard block |
||
| 417 | 439 | } |
| 418 | 440 | |
| 419 | 441 | // If any img tags were actually changed... |
| 420 | - if (!empty($replaces)) |
|
| 421 | - $message = strtr($message, $replaces); |
|
| 442 | + if (!empty($replaces)) { |
|
| 443 | + $message = strtr($message, $replaces); |
|
| 444 | + } |
|
| 422 | 445 | } |
| 423 | 446 | } |
| 424 | 447 | |
@@ -437,10 +460,11 @@ discard block |
||
| 437 | 460 | { |
| 438 | 461 | global $boardurl, $scripturl; |
| 439 | 462 | |
| 440 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
| 441 | - $domain_url = $match[1]; |
|
| 442 | - else |
|
| 443 | - $domain_url = $boardurl . '/'; |
|
| 463 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
| 464 | + $domain_url = $match[1]; |
|
| 465 | + } else { |
|
| 466 | + $domain_url = $boardurl . '/'; |
|
| 467 | + } |
|
| 444 | 468 | |
| 445 | 469 | $replaces = array(); |
| 446 | 470 | |
@@ -448,11 +472,11 @@ discard block |
||
| 448 | 472 | { |
| 449 | 473 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
| 450 | 474 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
| 475 | + } elseif ($hasEqualSign) { |
|
| 476 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
| 477 | + } else { |
|
| 478 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
| 451 | 479 | } |
| 452 | - elseif ($hasEqualSign) |
|
| 453 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
| 454 | - else |
|
| 455 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
| 456 | 480 | |
| 457 | 481 | foreach ($matches[0] as $k => $dummy) |
| 458 | 482 | { |
@@ -465,49 +489,53 @@ discard block |
||
| 465 | 489 | foreach ($protocols as $protocol) |
| 466 | 490 | { |
| 467 | 491 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
| 468 | - if ($found) |
|
| 469 | - break; |
|
| 492 | + if ($found) { |
|
| 493 | + break; |
|
| 494 | + } |
|
| 470 | 495 | } |
| 471 | 496 | |
| 472 | 497 | if (!$found && $protocols[0] == 'http') |
| 473 | 498 | { |
| 474 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
| 475 | - $replace = $domain_url . $replace; |
|
| 476 | - elseif (substr($replace, 0, 1) == '?') |
|
| 477 | - $replace = $scripturl . $replace; |
|
| 478 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
| 499 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
| 500 | + $replace = $domain_url . $replace; |
|
| 501 | + } elseif (substr($replace, 0, 1) == '?') { |
|
| 502 | + $replace = $scripturl . $replace; |
|
| 503 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
| 479 | 504 | { |
| 480 | 505 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
| 481 | 506 | $this_tag = 'iurl'; |
| 482 | 507 | $this_close = 'iurl'; |
| 508 | + } elseif (substr($replace, 0, 2) != '//') { |
|
| 509 | + $replace = $protocols[0] . '://' . $replace; |
|
| 483 | 510 | } |
| 484 | - elseif (substr($replace, 0, 2) != '//') |
|
| 485 | - $replace = $protocols[0] . '://' . $replace; |
|
| 486 | - } |
|
| 487 | - elseif (!$found && $protocols[0] == 'ftp') |
|
| 488 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
| 489 | - elseif (!$found) |
|
| 490 | - $replace = $protocols[0] . '://' . $replace; |
|
| 491 | - |
|
| 492 | - if ($hasEqualSign && $embeddedUrl) |
|
| 493 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
| 494 | - elseif ($hasEqualSign) |
|
| 495 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
| 496 | - elseif ($embeddedUrl) |
|
| 497 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
| 498 | - else |
|
| 499 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
| 511 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
| 512 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
| 513 | + } elseif (!$found) { |
|
| 514 | + $replace = $protocols[0] . '://' . $replace; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + if ($hasEqualSign && $embeddedUrl) { |
|
| 518 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
| 519 | + } elseif ($hasEqualSign) { |
|
| 520 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
| 521 | + } elseif ($embeddedUrl) { |
|
| 522 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
| 523 | + } else { |
|
| 524 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
| 525 | + } |
|
| 500 | 526 | } |
| 501 | 527 | |
| 502 | 528 | foreach ($replaces as $k => $v) |
| 503 | 529 | { |
| 504 | - if ($k == $v) |
|
| 505 | - unset($replaces[$k]); |
|
| 530 | + if ($k == $v) { |
|
| 531 | + unset($replaces[$k]); |
|
| 532 | + } |
|
| 506 | 533 | } |
| 507 | 534 | |
| 508 | - if (!empty($replaces)) |
|
| 509 | - $message = strtr($message, $replaces); |
|
| 510 | -} |
|
| 535 | + if (!empty($replaces)) { |
|
| 536 | + $message = strtr($message, $replaces); |
|
| 537 | + } |
|
| 538 | + } |
|
| 511 | 539 | |
| 512 | 540 | /** |
| 513 | 541 | * This function sends an email to the specified recipient(s). |
@@ -551,8 +579,9 @@ discard block |
||
| 551 | 579 | } |
| 552 | 580 | |
| 553 | 581 | // Nothing left? Nothing else to do |
| 554 | - if (empty($to_array)) |
|
| 555 | - return true; |
|
| 582 | + if (empty($to_array)) { |
|
| 583 | + return true; |
|
| 584 | + } |
|
| 556 | 585 | |
| 557 | 586 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
| 558 | 587 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -569,15 +598,17 @@ discard block |
||
| 569 | 598 | } |
| 570 | 599 | |
| 571 | 600 | // Call this function recursively for the hotmail addresses. |
| 572 | - if (!empty($hotmail_to)) |
|
| 573 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
| 601 | + if (!empty($hotmail_to)) { |
|
| 602 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
| 603 | + } |
|
| 574 | 604 | |
| 575 | 605 | // The remaining addresses no longer need the fix. |
| 576 | 606 | $hotmail_fix = false; |
| 577 | 607 | |
| 578 | 608 | // No other addresses left? Return instantly. |
| 579 | - if (empty($to_array)) |
|
| 580 | - return $mail_result; |
|
| 609 | + if (empty($to_array)) { |
|
| 610 | + return $mail_result; |
|
| 611 | + } |
|
| 581 | 612 | } |
| 582 | 613 | |
| 583 | 614 | // Get rid of entities. |
@@ -602,13 +633,15 @@ discard block |
||
| 602 | 633 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
| 603 | 634 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
| 604 | 635 | |
| 605 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
| 606 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
| 636 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
| 637 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
| 638 | + } |
|
| 607 | 639 | $headers .= 'X-Mailer: SMF' . $line_break; |
| 608 | 640 | |
| 609 | 641 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
| 610 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
| 611 | - return false; |
|
| 642 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
| 643 | + return false; |
|
| 644 | + } |
|
| 612 | 645 | |
| 613 | 646 | // Save the original message... |
| 614 | 647 | $orig_message = $message; |
@@ -657,17 +690,19 @@ discard block |
||
| 657 | 690 | } |
| 658 | 691 | |
| 659 | 692 | // Are we using the mail queue, if so this is where we butt in... |
| 660 | - if ($priority != 0) |
|
| 661 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
| 693 | + if ($priority != 0) { |
|
| 694 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
| 695 | + } |
|
| 662 | 696 | |
| 663 | 697 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
| 664 | 698 | elseif (!empty($modSettings['mail_limit'])) |
| 665 | 699 | { |
| 666 | 700 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
| 667 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
| 668 | - $new_queue_stat = time() . '|' . 1; |
|
| 669 | - else |
|
| 670 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
| 701 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
| 702 | + $new_queue_stat = time() . '|' . 1; |
|
| 703 | + } else { |
|
| 704 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
| 705 | + } |
|
| 671 | 706 | |
| 672 | 707 | updateSettings(array('mail_recent' => $new_queue_stat)); |
| 673 | 708 | } |
@@ -692,12 +727,13 @@ discard block |
||
| 692 | 727 | |
| 693 | 728 | // Wait, wait, I'm still sending here! |
| 694 | 729 | @set_time_limit(300); |
| 695 | - if (function_exists('apache_reset_timeout')) |
|
| 696 | - @apache_reset_timeout(); |
|
| 730 | + if (function_exists('apache_reset_timeout')) { |
|
| 731 | + @apache_reset_timeout(); |
|
| 732 | + } |
|
| 697 | 733 | } |
| 734 | + } else { |
|
| 735 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
| 698 | 736 | } |
| 699 | - else |
|
| 700 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
| 701 | 737 | |
| 702 | 738 | // Everything go smoothly? |
| 703 | 739 | return $mail_result; |
@@ -723,8 +759,9 @@ discard block |
||
| 723 | 759 | static $cur_insert = array(); |
| 724 | 760 | static $cur_insert_len = 0; |
| 725 | 761 | |
| 726 | - if ($cur_insert_len == 0) |
|
| 727 | - $cur_insert = array(); |
|
| 762 | + if ($cur_insert_len == 0) { |
|
| 763 | + $cur_insert = array(); |
|
| 764 | + } |
|
| 728 | 765 | |
| 729 | 766 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
| 730 | 767 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -799,8 +836,9 @@ discard block |
||
| 799 | 836 | } |
| 800 | 837 | |
| 801 | 838 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
| 802 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
| 803 | - return AddMailQueue(true); |
|
| 839 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
| 840 | + return AddMailQueue(true); |
|
| 841 | + } |
|
| 804 | 842 | |
| 805 | 843 | return true; |
| 806 | 844 | } |
@@ -833,23 +871,26 @@ discard block |
||
| 833 | 871 | 'sent' => array() |
| 834 | 872 | ); |
| 835 | 873 | |
| 836 | - if ($from === null) |
|
| 837 | - $from = array( |
|
| 874 | + if ($from === null) { |
|
| 875 | + $from = array( |
|
| 838 | 876 | 'id' => $user_info['id'], |
| 839 | 877 | 'name' => $user_info['name'], |
| 840 | 878 | 'username' => $user_info['username'] |
| 841 | 879 | ); |
| 880 | + } |
|
| 842 | 881 | |
| 843 | 882 | // This is the one that will go in their inbox. |
| 844 | 883 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
| 845 | 884 | preparsecode($htmlmessage); |
| 846 | 885 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
| 847 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
| 848 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
| 886 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
| 887 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
| 888 | + } |
|
| 849 | 889 | |
| 850 | 890 | // Make sure is an array |
| 851 | - if (!is_array($recipients)) |
|
| 852 | - $recipients = array($recipients); |
|
| 891 | + if (!is_array($recipients)) { |
|
| 892 | + $recipients = array($recipients); |
|
| 893 | + } |
|
| 853 | 894 | |
| 854 | 895 | // Integrated PMs |
| 855 | 896 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -877,21 +918,23 @@ discard block |
||
| 877 | 918 | 'usernames' => array_keys($usernames), |
| 878 | 919 | ) |
| 879 | 920 | ); |
| 880 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 881 | - 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'])])) |
|
| 882 | 923 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
| 924 | + } |
|
| 883 | 925 | $smcFunc['db_free_result']($request); |
| 884 | 926 | |
| 885 | 927 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
| 886 | - foreach ($recipients as $rec_type => $rec) |
|
| 887 | - foreach ($rec as $id => $member) |
|
| 928 | + foreach ($recipients as $rec_type => $rec) { |
|
| 929 | + foreach ($rec as $id => $member) |
|
| 888 | 930 | { |
| 889 | 931 | if (is_numeric($recipients[$rec_type][$id])) |
| 890 | 932 | continue; |
| 933 | + } |
|
| 891 | 934 | |
| 892 | - if (!empty($usernames[$member])) |
|
| 893 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
| 894 | - else |
|
| 935 | + if (!empty($usernames[$member])) { |
|
| 936 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
| 937 | + } else |
|
| 895 | 938 | { |
| 896 | 939 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
| 897 | 940 | unset($recipients[$rec_type][$id]); |
@@ -930,8 +973,9 @@ discard block |
||
| 930 | 973 | foreach ($criteria as $criterium) |
| 931 | 974 | { |
| 932 | 975 | $match = false; |
| 933 | - 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)) |
|
| 934 | - $delete = true; |
|
| 976 | + 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)) { |
|
| 977 | + $delete = true; |
|
| 978 | + } |
|
| 935 | 979 | // If we're adding and one criteria don't match then we stop! |
| 936 | 980 | elseif (!$row['is_or']) |
| 937 | 981 | { |
@@ -939,8 +983,9 @@ discard block |
||
| 939 | 983 | break; |
| 940 | 984 | } |
| 941 | 985 | } |
| 942 | - if ($delete) |
|
| 943 | - $deletes[$row['id_member']] = 1; |
|
| 986 | + if ($delete) { |
|
| 987 | + $deletes[$row['id_member']] = 1; |
|
| 988 | + } |
|
| 944 | 989 | } |
| 945 | 990 | $smcFunc['db_free_result']($request); |
| 946 | 991 | |
@@ -955,8 +1000,9 @@ discard block |
||
| 955 | 1000 | array( |
| 956 | 1001 | ) |
| 957 | 1002 | ); |
| 958 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 959 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
| 1003 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1004 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
| 1005 | + } |
|
| 960 | 1006 | $smcFunc['db_free_result']($request); |
| 961 | 1007 | } |
| 962 | 1008 | |
@@ -964,8 +1010,9 @@ discard block |
||
| 964 | 1010 | require_once($sourcedir . '/Subs-Members.php'); |
| 965 | 1011 | $pmReadGroups = groupsAllowedTo('pm_read'); |
| 966 | 1012 | |
| 967 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 968 | - $pmReadGroups['denied'] = array(); |
|
| 1013 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 1014 | + $pmReadGroups['denied'] = array(); |
|
| 1015 | + } |
|
| 969 | 1016 | |
| 970 | 1017 | // Load their alert preferences |
| 971 | 1018 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -997,8 +1044,9 @@ discard block |
||
| 997 | 1044 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 998 | 1045 | { |
| 999 | 1046 | // Don't do anything for members to be deleted! |
| 1000 | - if (isset($deletes[$row['id_member']])) |
|
| 1001 | - continue; |
|
| 1047 | + if (isset($deletes[$row['id_member']])) { |
|
| 1048 | + continue; |
|
| 1049 | + } |
|
| 1002 | 1050 | |
| 1003 | 1051 | // Load the preferences for this member (if any) |
| 1004 | 1052 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -1019,8 +1067,9 @@ discard block |
||
| 1019 | 1067 | { |
| 1020 | 1068 | foreach ($groups as $id) |
| 1021 | 1069 | { |
| 1022 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
| 1023 | - $message_limit = $message_limit_cache[$id]; |
|
| 1070 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
| 1071 | + $message_limit = $message_limit_cache[$id]; |
|
| 1072 | + } |
|
| 1024 | 1073 | } |
| 1025 | 1074 | |
| 1026 | 1075 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1068,8 +1117,9 @@ discard block |
||
| 1068 | 1117 | $smcFunc['db_free_result']($request); |
| 1069 | 1118 | |
| 1070 | 1119 | // Only 'send' the message if there are any recipients left. |
| 1071 | - if (empty($all_to)) |
|
| 1072 | - return $log; |
|
| 1120 | + if (empty($all_to)) { |
|
| 1121 | + return $log; |
|
| 1122 | + } |
|
| 1073 | 1123 | |
| 1074 | 1124 | // Insert the message itself and then grab the last insert id. |
| 1075 | 1125 | $smcFunc['db_insert']('', |
@@ -1090,8 +1140,8 @@ discard block |
||
| 1090 | 1140 | if (!empty($id_pm)) |
| 1091 | 1141 | { |
| 1092 | 1142 | // If this is new we need to set it part of it's own conversation. |
| 1093 | - if (empty($pm_head)) |
|
| 1094 | - $smcFunc['db_query']('', ' |
|
| 1143 | + if (empty($pm_head)) { |
|
| 1144 | + $smcFunc['db_query']('', ' |
|
| 1095 | 1145 | UPDATE {db_prefix}personal_messages |
| 1096 | 1146 | SET id_pm_head = {int:id_pm_head} |
| 1097 | 1147 | WHERE id_pm = {int:id_pm_head}', |
@@ -1099,6 +1149,7 @@ discard block |
||
| 1099 | 1149 | 'id_pm_head' => $id_pm, |
| 1100 | 1150 | ) |
| 1101 | 1151 | ); |
| 1152 | + } |
|
| 1102 | 1153 | |
| 1103 | 1154 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
| 1104 | 1155 | $smcFunc['db_query']('', ' |
@@ -1114,8 +1165,9 @@ discard block |
||
| 1114 | 1165 | foreach ($all_to as $to) |
| 1115 | 1166 | { |
| 1116 | 1167 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
| 1117 | - if (!in_array($to, $recipients['bcc'])) |
|
| 1118 | - $to_list[] = $to; |
|
| 1168 | + if (!in_array($to, $recipients['bcc'])) { |
|
| 1169 | + $to_list[] = $to; |
|
| 1170 | + } |
|
| 1119 | 1171 | } |
| 1120 | 1172 | |
| 1121 | 1173 | $smcFunc['db_insert']('insert', |
@@ -1133,9 +1185,9 @@ discard block |
||
| 1133 | 1185 | { |
| 1134 | 1186 | censorText($message); |
| 1135 | 1187 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
| 1188 | + } else { |
|
| 1189 | + $message = ''; |
|
| 1136 | 1190 | } |
| 1137 | - else |
|
| 1138 | - $message = ''; |
|
| 1139 | 1191 | |
| 1140 | 1192 | $to_names = array(); |
| 1141 | 1193 | if (count($to_list) > 1) |
@@ -1148,8 +1200,9 @@ discard block |
||
| 1148 | 1200 | 'to_members' => $to_list, |
| 1149 | 1201 | ) |
| 1150 | 1202 | ); |
| 1151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1152 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
| 1203 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1204 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
| 1205 | + } |
|
| 1153 | 1206 | $smcFunc['db_free_result']($request); |
| 1154 | 1207 | } |
| 1155 | 1208 | $replacements = array( |
@@ -1177,11 +1230,13 @@ discard block |
||
| 1177 | 1230 | loadLanguage('index+PersonalMessage'); |
| 1178 | 1231 | |
| 1179 | 1232 | // Add one to their unread and read message counts. |
| 1180 | - foreach ($all_to as $k => $id) |
|
| 1181 | - if (isset($deletes[$id])) |
|
| 1233 | + foreach ($all_to as $k => $id) { |
|
| 1234 | + if (isset($deletes[$id])) |
|
| 1182 | 1235 | unset($all_to[$k]); |
| 1183 | - if (!empty($all_to)) |
|
| 1184 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
| 1236 | + } |
|
| 1237 | + if (!empty($all_to)) { |
|
| 1238 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
| 1239 | + } |
|
| 1185 | 1240 | |
| 1186 | 1241 | return $log; |
| 1187 | 1242 | } |
@@ -1211,15 +1266,17 @@ discard block |
||
| 1211 | 1266 | // Let's, for now, assume there are only 'ish characters. |
| 1212 | 1267 | $simple = true; |
| 1213 | 1268 | |
| 1214 | - foreach ($matches[1] as $entity) |
|
| 1215 | - if ($entity > 128) |
|
| 1269 | + foreach ($matches[1] as $entity) { |
|
| 1270 | + if ($entity > 128) |
|
| 1216 | 1271 | $simple = false; |
| 1272 | + } |
|
| 1217 | 1273 | unset($matches); |
| 1218 | 1274 | |
| 1219 | - if ($simple) |
|
| 1220 | - $string = preg_replace_callback('~&#(\d{3,8});~', function ($m) |
|
| 1275 | + if ($simple) { |
|
| 1276 | + $string = preg_replace_callback('~&#(\d{3,8});~', function ($m) |
|
| 1221 | 1277 | { |
| 1222 | 1278 | return chr("$m[1]"); |
| 1279 | + } |
|
| 1223 | 1280 | }, $string); |
| 1224 | 1281 | else |
| 1225 | 1282 | { |
@@ -1227,8 +1284,9 @@ discard block |
||
| 1227 | 1284 | if (!$context['utf8'] && function_exists('iconv')) |
| 1228 | 1285 | { |
| 1229 | 1286 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
| 1230 | - if ($newstring) |
|
| 1231 | - $string = $newstring; |
|
| 1287 | + if ($newstring) { |
|
| 1288 | + $string = $newstring; |
|
| 1289 | + } |
|
| 1232 | 1290 | } |
| 1233 | 1291 | |
| 1234 | 1292 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1244,23 +1302,25 @@ discard block |
||
| 1244 | 1302 | if (!$context['utf8'] && function_exists('iconv')) |
| 1245 | 1303 | { |
| 1246 | 1304 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
| 1247 | - if ($newstring) |
|
| 1248 | - $string = $newstring; |
|
| 1305 | + if ($newstring) { |
|
| 1306 | + $string = $newstring; |
|
| 1307 | + } |
|
| 1249 | 1308 | } |
| 1250 | 1309 | |
| 1251 | 1310 | $entityConvert = function ($m) |
| 1252 | 1311 | { |
| 1253 | 1312 | $c = $m[1]; |
| 1254 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
| 1255 | - return $c; |
|
| 1256 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
| 1257 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
| 1258 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
| 1259 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
| 1260 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
| 1261 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
| 1262 | - else |
|
| 1263 | - return ""; |
|
| 1313 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
| 1314 | + return $c; |
|
| 1315 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
| 1316 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
| 1317 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
| 1318 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
| 1319 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
| 1320 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
| 1321 | + } else { |
|
| 1322 | + return ""; |
|
| 1323 | + } |
|
| 1264 | 1324 | }; |
| 1265 | 1325 | |
| 1266 | 1326 | // Convert all 'special' characters to HTML entities. |
@@ -1274,19 +1334,20 @@ discard block |
||
| 1274 | 1334 | $string = base64_encode($string); |
| 1275 | 1335 | |
| 1276 | 1336 | // Show the characterset and the transfer-encoding for header strings. |
| 1277 | - if ($with_charset) |
|
| 1278 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
| 1337 | + if ($with_charset) { |
|
| 1338 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
| 1339 | + } |
|
| 1279 | 1340 | |
| 1280 | 1341 | // Break it up in lines (mail body). |
| 1281 | - else |
|
| 1282 | - $string = chunk_split($string, 76, $line_break); |
|
| 1342 | + else { |
|
| 1343 | + $string = chunk_split($string, 76, $line_break); |
|
| 1344 | + } |
|
| 1283 | 1345 | |
| 1284 | 1346 | return array($charset, $string, 'base64'); |
| 1347 | + } else { |
|
| 1348 | + return array($charset, $string, '7bit'); |
|
| 1349 | + } |
|
| 1285 | 1350 | } |
| 1286 | - |
|
| 1287 | - else |
|
| 1288 | - return array($charset, $string, '7bit'); |
|
| 1289 | -} |
|
| 1290 | 1351 | |
| 1291 | 1352 | /** |
| 1292 | 1353 | * Sends mail, like mail() but over SMTP. |
@@ -1310,8 +1371,9 @@ discard block |
||
| 1310 | 1371 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
| 1311 | 1372 | { |
| 1312 | 1373 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
| 1313 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
| 1314 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
| 1374 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
| 1375 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
| 1376 | + } |
|
| 1315 | 1377 | |
| 1316 | 1378 | if ($socket) |
| 1317 | 1379 | { |
@@ -1332,8 +1394,9 @@ discard block |
||
| 1332 | 1394 | // Maybe we can still save this? The port might be wrong. |
| 1333 | 1395 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
| 1334 | 1396 | { |
| 1335 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
| 1336 | - log_error($txt['smtp_port_ssl']); |
|
| 1397 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
| 1398 | + log_error($txt['smtp_port_ssl']); |
|
| 1399 | + } |
|
| 1337 | 1400 | } |
| 1338 | 1401 | |
| 1339 | 1402 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1345,20 +1408,23 @@ discard block |
||
| 1345 | 1408 | } |
| 1346 | 1409 | |
| 1347 | 1410 | // Wait for a response of 220, without "-" continuer. |
| 1348 | - if (!server_parse(null, $socket, '220')) |
|
| 1349 | - return false; |
|
| 1411 | + if (!server_parse(null, $socket, '220')) { |
|
| 1412 | + return false; |
|
| 1413 | + } |
|
| 1350 | 1414 | |
| 1351 | 1415 | // Try and determine the servers name, fall back to the mail servers if not found |
| 1352 | 1416 | $helo = false; |
| 1353 | - if (function_exists('gethostname') && gethostname() !== false) |
|
| 1354 | - $helo = gethostname(); |
|
| 1355 | - elseif (function_exists('php_uname')) |
|
| 1356 | - $helo = php_uname('n'); |
|
| 1357 | - elseif (array_key_exists('SERVER_NAME',$_SERVER) && !empty($_SERVER['SERVER_NAME'])) |
|
| 1358 | - $helo = $_SERVER['SERVER_NAME']; |
|
| 1417 | + if (function_exists('gethostname') && gethostname() !== false) { |
|
| 1418 | + $helo = gethostname(); |
|
| 1419 | + } elseif (function_exists('php_uname')) { |
|
| 1420 | + $helo = php_uname('n'); |
|
| 1421 | + } elseif (array_key_exists('SERVER_NAME',$_SERVER) && !empty($_SERVER['SERVER_NAME'])) { |
|
| 1422 | + $helo = $_SERVER['SERVER_NAME']; |
|
| 1423 | + } |
|
| 1359 | 1424 | |
| 1360 | - if (empty($helo)) |
|
| 1361 | - $helo = $modSettings['smtp_host']; |
|
| 1425 | + if (empty($helo)) { |
|
| 1426 | + $helo = $modSettings['smtp_host']; |
|
| 1427 | + } |
|
| 1362 | 1428 | |
| 1363 | 1429 | // SMTP = 1, SMTP - STARTTLS = 2 |
| 1364 | 1430 | if (in_array($modSettings['mail_type'], array(1,2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
@@ -1370,33 +1436,39 @@ discard block |
||
| 1370 | 1436 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
| 1371 | 1437 | { |
| 1372 | 1438 | // Send STARTTLS to enable encryption |
| 1373 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
| 1374 | - return false; |
|
| 1439 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
| 1440 | + return false; |
|
| 1441 | + } |
|
| 1375 | 1442 | // Enable the encryption |
| 1376 | - if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) |
|
| 1377 | - return false; |
|
| 1443 | + if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
| 1444 | + return false; |
|
| 1445 | + } |
|
| 1378 | 1446 | // Send the EHLO command again |
| 1379 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
| 1380 | - return false; |
|
| 1447 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
| 1448 | + return false; |
|
| 1449 | + } |
|
| 1381 | 1450 | } |
| 1382 | 1451 | |
| 1383 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
| 1384 | - return false; |
|
| 1452 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
| 1453 | + return false; |
|
| 1454 | + } |
|
| 1385 | 1455 | // Send the username and password, encoded. |
| 1386 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
| 1387 | - return false; |
|
| 1456 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
| 1457 | + return false; |
|
| 1458 | + } |
|
| 1388 | 1459 | // The password is already encoded ;) |
| 1389 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
| 1390 | - return false; |
|
| 1460 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
| 1461 | + return false; |
|
| 1462 | + } |
|
| 1463 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
| 1464 | + return false; |
|
| 1391 | 1465 | } |
| 1392 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
| 1393 | - return false; |
|
| 1394 | - } |
|
| 1395 | - else |
|
| 1466 | + } else |
|
| 1396 | 1467 | { |
| 1397 | 1468 | // Just say "helo". |
| 1398 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
| 1399 | - return false; |
|
| 1469 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
| 1470 | + return false; |
|
| 1471 | + } |
|
| 1400 | 1472 | } |
| 1401 | 1473 | |
| 1402 | 1474 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1409,31 +1481,38 @@ discard block |
||
| 1409 | 1481 | // Reset the connection to send another email. |
| 1410 | 1482 | if ($i != 0) |
| 1411 | 1483 | { |
| 1412 | - if (!server_parse('RSET', $socket, '250')) |
|
| 1413 | - return false; |
|
| 1484 | + if (!server_parse('RSET', $socket, '250')) { |
|
| 1485 | + return false; |
|
| 1486 | + } |
|
| 1414 | 1487 | } |
| 1415 | 1488 | |
| 1416 | 1489 | // From, to, and then start the data... |
| 1417 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
| 1418 | - return false; |
|
| 1419 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
| 1420 | - return false; |
|
| 1421 | - if (!server_parse('DATA', $socket, '354')) |
|
| 1422 | - return false; |
|
| 1490 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
| 1491 | + return false; |
|
| 1492 | + } |
|
| 1493 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
| 1494 | + return false; |
|
| 1495 | + } |
|
| 1496 | + if (!server_parse('DATA', $socket, '354')) { |
|
| 1497 | + return false; |
|
| 1498 | + } |
|
| 1423 | 1499 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
| 1424 | - if (strlen($mail_to) > 0) |
|
| 1425 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
| 1500 | + if (strlen($mail_to) > 0) { |
|
| 1501 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
| 1502 | + } |
|
| 1426 | 1503 | fputs($socket, $headers . "\r\n\r\n"); |
| 1427 | 1504 | fputs($socket, $message . "\r\n"); |
| 1428 | 1505 | |
| 1429 | 1506 | // Send a ., or in other words "end of data". |
| 1430 | - if (!server_parse('.', $socket, '250')) |
|
| 1431 | - return false; |
|
| 1507 | + if (!server_parse('.', $socket, '250')) { |
|
| 1508 | + return false; |
|
| 1509 | + } |
|
| 1432 | 1510 | |
| 1433 | 1511 | // Almost done, almost done... don't stop me just yet! |
| 1434 | 1512 | @set_time_limit(300); |
| 1435 | - if (function_exists('apache_reset_timeout')) |
|
| 1436 | - @apache_reset_timeout(); |
|
| 1513 | + if (function_exists('apache_reset_timeout')) { |
|
| 1514 | + @apache_reset_timeout(); |
|
| 1515 | + } |
|
| 1437 | 1516 | } |
| 1438 | 1517 | fputs($socket, 'QUIT' . "\r\n"); |
| 1439 | 1518 | fclose($socket); |
@@ -1457,8 +1536,9 @@ discard block |
||
| 1457 | 1536 | { |
| 1458 | 1537 | global $txt; |
| 1459 | 1538 | |
| 1460 | - if ($message !== null) |
|
| 1461 | - fputs($socket, $message . "\r\n"); |
|
| 1539 | + if ($message !== null) { |
|
| 1540 | + fputs($socket, $message . "\r\n"); |
|
| 1541 | + } |
|
| 1462 | 1542 | |
| 1463 | 1543 | // No response yet. |
| 1464 | 1544 | $server_response = ''; |
@@ -1474,8 +1554,9 @@ discard block |
||
| 1474 | 1554 | $response .= $server_response; |
| 1475 | 1555 | } |
| 1476 | 1556 | |
| 1477 | - if ($code === null) |
|
| 1478 | - return substr($server_response, 0, 3); |
|
| 1557 | + if ($code === null) { |
|
| 1558 | + return substr($server_response, 0, 3); |
|
| 1559 | + } |
|
| 1479 | 1560 | |
| 1480 | 1561 | if (substr($server_response, 0, 3) != $code) |
| 1481 | 1562 | { |
@@ -1505,8 +1586,9 @@ discard block |
||
| 1505 | 1586 | // Create a pspell or enchant dictionary resource |
| 1506 | 1587 | $dict = spell_init(); |
| 1507 | 1588 | |
| 1508 | - if (!isset($_POST['spellstring']) || !$dict) |
|
| 1509 | - die; |
|
| 1589 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
| 1590 | + die; |
|
| 1591 | + } |
|
| 1510 | 1592 | |
| 1511 | 1593 | // Construct a bit of Javascript code. |
| 1512 | 1594 | $context['spell_js'] = ' |
@@ -1524,8 +1606,9 @@ discard block |
||
| 1524 | 1606 | $check_word = explode('|', $alphas[$i]); |
| 1525 | 1607 | |
| 1526 | 1608 | // If the word is a known word, or spelled right... |
| 1527 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
| 1528 | - continue; |
|
| 1609 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
| 1610 | + continue; |
|
| 1611 | + } |
|
| 1529 | 1612 | |
| 1530 | 1613 | // Find the word, and move up the "last occurrence" to here. |
| 1531 | 1614 | $found_words = true; |
@@ -1539,20 +1622,23 @@ discard block |
||
| 1539 | 1622 | if (!empty($suggestions)) |
| 1540 | 1623 | { |
| 1541 | 1624 | // But first check they aren't going to be censored - no naughty words! |
| 1542 | - foreach ($suggestions as $k => $word) |
|
| 1543 | - if ($suggestions[$k] != censorText($word)) |
|
| 1625 | + foreach ($suggestions as $k => $word) { |
|
| 1626 | + if ($suggestions[$k] != censorText($word)) |
|
| 1544 | 1627 | unset($suggestions[$k]); |
| 1628 | + } |
|
| 1545 | 1629 | |
| 1546 | - if (!empty($suggestions)) |
|
| 1547 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
| 1630 | + if (!empty($suggestions)) { |
|
| 1631 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
| 1632 | + } |
|
| 1548 | 1633 | } |
| 1549 | 1634 | |
| 1550 | 1635 | $context['spell_js'] .= ']),'; |
| 1551 | 1636 | } |
| 1552 | 1637 | |
| 1553 | 1638 | // If words were found, take off the last comma. |
| 1554 | - if ($found_words) |
|
| 1555 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
| 1639 | + if ($found_words) { |
|
| 1640 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
| 1641 | + } |
|
| 1556 | 1642 | |
| 1557 | 1643 | $context['spell_js'] .= ' |
| 1558 | 1644 | );'; |
@@ -1587,11 +1673,13 @@ discard block |
||
| 1587 | 1673 | global $user_info, $smcFunc; |
| 1588 | 1674 | |
| 1589 | 1675 | // Can't do it if there's no topics. |
| 1590 | - if (empty($topics)) |
|
| 1591 | - return; |
|
| 1676 | + if (empty($topics)) { |
|
| 1677 | + return; |
|
| 1678 | + } |
|
| 1592 | 1679 | // It must be an array - it must! |
| 1593 | - if (!is_array($topics)) |
|
| 1594 | - $topics = array($topics); |
|
| 1680 | + if (!is_array($topics)) { |
|
| 1681 | + $topics = array($topics); |
|
| 1682 | + } |
|
| 1595 | 1683 | |
| 1596 | 1684 | // Get the subject and body... |
| 1597 | 1685 | $result = $smcFunc['db_query']('', ' |
@@ -1639,14 +1727,15 @@ discard block |
||
| 1639 | 1727 | } |
| 1640 | 1728 | $smcFunc['db_free_result']($result); |
| 1641 | 1729 | |
| 1642 | - if (!empty($task_rows)) |
|
| 1643 | - $smcFunc['db_insert']('', |
|
| 1730 | + if (!empty($task_rows)) { |
|
| 1731 | + $smcFunc['db_insert']('', |
|
| 1644 | 1732 | '{db_prefix}background_tasks', |
| 1645 | 1733 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 1646 | 1734 | $task_rows, |
| 1647 | 1735 | array('id_task') |
| 1648 | 1736 | ); |
| 1649 | -} |
|
| 1737 | + } |
|
| 1738 | + } |
|
| 1650 | 1739 | |
| 1651 | 1740 | /** |
| 1652 | 1741 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1684,9 +1773,9 @@ discard block |
||
| 1684 | 1773 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
| 1685 | 1774 | |
| 1686 | 1775 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
| 1687 | - if (!$modSettings['postmod_active']) |
|
| 1688 | - $topicOptions['is_approved'] = true; |
|
| 1689 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
| 1776 | + if (!$modSettings['postmod_active']) { |
|
| 1777 | + $topicOptions['is_approved'] = true; |
|
| 1778 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
| 1690 | 1779 | { |
| 1691 | 1780 | $request = $smcFunc['db_query']('', ' |
| 1692 | 1781 | SELECT approved |
@@ -1709,8 +1798,7 @@ discard block |
||
| 1709 | 1798 | $posterOptions['id'] = 0; |
| 1710 | 1799 | $posterOptions['name'] = $txt['guest_title']; |
| 1711 | 1800 | $posterOptions['email'] = ''; |
| 1712 | - } |
|
| 1713 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
| 1801 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
| 1714 | 1802 | { |
| 1715 | 1803 | $request = $smcFunc['db_query']('', ' |
| 1716 | 1804 | SELECT member_name, email_address |
@@ -1728,12 +1816,11 @@ discard block |
||
| 1728 | 1816 | $posterOptions['id'] = 0; |
| 1729 | 1817 | $posterOptions['name'] = $txt['guest_title']; |
| 1730 | 1818 | $posterOptions['email'] = ''; |
| 1819 | + } else { |
|
| 1820 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
| 1731 | 1821 | } |
| 1732 | - else |
|
| 1733 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
| 1734 | 1822 | $smcFunc['db_free_result']($request); |
| 1735 | - } |
|
| 1736 | - else |
|
| 1823 | + } else |
|
| 1737 | 1824 | { |
| 1738 | 1825 | $posterOptions['name'] = $user_info['name']; |
| 1739 | 1826 | $posterOptions['email'] = $user_info['email']; |
@@ -1743,8 +1830,9 @@ discard block |
||
| 1743 | 1830 | if (!empty($modSettings['enable_mentions'])) |
| 1744 | 1831 | { |
| 1745 | 1832 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
| 1746 | - if (!empty($msgOptions['mentioned_members'])) |
|
| 1747 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
| 1833 | + if (!empty($msgOptions['mentioned_members'])) { |
|
| 1834 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
| 1835 | + } |
|
| 1748 | 1836 | } |
| 1749 | 1837 | |
| 1750 | 1838 | // It's do or die time: forget any user aborts! |
@@ -1777,12 +1865,13 @@ discard block |
||
| 1777 | 1865 | $msgOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg'); |
| 1778 | 1866 | |
| 1779 | 1867 | // Something went wrong creating the message... |
| 1780 | - if (empty($msgOptions['id'])) |
|
| 1781 | - return false; |
|
| 1868 | + if (empty($msgOptions['id'])) { |
|
| 1869 | + return false; |
|
| 1870 | + } |
|
| 1782 | 1871 | |
| 1783 | 1872 | // Fix the attachments. |
| 1784 | - if (!empty($msgOptions['attachments'])) |
|
| 1785 | - $smcFunc['db_query']('', ' |
|
| 1873 | + if (!empty($msgOptions['attachments'])) { |
|
| 1874 | + $smcFunc['db_query']('', ' |
|
| 1786 | 1875 | UPDATE {db_prefix}attachments |
| 1787 | 1876 | SET id_msg = {int:id_msg} |
| 1788 | 1877 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1791,6 +1880,7 @@ discard block |
||
| 1791 | 1880 | 'id_msg' => $msgOptions['id'], |
| 1792 | 1881 | ) |
| 1793 | 1882 | ); |
| 1883 | + } |
|
| 1794 | 1884 | |
| 1795 | 1885 | // What if we want to export new posts out to a CMS? |
| 1796 | 1886 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1868,20 +1958,23 @@ discard block |
||
| 1868 | 1958 | 'counter_increment' => 1, |
| 1869 | 1959 | ); |
| 1870 | 1960 | $topics_columns = array(); |
| 1871 | - if ($msgOptions['approved']) |
|
| 1872 | - $topics_columns = array( |
|
| 1961 | + if ($msgOptions['approved']) { |
|
| 1962 | + $topics_columns = array( |
|
| 1873 | 1963 | 'id_member_updated = {int:poster_id}', |
| 1874 | 1964 | 'id_last_msg = {int:id_msg}', |
| 1875 | 1965 | 'num_replies = num_replies + {int:counter_increment}', |
| 1876 | 1966 | ); |
| 1877 | - else |
|
| 1878 | - $topics_columns = array( |
|
| 1967 | + } else { |
|
| 1968 | + $topics_columns = array( |
|
| 1879 | 1969 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
| 1880 | 1970 | ); |
| 1881 | - if ($topicOptions['lock_mode'] !== null) |
|
| 1882 | - $topics_columns[] = 'locked = {int:locked}'; |
|
| 1883 | - if ($topicOptions['sticky_mode'] !== null) |
|
| 1884 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 1971 | + } |
|
| 1972 | + if ($topicOptions['lock_mode'] !== null) { |
|
| 1973 | + $topics_columns[] = 'locked = {int:locked}'; |
|
| 1974 | + } |
|
| 1975 | + if ($topicOptions['sticky_mode'] !== null) { |
|
| 1976 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 1977 | + } |
|
| 1885 | 1978 | |
| 1886 | 1979 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
| 1887 | 1980 | |
@@ -1910,8 +2003,8 @@ discard block |
||
| 1910 | 2003 | ); |
| 1911 | 2004 | |
| 1912 | 2005 | // Increase the number of posts and topics on the board. |
| 1913 | - if ($msgOptions['approved']) |
|
| 1914 | - $smcFunc['db_query']('', ' |
|
| 2006 | + if ($msgOptions['approved']) { |
|
| 2007 | + $smcFunc['db_query']('', ' |
|
| 1915 | 2008 | UPDATE {db_prefix}boards |
| 1916 | 2009 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
| 1917 | 2010 | WHERE id_board = {int:id_board}', |
@@ -1919,7 +2012,7 @@ discard block |
||
| 1919 | 2012 | 'id_board' => $topicOptions['board'], |
| 1920 | 2013 | ) |
| 1921 | 2014 | ); |
| 1922 | - else |
|
| 2015 | + } else |
|
| 1923 | 2016 | { |
| 1924 | 2017 | $smcFunc['db_query']('', ' |
| 1925 | 2018 | UPDATE {db_prefix}boards |
@@ -1989,8 +2082,8 @@ discard block |
||
| 1989 | 2082 | } |
| 1990 | 2083 | } |
| 1991 | 2084 | |
| 1992 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
| 1993 | - $smcFunc['db_insert']('', |
|
| 2085 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
| 2086 | + $smcFunc['db_insert']('', |
|
| 1994 | 2087 | '{db_prefix}background_tasks', |
| 1995 | 2088 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 1996 | 2089 | array( |
@@ -2002,19 +2095,22 @@ discard block |
||
| 2002 | 2095 | ), |
| 2003 | 2096 | array('id_task') |
| 2004 | 2097 | ); |
| 2098 | + } |
|
| 2005 | 2099 | |
| 2006 | 2100 | // If there's a custom search index, it may need updating... |
| 2007 | 2101 | require_once($sourcedir . '/Search.php'); |
| 2008 | 2102 | $searchAPI = findSearchAPI(); |
| 2009 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
| 2010 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 2103 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
| 2104 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 2105 | + } |
|
| 2011 | 2106 | |
| 2012 | 2107 | // Increase the post counter for the user that created the post. |
| 2013 | 2108 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
| 2014 | 2109 | { |
| 2015 | 2110 | // Are you the one that happened to create this post? |
| 2016 | - if ($user_info['id'] == $posterOptions['id']) |
|
| 2017 | - $user_info['posts']++; |
|
| 2111 | + if ($user_info['id'] == $posterOptions['id']) { |
|
| 2112 | + $user_info['posts']++; |
|
| 2113 | + } |
|
| 2018 | 2114 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
| 2019 | 2115 | } |
| 2020 | 2116 | |
@@ -2022,19 +2118,21 @@ discard block |
||
| 2022 | 2118 | $_SESSION['last_read_topic'] = 0; |
| 2023 | 2119 | |
| 2024 | 2120 | // Better safe than sorry. |
| 2025 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
| 2026 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 2121 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
| 2122 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 2123 | + } |
|
| 2027 | 2124 | |
| 2028 | 2125 | // Update all the stats so everyone knows about this new topic and message. |
| 2029 | 2126 | updateStats('message', true, $msgOptions['id']); |
| 2030 | 2127 | |
| 2031 | 2128 | // Update the last message on the board assuming it's approved AND the topic is. |
| 2032 | - if ($msgOptions['approved']) |
|
| 2033 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 2129 | + if ($msgOptions['approved']) { |
|
| 2130 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 2131 | + } |
|
| 2034 | 2132 | |
| 2035 | 2133 | // Queue createPost background notification |
| 2036 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
| 2037 | - $smcFunc['db_insert']('', |
|
| 2134 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
| 2135 | + $smcFunc['db_insert']('', |
|
| 2038 | 2136 | '{db_prefix}background_tasks', |
| 2039 | 2137 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2040 | 2138 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array( |
@@ -2045,6 +2143,7 @@ discard block |
||
| 2045 | 2143 | )), 0), |
| 2046 | 2144 | array('id_task') |
| 2047 | 2145 | ); |
| 2146 | + } |
|
| 2048 | 2147 | |
| 2049 | 2148 | // Alright, done now... we can abort now, I guess... at least this much is done. |
| 2050 | 2149 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2071,14 +2170,18 @@ discard block |
||
| 2071 | 2170 | |
| 2072 | 2171 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
| 2073 | 2172 | $messages_columns = array(); |
| 2074 | - if (isset($posterOptions['name'])) |
|
| 2075 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 2076 | - if (isset($posterOptions['email'])) |
|
| 2077 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 2078 | - if (isset($msgOptions['icon'])) |
|
| 2079 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
| 2080 | - if (isset($msgOptions['subject'])) |
|
| 2081 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
| 2173 | + if (isset($posterOptions['name'])) { |
|
| 2174 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 2175 | + } |
|
| 2176 | + if (isset($posterOptions['email'])) { |
|
| 2177 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 2178 | + } |
|
| 2179 | + if (isset($msgOptions['icon'])) { |
|
| 2180 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
| 2181 | + } |
|
| 2182 | + if (isset($msgOptions['subject'])) { |
|
| 2183 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
| 2184 | + } |
|
| 2082 | 2185 | if (isset($msgOptions['body'])) |
| 2083 | 2186 | { |
| 2084 | 2187 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2105,8 +2208,9 @@ discard block |
||
| 2105 | 2208 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
| 2106 | 2209 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
| 2107 | 2210 | } |
| 2108 | - if (isset($msgOptions['smileys_enabled'])) |
|
| 2109 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 2211 | + if (isset($msgOptions['smileys_enabled'])) { |
|
| 2212 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 2213 | + } |
|
| 2110 | 2214 | |
| 2111 | 2215 | // Which columns need to be ints? |
| 2112 | 2216 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2124,23 +2228,27 @@ discard block |
||
| 2124 | 2228 | { |
| 2125 | 2229 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
| 2126 | 2230 | |
| 2127 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
| 2128 | - foreach($match[1] as $i => $oldID) |
|
| 2231 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
| 2232 | + foreach($match[1] as $i => $oldID) |
|
| 2129 | 2233 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
| 2234 | + } |
|
| 2130 | 2235 | |
| 2131 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 2132 | - unset($msgOptions['old_body']); |
|
| 2236 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 2237 | + unset($msgOptions['old_body']); |
|
| 2238 | + } |
|
| 2133 | 2239 | } |
| 2134 | 2240 | |
| 2135 | 2241 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
| 2136 | 2242 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
| 2137 | 2243 | |
| 2138 | 2244 | // Remove the poster. |
| 2139 | - if(isset($mentions[$user_info['id']])) |
|
| 2140 | - unset($mentions[$user_info['id']]); |
|
| 2245 | + if(isset($mentions[$user_info['id']])) { |
|
| 2246 | + unset($mentions[$user_info['id']]); |
|
| 2247 | + } |
|
| 2141 | 2248 | |
| 2142 | - if(isset($oldmentions[$user_info['id']])) |
|
| 2143 | - unset($oldmentions[$user_info['id']]); |
|
| 2249 | + if(isset($oldmentions[$user_info['id']])) { |
|
| 2250 | + unset($oldmentions[$user_info['id']]); |
|
| 2251 | + } |
|
| 2144 | 2252 | |
| 2145 | 2253 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
| 2146 | 2254 | { |
@@ -2170,8 +2278,9 @@ discard block |
||
| 2170 | 2278 | } |
| 2171 | 2279 | |
| 2172 | 2280 | // Nothing to do? |
| 2173 | - if (empty($messages_columns)) |
|
| 2174 | - return true; |
|
| 2281 | + if (empty($messages_columns)) { |
|
| 2282 | + return true; |
|
| 2283 | + } |
|
| 2175 | 2284 | |
| 2176 | 2285 | // Change the post. |
| 2177 | 2286 | $smcFunc['db_query']('', ' |
@@ -2232,8 +2341,9 @@ discard block |
||
| 2232 | 2341 | // If there's a custom search index, it needs to be modified... |
| 2233 | 2342 | require_once($sourcedir . '/Search.php'); |
| 2234 | 2343 | $searchAPI = findSearchAPI(); |
| 2235 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
| 2236 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 2344 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
| 2345 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 2346 | + } |
|
| 2237 | 2347 | |
| 2238 | 2348 | if (isset($msgOptions['subject'])) |
| 2239 | 2349 | { |
@@ -2247,14 +2357,16 @@ discard block |
||
| 2247 | 2357 | 'id_first_msg' => $msgOptions['id'], |
| 2248 | 2358 | ) |
| 2249 | 2359 | ); |
| 2250 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 2251 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
| 2360 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 2361 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
| 2362 | + } |
|
| 2252 | 2363 | $smcFunc['db_free_result']($request); |
| 2253 | 2364 | } |
| 2254 | 2365 | |
| 2255 | 2366 | // Finally, if we are setting the approved state we need to do much more work :( |
| 2256 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
| 2257 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 2367 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
| 2368 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 2369 | + } |
|
| 2258 | 2370 | |
| 2259 | 2371 | return true; |
| 2260 | 2372 | } |
@@ -2271,11 +2383,13 @@ discard block |
||
| 2271 | 2383 | { |
| 2272 | 2384 | global $smcFunc; |
| 2273 | 2385 | |
| 2274 | - if (!is_array($msgs)) |
|
| 2275 | - $msgs = array($msgs); |
|
| 2386 | + if (!is_array($msgs)) { |
|
| 2387 | + $msgs = array($msgs); |
|
| 2388 | + } |
|
| 2276 | 2389 | |
| 2277 | - if (empty($msgs)) |
|
| 2278 | - return false; |
|
| 2390 | + if (empty($msgs)) { |
|
| 2391 | + return false; |
|
| 2392 | + } |
|
| 2279 | 2393 | |
| 2280 | 2394 | // May as well start at the beginning, working out *what* we need to change. |
| 2281 | 2395 | $request = $smcFunc['db_query']('', ' |
@@ -2307,20 +2421,22 @@ discard block |
||
| 2307 | 2421 | $topics[] = $row['id_topic']; |
| 2308 | 2422 | |
| 2309 | 2423 | // Ensure our change array exists already. |
| 2310 | - if (!isset($topic_changes[$row['id_topic']])) |
|
| 2311 | - $topic_changes[$row['id_topic']] = array( |
|
| 2424 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
| 2425 | + $topic_changes[$row['id_topic']] = array( |
|
| 2312 | 2426 | 'id_last_msg' => $row['id_last_msg'], |
| 2313 | 2427 | 'approved' => $row['topic_approved'], |
| 2314 | 2428 | 'replies' => 0, |
| 2315 | 2429 | 'unapproved_posts' => 0, |
| 2316 | 2430 | ); |
| 2317 | - if (!isset($board_changes[$row['id_board']])) |
|
| 2318 | - $board_changes[$row['id_board']] = array( |
|
| 2431 | + } |
|
| 2432 | + if (!isset($board_changes[$row['id_board']])) { |
|
| 2433 | + $board_changes[$row['id_board']] = array( |
|
| 2319 | 2434 | 'posts' => 0, |
| 2320 | 2435 | 'topics' => 0, |
| 2321 | 2436 | 'unapproved_posts' => 0, |
| 2322 | 2437 | 'unapproved_topics' => 0, |
| 2323 | 2438 | ); |
| 2439 | + } |
|
| 2324 | 2440 | |
| 2325 | 2441 | // If it's the first message then the topic state changes! |
| 2326 | 2442 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2341,14 +2457,13 @@ discard block |
||
| 2341 | 2457 | 'poster' => $row['id_member'], |
| 2342 | 2458 | 'new_topic' => true, |
| 2343 | 2459 | ); |
| 2344 | - } |
|
| 2345 | - else |
|
| 2460 | + } else |
|
| 2346 | 2461 | { |
| 2347 | 2462 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
| 2348 | 2463 | |
| 2349 | 2464 | // This will be a post... but don't notify unless it's not followed by approved ones. |
| 2350 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
| 2351 | - $notification_posts[$row['id_topic']] = array( |
|
| 2465 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
| 2466 | + $notification_posts[$row['id_topic']] = array( |
|
| 2352 | 2467 | 'id' => $row['id_msg'], |
| 2353 | 2468 | 'body' => $row['body'], |
| 2354 | 2469 | 'subject' => $row['subject'], |
@@ -2359,28 +2474,33 @@ discard block |
||
| 2359 | 2474 | 'new_topic' => false, |
| 2360 | 2475 | 'msg' => $row['id_msg'], |
| 2361 | 2476 | ); |
| 2477 | + } |
|
| 2362 | 2478 | } |
| 2363 | 2479 | |
| 2364 | 2480 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
| 2365 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
| 2366 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 2481 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
| 2482 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 2483 | + } |
|
| 2367 | 2484 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
| 2368 | - elseif (!$approve) |
|
| 2369 | - // Default to the first message and then we'll override in a bit ;) |
|
| 2485 | + elseif (!$approve) { |
|
| 2486 | + // Default to the first message and then we'll override in a bit ;) |
|
| 2370 | 2487 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
| 2488 | + } |
|
| 2371 | 2489 | |
| 2372 | 2490 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
| 2373 | 2491 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
| 2374 | 2492 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
| 2375 | 2493 | |
| 2376 | 2494 | // Post count for the user? |
| 2377 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
| 2378 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 2495 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
| 2496 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 2497 | + } |
|
| 2379 | 2498 | } |
| 2380 | 2499 | $smcFunc['db_free_result']($request); |
| 2381 | 2500 | |
| 2382 | - if (empty($msgs)) |
|
| 2383 | - return; |
|
| 2501 | + if (empty($msgs)) { |
|
| 2502 | + return; |
|
| 2503 | + } |
|
| 2384 | 2504 | |
| 2385 | 2505 | // Now we have the differences make the changes, first the easy one. |
| 2386 | 2506 | $smcFunc['db_query']('', ' |
@@ -2407,14 +2527,15 @@ discard block |
||
| 2407 | 2527 | 'approved' => 1, |
| 2408 | 2528 | ) |
| 2409 | 2529 | ); |
| 2410 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2411 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 2530 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2531 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 2532 | + } |
|
| 2412 | 2533 | $smcFunc['db_free_result']($request); |
| 2413 | 2534 | } |
| 2414 | 2535 | |
| 2415 | 2536 | // ... next the topics... |
| 2416 | - foreach ($topic_changes as $id => $changes) |
|
| 2417 | - $smcFunc['db_query']('', ' |
|
| 2537 | + foreach ($topic_changes as $id => $changes) { |
|
| 2538 | + $smcFunc['db_query']('', ' |
|
| 2418 | 2539 | UPDATE {db_prefix}topics |
| 2419 | 2540 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
| 2420 | 2541 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2427,10 +2548,11 @@ discard block |
||
| 2427 | 2548 | 'id_topic' => $id, |
| 2428 | 2549 | ) |
| 2429 | 2550 | ); |
| 2551 | + } |
|
| 2430 | 2552 | |
| 2431 | 2553 | // ... finally the boards... |
| 2432 | - foreach ($board_changes as $id => $changes) |
|
| 2433 | - $smcFunc['db_query']('', ' |
|
| 2554 | + foreach ($board_changes as $id => $changes) { |
|
| 2555 | + $smcFunc['db_query']('', ' |
|
| 2434 | 2556 | UPDATE {db_prefix}boards |
| 2435 | 2557 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
| 2436 | 2558 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2443,13 +2565,14 @@ discard block |
||
| 2443 | 2565 | 'id_board' => $id, |
| 2444 | 2566 | ) |
| 2445 | 2567 | ); |
| 2568 | + } |
|
| 2446 | 2569 | |
| 2447 | 2570 | // Finally, least importantly, notifications! |
| 2448 | 2571 | if ($approve) |
| 2449 | 2572 | { |
| 2450 | 2573 | $task_rows = array(); |
| 2451 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
| 2452 | - $task_rows[] = array( |
|
| 2574 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
| 2575 | + $task_rows[] = array( |
|
| 2453 | 2576 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array( |
| 2454 | 2577 | 'msgOptions' => array( |
| 2455 | 2578 | 'id' => $topic['msg'], |
@@ -2467,14 +2590,16 @@ discard block |
||
| 2467 | 2590 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
| 2468 | 2591 | )), 0 |
| 2469 | 2592 | ); |
| 2593 | + } |
|
| 2470 | 2594 | |
| 2471 | - if ($notify) |
|
| 2472 | - $smcFunc['db_insert']('', |
|
| 2595 | + if ($notify) { |
|
| 2596 | + $smcFunc['db_insert']('', |
|
| 2473 | 2597 | '{db_prefix}background_tasks', |
| 2474 | 2598 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2475 | 2599 | $task_rows, |
| 2476 | 2600 | array('id_task') |
| 2477 | 2601 | ); |
| 2602 | + } |
|
| 2478 | 2603 | |
| 2479 | 2604 | $smcFunc['db_query']('', ' |
| 2480 | 2605 | DELETE FROM {db_prefix}approval_queue |
@@ -2490,8 +2615,9 @@ discard block |
||
| 2490 | 2615 | else |
| 2491 | 2616 | { |
| 2492 | 2617 | $msgInserts = array(); |
| 2493 | - foreach ($msgs as $msg) |
|
| 2494 | - $msgInserts[] = array($msg); |
|
| 2618 | + foreach ($msgs as $msg) { |
|
| 2619 | + $msgInserts[] = array($msg); |
|
| 2620 | + } |
|
| 2495 | 2621 | |
| 2496 | 2622 | $smcFunc['db_insert']('ignore', |
| 2497 | 2623 | '{db_prefix}approval_queue', |
@@ -2505,9 +2631,10 @@ discard block |
||
| 2505 | 2631 | updateLastMessages(array_keys($board_changes)); |
| 2506 | 2632 | |
| 2507 | 2633 | // Post count for the members? |
| 2508 | - if (!empty($member_post_changes)) |
|
| 2509 | - foreach ($member_post_changes as $id_member => $count_change) |
|
| 2634 | + if (!empty($member_post_changes)) { |
|
| 2635 | + foreach ($member_post_changes as $id_member => $count_change) |
|
| 2510 | 2636 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
| 2637 | + } |
|
| 2511 | 2638 | |
| 2512 | 2639 | return true; |
| 2513 | 2640 | } |
@@ -2524,11 +2651,13 @@ discard block |
||
| 2524 | 2651 | { |
| 2525 | 2652 | global $smcFunc; |
| 2526 | 2653 | |
| 2527 | - if (!is_array($topics)) |
|
| 2528 | - $topics = array($topics); |
|
| 2654 | + if (!is_array($topics)) { |
|
| 2655 | + $topics = array($topics); |
|
| 2656 | + } |
|
| 2529 | 2657 | |
| 2530 | - if (empty($topics)) |
|
| 2531 | - return false; |
|
| 2658 | + if (empty($topics)) { |
|
| 2659 | + return false; |
|
| 2660 | + } |
|
| 2532 | 2661 | |
| 2533 | 2662 | $approve_type = $approve ? 0 : 1; |
| 2534 | 2663 | |
@@ -2544,8 +2673,9 @@ discard block |
||
| 2544 | 2673 | ) |
| 2545 | 2674 | ); |
| 2546 | 2675 | $msgs = array(); |
| 2547 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2548 | - $msgs[] = $row['id_msg']; |
|
| 2676 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2677 | + $msgs[] = $row['id_msg']; |
|
| 2678 | + } |
|
| 2549 | 2679 | $smcFunc['db_free_result']($request); |
| 2550 | 2680 | |
| 2551 | 2681 | return approvePosts($msgs, $approve); |
@@ -2568,11 +2698,13 @@ discard block |
||
| 2568 | 2698 | global $board_info, $board, $smcFunc; |
| 2569 | 2699 | |
| 2570 | 2700 | // Please - let's be sane. |
| 2571 | - if (empty($setboards)) |
|
| 2572 | - return false; |
|
| 2701 | + if (empty($setboards)) { |
|
| 2702 | + return false; |
|
| 2703 | + } |
|
| 2573 | 2704 | |
| 2574 | - if (!is_array($setboards)) |
|
| 2575 | - $setboards = array($setboards); |
|
| 2705 | + if (!is_array($setboards)) { |
|
| 2706 | + $setboards = array($setboards); |
|
| 2707 | + } |
|
| 2576 | 2708 | |
| 2577 | 2709 | // If we don't know the id_msg we need to find it. |
| 2578 | 2710 | if (!$id_msg) |
@@ -2590,15 +2722,16 @@ discard block |
||
| 2590 | 2722 | ) |
| 2591 | 2723 | ); |
| 2592 | 2724 | $lastMsg = array(); |
| 2593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2594 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 2725 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2726 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 2727 | + } |
|
| 2595 | 2728 | $smcFunc['db_free_result']($request); |
| 2596 | - } |
|
| 2597 | - else |
|
| 2729 | + } else |
|
| 2598 | 2730 | { |
| 2599 | 2731 | // Just to note - there should only be one board passed if we are doing this. |
| 2600 | - foreach ($setboards as $id_board) |
|
| 2601 | - $lastMsg[$id_board] = $id_msg; |
|
| 2732 | + foreach ($setboards as $id_board) { |
|
| 2733 | + $lastMsg[$id_board] = $id_msg; |
|
| 2734 | + } |
|
| 2602 | 2735 | } |
| 2603 | 2736 | |
| 2604 | 2737 | $parent_boards = array(); |
@@ -2613,10 +2746,11 @@ discard block |
||
| 2613 | 2746 | $lastModified[$id_board] = 0; |
| 2614 | 2747 | } |
| 2615 | 2748 | |
| 2616 | - if (!empty($board) && $id_board == $board) |
|
| 2617 | - $parents = $board_info['parent_boards']; |
|
| 2618 | - else |
|
| 2619 | - $parents = getBoardParents($id_board); |
|
| 2749 | + if (!empty($board) && $id_board == $board) { |
|
| 2750 | + $parents = $board_info['parent_boards']; |
|
| 2751 | + } else { |
|
| 2752 | + $parents = getBoardParents($id_board); |
|
| 2753 | + } |
|
| 2620 | 2754 | |
| 2621 | 2755 | // Ignore any parents on the top child level. |
| 2622 | 2756 | // @todo Why? |
@@ -2625,10 +2759,11 @@ discard block |
||
| 2625 | 2759 | if ($parent['level'] != 0) |
| 2626 | 2760 | { |
| 2627 | 2761 | // If we're already doing this one as a board, is this a higher last modified? |
| 2628 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
| 2629 | - $lastModified[$id] = $lastModified[$id_board]; |
|
| 2630 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
| 2631 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
| 2762 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
| 2763 | + $lastModified[$id] = $lastModified[$id_board]; |
|
| 2764 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
| 2765 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
| 2766 | + } |
|
| 2632 | 2767 | } |
| 2633 | 2768 | } |
| 2634 | 2769 | } |
@@ -2641,23 +2776,24 @@ discard block |
||
| 2641 | 2776 | // Finally, to save on queries make the changes... |
| 2642 | 2777 | foreach ($parent_boards as $id => $msg) |
| 2643 | 2778 | { |
| 2644 | - if (!isset($parent_updates[$msg])) |
|
| 2645 | - $parent_updates[$msg] = array($id); |
|
| 2646 | - else |
|
| 2647 | - $parent_updates[$msg][] = $id; |
|
| 2779 | + if (!isset($parent_updates[$msg])) { |
|
| 2780 | + $parent_updates[$msg] = array($id); |
|
| 2781 | + } else { |
|
| 2782 | + $parent_updates[$msg][] = $id; |
|
| 2783 | + } |
|
| 2648 | 2784 | } |
| 2649 | 2785 | |
| 2650 | 2786 | foreach ($lastMsg as $id => $msg) |
| 2651 | 2787 | { |
| 2652 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
| 2653 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 2788 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
| 2789 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 2654 | 2790 | 'id' => $msg, |
| 2655 | 2791 | 'updated' => $lastModified[$id], |
| 2656 | 2792 | 'boards' => array($id) |
| 2657 | 2793 | ); |
| 2658 | - |
|
| 2659 | - else |
|
| 2660 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 2794 | + } else { |
|
| 2795 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 2796 | + } |
|
| 2661 | 2797 | } |
| 2662 | 2798 | |
| 2663 | 2799 | // Now commit the changes! |
@@ -2749,11 +2885,13 @@ discard block |
||
| 2749 | 2885 | global $txt, $mbname, $scripturl, $settings; |
| 2750 | 2886 | |
| 2751 | 2887 | // First things first, load up the email templates language file, if we need to. |
| 2752 | - if ($loadLang) |
|
| 2753 | - loadLanguage('EmailTemplates', $lang); |
|
| 2888 | + if ($loadLang) { |
|
| 2889 | + loadLanguage('EmailTemplates', $lang); |
|
| 2890 | + } |
|
| 2754 | 2891 | |
| 2755 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
| 2756 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
| 2892 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
| 2893 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
| 2894 | + } |
|
| 2757 | 2895 | |
| 2758 | 2896 | $ret = array( |
| 2759 | 2897 | 'subject' => $txt[$template . '_subject'], |
@@ -2803,17 +2941,18 @@ discard block |
||
| 2803 | 2941 | function user_info_callback($matches) |
| 2804 | 2942 | { |
| 2805 | 2943 | global $user_info; |
| 2806 | - if (empty($matches[1])) |
|
| 2807 | - return ''; |
|
| 2944 | + if (empty($matches[1])) { |
|
| 2945 | + return ''; |
|
| 2946 | + } |
|
| 2808 | 2947 | |
| 2809 | 2948 | $use_ref = true; |
| 2810 | 2949 | $ref = &$user_info; |
| 2811 | 2950 | |
| 2812 | 2951 | foreach (explode('.', $matches[1]) as $index) |
| 2813 | 2952 | { |
| 2814 | - if ($use_ref && isset($ref[$index])) |
|
| 2815 | - $ref = &$ref[$index]; |
|
| 2816 | - else |
|
| 2953 | + if ($use_ref && isset($ref[$index])) { |
|
| 2954 | + $ref = &$ref[$index]; |
|
| 2955 | + } else |
|
| 2817 | 2956 | { |
| 2818 | 2957 | $use_ref = false; |
| 2819 | 2958 | break; |
@@ -2850,8 +2989,7 @@ discard block |
||
| 2850 | 2989 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
| 2851 | 2990 | { |
| 2852 | 2991 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
| 2853 | - } |
|
| 2854 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
| 2992 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
| 2855 | 2993 | { |
| 2856 | 2994 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
| 2857 | 2995 | } |
@@ -2861,8 +2999,7 @@ discard block |
||
| 2861 | 2999 | { |
| 2862 | 3000 | $context['provider'] = 'enchant'; |
| 2863 | 3001 | return $enchant_link; |
| 2864 | - } |
|
| 2865 | - else |
|
| 3002 | + } else |
|
| 2866 | 3003 | { |
| 2867 | 3004 | // Free up any resources used... |
| 2868 | 3005 | @enchant_broker_free($context['enchant_broker']); |
@@ -2883,8 +3020,9 @@ discard block |
||
| 2883 | 3020 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
| 2884 | 3021 | |
| 2885 | 3022 | // Most people don't have anything but English installed... So we use English as a last resort. |
| 2886 | - if (!$pspell_link) |
|
| 2887 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
| 3023 | + if (!$pspell_link) { |
|
| 3024 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
| 3025 | + } |
|
| 2888 | 3026 | |
| 2889 | 3027 | error_reporting($old); |
| 2890 | 3028 | ob_end_clean(); |
@@ -2924,8 +3062,7 @@ discard block |
||
| 2924 | 3062 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
| 2925 | 3063 | } |
| 2926 | 3064 | return enchant_dict_check($dict, $word); |
| 2927 | - } |
|
| 2928 | - elseif ($context['provider'] == 'pspell') |
|
| 3065 | + } elseif ($context['provider'] == 'pspell') |
|
| 2929 | 3066 | { |
| 2930 | 3067 | return pspell_check($dict, $word); |
| 2931 | 3068 | } |
@@ -2961,13 +3098,11 @@ discard block |
||
| 2961 | 3098 | } |
| 2962 | 3099 | |
| 2963 | 3100 | return $suggestions; |
| 2964 | - } |
|
| 2965 | - else |
|
| 3101 | + } else |
|
| 2966 | 3102 | { |
| 2967 | 3103 | return enchant_dict_suggest($dict, $word); |
| 2968 | 3104 | } |
| 2969 | - } |
|
| 2970 | - elseif ($context['provider'] == 'pspell') |
|
| 3105 | + } elseif ($context['provider'] == 'pspell') |
|
| 2971 | 3106 | { |
| 2972 | 3107 | return pspell_suggest($dict, $word); |
| 2973 | 3108 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Locks a topic... either by way of a moderator or the topic starter. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $topic, $user_info, $sourcedir, $board, $smcFunc; |
| 33 | 34 | |
| 34 | 35 | // Just quit if there's no topic to lock. |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('not_a_topic', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('not_a_topic', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | checkSession('get'); |
| 39 | 41 | |
@@ -55,23 +57,28 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | // Can you lock topics here, mister? |
| 57 | 59 | $user_lock = !allowedTo('lock_any'); |
| 58 | - if ($user_lock && $starter == $user_info['id']) |
|
| 59 | - isAllowedTo('lock_own'); |
|
| 60 | - else |
|
| 61 | - isAllowedTo('lock_any'); |
|
| 60 | + if ($user_lock && $starter == $user_info['id']) { |
|
| 61 | + isAllowedTo('lock_own'); |
|
| 62 | + } else { |
|
| 63 | + isAllowedTo('lock_any'); |
|
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | // Locking with high privileges. |
| 64 | - if ($locked == '0' && !$user_lock) |
|
| 65 | - $locked = '1'; |
|
| 67 | + if ($locked == '0' && !$user_lock) { |
|
| 68 | + $locked = '1'; |
|
| 69 | + } |
|
| 66 | 70 | // Locking with low privileges. |
| 67 | - elseif ($locked == '0') |
|
| 68 | - $locked = '2'; |
|
| 71 | + elseif ($locked == '0') { |
|
| 72 | + $locked = '2'; |
|
| 73 | + } |
|
| 69 | 74 | // Unlocking - make sure you don't unlock what you can't. |
| 70 | - elseif ($locked == '2' || ($locked == '1' && !$user_lock)) |
|
| 71 | - $locked = '0'; |
|
| 75 | + elseif ($locked == '2' || ($locked == '1' && !$user_lock)) { |
|
| 76 | + $locked = '0'; |
|
| 77 | + } |
|
| 72 | 78 | // You cannot unlock this! |
| 73 | - else |
|
| 74 | - fatal_lang_error('locked_by_admin', 'user'); |
|
| 79 | + else { |
|
| 80 | + fatal_lang_error('locked_by_admin', 'user'); |
|
| 81 | + } |
|
| 75 | 82 | |
| 76 | 83 | // Actually lock the topic in the database with the new value. |
| 77 | 84 | $smcFunc['db_query']('', ' |
@@ -85,8 +92,9 @@ discard block |
||
| 85 | 92 | ); |
| 86 | 93 | |
| 87 | 94 | // If they are allowed a "moderator" permission, log it in the moderator log. |
| 88 | - if (!$user_lock) |
|
| 89 | - logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
| 95 | + if (!$user_lock) { |
|
| 96 | + logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
| 97 | + } |
|
| 90 | 98 | // Notify people that this topic has been locked? |
| 91 | 99 | sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); |
| 92 | 100 | |
@@ -112,8 +120,9 @@ discard block |
||
| 112 | 120 | isAllowedTo('make_sticky'); |
| 113 | 121 | |
| 114 | 122 | // You can't sticky a board or something! |
| 115 | - if (empty($topic)) |
|
| 116 | - fatal_lang_error('not_a_topic', false); |
|
| 123 | + if (empty($topic)) { |
|
| 124 | + fatal_lang_error('not_a_topic', false); |
|
| 125 | + } |
|
| 117 | 126 | |
| 118 | 127 | checkSession('get'); |
| 119 | 128 | |
@@ -147,8 +156,9 @@ discard block |
||
| 147 | 156 | // Log this sticky action - always a moderator thing. |
| 148 | 157 | logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); |
| 149 | 158 | // Notify people that this topic has been stickied? |
| 150 | - if (empty($is_sticky)) |
|
| 151 | - sendNotifications($topic, 'sticky'); |
|
| 159 | + if (empty($is_sticky)) { |
|
| 160 | + sendNotifications($topic, 'sticky'); |
|
| 161 | + } |
|
| 152 | 162 | |
| 153 | 163 | // Take them back to the now stickied topic. |
| 154 | 164 | redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
| 37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
| 38 | 39 | |
| 39 | 40 | // For performance, track the latest post while going through the boards. |
| 40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
| 41 | - $latest_post = array( |
|
| 41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
| 42 | + $latest_post = array( |
|
| 42 | 43 | 'timestamp' => 0, |
| 43 | 44 | 'ref' => 0, |
| 44 | 45 | ); |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
| 47 | 49 | $result_boards = $smcFunc['db_query']('boardindex_fetch_boards', ' |
@@ -74,10 +76,11 @@ discard block |
||
| 74 | 76 | ); |
| 75 | 77 | |
| 76 | 78 | // Start with an empty array. |
| 77 | - if ($boardIndexOptions['include_categories']) |
|
| 78 | - $categories = array(); |
|
| 79 | - else |
|
| 80 | - $this_category = array(); |
|
| 79 | + if ($boardIndexOptions['include_categories']) { |
|
| 80 | + $categories = array(); |
|
| 81 | + } else { |
|
| 82 | + $this_category = array(); |
|
| 83 | + } |
|
| 81 | 84 | $boards = array(); |
| 82 | 85 | |
| 83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
| 89 | 92 | |
| 90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
| 91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
| 92 | - $boards[] = $row_board['id_board']; |
|
| 94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
| 95 | + $boards[] = $row_board['id_board']; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | if ($boardIndexOptions['include_categories']) |
| 95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
| 114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
| 115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
| 119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
| 118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -160,14 +165,12 @@ discard block |
||
| 160 | 165 | { |
| 161 | 166 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
| 162 | 167 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
| 163 | - } |
|
| 164 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 168 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 165 | 169 | { |
| 166 | 170 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
| 167 | 171 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
| 168 | 172 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
| 169 | - } |
|
| 170 | - else |
|
| 173 | + } else |
|
| 171 | 174 | { |
| 172 | 175 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
| 173 | 176 | } |
@@ -218,14 +221,16 @@ discard block |
||
| 218 | 221 | // Child of a child... just add it on... |
| 219 | 222 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
| 220 | 223 | { |
| 221 | - if (!isset($parent_map)) |
|
| 222 | - $parent_map = array(); |
|
| 224 | + if (!isset($parent_map)) { |
|
| 225 | + $parent_map = array(); |
|
| 226 | + } |
|
| 223 | 227 | |
| 224 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
| 225 | - foreach ($this_category as $id => $board) |
|
| 228 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
| 229 | + foreach ($this_category as $id => $board) |
|
| 226 | 230 | { |
| 227 | 231 | if (!isset($board['children'][$row_board['id_parent']])) |
| 228 | 232 | continue; |
| 233 | + } |
|
| 229 | 234 | |
| 230 | 235 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
| 231 | 236 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -246,8 +251,9 @@ discard block |
||
| 246 | 251 | continue; |
| 247 | 252 | } |
| 248 | 253 | // Found a child of a child - skip. |
| 249 | - else |
|
| 250 | - continue; |
|
| 254 | + else { |
|
| 255 | + continue; |
|
| 256 | + } |
|
| 251 | 257 | |
| 252 | 258 | // Prepare the subject, and make sure it's not too long. |
| 253 | 259 | censorText($row_board['subject']); |
@@ -268,12 +274,13 @@ discard block |
||
| 268 | 274 | 'topic' => $row_board['id_topic'] |
| 269 | 275 | ); |
| 270 | 276 | |
| 271 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
| 272 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 277 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
| 278 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 273 | 279 | 'avatar' => $row_board['avatar'], |
| 274 | 280 | 'email' => $row_board['email_address'], |
| 275 | 281 | 'filename' => !empty($row['member_filename']) ? $row_board['member_filename'] : '', |
| 276 | 282 | )); |
| 283 | + } |
|
| 277 | 284 | |
| 278 | 285 | // Provide the href and link. |
| 279 | 286 | if ($row_board['subject'] != '') |
@@ -285,8 +292,7 @@ discard block |
||
| 285 | 292 | link, href, subject, start (where they should go for the first unread post.), |
| 286 | 293 | and member. (which has id, name, link, href, username in it.) */ |
| 287 | 294 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
| 288 | - } |
|
| 289 | - else |
|
| 295 | + } else |
|
| 290 | 296 | { |
| 291 | 297 | $this_last_post['href'] = ''; |
| 292 | 298 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -294,8 +300,9 @@ discard block |
||
| 294 | 300 | } |
| 295 | 301 | |
| 296 | 302 | // Set the last post in the parent board. |
| 297 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
| 298 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 303 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
| 304 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 305 | + } |
|
| 299 | 306 | // Just in the child...? |
| 300 | 307 | if ($isChild) |
| 301 | 308 | { |
@@ -305,15 +312,17 @@ discard block |
||
| 305 | 312 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
| 306 | 313 | } |
| 307 | 314 | // No last post for this board? It's not new then, is it..? |
| 308 | - elseif ($row_board['poster_name'] == '') |
|
| 309 | - $this_category[$row_board['id_board']]['new'] = false; |
|
| 315 | + elseif ($row_board['poster_name'] == '') { |
|
| 316 | + $this_category[$row_board['id_board']]['new'] = false; |
|
| 317 | + } |
|
| 310 | 318 | |
| 311 | 319 | // Determine a global most recent topic. |
| 312 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
| 313 | - $latest_post = array( |
|
| 320 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
| 321 | + $latest_post = array( |
|
| 314 | 322 | 'timestamp' => $row_board['poster_time'], |
| 315 | 323 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
| 316 | 324 | ); |
| 325 | + } |
|
| 317 | 326 | } |
| 318 | 327 | $smcFunc['db_free_result']($result_boards); |
| 319 | 328 | |
@@ -330,8 +339,9 @@ discard block |
||
| 330 | 339 | if (!empty($moderators[$board['id']])) |
| 331 | 340 | { |
| 332 | 341 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
| 333 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 334 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 342 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 343 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 344 | + } |
|
| 335 | 345 | } |
| 336 | 346 | if (!empty($groups[$board['id']])) |
| 337 | 347 | { |
@@ -344,16 +354,16 @@ discard block |
||
| 344 | 354 | } |
| 345 | 355 | } |
| 346 | 356 | } |
| 347 | - } |
|
| 348 | - else |
|
| 357 | + } else |
|
| 349 | 358 | { |
| 350 | 359 | foreach ($this_category as $k => $board) |
| 351 | 360 | { |
| 352 | 361 | if (!empty($moderators[$board['id']])) |
| 353 | 362 | { |
| 354 | 363 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
| 355 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 356 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 364 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 365 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 366 | + } |
|
| 357 | 367 | } |
| 358 | 368 | if (!empty($groups[$board['id']])) |
| 359 | 369 | { |
@@ -367,20 +377,23 @@ discard block |
||
| 367 | 377 | } |
| 368 | 378 | } |
| 369 | 379 | |
| 370 | - if ($boardIndexOptions['include_categories']) |
|
| 371 | - sortCategories($categories); |
|
| 372 | - else |
|
| 373 | - sortBoards($this_category); |
|
| 380 | + if ($boardIndexOptions['include_categories']) { |
|
| 381 | + sortCategories($categories); |
|
| 382 | + } else { |
|
| 383 | + sortBoards($this_category); |
|
| 384 | + } |
|
| 374 | 385 | |
| 375 | 386 | // By now we should know the most recent post...if we wanna know it that is. |
| 376 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
| 377 | - $context['latest_post'] = $latest_post['ref']; |
|
| 387 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
| 388 | + $context['latest_post'] = $latest_post['ref']; |
|
| 389 | + } |
|
| 378 | 390 | |
| 379 | 391 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
| 380 | - if ($boardIndexOptions['include_categories']) |
|
| 381 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 382 | - else |
|
| 383 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 392 | + if ($boardIndexOptions['include_categories']) { |
|
| 393 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 394 | + } else { |
|
| 395 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 396 | + } |
|
| 384 | 397 | |
| 385 | 398 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
| 386 | 399 | } |
@@ -132,8 +132,9 @@ discard block |
||
| 132 | 132 | 'GROUPNAME' => $user['group_name'], |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - if (!empty($custom_reason)) |
|
| 136 | - $replacements['REASON'] = $custom_reason; |
|
| 135 | + if (!empty($custom_reason)) { |
|
| 136 | + $replacements['REASON'] = $custom_reason; |
|
| 137 | + } |
|
| 137 | 138 | |
| 138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
| 139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
| 142 | 143 | } |
| 143 | 144 | |
| 144 | 145 | // Insert the alerts if any |
| 145 | - if (!empty($alert_rows)) |
|
| 146 | - $smcFunc['db_insert']('', |
|
| 146 | + if (!empty($alert_rows)) { |
|
| 147 | + $smcFunc['db_insert']('', |
|
| 147 | 148 | '{db_prefix}user_alerts', |
| 148 | 149 | array( |
| 149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
| 152 | 153 | $alert_rows, |
| 153 | 154 | array() |
| 154 | 155 | ); |
| 156 | + } |
|
| 155 | 157 | } |
| 156 | 158 | |
| 157 | 159 | return true; |
@@ -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. |