@@ -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']; |
@@ -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. |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | 'last_comment' => $this->_details['comment_id'], |
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 44 | - $possible_members[] = $row[0]; |
|
| 43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 44 | + $possible_members[] = $row[0]; |
|
| 45 | + } |
|
| 45 | 46 | $smcFunc['db_free_result']($request); |
| 46 | 47 | |
| 47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
| 51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
| 52 | 53 | } |
| 53 | - if (empty($possible_members)) |
|
| 54 | - return true; |
|
| 54 | + if (empty($possible_members)) { |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
| 57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -67,8 +69,9 @@ discard block |
||
| 67 | 69 | 'current_board' => $this->_details['board_id'], |
| 68 | 70 | ) |
| 69 | 71 | ); |
| 70 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 71 | - $members[] = $row['id_member']; |
|
| 72 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 73 | + $members[] = $row['id_member']; |
|
| 74 | + } |
|
| 72 | 75 | $smcFunc['db_free_result']($request); |
| 73 | 76 | |
| 74 | 77 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -85,8 +88,9 @@ discard block |
||
| 85 | 88 | ) |
| 86 | 89 | ); |
| 87 | 90 | |
| 88 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 89 | - $members[] = $row['id_member']; |
|
| 91 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 92 | + $members[] = $row['id_member']; |
|
| 93 | + } |
|
| 90 | 94 | $smcFunc['db_free_result']($request); |
| 91 | 95 | |
| 92 | 96 | // So now we have two lists: the people who replied to a report in the past, |
@@ -108,8 +112,9 @@ discard block |
||
| 108 | 112 | { |
| 109 | 113 | foreach ($alert_bits as $type => $bitvalue) |
| 110 | 114 | { |
| 111 | - if ($pref_option['msg_report_reply'] & $bitvalue) |
|
| 112 | - $notifies[$type][] = $member; |
|
| 115 | + if ($pref_option['msg_report_reply'] & $bitvalue) { |
|
| 116 | + $notifies[$type][] = $member; |
|
| 117 | + } |
|
| 113 | 118 | } |
| 114 | 119 | } |
| 115 | 120 | |
@@ -170,8 +175,9 @@ discard block |
||
| 170 | 175 | ); |
| 171 | 176 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 172 | 177 | { |
| 173 | - if (empty($row['lngfile'])) |
|
| 174 | - $row['lngfile'] = $language; |
|
| 178 | + if (empty($row['lngfile'])) { |
|
| 179 | + $row['lngfile'] = $language; |
|
| 180 | + } |
|
| 175 | 181 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 176 | 182 | } |
| 177 | 183 | $smcFunc['db_free_result']($request); |
@@ -203,8 +209,9 @@ discard block |
||
| 203 | 209 | $emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 204 | 210 | |
| 205 | 211 | // And do the actual sending... |
| 206 | - foreach ($recipients as $id_member => $email_address) |
|
| 207 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 212 | + foreach ($recipients as $id_member => $email_address) { |
|
| 213 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 214 | + } |
|
| 208 | 215 | } |
| 209 | 216 | } |
| 210 | 217 | |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | $birthdays = array(); |
| 52 | 52 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 53 | 53 | { |
| 54 | - if (!isset($birthdays[$row['lngfile']])) |
|
| 55 | - $birthdays[$row['lngfile']] = array(); |
|
| 54 | + if (!isset($birthdays[$row['lngfile']])) { |
|
| 55 | + $birthdays[$row['lngfile']] = array(); |
|
| 56 | + } |
|
| 56 | 57 | $birthdays[$row['lngfile']][$row['id_member']] = array( |
| 57 | 58 | 'name' => $row['real_name'], |
| 58 | 59 | 'email' => $row['email_address'] |
@@ -117,8 +118,8 @@ discard block |
||
| 117 | 118 | AddMailQueue(true); |
| 118 | 119 | |
| 119 | 120 | // Insert the alerts if any |
| 120 | - if (!empty($alert_rows)) |
|
| 121 | - $smcFunc['db_insert']('', |
|
| 121 | + if (!empty($alert_rows)) { |
|
| 122 | + $smcFunc['db_insert']('', |
|
| 122 | 123 | '{db_prefix}user_alerts', |
| 123 | 124 | array( |
| 124 | 125 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -127,6 +128,7 @@ discard block |
||
| 127 | 128 | $alert_rows, |
| 128 | 129 | array() |
| 129 | 130 | ); |
| 131 | + } |
|
| 130 | 132 | } |
| 131 | 133 | |
| 132 | 134 | return true; |