@@ -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 |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | |
| 30 | 31 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
| 31 | 32 | |
| 32 | - if ($test) |
|
| 33 | - return $supported; |
|
| 33 | + if ($test) { |
|
| 34 | + return $supported; |
|
| 35 | + } |
|
| 34 | 36 | return parent::isSupported() && $supported; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
| 52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 53 | 55 | |
| 54 | 56 | // An extended key is needed to counteract a bug in APC. |
| 55 | - if ($value === null) |
|
| 56 | - return apc_delete($key . 'smf'); |
|
| 57 | - else |
|
| 58 | - return apc_store($key . 'smf', $value, $ttl); |
|
| 57 | + if ($value === null) { |
|
| 58 | + return apc_delete($key . 'smf'); |
|
| 59 | + } else { |
|
| 60 | + return apc_store($key . 'smf', $value, $ttl); |
|
| 61 | + } |
|
| 59 | 62 | } |
| 60 | 63 | |
| 61 | 64 | /** |
@@ -69,9 +72,9 @@ discard block |
||
| 69 | 72 | // Always returns true. |
| 70 | 73 | apc_clear_cache('user'); |
| 71 | 74 | apc_clear_cache('system'); |
| 75 | + } elseif ($type === 'user') { |
|
| 76 | + apc_clear_cache('user'); |
|
| 72 | 77 | } |
| 73 | - elseif ($type === 'user') |
|
| 74 | - apc_clear_cache('user'); |
|
| 75 | 78 | |
| 76 | 79 | $this->invalidateCache(); |
| 77 | 80 | return true; |
@@ -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 |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | |
| 30 | 31 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
| 31 | 32 | |
| 32 | - if ($test) |
|
| 33 | - return $supported; |
|
| 33 | + if ($test) { |
|
| 34 | + return $supported; |
|
| 35 | + } |
|
| 34 | 36 | return parent::isSupported() && $supported; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
| 52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 53 | 55 | |
| 54 | 56 | // An extended key is needed to counteract a bug in APC. |
| 55 | - if ($value === null) |
|
| 56 | - return apcu_delete($key . 'smf'); |
|
| 57 | - else |
|
| 58 | - return apcu_store($key . 'smf', $value, $ttl); |
|
| 57 | + if ($value === null) { |
|
| 58 | + return apcu_delete($key . 'smf'); |
|
| 59 | + } else { |
|
| 60 | + return apcu_store($key . 'smf', $value, $ttl); |
|
| 61 | + } |
|
| 59 | 62 | } |
| 60 | 63 | |
| 61 | 64 | /** |
@@ -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('memcached'); |
| 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 | |
@@ -54,9 +56,9 @@ discard block |
||
| 54 | 56 | $currentServers = $this->memcached->getServerList(); |
| 55 | 57 | foreach ($servers as $server) |
| 56 | 58 | { |
| 57 | - if (strpos($server,'/') !== false) |
|
| 58 | - $tempServer = array($server, 0); |
|
| 59 | - else |
|
| 59 | + if (strpos($server,'/') !== false) { |
|
| 60 | + $tempServer = array($server, 0); |
|
| 61 | + } else |
|
| 60 | 62 | { |
| 61 | 63 | $server = explode(':', $server); |
| 62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | // Found it? |
| 77 | - if (empty($foundServer)) |
|
| 78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 79 | + if (empty($foundServer)) { |
|
| 80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | $value = $this->memcached->get($key); |
| 93 | 96 | |
| 94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
| 95 | - if ($value === false) |
|
| 96 | - return null; |
|
| 98 | + if ($value === false) { |
|
| 99 | + return null; |
|
| 100 | + } |
|
| 97 | 101 | return $value; |
| 98 | 102 | } |
| 99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
| 136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
| 137 | 141 | $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>'); |
| 138 | 142 | |
| 139 | - if (!isset($context['settings_post_javascript'])) |
|
| 140 | - $context['settings_post_javascript'] = ''; |
|
| 143 | + if (!isset($context['settings_post_javascript'])) { |
|
| 144 | + $context['settings_post_javascript'] = ''; |
|
| 145 | + } |
|
| 141 | 146 | |
| 142 | 147 | $context['settings_post_javascript'] .= ' |
| 143 | 148 | $("#cache_accelerator").change(function (e) { |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
| 15 | 15 | // SMF Payment Gateway: paypal |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
| 118 | 119 | { |
| 119 | 120 | $return_data['hidden']['p3'] = 1; |
| 120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
| 121 | - } |
|
| 122 | - else |
|
| 122 | + } else |
|
| 123 | 123 | { |
| 124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
| 125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // If it's repeatable do some javascript to respect this idea. |
| 133 | - if (!empty($sub_data['repeatable'])) |
|
| 134 | - $return_data['javascript'] = ' |
|
| 133 | + if (!empty($sub_data['repeatable'])) { |
|
| 134 | + $return_data['javascript'] = ' |
|
| 135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\'); |
| 136 | 136 | |
| 137 | 137 | function switchPaypalRecur() |
| 138 | 138 | { |
| 139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
| 140 | 140 | }'; |
| 141 | + } |
|
| 141 | 142 | |
| 142 | 143 | return $return_data; |
| 143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
| 160 | 161 | global $modSettings; |
| 161 | 162 | |
| 162 | 163 | // Has the user set up an email address? |
| 163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
| 164 | - return false; |
|
| 164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
| 165 | + return false; |
|
| 166 | + } |
|
| 165 | 167 | // Check the correct transaction types are even here. |
| 166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
| 167 | - return false; |
|
| 168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 168 | 171 | // Correct email address? |
| 169 | - if (!isset($_POST['business'])) |
|
| 170 | - $_POST['business'] = $_POST['receiver_email']; |
|
| 172 | + if (!isset($_POST['business'])) { |
|
| 173 | + $_POST['business'] = $_POST['receiver_email']; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | // Are we testing? |
| 173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
| 174 | - return false; |
|
| 175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
| 176 | - return false; |
|
| 177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
| 178 | + return false; |
|
| 179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 177 | 182 | return true; |
| 178 | 183 | } |
| 179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
| 192 | 197 | global $modSettings, $txt; |
| 193 | 198 | |
| 194 | 199 | // Put this to some default value. |
| 195 | - if (!isset($_POST['txn_type'])) |
|
| 196 | - $_POST['txn_type'] = ''; |
|
| 200 | + if (!isset($_POST['txn_type'])) { |
|
| 201 | + $_POST['txn_type'] = ''; |
|
| 202 | + } |
|
| 197 | 203 | |
| 198 | 204 | // Build the request string - starting with the minimum requirement. |
| 199 | 205 | $requestString = 'cmd=_notify-validate'; |
| 200 | 206 | |
| 201 | 207 | // Now my dear, add all the posted bits in the order we got them |
| 202 | - foreach ($_POST as $k => $v) |
|
| 203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
| 208 | + foreach ($_POST as $k => $v) { |
|
| 209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
| 210 | + } |
|
| 204 | 211 | |
| 205 | 212 | // Can we use curl? |
| 206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'http://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
| 240 | 247 | $header .= 'Connection: close' . "\r\n\r\n"; |
| 241 | 248 | |
| 242 | 249 | // Open the connection. |
| 243 | - if (!empty($modSettings['paidsubs_test'])) |
|
| 244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
| 245 | - else |
|
| 246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
| 250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
| 251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
| 252 | + } else { |
|
| 253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
| 254 | + } |
|
| 247 | 255 | |
| 248 | 256 | // Did it work? |
| 249 | - if (!$fp) |
|
| 250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
| 257 | + if (!$fp) { |
|
| 258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
| 259 | + } |
|
| 251 | 260 | |
| 252 | 261 | // Put the data to the port. |
| 253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
| 256 | 265 | while (!feof($fp)) |
| 257 | 266 | { |
| 258 | 267 | $this->return_data = fgets($fp, 1024); |
| 259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
| 260 | - break; |
|
| 268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
| 269 | + break; |
|
| 270 | + } |
|
| 261 | 271 | } |
| 262 | 272 | |
| 263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
| 265 | 275 | } |
| 266 | 276 | |
| 267 | 277 | // If this isn't verified then give up... |
| 268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
| 269 | - exit; |
|
| 278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
| 279 | + exit; |
|
| 280 | + } |
|
| 270 | 281 | |
| 271 | 282 | // Check that this is intended for us. |
| 272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
| 273 | - exit; |
|
| 283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
| 284 | + exit; |
|
| 285 | + } |
|
| 274 | 286 | |
| 275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
| 276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
| 277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
| 278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
| 279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
| 280 | - // Calculate the subscription it relates to! |
|
| 289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
| 290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
| 291 | + } |
|
| 292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
| 293 | + // Calculate the subscription it relates to! |
|
| 281 | 294 | $this->_findSubscription(); |
| 295 | + } |
|
| 282 | 296 | |
| 283 | 297 | // Verify the currency! |
| 284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
| 285 | - exit; |
|
| 298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
| 299 | + exit; |
|
| 300 | + } |
|
| 286 | 301 | |
| 287 | 302 | // Can't exist if it doesn't contain anything. |
| 288 | - if (empty($_POST['item_number'])) |
|
| 289 | - exit; |
|
| 303 | + if (empty($_POST['item_number'])) { |
|
| 304 | + exit; |
|
| 305 | + } |
|
| 290 | 306 | |
| 291 | 307 | // Return the id_sub and id_member |
| 292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
| 299 | 315 | */ |
| 300 | 316 | public function isRefund() |
| 301 | 317 | { |
| 302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
| 303 | - return true; |
|
| 304 | - else |
|
| 305 | - return false; |
|
| 318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
| 319 | + return true; |
|
| 320 | + } else { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 306 | 323 | } |
| 307 | 324 | |
| 308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
| 312 | 329 | */ |
| 313 | 330 | public function isSubscription() |
| 314 | 331 | { |
| 315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
| 316 | - return true; |
|
| 317 | - else |
|
| 318 | - return false; |
|
| 332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
| 333 | + return true; |
|
| 334 | + } else { |
|
| 335 | + return false; |
|
| 336 | + } |
|
| 319 | 337 | } |
| 320 | 338 | |
| 321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
| 325 | 343 | */ |
| 326 | 344 | public function isPayment() |
| 327 | 345 | { |
| 328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
| 329 | - return true; |
|
| 330 | - else |
|
| 331 | - return false; |
|
| 346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
| 347 | + return true; |
|
| 348 | + } else { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 332 | 351 | } |
| 333 | 352 | |
| 334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
| 341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
| 342 | 361 | // Neither require us to *do* anything as per performCancel(). |
| 343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
| 344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
| 345 | - return true; |
|
| 346 | - else |
|
| 347 | - return false; |
|
| 363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
| 364 | + return true; |
|
| 365 | + } else { |
|
| 366 | + return false; |
|
| 367 | + } |
|
| 348 | 368 | } |
| 349 | 369 | |
| 350 | 370 | /** |
@@ -409,8 +429,9 @@ discard block |
||
| 409 | 429 | global $smcFunc; |
| 410 | 430 | |
| 411 | 431 | // Assume we have this? |
| 412 | - if (empty($_POST['subscr_id'])) |
|
| 413 | - return false; |
|
| 432 | + if (empty($_POST['subscr_id'])) { |
|
| 433 | + return false; |
|
| 434 | + } |
|
| 414 | 435 | |
| 415 | 436 | // Do we have this in the database? |
| 416 | 437 | $request = $smcFunc['db_query']('', ' |
@@ -439,11 +460,12 @@ discard block |
||
| 439 | 460 | 'payer_email' => $_POST['payer_email'], |
| 440 | 461 | ) |
| 441 | 462 | ); |
| 442 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 443 | - return false; |
|
| 463 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 464 | + return false; |
|
| 465 | + } |
|
| 466 | + } else { |
|
| 467 | + return false; |
|
| 444 | 468 | } |
| 445 | - else |
|
| 446 | - return false; |
|
| 447 | 469 | } |
| 448 | 470 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
| 449 | 471 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |
@@ -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 | * Display some useful/interesting board statistics. |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | |
| 31 | 32 | isAllowedTo('view_stats'); |
| 32 | 33 | // Page disabled - redirect them out |
| 33 | - if (empty($modSettings['trackStats'])) |
|
| 34 | - fatal_lang_error('feature_disabled', true); |
|
| 34 | + if (empty($modSettings['trackStats'])) { |
|
| 35 | + fatal_lang_error('feature_disabled', true); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | if (!empty($_REQUEST['expand'])) |
| 37 | 39 | { |
@@ -39,31 +41,34 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | $month = (int) substr($_REQUEST['expand'], 4); |
| 41 | 43 | $year = (int) substr($_REQUEST['expand'], 0, 4); |
| 42 | - if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
|
| 43 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
| 44 | - } |
|
| 45 | - elseif (!empty($_REQUEST['collapse'])) |
|
| 44 | + if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) { |
|
| 45 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
| 46 | + } |
|
| 47 | + } elseif (!empty($_REQUEST['collapse'])) |
|
| 46 | 48 | { |
| 47 | 49 | $context['robot_no_index'] = true; |
| 48 | 50 | |
| 49 | 51 | $month = (int) substr($_REQUEST['collapse'], 4); |
| 50 | 52 | $year = (int) substr($_REQUEST['collapse'], 0, 4); |
| 51 | - if (!empty($_SESSION['expanded_stats'][$year])) |
|
| 52 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
| 53 | + if (!empty($_SESSION['expanded_stats'][$year])) { |
|
| 54 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | // Handle the XMLHttpRequest. |
| 56 | 59 | if (isset($_REQUEST['xml'])) |
| 57 | 60 | { |
| 58 | 61 | // Collapsing stats only needs adjustments of the session variables. |
| 59 | - if (!empty($_REQUEST['collapse'])) |
|
| 60 | - obExit(false); |
|
| 62 | + if (!empty($_REQUEST['collapse'])) { |
|
| 63 | + obExit(false); |
|
| 64 | + } |
|
| 61 | 65 | |
| 62 | 66 | $context['sub_template'] = 'stats'; |
| 63 | 67 | $context['yearly'] = array(); |
| 64 | 68 | |
| 65 | - if (empty($month) || empty($year)) |
|
| 66 | - return; |
|
| 69 | + if (empty($month) || empty($year)) { |
|
| 70 | + return; |
|
| 71 | + } |
|
| 67 | 72 | |
| 68 | 73 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
| 69 | 74 | $context['yearly'][$year]['months'][$month]['date'] = array( |
@@ -220,8 +225,9 @@ discard block |
||
| 220 | 225 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
| 221 | 226 | ); |
| 222 | 227 | |
| 223 | - if ($max_num_posts < $row_members['posts']) |
|
| 224 | - $max_num_posts = $row_members['posts']; |
|
| 228 | + if ($max_num_posts < $row_members['posts']) { |
|
| 229 | + $max_num_posts = $row_members['posts']; |
|
| 230 | + } |
|
| 225 | 231 | } |
| 226 | 232 | $smcFunc['db_free_result']($members_result); |
| 227 | 233 | |
@@ -257,8 +263,9 @@ discard block |
||
| 257 | 263 | 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>' |
| 258 | 264 | ); |
| 259 | 265 | |
| 260 | - if ($max_num_posts < $row_board['num_posts']) |
|
| 261 | - $max_num_posts = $row_board['num_posts']; |
|
| 266 | + if ($max_num_posts < $row_board['num_posts']) { |
|
| 267 | + $max_num_posts = $row_board['num_posts']; |
|
| 268 | + } |
|
| 262 | 269 | } |
| 263 | 270 | $smcFunc['db_free_result']($boards_result); |
| 264 | 271 | |
@@ -284,12 +291,13 @@ discard block |
||
| 284 | 291 | ) |
| 285 | 292 | ); |
| 286 | 293 | $topic_ids = array(); |
| 287 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 288 | - $topic_ids[] = $row['id_topic']; |
|
| 294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 295 | + $topic_ids[] = $row['id_topic']; |
|
| 296 | + } |
|
| 289 | 297 | $smcFunc['db_free_result']($request); |
| 298 | + } else { |
|
| 299 | + $topic_ids = array(); |
|
| 290 | 300 | } |
| 291 | - else |
|
| 292 | - $topic_ids = array(); |
|
| 293 | 301 | |
| 294 | 302 | // Topic replies top 10. |
| 295 | 303 | $topic_reply_result = $smcFunc['db_query']('', ' |
@@ -329,8 +337,9 @@ discard block |
||
| 329 | 337 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>' |
| 330 | 338 | ); |
| 331 | 339 | |
| 332 | - if ($max_num_replies < $row_topic_reply['num_replies']) |
|
| 333 | - $max_num_replies = $row_topic_reply['num_replies']; |
|
| 340 | + if ($max_num_replies < $row_topic_reply['num_replies']) { |
|
| 341 | + $max_num_replies = $row_topic_reply['num_replies']; |
|
| 342 | + } |
|
| 334 | 343 | } |
| 335 | 344 | $smcFunc['db_free_result']($topic_reply_result); |
| 336 | 345 | |
@@ -354,12 +363,13 @@ discard block |
||
| 354 | 363 | ) |
| 355 | 364 | ); |
| 356 | 365 | $topic_ids = array(); |
| 357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 358 | - $topic_ids[] = $row['id_topic']; |
|
| 366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 367 | + $topic_ids[] = $row['id_topic']; |
|
| 368 | + } |
|
| 359 | 369 | $smcFunc['db_free_result']($request); |
| 370 | + } else { |
|
| 371 | + $topic_ids = array(); |
|
| 360 | 372 | } |
| 361 | - else |
|
| 362 | - $topic_ids = array(); |
|
| 363 | 373 | |
| 364 | 374 | // Topic views top 10. |
| 365 | 375 | $topic_view_result = $smcFunc['db_query']('', ' |
@@ -399,8 +409,9 @@ discard block |
||
| 399 | 409 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>' |
| 400 | 410 | ); |
| 401 | 411 | |
| 402 | - if ($max_num < $row_topic_views['num_views']) |
|
| 403 | - $max_num = $row_topic_views['num_views']; |
|
| 412 | + if ($max_num < $row_topic_views['num_views']) { |
|
| 413 | + $max_num = $row_topic_views['num_views']; |
|
| 414 | + } |
|
| 404 | 415 | } |
| 405 | 416 | $smcFunc['db_free_result']($topic_view_result); |
| 406 | 417 | |
@@ -425,15 +436,17 @@ discard block |
||
| 425 | 436 | ) |
| 426 | 437 | ); |
| 427 | 438 | $members = array(); |
| 428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 429 | - $members[$row['id_member_started']] = $row['hits']; |
|
| 439 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 440 | + $members[$row['id_member_started']] = $row['hits']; |
|
| 441 | + } |
|
| 430 | 442 | $smcFunc['db_free_result']($request); |
| 431 | 443 | |
| 432 | 444 | cache_put_data('stats_top_starters', $members, 360); |
| 433 | 445 | } |
| 434 | 446 | |
| 435 | - if (empty($members)) |
|
| 436 | - $members = array(0 => 0); |
|
| 447 | + if (empty($members)) { |
|
| 448 | + $members = array(0 => 0); |
|
| 449 | + } |
|
| 437 | 450 | |
| 438 | 451 | // Topic poster top 10. |
| 439 | 452 | $members_result = $smcFunc['db_query']('', ' |
@@ -458,8 +471,9 @@ discard block |
||
| 458 | 471 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
| 459 | 472 | ); |
| 460 | 473 | |
| 461 | - if ($max_num < $members[$row_members['id_member']]) |
|
| 462 | - $max_num = $members[$row_members['id_member']]; |
|
| 474 | + if ($max_num < $members[$row_members['id_member']]) { |
|
| 475 | + $max_num = $members[$row_members['id_member']]; |
|
| 476 | + } |
|
| 463 | 477 | } |
| 464 | 478 | ksort($context['stats_blocks']['starters']); |
| 465 | 479 | $smcFunc['db_free_result']($members_result); |
@@ -488,8 +502,9 @@ discard block |
||
| 488 | 502 | while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) |
| 489 | 503 | { |
| 490 | 504 | $temp2[] = (int) $row_members['id_member']; |
| 491 | - if (count($context['stats_blocks']['time_online']) >= 10) |
|
| 492 | - continue; |
|
| 505 | + if (count($context['stats_blocks']['time_online']) >= 10) { |
|
| 506 | + continue; |
|
| 507 | + } |
|
| 493 | 508 | |
| 494 | 509 | // Figure out the days, hours and minutes. |
| 495 | 510 | $timeDays = floor($row_members['total_time_logged_in'] / 86400); |
@@ -497,10 +512,12 @@ discard block |
||
| 497 | 512 | |
| 498 | 513 | // Figure out which things to show... (days, hours, minutes, etc.) |
| 499 | 514 | $timelogged = ''; |
| 500 | - if ($timeDays > 0) |
|
| 501 | - $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
| 502 | - if ($timeHours > 0) |
|
| 503 | - $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
| 515 | + if ($timeDays > 0) { |
|
| 516 | + $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
| 517 | + } |
|
| 518 | + if ($timeHours > 0) { |
|
| 519 | + $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
| 520 | + } |
|
| 504 | 521 | $timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7']; |
| 505 | 522 | |
| 506 | 523 | $context['stats_blocks']['time_online'][] = array( |
@@ -512,17 +529,20 @@ discard block |
||
| 512 | 529 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
| 513 | 530 | ); |
| 514 | 531 | |
| 515 | - if ($max_time_online < $row_members['total_time_logged_in']) |
|
| 516 | - $max_time_online = $row_members['total_time_logged_in']; |
|
| 532 | + if ($max_time_online < $row_members['total_time_logged_in']) { |
|
| 533 | + $max_time_online = $row_members['total_time_logged_in']; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | $smcFunc['db_free_result']($members_result); |
| 519 | 537 | |
| 520 | - foreach ($context['stats_blocks']['time_online'] as $i => $member) |
|
| 521 | - $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
| 538 | + foreach ($context['stats_blocks']['time_online'] as $i => $member) { |
|
| 539 | + $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
| 540 | + } |
|
| 522 | 541 | |
| 523 | 542 | // Cache the ones we found for a bit, just so we don't have to look again. |
| 524 | - if ($temp !== $temp2) |
|
| 525 | - cache_put_data('stats_total_time_members', $temp2, 480); |
|
| 543 | + if ($temp !== $temp2) { |
|
| 544 | + cache_put_data('stats_total_time_members', $temp2, 480); |
|
| 545 | + } |
|
| 526 | 546 | |
| 527 | 547 | // Likes. |
| 528 | 548 | if (!empty($modSettings['enable_likes'])) |
@@ -558,13 +578,15 @@ discard block |
||
| 558 | 578 | 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
| 559 | 579 | ); |
| 560 | 580 | |
| 561 | - if ($max_liked_message < $row_liked_message['likes']) |
|
| 562 | - $max_liked_message = $row_liked_message['likes']; |
|
| 581 | + if ($max_liked_message < $row_liked_message['likes']) { |
|
| 582 | + $max_liked_message = $row_liked_message['likes']; |
|
| 583 | + } |
|
| 563 | 584 | } |
| 564 | 585 | $smcFunc['db_free_result']($liked_messages); |
| 565 | 586 | |
| 566 | - foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) |
|
| 567 | - $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
| 587 | + foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { |
|
| 588 | + $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
| 589 | + } |
|
| 568 | 590 | |
| 569 | 591 | // Liked users top 10. |
| 570 | 592 | $context['stats_blocks']['liked_users'] = array(); |
@@ -595,14 +617,16 @@ discard block |
||
| 595 | 617 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>', |
| 596 | 618 | ); |
| 597 | 619 | |
| 598 | - if ($max_liked_users < $row_liked_users['count']) |
|
| 599 | - $max_liked_users = $row_liked_users['count']; |
|
| 620 | + if ($max_liked_users < $row_liked_users['count']) { |
|
| 621 | + $max_liked_users = $row_liked_users['count']; |
|
| 622 | + } |
|
| 600 | 623 | } |
| 601 | 624 | |
| 602 | 625 | $smcFunc['db_free_result']($liked_users); |
| 603 | 626 | |
| 604 | - foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) |
|
| 605 | - $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
| 627 | + foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) { |
|
| 628 | + $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
| 629 | + } |
|
| 606 | 630 | } |
| 607 | 631 | |
| 608 | 632 | // Activity by month. |
@@ -620,8 +644,8 @@ discard block |
||
| 620 | 644 | $ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']); |
| 621 | 645 | $expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]); |
| 622 | 646 | |
| 623 | - if (!isset($context['yearly'][$row_months['stats_year']])) |
|
| 624 | - $context['yearly'][$row_months['stats_year']] = array( |
|
| 647 | + if (!isset($context['yearly'][$row_months['stats_year']])) { |
|
| 648 | + $context['yearly'][$row_months['stats_year']] = array( |
|
| 625 | 649 | 'year' => $row_months['stats_year'], |
| 626 | 650 | 'new_topics' => 0, |
| 627 | 651 | 'new_posts' => 0, |
@@ -633,6 +657,7 @@ discard block |
||
| 633 | 657 | 'expanded' => false, |
| 634 | 658 | 'current_year' => $row_months['stats_year'] == date('Y'), |
| 635 | 659 | ); |
| 660 | + } |
|
| 636 | 661 | |
| 637 | 662 | $context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array( |
| 638 | 663 | 'id' => $ID_MONTH, |
@@ -678,26 +703,30 @@ discard block |
||
| 678 | 703 | $context['yearly'][$year]['hits'] = comma_format($data['hits']); |
| 679 | 704 | |
| 680 | 705 | // Keep a list of collapsed years. |
| 681 | - if (!$data['expanded'] && !$data['current_year']) |
|
| 682 | - $context['collapsed_years'][] = $year; |
|
| 706 | + if (!$data['expanded'] && !$data['current_year']) { |
|
| 707 | + $context['collapsed_years'][] = $year; |
|
| 708 | + } |
|
| 683 | 709 | } |
| 684 | 710 | |
| 685 | - if (empty($_SESSION['expanded_stats'])) |
|
| 686 | - return; |
|
| 711 | + if (empty($_SESSION['expanded_stats'])) { |
|
| 712 | + return; |
|
| 713 | + } |
|
| 687 | 714 | |
| 688 | 715 | $condition_text = array(); |
| 689 | 716 | $condition_params = array(); |
| 690 | - foreach ($_SESSION['expanded_stats'] as $year => $months) |
|
| 691 | - if (!empty($months)) |
|
| 717 | + foreach ($_SESSION['expanded_stats'] as $year => $months) { |
|
| 718 | + if (!empty($months)) |
|
| 692 | 719 | { |
| 693 | 720 | $condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})'; |
| 721 | + } |
|
| 694 | 722 | $condition_params['year_' . $year] = $year; |
| 695 | 723 | $condition_params['months_' . $year] = $months; |
| 696 | 724 | } |
| 697 | 725 | |
| 698 | 726 | // No daily stats to even look at? |
| 699 | - if (empty($condition_text)) |
|
| 700 | - return; |
|
| 727 | + if (empty($condition_text)) { |
|
| 728 | + return; |
|
| 729 | + } |
|
| 701 | 730 | |
| 702 | 731 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
| 703 | 732 | |
@@ -723,8 +752,8 @@ discard block |
||
| 723 | 752 | ORDER BY stats_day ASC', |
| 724 | 753 | $condition_parameters |
| 725 | 754 | ); |
| 726 | - while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) |
|
| 727 | - $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
| 755 | + while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) { |
|
| 756 | + $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
| 728 | 757 | 'day' => sprintf('%02d', $row_days['stats_day']), |
| 729 | 758 | 'month' => sprintf('%02d', $row_days['stats_month']), |
| 730 | 759 | 'year' => $row_days['stats_year'], |
@@ -734,6 +763,7 @@ discard block |
||
| 734 | 763 | 'most_members_online' => comma_format($row_days['most_on']), |
| 735 | 764 | 'hits' => comma_format($row_days['hits']) |
| 736 | 765 | ); |
| 766 | + } |
|
| 737 | 767 | $smcFunc['db_free_result']($days_result); |
| 738 | 768 | } |
| 739 | 769 | |
@@ -752,16 +782,19 @@ discard block |
||
| 752 | 782 | global $modSettings, $user_info, $forum_version, $sourcedir; |
| 753 | 783 | |
| 754 | 784 | // First, is it disabled? |
| 755 | - if (empty($modSettings['allow_sm_stats'])) |
|
| 756 | - die(); |
|
| 785 | + if (empty($modSettings['allow_sm_stats'])) { |
|
| 786 | + die(); |
|
| 787 | + } |
|
| 757 | 788 | |
| 758 | 789 | // Are we saying who we are, and are we right? (OR an admin) |
| 759 | - if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) |
|
| 760 | - die(); |
|
| 790 | + if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) { |
|
| 791 | + die(); |
|
| 792 | + } |
|
| 761 | 793 | |
| 762 | 794 | // Verify the referer... |
| 763 | - if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) |
|
| 764 | - die(); |
|
| 795 | + if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) { |
|
| 796 | + die(); |
|
| 797 | + } |
|
| 765 | 798 | |
| 766 | 799 | // Get some server versions. |
| 767 | 800 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -787,16 +820,17 @@ discard block |
||
| 787 | 820 | ); |
| 788 | 821 | |
| 789 | 822 | // Encode all the data, for security. |
| 790 | - foreach ($stats_to_send as $k => $v) |
|
| 791 | - $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
| 823 | + foreach ($stats_to_send as $k => $v) { |
|
| 824 | + $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
| 825 | + } |
|
| 792 | 826 | |
| 793 | 827 | // Turn this into the query string! |
| 794 | 828 | $stats_to_send = implode('&', $stats_to_send); |
| 795 | 829 | |
| 796 | 830 | // If we're an admin, just plonk them out. |
| 797 | - if ($user_info['is_admin']) |
|
| 798 | - echo $stats_to_send; |
|
| 799 | - else |
|
| 831 | + if ($user_info['is_admin']) { |
|
| 832 | + echo $stats_to_send; |
|
| 833 | + } else |
|
| 800 | 834 | { |
| 801 | 835 | // Connect to the collection script. |
| 802 | 836 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -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 | * Log an error, if the error logging is enabled. |
@@ -36,8 +37,9 @@ discard block |
||
| 36 | 37 | static $tried_hook = false; |
| 37 | 38 | |
| 38 | 39 | // Check if error logging is actually on. |
| 39 | - if (empty($modSettings['enableErrorLogging'])) |
|
| 40 | - return $error_message; |
|
| 40 | + if (empty($modSettings['enableErrorLogging'])) { |
|
| 41 | + return $error_message; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | // Basically, htmlspecialchars it minus &. (for entities!) |
| 43 | 45 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -45,22 +47,26 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | // Add a file and line to the error message? |
| 47 | 49 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
| 48 | - if ($file == null) |
|
| 49 | - $file = ''; |
|
| 50 | - else |
|
| 51 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
| 50 | + if ($file == null) { |
|
| 51 | + $file = ''; |
|
| 52 | + } else { |
|
| 53 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
| 52 | 54 | $file = str_replace('\\', '/', $file); |
| 55 | + } |
|
| 53 | 56 | |
| 54 | - if ($line == null) |
|
| 55 | - $line = 0; |
|
| 56 | - else |
|
| 57 | - $line = (int) $line; |
|
| 57 | + if ($line == null) { |
|
| 58 | + $line = 0; |
|
| 59 | + } else { |
|
| 60 | + $line = (int) $line; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | // Just in case there's no id_member or IP set yet. |
| 60 | - if (empty($user_info['id'])) |
|
| 61 | - $user_info['id'] = 0; |
|
| 62 | - if (empty($user_info['ip'])) |
|
| 63 | - $user_info['ip'] = ''; |
|
| 64 | + if (empty($user_info['id'])) { |
|
| 65 | + $user_info['id'] = 0; |
|
| 66 | + } |
|
| 67 | + if (empty($user_info['ip'])) { |
|
| 68 | + $user_info['ip'] = ''; |
|
| 69 | + } |
|
| 64 | 70 | |
| 65 | 71 | // Find the best query string we can... |
| 66 | 72 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
@@ -69,8 +75,9 @@ discard block |
||
| 69 | 75 | $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
| 70 | 76 | |
| 71 | 77 | // Just so we know what board error messages are from. |
| 72 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
| 73 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 78 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
| 79 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 80 | + } |
|
| 74 | 81 | |
| 75 | 82 | // What types of categories do we have? |
| 76 | 83 | $known_error_types = array( |
@@ -132,12 +139,14 @@ discard block |
||
| 132 | 139 | global $txt; |
| 133 | 140 | |
| 134 | 141 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
| 135 | - if (!empty($status)) |
|
| 136 | - send_http_status($status); |
|
| 142 | + if (!empty($status)) { |
|
| 143 | + send_http_status($status); |
|
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | // We don't have $txt yet, but that's okay... |
| 139 | - if (empty($txt)) |
|
| 140 | - die($error); |
|
| 147 | + if (empty($txt)) { |
|
| 148 | + die($error); |
|
| 149 | + } |
|
| 141 | 150 | |
| 142 | 151 | log_error_online($error, false); |
| 143 | 152 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -164,8 +173,9 @@ discard block |
||
| 164 | 173 | static $fatal_error_called = false; |
| 165 | 174 | |
| 166 | 175 | // Send the status header - set this to 0 or false if you don't want to send one at all |
| 167 | - if (!empty($status)) |
|
| 168 | - send_http_status($status); |
|
| 176 | + if (!empty($status)) { |
|
| 177 | + send_http_status($status); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // Try to load a theme if we don't have one. |
| 171 | 181 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -175,8 +185,9 @@ discard block |
||
| 175 | 185 | } |
| 176 | 186 | |
| 177 | 187 | // If we have no theme stuff we can't have the language file... |
| 178 | - if (empty($context['theme_loaded'])) |
|
| 179 | - die($error); |
|
| 188 | + if (empty($context['theme_loaded'])) { |
|
| 189 | + die($error); |
|
| 190 | + } |
|
| 180 | 191 | |
| 181 | 192 | $reload_lang_file = true; |
| 182 | 193 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -212,8 +223,9 @@ discard block |
||
| 212 | 223 | global $settings, $modSettings, $db_show_debug; |
| 213 | 224 | |
| 214 | 225 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
| 215 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
| 216 | - return; |
|
| 226 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
| 219 | 231 | { |
@@ -221,19 +233,22 @@ discard block |
||
| 221 | 233 | $count = count($array); |
| 222 | 234 | for ($i = 0; $i < $count; $i++) |
| 223 | 235 | { |
| 224 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
| 225 | - continue; |
|
| 236 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
| 237 | + continue; |
|
| 238 | + } |
|
| 226 | 239 | |
| 227 | 240 | // This is a bug in PHP, with eval, it seems! |
| 228 | - if (empty($array[$i]['args'])) |
|
| 229 | - $i++; |
|
| 241 | + if (empty($array[$i]['args'])) { |
|
| 242 | + $i++; |
|
| 243 | + } |
|
| 230 | 244 | break; |
| 231 | 245 | } |
| 232 | 246 | |
| 233 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
| 234 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 235 | - else |
|
| 236 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 247 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
| 248 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 249 | + } else { |
|
| 250 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 251 | + } |
|
| 237 | 252 | } |
| 238 | 253 | |
| 239 | 254 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -242,8 +257,9 @@ discard block |
||
| 242 | 257 | if ($error_level % 255 != E_ERROR) |
| 243 | 258 | { |
| 244 | 259 | $temporary = ob_get_contents(); |
| 245 | - if (substr($temporary, -2) == '="') |
|
| 246 | - echo '"'; |
|
| 260 | + if (substr($temporary, -2) == '="') { |
|
| 261 | + echo '"'; |
|
| 262 | + } |
|
| 247 | 263 | } |
| 248 | 264 | |
| 249 | 265 | // Debugging! This should look like a PHP error message. |
@@ -259,23 +275,27 @@ discard block |
||
| 259 | 275 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
| 260 | 276 | |
| 261 | 277 | // Dying on these errors only causes MORE problems (blank pages!) |
| 262 | - if ($file == 'Unknown') |
|
| 263 | - return; |
|
| 278 | + if ($file == 'Unknown') { |
|
| 279 | + return; |
|
| 280 | + } |
|
| 264 | 281 | |
| 265 | 282 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 266 | - if ($error_level % 255 == E_ERROR) |
|
| 267 | - obExit(false); |
|
| 268 | - else |
|
| 269 | - return; |
|
| 283 | + if ($error_level % 255 == E_ERROR) { |
|
| 284 | + obExit(false); |
|
| 285 | + } else { |
|
| 286 | + return; |
|
| 287 | + } |
|
| 270 | 288 | |
| 271 | 289 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
| 272 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
| 273 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 290 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
| 291 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 292 | + } |
|
| 274 | 293 | |
| 275 | 294 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
| 276 | - if ($error_level % 255 == E_ERROR) |
|
| 277 | - die('No direct access...'); |
|
| 278 | -} |
|
| 295 | + if ($error_level % 255 == E_ERROR) { |
|
| 296 | + die('No direct access...'); |
|
| 297 | + } |
|
| 298 | + } |
|
| 279 | 299 | |
| 280 | 300 | /** |
| 281 | 301 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -291,24 +311,28 @@ discard block |
||
| 291 | 311 | |
| 292 | 312 | // Attempt to prevent a recursive loop. |
| 293 | 313 | ++$level; |
| 294 | - if ($level > 1) |
|
| 295 | - return false; |
|
| 314 | + if ($level > 1) { |
|
| 315 | + return false; |
|
| 316 | + } |
|
| 296 | 317 | |
| 297 | 318 | // Maybe they came from dlattach or similar? |
| 298 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
| 299 | - loadTheme(); |
|
| 319 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
| 320 | + loadTheme(); |
|
| 321 | + } |
|
| 300 | 322 | |
| 301 | 323 | // Don't bother indexing errors mate... |
| 302 | 324 | $context['robot_no_index'] = true; |
| 303 | 325 | |
| 304 | - if (!isset($context['error_title'])) |
|
| 305 | - $context['error_title'] = $txt['error_occured']; |
|
| 326 | + if (!isset($context['error_title'])) { |
|
| 327 | + $context['error_title'] = $txt['error_occured']; |
|
| 328 | + } |
|
| 306 | 329 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
| 307 | 330 | |
| 308 | 331 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
| 309 | 332 | |
| 310 | - if (empty($context['page_title'])) |
|
| 311 | - $context['page_title'] = $context['error_title']; |
|
| 333 | + if (empty($context['page_title'])) { |
|
| 334 | + $context['page_title'] = $context['error_title']; |
|
| 335 | + } |
|
| 312 | 336 | |
| 313 | 337 | loadTemplate('Errors'); |
| 314 | 338 | $context['sub_template'] = 'fatal_error'; |
@@ -316,23 +340,26 @@ discard block |
||
| 316 | 340 | // If this is SSI, what do they want us to do? |
| 317 | 341 | if (SMF == 'SSI') |
| 318 | 342 | { |
| 319 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
| 320 | - $ssi_on_error_method(); |
|
| 321 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 322 | - loadSubTemplate('fatal_error'); |
|
| 343 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
| 344 | + $ssi_on_error_method(); |
|
| 345 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 346 | + loadSubTemplate('fatal_error'); |
|
| 347 | + } |
|
| 323 | 348 | |
| 324 | 349 | // No layers? |
| 325 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 326 | - exit; |
|
| 350 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 351 | + exit; |
|
| 352 | + } |
|
| 327 | 353 | } |
| 328 | 354 | // Alternatively from the cron call? |
| 329 | 355 | elseif (SMF == 'BACKGROUND') |
| 330 | 356 | { |
| 331 | 357 | // We can't rely on even having language files available. |
| 332 | - if (defined('FROM_CLI') && FROM_CLI) |
|
| 333 | - echo 'cron error: ', $context['error_message']; |
|
| 334 | - else |
|
| 335 | - echo 'An error occurred. More information may be available in your logs.'; |
|
| 358 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
| 359 | + echo 'cron error: ', $context['error_message']; |
|
| 360 | + } else { |
|
| 361 | + echo 'An error occurred. More information may be available in your logs.'; |
|
| 362 | + } |
|
| 336 | 363 | exit; |
| 337 | 364 | } |
| 338 | 365 | |
@@ -360,8 +387,8 @@ discard block |
||
| 360 | 387 | |
| 361 | 388 | set_fatal_error_headers(); |
| 362 | 389 | |
| 363 | - if (!empty($maintenance)) |
|
| 364 | - echo '<!DOCTYPE html> |
|
| 390 | + if (!empty($maintenance)) { |
|
| 391 | + echo '<!DOCTYPE html> |
|
| 365 | 392 | <html> |
| 366 | 393 | <head> |
| 367 | 394 | <meta name="robots" content="noindex"> |
@@ -372,6 +399,7 @@ discard block |
||
| 372 | 399 | ', $mmessage, ' |
| 373 | 400 | </body> |
| 374 | 401 | </html>'; |
| 402 | + } |
|
| 375 | 403 | |
| 376 | 404 | die(); |
| 377 | 405 | } |
@@ -393,15 +421,17 @@ discard block |
||
| 393 | 421 | // For our purposes, we're gonna want this on if at all possible. |
| 394 | 422 | $modSettings['cache_enable'] = '1'; |
| 395 | 423 | |
| 396 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 397 | - $db_last_error = max($db_last_error, $temp); |
|
| 424 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 425 | + $db_last_error = max($db_last_error, $temp); |
|
| 426 | + } |
|
| 398 | 427 | |
| 399 | 428 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
| 400 | 429 | { |
| 401 | 430 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
| 402 | 431 | cache_put_data('db_last_error', time(), 600); |
| 403 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 404 | - logLastDatabaseError(); |
|
| 432 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 433 | + logLastDatabaseError(); |
|
| 434 | + } |
|
| 405 | 435 | |
| 406 | 436 | // Language files aren't loaded yet :(. |
| 407 | 437 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -482,12 +512,14 @@ discard block |
||
| 482 | 512 | global $smcFunc, $user_info, $modSettings; |
| 483 | 513 | |
| 484 | 514 | // Don't bother if Who's Online is disabled. |
| 485 | - if (empty($modSettings['who_enabled'])) |
|
| 486 | - return; |
|
| 515 | + if (empty($modSettings['who_enabled'])) { |
|
| 516 | + return; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Maybe they came from SSI or similar where sessions are not recorded? |
| 489 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
| 490 | - return; |
|
| 520 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 491 | 523 | |
| 492 | 524 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
| 493 | 525 | |
@@ -506,8 +538,9 @@ discard block |
||
| 506 | 538 | $url = smf_json_decode($url, true); |
| 507 | 539 | $url['error'] = $error; |
| 508 | 540 | |
| 509 | - if (!empty($sprintf)) |
|
| 510 | - $url['error_params'] = $sprintf; |
|
| 541 | + if (!empty($sprintf)) { |
|
| 542 | + $url['error_params'] = $sprintf; |
|
| 543 | + } |
|
| 511 | 544 | |
| 512 | 545 | $smcFunc['db_query']('', ' |
| 513 | 546 | UPDATE {db_prefix}log_online |
@@ -538,10 +571,11 @@ discard block |
||
| 538 | 571 | |
| 539 | 572 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
| 540 | 573 | |
| 541 | - if (!isset($statuses[$code])) |
|
| 542 | - header($protocol . ' 500 Internal Server Error'); |
|
| 543 | - else |
|
| 544 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 545 | -} |
|
| 574 | + if (!isset($statuses[$code])) { |
|
| 575 | + header($protocol . ' 500 Internal Server Error'); |
|
| 576 | + } else { |
|
| 577 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 578 | + } |
|
| 579 | + } |
|
| 546 | 580 | |
| 547 | 581 | ?> |
| 548 | 582 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_search_query' => 'smf_db_query', |
| 29 | 30 | 'db_search_support' => 'smf_db_search_support', |
| 30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
| 31 | 32 | 'db_support_ignore' => true, |
| 32 | 33 | ); |
| 33 | -} |
|
| 34 | + } |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /** |
| 36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
| 54 | 56 | { |
| 55 | 57 | global $smcFunc; |
| 56 | 58 | |
| 57 | - if ($size == 'small') |
|
| 58 | - $size = 'smallint(5)'; |
|
| 59 | - elseif ($size == 'medium') |
|
| 60 | - $size = 'mediumint(8)'; |
|
| 61 | - else |
|
| 62 | - $size = 'int(10)'; |
|
| 59 | + if ($size == 'small') { |
|
| 60 | + $size = 'smallint(5)'; |
|
| 61 | + } elseif ($size == 'medium') { |
|
| 62 | + $size = 'mediumint(8)'; |
|
| 63 | + } else { |
|
| 64 | + $size = 'int(10)'; |
|
| 65 | + } |
|
| 63 | 66 | |
| 64 | 67 | $smcFunc['db_query']('', ' |
| 65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | is_not_guest(); |
| 35 | 36 | |
| 36 | 37 | // You have to specify a board to turn notifications on! |
| 37 | - if (empty($board)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($board)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // No subaction: find out what to do. |
| 41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
| 48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
| 49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
| 50 | 52 | |
| 51 | - if ($mode > 1) |
|
| 52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | + if ($mode > 1) { |
|
| 54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | 55 | $smcFunc['db_insert']('ignore', |
| 54 | 56 | '{db_prefix}log_notify', |
| 55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
| 56 | 58 | array($user_info['id'], $board), |
| 57 | 59 | array('id_member', 'id_board') |
| 58 | 60 | ); |
| 59 | - else |
|
| 60 | - $smcFunc['db_query']('', ' |
|
| 61 | + } else { |
|
| 62 | + $smcFunc['db_query']('', ' |
|
| 61 | 63 | DELETE FROM {db_prefix}log_notify |
| 62 | 64 | WHERE id_member = {int:current_member} |
| 63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
| 66 | 68 | 'current_member' => $user_info['id'], |
| 67 | 69 | ) |
| 68 | 70 | ); |
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | } |
| 71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
| 81 | 84 | ), |
| 82 | 85 | ); |
| 83 | 86 | $context['sub_template'] = 'generic_xml'; |
| 87 | + } else { |
|
| 88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 89 | + } |
|
| 84 | 90 | } |
| 85 | - else |
|
| 86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 87 | -} |
|
| 88 | 91 | |
| 89 | 92 | /** |
| 90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
| 108 | 111 | $mode = (int) $_GET['mode']; |
| 109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
| 110 | 113 | |
| 111 | - if (empty($mode)) |
|
| 112 | - $mode = 1; |
|
| 114 | + if (empty($mode)) { |
|
| 115 | + $mode = 1; |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | $request = $smcFunc['db_query']('', ' |
| 115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
| 132 | 136 | 'id_msg' => 0, |
| 133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
| 134 | 138 | ); |
| 135 | - } |
|
| 136 | - else |
|
| 139 | + } else |
|
| 137 | 140 | { |
| 138 | 141 | $insert = false; |
| 139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
| 160 | 163 | array($user_info['id'], $log['id_topic']), |
| 161 | 164 | array('id_member', 'id_board') |
| 162 | 165 | ); |
| 163 | - } |
|
| 164 | - else |
|
| 165 | - $smcFunc['db_query']('', ' |
|
| 166 | + } else { |
|
| 167 | + $smcFunc['db_query']('', ' |
|
| 166 | 168 | DELETE FROM {db_prefix}log_notify |
| 167 | 169 | WHERE id_topic = {int:topic} |
| 168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
| 170 | 172 | 'topic' => $log['id_topic'], |
| 171 | 173 | 'member' => $user_info['id'], |
| 172 | 174 | )); |
| 175 | + } |
|
| 173 | 176 | |
| 174 | 177 | } |
| 175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
| 186 | 189 | ), |
| 187 | 190 | ); |
| 188 | 191 | $context['sub_template'] = 'generic_xml'; |
| 192 | + } else { |
|
| 193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 194 | + } |
|
| 189 | 195 | } |
| 190 | - else |
|
| 191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 192 | -} |
|
| 193 | 196 | |
| 194 | 197 | ?> |
| 195 | 198 | \ No newline at end of file |