@@ -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); |
@@ -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 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Check for the administrative permission to do this. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
85 | 87 | ); |
86 | 88 | |
87 | 89 | // Set up the filtering... |
88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
89 | - $filter = array( |
|
90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
91 | + $filter = array( |
|
90 | 92 | 'variable' => $_GET['filter'], |
91 | 93 | 'value' => array( |
92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
96 | 98 | ); |
99 | + } |
|
97 | 100 | |
98 | 101 | // Deleting, are we? |
99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
100 | - deleteErrors(); |
|
102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
103 | + deleteErrors(); |
|
104 | + } |
|
101 | 105 | |
102 | 106 | // Just how many errors are there? |
103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
112 | 116 | $smcFunc['db_free_result']($result); |
113 | 117 | |
114 | 118 | // If this filter is empty... |
115 | - if ($num_errors == 0 && isset($filter)) |
|
116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
119 | + if ($num_errors == 0 && isset($filter)) { |
|
120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Clean up start. |
119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
120 | - $_GET['start'] = 0; |
|
124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
125 | + $_GET['start'] = 0; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Do we want to reverse error listing? |
123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
127 | 133 | $context['start'] = $_GET['start']; |
128 | 134 | |
129 | 135 | // Update the error count |
130 | - if (!isset($filter)) |
|
131 | - $context['num_errors'] = $num_errors; |
|
132 | - else |
|
136 | + if (!isset($filter)) { |
|
137 | + $context['num_errors'] = $num_errors; |
|
138 | + } else |
|
133 | 139 | { |
134 | 140 | // We want all errors, not just the number of filtered messages... |
135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
162 | 168 | { |
163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | - if ($search_message == $filter['value']['sql']) |
|
165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
170 | + if ($search_message == $filter['value']['sql']) { |
|
171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
172 | + } |
|
166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
167 | 174 | |
168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
221 | 228 | 'members' => count($members), |
222 | 229 | ) |
223 | 230 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
225 | - $members[$row['id_member']] = $row; |
|
231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
232 | + $members[$row['id_member']] = $row; |
|
233 | + } |
|
226 | 234 | $smcFunc['db_free_result']($request); |
227 | 235 | |
228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
254 | 262 | $id = $filter['value']['sql']; |
255 | 263 | loadMemberData($id, false, 'minimal'); |
256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
257 | - } |
|
258 | - elseif ($filter['variable'] == 'url') |
|
259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
260 | - elseif ($filter['variable'] == 'message') |
|
265 | + } elseif ($filter['variable'] == 'url') { |
|
266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
267 | + } elseif ($filter['variable'] == 'message') |
|
261 | 268 | { |
262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
264 | - } |
|
265 | - elseif ($filter['variable'] == 'error_type') |
|
271 | + } elseif ($filter['variable'] == 'error_type') |
|
266 | 272 | { |
267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
274 | + } else { |
|
275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
268 | 276 | } |
269 | - else |
|
270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
271 | 277 | } |
272 | 278 | |
273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
309 | 315 | |
310 | 316 | // Finally, work out what is the last tab! |
311 | - if (isset($context['error_types'][$sum])) |
|
312 | - $context['error_types'][$sum]['is_last'] = true; |
|
313 | - else |
|
314 | - $context['error_types']['all']['is_last'] = true; |
|
317 | + if (isset($context['error_types'][$sum])) { |
|
318 | + $context['error_types'][$sum]['is_last'] = true; |
|
319 | + } else { |
|
320 | + $context['error_types']['all']['is_last'] = true; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // And this is pretty basic ;). |
317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
337 | 344 | validateToken('admin-el'); |
338 | 345 | |
339 | 346 | // Delete all or just some? |
340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
341 | - $smcFunc['db_query']('truncate_table', ' |
|
347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
348 | + $smcFunc['db_query']('truncate_table', ' |
|
342 | 349 | TRUNCATE {db_prefix}log_errors', |
343 | 350 | array( |
344 | 351 | ) |
345 | 352 | ); |
353 | + } |
|
346 | 354 | // Deleting all with a filter? |
347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
348 | - $smcFunc['db_query']('', ' |
|
355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
356 | + $smcFunc['db_query']('', ' |
|
349 | 357 | DELETE FROM {db_prefix}log_errors |
350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
351 | 359 | array( |
352 | 360 | 'filter' => $filter['value']['sql'], |
353 | 361 | ) |
354 | 362 | ); |
363 | + } |
|
355 | 364 | // Just specific errors? |
356 | 365 | elseif (!empty($_POST['delete'])) |
357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
398 | 407 | |
399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
411 | + } |
|
402 | 412 | |
403 | 413 | // get the min and max lines |
404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
406 | 416 | |
407 | - if ($max <= 0 || $min >= $max) |
|
408 | - fatal_lang_error('error_bad_line'); |
|
417 | + if ($max <= 0 || $min >= $max) { |
|
418 | + fatal_lang_error('error_bad_line'); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
411 | 422 |
@@ -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 | * Outputs xml data representing recent information or a profile. |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | global $query_this_board, $smcFunc, $forum_version; |
38 | 39 | |
39 | 40 | // If it's not enabled, die. |
40 | - if (empty($modSettings['xmlnews_enable'])) |
|
41 | - obExit(false); |
|
41 | + if (empty($modSettings['xmlnews_enable'])) { |
|
42 | + obExit(false); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | loadLanguage('Stats'); |
44 | 46 | |
@@ -53,8 +55,9 @@ discard block |
||
53 | 55 | if (!empty($_REQUEST['c']) && empty($board)) |
54 | 56 | { |
55 | 57 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
56 | - foreach ($_REQUEST['c'] as $i => $c) |
|
57 | - $_REQUEST['c'][$i] = (int) $c; |
|
58 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
59 | + $_REQUEST['c'][$i] = (int) $c; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | if (count($_REQUEST['c']) == 1) |
60 | 63 | { |
@@ -90,18 +93,20 @@ discard block |
||
90 | 93 | } |
91 | 94 | $smcFunc['db_free_result']($request); |
92 | 95 | |
93 | - if (!empty($boards)) |
|
94 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
96 | + if (!empty($boards)) { |
|
97 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
98 | + } |
|
95 | 99 | |
96 | 100 | // Try to limit the number of messages we look through. |
97 | - if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
|
98 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
99 | - } |
|
100 | - elseif (!empty($_REQUEST['boards'])) |
|
101 | + if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) { |
|
102 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
103 | + } |
|
104 | + } elseif (!empty($_REQUEST['boards'])) |
|
101 | 105 | { |
102 | 106 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
103 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
104 | - $_REQUEST['boards'][$i] = (int) $b; |
|
107 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
108 | + $_REQUEST['boards'][$i] = (int) $b; |
|
109 | + } |
|
105 | 110 | |
106 | 111 | $request = $smcFunc['db_query']('', ' |
107 | 112 | SELECT b.id_board, b.num_posts, b.name |
@@ -117,29 +122,32 @@ discard block |
||
117 | 122 | |
118 | 123 | // Either the board specified doesn't exist or you have no access. |
119 | 124 | $num_boards = $smcFunc['db_num_rows']($request); |
120 | - if ($num_boards == 0) |
|
121 | - fatal_lang_error('no_board'); |
|
125 | + if ($num_boards == 0) { |
|
126 | + fatal_lang_error('no_board'); |
|
127 | + } |
|
122 | 128 | |
123 | 129 | $total_posts = 0; |
124 | 130 | $boards = array(); |
125 | 131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
126 | 132 | { |
127 | - if ($num_boards == 1) |
|
128 | - $feed_title = ' - ' . strip_tags($row['name']); |
|
133 | + if ($num_boards == 1) { |
|
134 | + $feed_title = ' - ' . strip_tags($row['name']); |
|
135 | + } |
|
129 | 136 | |
130 | 137 | $boards[] = $row['id_board']; |
131 | 138 | $total_posts += $row['num_posts']; |
132 | 139 | } |
133 | 140 | $smcFunc['db_free_result']($request); |
134 | 141 | |
135 | - if (!empty($boards)) |
|
136 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
142 | + if (!empty($boards)) { |
|
143 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
144 | + } |
|
137 | 145 | |
138 | 146 | // The more boards, the more we're going to look through... |
139 | - if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
|
140 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
141 | - } |
|
142 | - elseif (!empty($board)) |
|
147 | + if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) { |
|
148 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
149 | + } |
|
150 | + } elseif (!empty($board)) |
|
143 | 151 | { |
144 | 152 | $request = $smcFunc['db_query']('', ' |
145 | 153 | SELECT num_posts |
@@ -158,10 +166,10 @@ discard block |
||
158 | 166 | $query_this_board = 'b.id_board = ' . $board; |
159 | 167 | |
160 | 168 | // Try to look through just a few messages, if at all possible. |
161 | - if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) |
|
162 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
163 | - } |
|
164 | - else |
|
169 | + if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) { |
|
170 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
171 | + } |
|
172 | + } else |
|
165 | 173 | { |
166 | 174 | $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
167 | 175 | AND b.id_board != ' . $modSettings['recycle_board'] : ''); |
@@ -184,30 +192,35 @@ discard block |
||
184 | 192 | // Easy adding of sub actions |
185 | 193 | call_integration_hook('integrate_xmlfeeds', array(&$subActions)); |
186 | 194 | |
187 | - if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
188 | - $_GET['sa'] = 'recent'; |
|
195 | + if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
196 | + $_GET['sa'] = 'recent'; |
|
197 | + } |
|
189 | 198 | |
190 | 199 | // We only want some information, not all of it. |
191 | 200 | $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']); |
192 | - foreach (array('board', 'boards', 'c') as $var) |
|
193 | - if (isset($_REQUEST[$var])) |
|
201 | + foreach (array('board', 'boards', 'c') as $var) { |
|
202 | + if (isset($_REQUEST[$var])) |
|
194 | 203 | $cachekey[] = $_REQUEST[$var]; |
204 | + } |
|
195 | 205 | $cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : '')); |
196 | 206 | $cache_t = microtime(); |
197 | 207 | |
198 | 208 | // Get the associative array representing the xml. |
199 | - if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) |
|
200 | - $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
209 | + if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) { |
|
210 | + $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
211 | + } |
|
201 | 212 | if (empty($xml)) |
202 | 213 | { |
203 | 214 | $call = call_helper($subActions[$_GET['sa']][0], true); |
204 | 215 | |
205 | - if (!empty($call)) |
|
206 | - $xml = call_user_func($call, $xml_format); |
|
216 | + if (!empty($call)) { |
|
217 | + $xml = call_user_func($call, $xml_format); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3) |
209 | - || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) |
|
210 | - cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
221 | + || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) { |
|
222 | + cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
223 | + } |
|
211 | 224 | } |
212 | 225 | |
213 | 226 | $feed_title = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_title) ? $feed_title : ''); |
@@ -218,19 +231,21 @@ discard block |
||
218 | 231 | |
219 | 232 | // This is an xml file.... |
220 | 233 | ob_end_clean(); |
221 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
222 | - @ob_start('ob_gzhandler'); |
|
223 | - else |
|
224 | - ob_start(); |
|
234 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
235 | + @ob_start('ob_gzhandler'); |
|
236 | + } else { |
|
237 | + ob_start(); |
|
238 | + } |
|
225 | 239 | |
226 | - if ($xml_format == 'smf' || isset($_REQUEST['debug'])) |
|
227 | - header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
228 | - elseif ($xml_format == 'rss' || $xml_format == 'rss2') |
|
229 | - header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
230 | - elseif ($xml_format == 'atom') |
|
231 | - header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
232 | - elseif ($xml_format == 'rdf') |
|
233 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
240 | + if ($xml_format == 'smf' || isset($_REQUEST['debug'])) { |
|
241 | + header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
242 | + } elseif ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
243 | + header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
244 | + } elseif ($xml_format == 'atom') { |
|
245 | + header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
246 | + } elseif ($xml_format == 'rdf') { |
|
247 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
248 | + } |
|
234 | 249 | |
235 | 250 | // First, output the xml header. |
236 | 251 | echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>'; |
@@ -247,8 +262,9 @@ discard block |
||
247 | 262 | <description>', cdata_parse(strip_tags($txt['xml_rss_desc'])), '</description>'; |
248 | 263 | |
249 | 264 | // RSS2 calls for this. |
250 | - if ($xml_format == 'rss2') |
|
251 | - echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />'; |
|
265 | + if ($xml_format == 'rss2') { |
|
266 | + echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />'; |
|
267 | + } |
|
252 | 268 | |
253 | 269 | // Output all of the associative array, start indenting with 2 tabs, and name everything "item". |
254 | 270 | dumpTags($xml, 2, 'item', $xml_format); |
@@ -257,12 +273,12 @@ discard block |
||
257 | 273 | echo ' |
258 | 274 | </channel> |
259 | 275 | </rss>'; |
260 | - } |
|
261 | - elseif ($xml_format == 'atom') |
|
276 | + } elseif ($xml_format == 'atom') |
|
262 | 277 | { |
263 | - foreach ($_REQUEST as $var => $val) |
|
264 | - if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
278 | + foreach ($_REQUEST as $var => $val) { |
|
279 | + if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
265 | 280 | $url_parts[] = $var . '=' . (is_array($_REQUEST[$var]) ? implode(',', $_REQUEST[$var]) : $_REQUEST[$var]); |
281 | + } |
|
266 | 282 | |
267 | 283 | echo ' |
268 | 284 | <feed xmlns="http://www.w3.org/2005/Atom"> |
@@ -283,8 +299,7 @@ discard block |
||
283 | 299 | |
284 | 300 | echo ' |
285 | 301 | </feed>'; |
286 | - } |
|
287 | - elseif ($xml_format == 'rdf') |
|
302 | + } elseif ($xml_format == 'rdf') |
|
288 | 303 | { |
289 | 304 | echo ' |
290 | 305 | <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/"> |
@@ -295,9 +310,10 @@ discard block |
||
295 | 310 | <items> |
296 | 311 | <rdf:Seq>'; |
297 | 312 | |
298 | - foreach ($xml as $item) |
|
299 | - echo ' |
|
313 | + foreach ($xml as $item) { |
|
314 | + echo ' |
|
300 | 315 | <rdf:li rdf:resource="', $item['link'], '" />'; |
316 | + } |
|
301 | 317 | |
302 | 318 | echo ' |
303 | 319 | </rdf:Seq> |
@@ -337,13 +353,15 @@ discard block |
||
337 | 353 | { |
338 | 354 | global $modSettings, $context, $scripturl; |
339 | 355 | |
340 | - if (substr($val, 0, strlen($scripturl)) != $scripturl) |
|
341 | - return $val; |
|
356 | + if (substr($val, 0, strlen($scripturl)) != $scripturl) { |
|
357 | + return $val; |
|
358 | + } |
|
342 | 359 | |
343 | 360 | call_integration_hook('integrate_fix_url', array(&$val)); |
344 | 361 | |
345 | - if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
|
346 | - return $val; |
|
362 | + if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) { |
|
363 | + return $val; |
|
364 | + } |
|
347 | 365 | |
348 | 366 | $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function ($m) use ($scripturl) |
349 | 367 | { |
@@ -365,8 +383,9 @@ discard block |
||
365 | 383 | global $smcFunc; |
366 | 384 | |
367 | 385 | // Do we even need to do this? |
368 | - if (strpbrk($data, '<>&') == false) |
|
369 | - return $data; |
|
386 | + if (strpbrk($data, '<>&') == false) { |
|
387 | + return $data; |
|
388 | + } |
|
370 | 389 | |
371 | 390 | $cdata = '<, |
377 | 396 | $smcFunc['strpos']($data, ']', $pos), |
378 | 397 | ); |
379 | - if ($ns != '') |
|
380 | - $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
398 | + if ($ns != '') { |
|
399 | + $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
400 | + } |
|
381 | 401 | foreach ($positions as $k => $dummy) |
382 | 402 | { |
383 | - if ($dummy === false) |
|
384 | - unset($positions[$k]); |
|
403 | + if ($dummy === false) { |
|
404 | + unset($positions[$k]); |
|
405 | + } |
|
385 | 406 | } |
386 | 407 | |
387 | 408 | $old = $pos; |
388 | 409 | $pos = empty($positions) ? $n : min($positions); |
389 | 410 | |
390 | - if ($pos - $old > 0) |
|
391 | - $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
392 | - if ($pos >= $n) |
|
393 | - break; |
|
411 | + if ($pos - $old > 0) { |
|
412 | + $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
413 | + } |
|
414 | + if ($pos >= $n) { |
|
415 | + break; |
|
416 | + } |
|
394 | 417 | |
395 | 418 | if ($smcFunc['substr']($data, $pos, 1) == '<') |
396 | 419 | { |
397 | 420 | $pos2 = $smcFunc['strpos']($data, '>', $pos); |
398 | - if ($pos2 === false) |
|
399 | - $pos2 = $n; |
|
400 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '/') |
|
401 | - $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
402 | - else |
|
403 | - $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == '/') { |
|
425 | + $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
426 | + } else { |
|
427 | + $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == ']') |
|
430 | + } elseif ($smcFunc['substr']($data, $pos, 1) == ']') |
|
407 | 431 | { |
408 | 432 | $cdata .= ']]>]< == '&') |
|
434 | + } elseif ($smcFunc['substr']($data, $pos, 1) == '&') |
|
412 | 435 | { |
413 | 436 | $pos2 = $smcFunc['strpos']($data, ';', $pos); |
414 | - if ($pos2 === false) |
|
415 | - $pos2 = $n; |
|
437 | + if ($pos2 === false) { |
|
438 | + $pos2 = $n; |
|
439 | + } |
|
416 | 440 | $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1); |
417 | 441 | |
418 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '#') |
|
419 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
420 | - elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
|
421 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '< == '#') { |
|
443 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
444 | + } elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) { |
|
445 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
446 | + } |
|
422 | 447 | |
423 | 448 | $pos = $pos2 + 1; |
424 | 449 | } |
@@ -456,19 +481,22 @@ discard block |
||
456 | 481 | 'gender', |
457 | 482 | 'blurb', |
458 | 483 | ); |
459 | - if ($xml_format != 'atom') |
|
460 | - $keysToCdata[] = 'category'; |
|
484 | + if ($xml_format != 'atom') { |
|
485 | + $keysToCdata[] = 'category'; |
|
486 | + } |
|
461 | 487 | |
462 | 488 | // For every array in the data... |
463 | 489 | foreach ($data as $key => $val) |
464 | 490 | { |
465 | 491 | // Skip it, it's been set to null. |
466 | - if ($val === null) |
|
467 | - continue; |
|
492 | + if ($val === null) { |
|
493 | + continue; |
|
494 | + } |
|
468 | 495 | |
469 | 496 | // If the value should maybe be CDATA, do that now. |
470 | - if (!is_array($val) && in_array($key, $keysToCdata)) |
|
471 | - $val = cdata_parse($val); |
|
497 | + if (!is_array($val) && in_array($key, $keysToCdata)) { |
|
498 | + $val = cdata_parse($val); |
|
499 | + } |
|
472 | 500 | |
473 | 501 | // If a tag was passed, use it instead of the key. |
474 | 502 | $key = isset($tag) ? $tag : $key; |
@@ -484,11 +512,11 @@ discard block |
||
484 | 512 | } |
485 | 513 | |
486 | 514 | // If it's empty/0/nothing simply output an empty tag. |
487 | - if ($val == '') |
|
488 | - echo '<', $key, ' />'; |
|
489 | - elseif ($xml_format == 'atom' && $key == 'category') |
|
490 | - echo '<', $key, ' term="', $val, '" />'; |
|
491 | - else |
|
515 | + if ($val == '') { |
|
516 | + echo '<', $key, ' />'; |
|
517 | + } elseif ($xml_format == 'atom' && $key == 'category') { |
|
518 | + echo '<', $key, ' term="', $val, '" />'; |
|
519 | + } else |
|
492 | 520 | { |
493 | 521 | // Beginning tag. |
494 | 522 | if ($xml_format == 'rdf' && $key == 'item' && isset($val['link'])) |
@@ -496,11 +524,11 @@ discard block |
||
496 | 524 | echo '<', $key, ' rdf:about="', fix_possible_url($val['link']), '">'; |
497 | 525 | echo "\n", str_repeat("\t", $i + 1); |
498 | 526 | echo '<dc:format>text/html</dc:format>'; |
527 | + } elseif ($xml_format == 'atom' && $key == 'summary') { |
|
528 | + echo '<', $key, ' type="html">'; |
|
529 | + } else { |
|
530 | + echo '<', $key, '>'; |
|
499 | 531 | } |
500 | - elseif ($xml_format == 'atom' && $key == 'summary') |
|
501 | - echo '<', $key, ' type="html">'; |
|
502 | - else |
|
503 | - echo '<', $key, '>'; |
|
504 | 532 | |
505 | 533 | // The element's value. |
506 | 534 | if (is_array($val)) |
@@ -510,11 +538,13 @@ discard block |
||
510 | 538 | echo "\n", str_repeat("\t", $i); |
511 | 539 | } |
512 | 540 | // A string with returns in it.... show this as a multiline element. |
513 | - elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) |
|
514 | - echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
541 | + elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) { |
|
542 | + echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
543 | + } |
|
515 | 544 | // A simple string. |
516 | - else |
|
517 | - echo fix_possible_url($val); |
|
545 | + else { |
|
546 | + echo fix_possible_url($val); |
|
547 | + } |
|
518 | 548 | |
519 | 549 | // Ending tag. |
520 | 550 | echo '</', $key, '>'; |
@@ -534,8 +564,9 @@ discard block |
||
534 | 564 | { |
535 | 565 | global $scripturl, $smcFunc; |
536 | 566 | |
537 | - if (!allowedTo('view_mlist')) |
|
538 | - return array(); |
|
567 | + if (!allowedTo('view_mlist')) { |
|
568 | + return array(); |
|
569 | + } |
|
539 | 570 | |
540 | 571 | // Find the most recent members. |
541 | 572 | $request = $smcFunc['db_query']('', ' |
@@ -551,35 +582,37 @@ discard block |
||
551 | 582 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
552 | 583 | { |
553 | 584 | // Make the data look rss-ish. |
554 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
555 | - $data[] = array( |
|
585 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
586 | + $data[] = array( |
|
556 | 587 | 'title' => $row['real_name'], |
557 | 588 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
558 | 589 | 'comments' => $scripturl . '?action=pm;sa=send;u=' . $row['id_member'], |
559 | 590 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['date_registered']), |
560 | 591 | 'guid' => $scripturl . '?action=profile;u=' . $row['id_member'], |
561 | 592 | ); |
562 | - elseif ($xml_format == 'rdf') |
|
563 | - $data[] = array( |
|
593 | + } elseif ($xml_format == 'rdf') { |
|
594 | + $data[] = array( |
|
564 | 595 | 'title' => $row['real_name'], |
565 | 596 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
566 | 597 | ); |
567 | - elseif ($xml_format == 'atom') |
|
568 | - $data[] = array( |
|
598 | + } elseif ($xml_format == 'atom') { |
|
599 | + $data[] = array( |
|
569 | 600 | 'title' => $row['real_name'], |
570 | 601 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
571 | 602 | 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['date_registered']), |
572 | 603 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['last_login']), |
573 | 604 | 'id' => $scripturl . '?action=profile;u=' . $row['id_member'], |
574 | 605 | ); |
606 | + } |
|
575 | 607 | // More logical format for the data, but harder to apply. |
576 | - else |
|
577 | - $data[] = array( |
|
608 | + else { |
|
609 | + $data[] = array( |
|
578 | 610 | 'name' => $row['real_name'], |
579 | 611 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['date_registered']))), |
580 | 612 | 'id' => $row['id_member'], |
581 | 613 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'] |
582 | 614 | ); |
615 | + } |
|
583 | 616 | } |
584 | 617 | $smcFunc['db_free_result']($request); |
585 | 618 | |
@@ -640,22 +673,24 @@ discard block |
||
640 | 673 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
641 | 674 | { |
642 | 675 | $smcFunc['db_free_result']($request); |
643 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
644 | - unset($context['optimize_msg']['lowest']); |
|
645 | - else |
|
646 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
676 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
677 | + unset($context['optimize_msg']['lowest']); |
|
678 | + } else { |
|
679 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
680 | + } |
|
647 | 681 | $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg'; |
648 | 682 | $loops++; |
683 | + } else { |
|
684 | + $done = true; |
|
649 | 685 | } |
650 | - else |
|
651 | - $done = true; |
|
652 | 686 | } |
653 | 687 | $data = array(); |
654 | 688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
655 | 689 | { |
656 | 690 | // Limit the length of the message, if the option is set. |
657 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
658 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
691 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
692 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
693 | + } |
|
659 | 694 | |
660 | 695 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
661 | 696 | |
@@ -663,8 +698,8 @@ discard block |
||
663 | 698 | censorText($row['subject']); |
664 | 699 | |
665 | 700 | // Being news, this actually makes sense in rss format. |
666 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
667 | - $data[] = array( |
|
701 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
702 | + $data[] = array( |
|
668 | 703 | 'title' => $row['subject'], |
669 | 704 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
670 | 705 | 'description' => $row['body'], |
@@ -674,14 +709,14 @@ discard block |
||
674 | 709 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
675 | 710 | 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
676 | 711 | ); |
677 | - elseif ($xml_format == 'rdf') |
|
678 | - $data[] = array( |
|
712 | + } elseif ($xml_format == 'rdf') { |
|
713 | + $data[] = array( |
|
679 | 714 | 'title' => $row['subject'], |
680 | 715 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
681 | 716 | 'description' => $row['body'], |
682 | 717 | ); |
683 | - elseif ($xml_format == 'atom') |
|
684 | - $data[] = array( |
|
718 | + } elseif ($xml_format == 'atom') { |
|
719 | + $data[] = array( |
|
685 | 720 | 'title' => $row['subject'], |
686 | 721 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
687 | 722 | 'summary' => $row['body'], |
@@ -695,9 +730,10 @@ discard block |
||
695 | 730 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), |
696 | 731 | 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
697 | 732 | ); |
733 | + } |
|
698 | 734 | // The biggest difference here is more information. |
699 | - else |
|
700 | - $data[] = array( |
|
735 | + else { |
|
736 | + $data[] = array( |
|
701 | 737 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))), |
702 | 738 | 'id' => $row['id_topic'], |
703 | 739 | 'subject' => $row['subject'], |
@@ -715,6 +751,7 @@ discard block |
||
715 | 751 | ), |
716 | 752 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
717 | 753 | ); |
754 | + } |
|
718 | 755 | } |
719 | 756 | $smcFunc['db_free_result']($request); |
720 | 757 | |
@@ -761,22 +798,25 @@ discard block |
||
761 | 798 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
762 | 799 | { |
763 | 800 | $smcFunc['db_free_result']($request); |
764 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
765 | - unset($context['optimize_msg']['lowest']); |
|
766 | - else |
|
767 | - $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
801 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
802 | + unset($context['optimize_msg']['lowest']); |
|
803 | + } else { |
|
804 | + $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
805 | + } |
|
768 | 806 | $loops++; |
807 | + } else { |
|
808 | + $done = true; |
|
769 | 809 | } |
770 | - else |
|
771 | - $done = true; |
|
772 | 810 | } |
773 | 811 | $messages = array(); |
774 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
775 | - $messages[] = $row['id_msg']; |
|
812 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
813 | + $messages[] = $row['id_msg']; |
|
814 | + } |
|
776 | 815 | $smcFunc['db_free_result']($request); |
777 | 816 | |
778 | - if (empty($messages)) |
|
779 | - return array(); |
|
817 | + if (empty($messages)) { |
|
818 | + return array(); |
|
819 | + } |
|
780 | 820 | |
781 | 821 | // Find the most recent posts this user can see. |
782 | 822 | $request = $smcFunc['db_query']('', ' |
@@ -806,8 +846,9 @@ discard block |
||
806 | 846 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
807 | 847 | { |
808 | 848 | // Limit the length of the message, if the option is set. |
809 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
810 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
849 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
850 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
851 | + } |
|
811 | 852 | |
812 | 853 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
813 | 854 | |
@@ -815,8 +856,8 @@ discard block |
||
815 | 856 | censorText($row['subject']); |
816 | 857 | |
817 | 858 | // Doesn't work as well as news, but it kinda does.. |
818 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
819 | - $data[] = array( |
|
859 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
860 | + $data[] = array( |
|
820 | 861 | 'title' => $row['subject'], |
821 | 862 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
822 | 863 | 'description' => $row['body'], |
@@ -826,14 +867,14 @@ discard block |
||
826 | 867 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
827 | 868 | 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] |
828 | 869 | ); |
829 | - elseif ($xml_format == 'rdf') |
|
830 | - $data[] = array( |
|
870 | + } elseif ($xml_format == 'rdf') { |
|
871 | + $data[] = array( |
|
831 | 872 | 'title' => $row['subject'], |
832 | 873 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
833 | 874 | 'description' => $row['body'], |
834 | 875 | ); |
835 | - elseif ($xml_format == 'atom') |
|
836 | - $data[] = array( |
|
876 | + } elseif ($xml_format == 'atom') { |
|
877 | + $data[] = array( |
|
837 | 878 | 'title' => $row['subject'], |
838 | 879 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
839 | 880 | 'summary' => $row['body'], |
@@ -847,9 +888,10 @@ discard block |
||
847 | 888 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), |
848 | 889 | 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
849 | 890 | ); |
891 | + } |
|
850 | 892 | // A lot of information here. Should be enough to please the rss-ers. |
851 | - else |
|
852 | - $data[] = array( |
|
893 | + else { |
|
894 | + $data[] = array( |
|
853 | 895 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))), |
854 | 896 | 'id' => $row['id_msg'], |
855 | 897 | 'subject' => $row['subject'], |
@@ -876,6 +918,7 @@ discard block |
||
876 | 918 | ), |
877 | 919 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] |
878 | 920 | ); |
921 | + } |
|
879 | 922 | } |
880 | 923 | $smcFunc['db_free_result']($request); |
881 | 924 | |
@@ -895,20 +938,22 @@ discard block |
||
895 | 938 | global $scripturl, $memberContext, $user_profile, $user_info; |
896 | 939 | |
897 | 940 | // You must input a valid user.... |
898 | - if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) |
|
899 | - return array(); |
|
941 | + if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) { |
|
942 | + return array(); |
|
943 | + } |
|
900 | 944 | |
901 | 945 | // Make sure the id is a number and not "I like trying to hack the database". |
902 | 946 | $_GET['u'] = (int) $_GET['u']; |
903 | 947 | // Load the member's contextual information! |
904 | - if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) |
|
905 | - return array(); |
|
948 | + if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) { |
|
949 | + return array(); |
|
950 | + } |
|
906 | 951 | |
907 | 952 | // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. |
908 | 953 | $profile = &$memberContext[$_GET['u']]; |
909 | 954 | |
910 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
911 | - $data = array(array( |
|
955 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
956 | + $data = array(array( |
|
912 | 957 | 'title' => $profile['name'], |
913 | 958 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
914 | 959 | 'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
@@ -916,14 +961,14 @@ discard block |
||
916 | 961 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered']), |
917 | 962 | 'guid' => $scripturl . '?action=profile;u=' . $profile['id'], |
918 | 963 | )); |
919 | - elseif ($xml_format == 'rdf') |
|
920 | - $data = array(array( |
|
964 | + } elseif ($xml_format == 'rdf') { |
|
965 | + $data = array(array( |
|
921 | 966 | 'title' => $profile['name'], |
922 | 967 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
923 | 968 | 'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
924 | 969 | )); |
925 | - elseif ($xml_format == 'atom') |
|
926 | - $data[] = array( |
|
970 | + } elseif ($xml_format == 'atom') { |
|
971 | + $data[] = array( |
|
927 | 972 | 'title' => $profile['name'], |
928 | 973 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
929 | 974 | 'summary' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
@@ -937,7 +982,7 @@ discard block |
||
937 | 982 | 'id' => $scripturl . '?action=profile;u=' . $profile['id'], |
938 | 983 | 'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : '', |
939 | 984 | ); |
940 | - else |
|
985 | + } else |
|
941 | 986 | { |
942 | 987 | $data = array( |
943 | 988 | 'username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? $profile['username'] : '', |
@@ -951,34 +996,43 @@ discard block |
||
951 | 996 | ); |
952 | 997 | |
953 | 998 | // Everything below here might not be set, and thus maybe shouldn't be displayed. |
954 | - if ($profile['gender']['name'] != '') |
|
955 | - $data['gender'] = $profile['gender']['name']; |
|
999 | + if ($profile['gender']['name'] != '') { |
|
1000 | + $data['gender'] = $profile['gender']['name']; |
|
1001 | + } |
|
956 | 1002 | |
957 | - if ($profile['avatar']['name'] != '') |
|
958 | - $data['avatar'] = $profile['avatar']['url']; |
|
1003 | + if ($profile['avatar']['name'] != '') { |
|
1004 | + $data['avatar'] = $profile['avatar']['url']; |
|
1005 | + } |
|
959 | 1006 | |
960 | 1007 | // If they are online, show an empty tag... no reason to put anything inside it. |
961 | - if ($profile['online']['is_online']) |
|
962 | - $data['online'] = ''; |
|
963 | - |
|
964 | - if ($profile['signature'] != '') |
|
965 | - $data['signature'] = $profile['signature']; |
|
966 | - if ($profile['blurb'] != '') |
|
967 | - $data['blurb'] = $profile['blurb']; |
|
968 | - if ($profile['title'] != '') |
|
969 | - $data['title'] = $profile['title']; |
|
970 | - |
|
971 | - if ($profile['website']['title'] != '') |
|
972 | - $data['website'] = array( |
|
1008 | + if ($profile['online']['is_online']) { |
|
1009 | + $data['online'] = ''; |
|
1010 | + } |
|
1011 | + |
|
1012 | + if ($profile['signature'] != '') { |
|
1013 | + $data['signature'] = $profile['signature']; |
|
1014 | + } |
|
1015 | + if ($profile['blurb'] != '') { |
|
1016 | + $data['blurb'] = $profile['blurb']; |
|
1017 | + } |
|
1018 | + if ($profile['title'] != '') { |
|
1019 | + $data['title'] = $profile['title']; |
|
1020 | + } |
|
1021 | + |
|
1022 | + if ($profile['website']['title'] != '') { |
|
1023 | + $data['website'] = array( |
|
973 | 1024 | 'title' => $profile['website']['title'], |
974 | 1025 | 'link' => $profile['website']['url'] |
975 | 1026 | ); |
1027 | + } |
|
976 | 1028 | |
977 | - if ($profile['group'] != '') |
|
978 | - $data['position'] = $profile['group']; |
|
1029 | + if ($profile['group'] != '') { |
|
1030 | + $data['position'] = $profile['group']; |
|
1031 | + } |
|
979 | 1032 | |
980 | - if ($profile['show_email']) |
|
981 | - $data['email'] = $profile['email']; |
|
1033 | + if ($profile['show_email']) { |
|
1034 | + $data['email'] = $profile['email']; |
|
1035 | + } |
|
982 | 1036 | |
983 | 1037 | if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') |
984 | 1038 | { |
@@ -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 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
24 | 25 | global $time_start, $smcFunc, $modSettings; |
25 | 26 | |
26 | 27 | // Special case for doing the mail queue. |
27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
28 | - ReduceMailQueue(); |
|
29 | - else |
|
28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
29 | + ReduceMailQueue(); |
|
30 | + } else |
|
30 | 31 | { |
31 | 32 | $task_string = ''; |
32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
53 | 54 | |
54 | 55 | // How long in seconds it the gap? |
55 | 56 | $duration = $row['time_regularity']; |
56 | - if ($row['time_unit'] == 'm') |
|
57 | - $duration *= 60; |
|
58 | - elseif ($row['time_unit'] == 'h') |
|
59 | - $duration *= 3600; |
|
60 | - elseif ($row['time_unit'] == 'd') |
|
61 | - $duration *= 86400; |
|
62 | - elseif ($row['time_unit'] == 'w') |
|
63 | - $duration *= 604800; |
|
57 | + if ($row['time_unit'] == 'm') { |
|
58 | + $duration *= 60; |
|
59 | + } elseif ($row['time_unit'] == 'h') { |
|
60 | + $duration *= 3600; |
|
61 | + } elseif ($row['time_unit'] == 'd') { |
|
62 | + $duration *= 86400; |
|
63 | + } elseif ($row['time_unit'] == 'w') { |
|
64 | + $duration *= 604800; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // If we were really late running this task actually skip the next one. |
66 | - if (time() + ($duration / 2) > $next_time) |
|
67 | - $next_time += $duration; |
|
68 | + if (time() + ($duration / 2) > $next_time) { |
|
69 | + $next_time += $duration; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Update it now, so no others run this! |
70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
82 | 85 | |
83 | 86 | // What kind of task are we handling? |
84 | - if (!empty($row['callable'])) |
|
85 | - $task_string = $row['callable']; |
|
87 | + if (!empty($row['callable'])) { |
|
88 | + $task_string = $row['callable']; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | // Default SMF task or old mods? |
88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
89 | - $task_string = 'scheduled_' . $row['task']; |
|
92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
93 | + $task_string = 'scheduled_' . $row['task']; |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // One last resource, the task name. |
92 | - elseif (!empty($row['task'])) |
|
93 | - $task_string = $row['task']; |
|
97 | + elseif (!empty($row['task'])) { |
|
98 | + $task_string = $row['task']; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
101 | 107 | $callable_task = call_helper($task_string, true); |
102 | 108 | |
103 | 109 | // Perform the task. |
104 | - if (!empty($callable_task)) |
|
105 | - $completed = call_user_func($callable_task); |
|
106 | - |
|
107 | - else |
|
108 | - $completed = false; |
|
110 | + if (!empty($callable_task)) { |
|
111 | + $completed = call_user_func($callable_task); |
|
112 | + } else { |
|
113 | + $completed = false; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Log that we did it ;) |
111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
138 | 144 | ) |
139 | 145 | ); |
140 | 146 | // No new task scheduled yet? |
141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
142 | - $nextEvent = time() + 86400; |
|
143 | - else |
|
144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
148 | + $nextEvent = time() + 86400; |
|
149 | + } else { |
|
150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
151 | + } |
|
145 | 152 | $smcFunc['db_free_result']($request); |
146 | 153 | |
147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
148 | 155 | } |
149 | 156 | |
150 | 157 | // Shall we return? |
151 | - if (!isset($_GET['scheduled'])) |
|
152 | - return true; |
|
158 | + if (!isset($_GET['scheduled'])) { |
|
159 | + return true; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | // Finally, send some stuff... |
155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
182 | 190 | { |
183 | 191 | // If this is no longer around we'll ignore it. |
184 | - if (empty($row['id_topic'])) |
|
185 | - continue; |
|
192 | + if (empty($row['id_topic'])) { |
|
193 | + continue; |
|
194 | + } |
|
186 | 195 | |
187 | 196 | // What type is it? |
188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
189 | - $type = 'topic'; |
|
190 | - elseif ($row['id_attach']) |
|
191 | - $type = 'attach'; |
|
192 | - else |
|
193 | - $type = 'msg'; |
|
197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
198 | + $type = 'topic'; |
|
199 | + } elseif ($row['id_attach']) { |
|
200 | + $type = 'attach'; |
|
201 | + } else { |
|
202 | + $type = 'msg'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // Add it to the array otherwise. |
196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
211 | 221 | ); |
212 | 222 | |
213 | 223 | // If nothing quit now. |
214 | - if (empty($notices)) |
|
215 | - return true; |
|
224 | + if (empty($notices)) { |
|
225 | + return true; |
|
226 | + } |
|
216 | 227 | |
217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
232 | 243 | { |
233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
234 | - if ($row['id_group'] < 2) |
|
235 | - continue; |
|
245 | + if ($row['id_group'] < 2) { |
|
246 | + continue; |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
238 | 250 | |
239 | 251 | // Anyone who can access has to be considered. |
240 | - if ($row['add_deny']) |
|
241 | - $addGroups[] = $row['id_group']; |
|
252 | + if ($row['add_deny']) { |
|
253 | + $addGroups[] = $row['id_group']; |
|
254 | + } |
|
242 | 255 | } |
243 | 256 | $smcFunc['db_free_result']($request); |
244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | if (!empty($row['mod_prefs'])) |
284 | 297 | { |
285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
286 | - if (!($pref_binary & 4)) |
|
287 | - continue; |
|
299 | + if (!($pref_binary & 4)) { |
|
300 | + continue; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | |
290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
309 | 323 | $emailbody = ''; |
310 | 324 | |
311 | 325 | // Load the language file as required. |
312 | - if (empty($current_language) || $current_language != $member['language']) |
|
313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // Loop through each notice... |
316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
318 | 333 | $access = false; |
319 | 334 | |
320 | 335 | // Can they mod in this board? |
321 | - if (isset($mods[$id][$board])) |
|
322 | - $access = true; |
|
336 | + if (isset($mods[$id][$board])) { |
|
337 | + $access = true; |
|
338 | + } |
|
323 | 339 | |
324 | 340 | // Do the group check... |
325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
326 | 342 | { |
327 | 343 | // They can access?! |
328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
329 | - $access = true; |
|
344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
345 | + $access = true; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | // If they have deny rights don't consider them! |
332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
334 | 351 | $access = false; |
352 | + } |
|
335 | 353 | } |
336 | 354 | |
337 | 355 | // Finally, fix it for admins! |
338 | - if (in_array(1, $member['groups'])) |
|
339 | - $access = true; |
|
356 | + if (in_array(1, $member['groups'])) { |
|
357 | + $access = true; |
|
358 | + } |
|
340 | 359 | |
341 | 360 | // If they can't access it then give it a break! |
342 | - if (!$access) |
|
343 | - continue; |
|
361 | + if (!$access) { |
|
362 | + continue; |
|
363 | + } |
|
344 | 364 | |
345 | 365 | foreach ($notice as $type => $items) |
346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
349 | 369 | '------------------------------------------------------' . "\n"; |
350 | 370 | |
351 | - foreach ($items as $item) |
|
352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
371 | + foreach ($items as $item) { |
|
372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
373 | + } |
|
353 | 374 | |
354 | 375 | $emailbody .= "\n"; |
355 | 376 | } |
356 | 377 | } |
357 | 378 | |
358 | - if ($emailbody == '') |
|
359 | - continue; |
|
379 | + if ($emailbody == '') { |
|
380 | + continue; |
|
381 | + } |
|
360 | 382 | |
361 | 383 | $replacements = array( |
362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
397 | 419 | ) |
398 | 420 | ); |
399 | 421 | $members = array(); |
400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
401 | - $members[$row['id_member']] = $row['warning']; |
|
422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
423 | + $members[$row['id_member']] = $row['warning']; |
|
424 | + } |
|
402 | 425 | $smcFunc['db_free_result']($request); |
403 | 426 | |
404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
421 | 444 | { |
422 | 445 | // More than 24 hours ago? |
423 | - if ($row['last_warning'] <= time() - 86400) |
|
424 | - $member_changes[] = array( |
|
446 | + if ($row['last_warning'] <= time() - 86400) { |
|
447 | + $member_changes[] = array( |
|
425 | 448 | 'id' => $row['id_recipient'], |
426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
427 | 450 | ); |
451 | + } |
|
428 | 452 | } |
429 | 453 | $smcFunc['db_free_result']($request); |
430 | 454 | |
431 | 455 | // Have some members to change? |
432 | - if (!empty($member_changes)) |
|
433 | - foreach ($member_changes as $change) |
|
456 | + if (!empty($member_changes)) { |
|
457 | + foreach ($member_changes as $change) |
|
434 | 458 | $smcFunc['db_query']('', ' |
435 | 459 | UPDATE {db_prefix}members |
436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
440 | 464 | 'id_member' => $change['id'], |
441 | 465 | ) |
442 | 466 | ); |
467 | + } |
|
443 | 468 | } |
444 | 469 | } |
445 | 470 | |
@@ -452,16 +477,17 @@ discard block |
||
452 | 477 | |
453 | 478 | // Check the database version - for some buggy MySQL version. |
454 | 479 | $server_version = $smcFunc['db_server_info'](); |
455 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
456 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
457 | - elseif (!empty($modSettings['db_mysql_group_by_fix'])) |
|
458 | - $smcFunc['db_query']('', ' |
|
480 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
482 | + } elseif (!empty($modSettings['db_mysql_group_by_fix'])) { |
|
483 | + $smcFunc['db_query']('', ' |
|
459 | 484 | DELETE FROM {db_prefix}settings |
460 | 485 | WHERE variable = {string:mysql_fix}', |
461 | 486 | array( |
462 | 487 | 'mysql_fix' => 'db_mysql_group_by_fix', |
463 | 488 | ) |
464 | 489 | ); |
490 | + } |
|
465 | 491 | |
466 | 492 | // Clean up some old login history information. |
467 | 493 | $smcFunc['db_query']('', ' |
@@ -519,15 +545,17 @@ discard block |
||
519 | 545 | |
520 | 546 | // Store this useful data! |
521 | 547 | $boards[$row['id_board']] = $row['id_board']; |
522 | - if ($row['id_topic']) |
|
523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
524 | - else |
|
525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
548 | + if ($row['id_topic']) { |
|
549 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
550 | + } else { |
|
551 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
552 | + } |
|
526 | 553 | } |
527 | 554 | $smcFunc['db_free_result']($request); |
528 | 555 | |
529 | - if (empty($boards)) |
|
530 | - return true; |
|
556 | + if (empty($boards)) { |
|
557 | + return true; |
|
558 | + } |
|
531 | 559 | |
532 | 560 | // Just get the board names. |
533 | 561 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +567,14 @@ discard block |
||
539 | 567 | ) |
540 | 568 | ); |
541 | 569 | $boards = array(); |
542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
543 | - $boards[$row['id_board']] = $row['name']; |
|
570 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
571 | + $boards[$row['id_board']] = $row['name']; |
|
572 | + } |
|
544 | 573 | $smcFunc['db_free_result']($request); |
545 | 574 | |
546 | - if (empty($boards)) |
|
547 | - return true; |
|
575 | + if (empty($boards)) { |
|
576 | + return true; |
|
577 | + } |
|
548 | 578 | |
549 | 579 | // Get the actual topics... |
550 | 580 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +594,57 @@ discard block |
||
564 | 594 | $types = array(); |
565 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
566 | 596 | { |
567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
597 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
598 | + $types[$row['note_type']][$row['id_board']] = array( |
|
569 | 599 | 'lines' => array(), |
570 | 600 | 'name' => $row['board_name'], |
571 | 601 | 'id' => $row['id_board'], |
572 | 602 | ); |
603 | + } |
|
573 | 604 | |
574 | 605 | if ($row['note_type'] == 'reply') |
575 | 606 | { |
576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
578 | - else |
|
579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
607 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
608 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
609 | + } else { |
|
610 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
580 | 611 | 'id' => $row['id_topic'], |
581 | 612 | 'subject' => un_htmlspecialchars($row['subject']), |
582 | 613 | 'count' => 1, |
583 | 614 | ); |
584 | - } |
|
585 | - elseif ($row['note_type'] == 'topic') |
|
615 | + } |
|
616 | + } elseif ($row['note_type'] == 'topic') |
|
586 | 617 | { |
587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
618 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
619 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
589 | 620 | 'id' => $row['id_topic'], |
590 | 621 | 'subject' => un_htmlspecialchars($row['subject']), |
591 | 622 | ); |
592 | - } |
|
593 | - else |
|
623 | + } |
|
624 | + } else |
|
594 | 625 | { |
595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
626 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
627 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
597 | 628 | 'id' => $row['id_topic'], |
598 | 629 | 'subject' => un_htmlspecialchars($row['subject']), |
599 | 630 | 'starter' => $row['id_member_started'], |
600 | 631 | ); |
632 | + } |
|
601 | 633 | } |
602 | 634 | |
603 | 635 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
636 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
637 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
638 | + } |
|
639 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
640 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
641 | + } |
|
608 | 642 | } |
609 | 643 | $smcFunc['db_free_result']($request); |
610 | 644 | |
611 | - if (empty($types)) |
|
612 | - return true; |
|
645 | + if (empty($types)) { |
|
646 | + return true; |
|
647 | + } |
|
613 | 648 | |
614 | 649 | // Let's load all the languages into a cache thingy. |
615 | 650 | $langtxt = array(); |
@@ -651,8 +686,9 @@ discard block |
||
651 | 686 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
652 | 687 | |
653 | 688 | // Did they not elect to choose this? |
654 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
655 | - continue; |
|
689 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
690 | + continue; |
|
691 | + } |
|
656 | 692 | |
657 | 693 | // Right character set! |
658 | 694 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -668,39 +704,43 @@ discard block |
||
668 | 704 | if (isset($types['topic'])) |
669 | 705 | { |
670 | 706 | $titled = false; |
671 | - foreach ($types['topic'] as $id => $board) |
|
672 | - foreach ($board['lines'] as $topic) |
|
707 | + foreach ($types['topic'] as $id => $board) { |
|
708 | + foreach ($board['lines'] as $topic) |
|
673 | 709 | if (in_array($mid, $topic['members'])) |
674 | 710 | { |
675 | 711 | if (!$titled) |
676 | 712 | { |
677 | 713 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
714 | + } |
|
678 | 715 | $titled = true; |
679 | 716 | } |
680 | 717 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
681 | 718 | } |
682 | - if ($titled) |
|
683 | - $email['body'] .= "\n"; |
|
719 | + if ($titled) { |
|
720 | + $email['body'] .= "\n"; |
|
721 | + } |
|
684 | 722 | } |
685 | 723 | |
686 | 724 | // What about replies? |
687 | 725 | if (isset($types['reply'])) |
688 | 726 | { |
689 | 727 | $titled = false; |
690 | - foreach ($types['reply'] as $id => $board) |
|
691 | - foreach ($board['lines'] as $topic) |
|
728 | + foreach ($types['reply'] as $id => $board) { |
|
729 | + foreach ($board['lines'] as $topic) |
|
692 | 730 | if (in_array($mid, $topic['members'])) |
693 | 731 | { |
694 | 732 | if (!$titled) |
695 | 733 | { |
696 | 734 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
735 | + } |
|
697 | 736 | $titled = true; |
698 | 737 | } |
699 | 738 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
700 | 739 | } |
701 | 740 | |
702 | - if ($titled) |
|
703 | - $email['body'] .= "\n"; |
|
741 | + if ($titled) { |
|
742 | + $email['body'] .= "\n"; |
|
743 | + } |
|
704 | 744 | } |
705 | 745 | |
706 | 746 | // Finally, moderation actions! |
@@ -709,24 +749,27 @@ discard block |
||
709 | 749 | $titled = false; |
710 | 750 | foreach ($types as $note_type => $type) |
711 | 751 | { |
712 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
713 | - continue; |
|
752 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
753 | + continue; |
|
754 | + } |
|
714 | 755 | |
715 | - foreach ($type as $id => $board) |
|
716 | - foreach ($board['lines'] as $topic) |
|
756 | + foreach ($type as $id => $board) { |
|
757 | + foreach ($board['lines'] as $topic) |
|
717 | 758 | if (in_array($mid, $topic['members'])) |
718 | 759 | { |
719 | 760 | if (!$titled) |
720 | 761 | { |
721 | 762 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
763 | + } |
|
722 | 764 | $titled = true; |
723 | 765 | } |
724 | 766 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
725 | 767 | } |
726 | 768 | } |
727 | 769 | } |
728 | - if ($titled) |
|
729 | - $email['body'] .= "\n"; |
|
770 | + if ($titled) { |
|
771 | + $email['body'] .= "\n"; |
|
772 | + } |
|
730 | 773 | |
731 | 774 | // Then just say our goodbyes! |
732 | 775 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -754,8 +797,7 @@ discard block |
||
754 | 797 | 'not_daily' => 0, |
755 | 798 | ) |
756 | 799 | ); |
757 | - } |
|
758 | - else |
|
800 | + } else |
|
759 | 801 | { |
760 | 802 | // Clear any only weekly ones, and stop us from sending daily again. |
761 | 803 | $smcFunc['db_query']('', ' |
@@ -817,16 +859,19 @@ discard block |
||
817 | 859 | global $modSettings, $smcFunc, $sourcedir; |
818 | 860 | |
819 | 861 | // Are we intending another script to be sending out the queue? |
820 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
821 | - return false; |
|
862 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
863 | + return false; |
|
864 | + } |
|
822 | 865 | |
823 | 866 | // By default send 5 at once. |
824 | - if (!$number) |
|
825 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
867 | + if (!$number) { |
|
868 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
869 | + } |
|
826 | 870 | |
827 | 871 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
828 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
829 | - return false; |
|
872 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
873 | + return false; |
|
874 | + } |
|
830 | 875 | |
831 | 876 | // By default move the next sending on by 10 seconds, and require an affected row. |
832 | 877 | if (!$override_limit) |
@@ -843,8 +888,9 @@ discard block |
||
843 | 888 | 'last_send' => $modSettings['mail_next_send'], |
844 | 889 | ) |
845 | 890 | ); |
846 | - if ($smcFunc['db_affected_rows']() == 0) |
|
847 | - return false; |
|
891 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
892 | + return false; |
|
893 | + } |
|
848 | 894 | $modSettings['mail_next_send'] = time() + $delay; |
849 | 895 | } |
850 | 896 | |
@@ -865,8 +911,9 @@ discard block |
||
865 | 911 | $mn += $number; |
866 | 912 | } |
867 | 913 | // No more I'm afraid, return! |
868 | - else |
|
869 | - return false; |
|
914 | + else { |
|
915 | + return false; |
|
916 | + } |
|
870 | 917 | |
871 | 918 | // Reflect that we're about to send some, do it now to be safe. |
872 | 919 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -901,14 +948,15 @@ discard block |
||
901 | 948 | $smcFunc['db_free_result']($request); |
902 | 949 | |
903 | 950 | // Delete, delete, delete!!! |
904 | - if (!empty($ids)) |
|
905 | - $smcFunc['db_query']('', ' |
|
951 | + if (!empty($ids)) { |
|
952 | + $smcFunc['db_query']('', ' |
|
906 | 953 | DELETE FROM {db_prefix}mail_queue |
907 | 954 | WHERE id_mail IN ({array_int:mail_list})', |
908 | 955 | array( |
909 | 956 | 'mail_list' => $ids, |
910 | 957 | ) |
911 | 958 | ); |
959 | + } |
|
912 | 960 | |
913 | 961 | // Don't believe we have any left? |
914 | 962 | if (count($ids) < $number) |
@@ -926,11 +974,13 @@ discard block |
||
926 | 974 | ); |
927 | 975 | } |
928 | 976 | |
929 | - if (empty($ids)) |
|
930 | - return false; |
|
977 | + if (empty($ids)) { |
|
978 | + return false; |
|
979 | + } |
|
931 | 980 | |
932 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
933 | - require_once($sourcedir . '/Subs-Post.php'); |
|
981 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
982 | + require_once($sourcedir . '/Subs-Post.php'); |
|
983 | + } |
|
934 | 984 | |
935 | 985 | // Send each email, yea! |
936 | 986 | $failed_emails = array(); |
@@ -950,15 +1000,17 @@ discard block |
||
950 | 1000 | |
951 | 1001 | // Try to stop a timeout, this would be bad... |
952 | 1002 | @set_time_limit(300); |
953 | - if (function_exists('apache_reset_timeout')) |
|
954 | - @apache_reset_timeout(); |
|
1003 | + if (function_exists('apache_reset_timeout')) { |
|
1004 | + @apache_reset_timeout(); |
|
1005 | + } |
|
1006 | + } else { |
|
1007 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
955 | 1008 | } |
956 | - else |
|
957 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
958 | 1009 | |
959 | 1010 | // Hopefully it sent? |
960 | - if (!$result) |
|
961 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1011 | + if (!$result) { |
|
1012 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1013 | + } |
|
962 | 1014 | } |
963 | 1015 | |
964 | 1016 | // Any emails that didn't send? |
@@ -973,8 +1025,8 @@ discard block |
||
973 | 1025 | ); |
974 | 1026 | |
975 | 1027 | // If we have failed to many times, tell mail to wait a bit and try again. |
976 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
977 | - $smcFunc['db_query']('', ' |
|
1028 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
1029 | + $smcFunc['db_query']('', ' |
|
978 | 1030 | UPDATE {db_prefix}settings |
979 | 1031 | SET value = {string:next_mail_send} |
980 | 1032 | WHERE variable = {literal:mail_next_send} |
@@ -983,6 +1035,7 @@ discard block |
||
983 | 1035 | 'next_mail_send' => time() + 60, |
984 | 1036 | 'last_send' => $modSettings['mail_next_send'], |
985 | 1037 | )); |
1038 | + } |
|
986 | 1039 | |
987 | 1040 | // Add our email back to the queue, manually. |
988 | 1041 | $smcFunc['db_insert']('insert', |
@@ -995,8 +1048,8 @@ discard block |
||
995 | 1048 | return false; |
996 | 1049 | } |
997 | 1050 | // We where unable to send the email, clear our failed attempts. |
998 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
999 | - $smcFunc['db_query']('', ' |
|
1051 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
1052 | + $smcFunc['db_query']('', ' |
|
1000 | 1053 | UPDATE {db_prefix}settings |
1001 | 1054 | SET value = {string:zero} |
1002 | 1055 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1004,6 +1057,7 @@ discard block |
||
1004 | 1057 | 'zero' => '0', |
1005 | 1058 | 'mail_failed_attempts' => 'mail_failed_attempts', |
1006 | 1059 | )); |
1060 | + } |
|
1007 | 1061 | |
1008 | 1062 | // Had something to send... |
1009 | 1063 | return true; |
@@ -1020,16 +1074,18 @@ discard block |
||
1020 | 1074 | global $modSettings, $smcFunc; |
1021 | 1075 | |
1022 | 1076 | $task_query = ''; |
1023 | - if (!is_array($tasks)) |
|
1024 | - $tasks = array($tasks); |
|
1077 | + if (!is_array($tasks)) { |
|
1078 | + $tasks = array($tasks); |
|
1079 | + } |
|
1025 | 1080 | |
1026 | 1081 | // Actually have something passed? |
1027 | 1082 | if (!empty($tasks)) |
1028 | 1083 | { |
1029 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
1030 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1031 | - else |
|
1032 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
1084 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
1085 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1086 | + } else { |
|
1087 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
1088 | + } |
|
1033 | 1089 | } |
1034 | 1090 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
1035 | 1091 | |
@@ -1050,20 +1106,22 @@ discard block |
||
1050 | 1106 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
1051 | 1107 | |
1052 | 1108 | // Only bother moving the task if it's out of place or we're forcing it! |
1053 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
1054 | - $tasks[$row['id_task']] = $next_time; |
|
1055 | - else |
|
1056 | - $next_time = $row['next_time']; |
|
1109 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
1110 | + $tasks[$row['id_task']] = $next_time; |
|
1111 | + } else { |
|
1112 | + $next_time = $row['next_time']; |
|
1113 | + } |
|
1057 | 1114 | |
1058 | 1115 | // If this is sooner than the current next task, make this the next task. |
1059 | - if ($next_time < $nextTaskTime) |
|
1060 | - $nextTaskTime = $next_time; |
|
1116 | + if ($next_time < $nextTaskTime) { |
|
1117 | + $nextTaskTime = $next_time; |
|
1118 | + } |
|
1061 | 1119 | } |
1062 | 1120 | $smcFunc['db_free_result']($request); |
1063 | 1121 | |
1064 | 1122 | // Now make the changes! |
1065 | - foreach ($tasks as $id => $time) |
|
1066 | - $smcFunc['db_query']('', ' |
|
1123 | + foreach ($tasks as $id => $time) { |
|
1124 | + $smcFunc['db_query']('', ' |
|
1067 | 1125 | UPDATE {db_prefix}scheduled_tasks |
1068 | 1126 | SET next_time = {int:next_time} |
1069 | 1127 | WHERE id_task = {int:id_task}', |
@@ -1072,11 +1130,13 @@ discard block |
||
1072 | 1130 | 'id_task' => $id, |
1073 | 1131 | ) |
1074 | 1132 | ); |
1133 | + } |
|
1075 | 1134 | |
1076 | 1135 | // If the next task is now different update. |
1077 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
1078 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1079 | -} |
|
1136 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
1137 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1138 | + } |
|
1139 | + } |
|
1080 | 1140 | |
1081 | 1141 | /** |
1082 | 1142 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1089,8 +1149,9 @@ discard block |
||
1089 | 1149 | function next_time($regularity, $unit, $offset) |
1090 | 1150 | { |
1091 | 1151 | // Just in case! |
1092 | - if ($regularity == 0) |
|
1093 | - $regularity = 2; |
|
1152 | + if ($regularity == 0) { |
|
1153 | + $regularity = 2; |
|
1154 | + } |
|
1094 | 1155 | |
1095 | 1156 | $curHour = date('H', time()); |
1096 | 1157 | $curMin = date('i', time()); |
@@ -1102,15 +1163,16 @@ discard block |
||
1102 | 1163 | $off = date('i', $offset); |
1103 | 1164 | |
1104 | 1165 | // If it's now just pretend it ain't, |
1105 | - if ($off == $curMin) |
|
1106 | - $next_time = time() + $regularity; |
|
1107 | - else |
|
1166 | + if ($off == $curMin) { |
|
1167 | + $next_time = time() + $regularity; |
|
1168 | + } else |
|
1108 | 1169 | { |
1109 | 1170 | // Make sure that the offset is always in the past. |
1110 | 1171 | $off = $off > $curMin ? $off - 60 : $off; |
1111 | 1172 | |
1112 | - while ($off <= $curMin) |
|
1113 | - $off += $regularity; |
|
1173 | + while ($off <= $curMin) { |
|
1174 | + $off += $regularity; |
|
1175 | + } |
|
1114 | 1176 | |
1115 | 1177 | // Now we know when the time should be! |
1116 | 1178 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1130,11 +1192,13 @@ discard block |
||
1130 | 1192 | // Default we'll jump in hours. |
1131 | 1193 | $applyOffset = 3600; |
1132 | 1194 | // 24 hours = 1 day. |
1133 | - if ($unit == 'd') |
|
1134 | - $applyOffset = 86400; |
|
1195 | + if ($unit == 'd') { |
|
1196 | + $applyOffset = 86400; |
|
1197 | + } |
|
1135 | 1198 | // Otherwise a week. |
1136 | - if ($unit == 'w') |
|
1137 | - $applyOffset = 604800; |
|
1199 | + if ($unit == 'w') { |
|
1200 | + $applyOffset = 604800; |
|
1201 | + } |
|
1138 | 1202 | |
1139 | 1203 | $applyOffset *= $regularity; |
1140 | 1204 | |
@@ -1171,8 +1235,9 @@ discard block |
||
1171 | 1235 | $settings[$row['variable']] = $row['value']; |
1172 | 1236 | |
1173 | 1237 | // Is this the default theme? |
1174 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
1175 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1238 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
1239 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1240 | + } |
|
1176 | 1241 | } |
1177 | 1242 | $smcFunc['db_free_result']($result); |
1178 | 1243 | |
@@ -1182,12 +1247,14 @@ discard block |
||
1182 | 1247 | $settings['template_dirs'] = array($settings['theme_dir']); |
1183 | 1248 | |
1184 | 1249 | // Based on theme (if there is one). |
1185 | - if (!empty($settings['base_theme_dir'])) |
|
1186 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1250 | + if (!empty($settings['base_theme_dir'])) { |
|
1251 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1252 | + } |
|
1187 | 1253 | |
1188 | 1254 | // Lastly the default theme. |
1189 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1190 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1255 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1256 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1257 | + } |
|
1191 | 1258 | } |
1192 | 1259 | |
1193 | 1260 | // Assume we want this. |
@@ -1333,8 +1400,9 @@ discard block |
||
1333 | 1400 | // Ok should we prune the logs? |
1334 | 1401 | if (!empty($modSettings['pruningOptions'])) |
1335 | 1402 | { |
1336 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
1337 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1403 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
1404 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1405 | + } |
|
1338 | 1406 | |
1339 | 1407 | if (!empty($modSettings['pruneErrorLog'])) |
1340 | 1408 | { |
@@ -1400,8 +1468,9 @@ discard block |
||
1400 | 1468 | ) |
1401 | 1469 | ); |
1402 | 1470 | |
1403 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
1404 | - $reports[] = $row[0]; |
|
1471 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
1472 | + $reports[] = $row[0]; |
|
1473 | + } |
|
1405 | 1474 | |
1406 | 1475 | $smcFunc['db_free_result']($result); |
1407 | 1476 | |
@@ -1563,8 +1632,9 @@ discard block |
||
1563 | 1632 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
1564 | 1633 | |
1565 | 1634 | // Send the actual email. |
1566 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
1567 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1635 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
1636 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1637 | + } |
|
1568 | 1638 | |
1569 | 1639 | if ($notifyPrefs[$row['id_member']] & 0x01) |
1570 | 1640 | { |
@@ -1587,18 +1657,19 @@ discard block |
||
1587 | 1657 | } |
1588 | 1658 | |
1589 | 1659 | // Insert the alerts if any |
1590 | - if (!empty($alert_rows)) |
|
1591 | - $smcFunc['db_insert']('', |
|
1660 | + if (!empty($alert_rows)) { |
|
1661 | + $smcFunc['db_insert']('', |
|
1592 | 1662 | '{db_prefix}user_alerts', |
1593 | 1663 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
1594 | 1664 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
1595 | 1665 | $alert_rows, |
1596 | 1666 | array() |
1597 | 1667 | ); |
1668 | + } |
|
1598 | 1669 | |
1599 | 1670 | // Mark the reminder as sent. |
1600 | - if (!empty($subs_reminded)) |
|
1601 | - $smcFunc['db_query']('', ' |
|
1671 | + if (!empty($subs_reminded)) { |
|
1672 | + $smcFunc['db_query']('', ' |
|
1602 | 1673 | UPDATE {db_prefix}log_subscribed |
1603 | 1674 | SET reminder_sent = {int:reminder_sent} |
1604 | 1675 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1607,6 +1678,7 @@ discard block |
||
1607 | 1678 | 'reminder_sent' => 1, |
1608 | 1679 | ) |
1609 | 1680 | ); |
1681 | + } |
|
1610 | 1682 | |
1611 | 1683 | return true; |
1612 | 1684 | } |
@@ -1622,13 +1694,13 @@ discard block |
||
1622 | 1694 | // We need to know where this thing is going. |
1623 | 1695 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1624 | 1696 | { |
1625 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1626 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1697 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1698 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1699 | + } |
|
1627 | 1700 | |
1628 | 1701 | // Just use the current path for temp files. |
1629 | 1702 | $attach_dirs = $modSettings['attachmentUploadDir']; |
1630 | - } |
|
1631 | - else |
|
1703 | + } else |
|
1632 | 1704 | { |
1633 | 1705 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
1634 | 1706 | } |
@@ -1647,14 +1719,16 @@ discard block |
||
1647 | 1719 | |
1648 | 1720 | while ($file = readdir($dir)) |
1649 | 1721 | { |
1650 | - if ($file == '.' || $file == '..') |
|
1651 | - continue; |
|
1722 | + if ($file == '.' || $file == '..') { |
|
1723 | + continue; |
|
1724 | + } |
|
1652 | 1725 | |
1653 | 1726 | if (strpos($file, 'post_tmp_') !== false) |
1654 | 1727 | { |
1655 | 1728 | // Temp file is more than 5 hours old! |
1656 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1657 | - @unlink($attach_dir . '/' . $file); |
|
1729 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1730 | + @unlink($attach_dir . '/' . $file); |
|
1731 | + } |
|
1658 | 1732 | } |
1659 | 1733 | } |
1660 | 1734 | closedir($dir); |
@@ -1687,8 +1761,9 @@ discard block |
||
1687 | 1761 | ) |
1688 | 1762 | ); |
1689 | 1763 | |
1690 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1691 | - $topics[] = $row[0]; |
|
1764 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1765 | + $topics[] = $row[0]; |
|
1766 | + } |
|
1692 | 1767 | $smcFunc['db_free_result']($request); |
1693 | 1768 | |
1694 | 1769 | // Zap, your gone |
@@ -1708,8 +1783,9 @@ discard block |
||
1708 | 1783 | { |
1709 | 1784 | global $smcFunc, $sourcedir, $modSettings; |
1710 | 1785 | |
1711 | - if (empty($modSettings['drafts_keep_days'])) |
|
1712 | - return true; |
|
1786 | + if (empty($modSettings['drafts_keep_days'])) { |
|
1787 | + return true; |
|
1788 | + } |
|
1713 | 1789 | |
1714 | 1790 | // init |
1715 | 1791 | $drafts = array(); |
@@ -1727,8 +1803,9 @@ discard block |
||
1727 | 1803 | ) |
1728 | 1804 | ); |
1729 | 1805 | |
1730 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1731 | - $drafts[] = (int) $row[0]; |
|
1806 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1807 | + $drafts[] = (int) $row[0]; |
|
1808 | + } |
|
1732 | 1809 | $smcFunc['db_free_result']($request); |
1733 | 1810 | |
1734 | 1811 | // If we have old one, remove them |
@@ -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'); |