@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
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 |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | { |
28 | 29 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
29 | 30 | |
30 | - if ($test) |
|
31 | - return $supported; |
|
31 | + if ($test) { |
|
32 | + return $supported; |
|
33 | + } |
|
32 | 34 | return parent::isSupported() && $supported; |
33 | 35 | } |
34 | 36 | |
@@ -50,10 +52,11 @@ discard block |
||
50 | 52 | $key = $this->prefix . strtr($key, ':/', '-_'); |
51 | 53 | |
52 | 54 | // An extended key is needed to counteract a bug in APC. |
53 | - if ($value === null) |
|
54 | - return apcu_delete($key . 'smf'); |
|
55 | - else |
|
56 | - return apcu_store($key . 'smf', $value, $ttl); |
|
55 | + if ($value === null) { |
|
56 | + return apcu_delete($key . 'smf'); |
|
57 | + } else { |
|
58 | + return apcu_store($key . 'smf', $value, $ttl); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | |
59 | 62 | /** |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $board_info, $smcFunc, $modSettings; |
33 | 34 | |
34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
35 | - if (empty($topic)) |
|
36 | - redirectexit(); |
|
36 | + if (empty($topic)) { |
|
37 | + redirectexit(); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | ) |
60 | 62 | ); |
61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
63 | - redirectexit(); |
|
64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
65 | + redirectexit(); |
|
66 | + } |
|
64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
65 | 68 | $smcFunc['db_free_result']($request); |
66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
135 | 138 | { |
136 | 139 | $guestvoted = explode(',', $guestvoted); |
137 | - if ($guestvoted[0] == $row['id_poll']) |
|
138 | - break; |
|
140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
141 | + break; |
|
142 | + } |
|
139 | 143 | } |
140 | 144 | // Has the poll been reset since guest voted? |
141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
142 | 146 | { |
143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
144 | 148 | unset($guestinfo[$i]); |
145 | - if (!empty($guestinfo)) |
|
146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
147 | - else |
|
148 | - unset($_COOKIE['guest_poll_vote']); |
|
149 | - } |
|
150 | - else |
|
149 | + if (!empty($guestinfo)) { |
|
150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
151 | + } else { |
|
152 | + unset($_COOKIE['guest_poll_vote']); |
|
153 | + } |
|
154 | + } else |
|
151 | 155 | { |
152 | 156 | // What did they vote for? |
153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
233 | 237 | $context['poster_name'] = $row['poster_name']; |
234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
235 | 239 | $context['parent_boards'] = array(); |
236 | - foreach ($board_info['parent_boards'] as $parent) |
|
237 | - $context['parent_boards'][] = $parent['name']; |
|
240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
241 | + $context['parent_boards'][] = $parent['name']; |
|
242 | + } |
|
238 | 243 | |
239 | 244 | // Split the topics up so we can print them. |
240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
266 | 271 | 'id_msg' => $row['id_msg'], |
267 | 272 | ); |
268 | 273 | |
269 | - if (!isset($context['topic_subject'])) |
|
270 | - $context['topic_subject'] = $row['subject']; |
|
274 | + if (!isset($context['topic_subject'])) { |
|
275 | + $context['topic_subject'] = $row['subject']; |
|
276 | + } |
|
271 | 277 | } |
272 | 278 | $smcFunc['db_free_result']($request); |
273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
276 | 282 | { |
277 | 283 | $messages = array(); |
278 | - foreach ($context['posts'] as $temp) |
|
279 | - $messages[] = $temp['id_msg']; |
|
284 | + foreach ($context['posts'] as $temp) { |
|
285 | + $messages[] = $temp['id_msg']; |
|
286 | + } |
|
280 | 287 | |
281 | 288 | // build the request |
282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
296 | 303 | { |
297 | 304 | $temp[$row['id_attach']] = $row; |
298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
299 | - $context['printattach'][$row['id_msg']] = array(); |
|
305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
306 | + $context['printattach'][$row['id_msg']] = array(); |
|
307 | + } |
|
300 | 308 | } |
301 | 309 | $smcFunc['db_free_result']($request); |
302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
314 | 322 | $row['width'] = $modSettings['max_image_width']; |
315 | 323 | } |
316 | - } |
|
317 | - elseif (!empty($modSettings['max_image_width'])) |
|
324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
318 | 325 | { |
319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
320 | 327 | { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'value' => $txt['date'], |
137 | 137 | ), |
138 | 138 | 'data' => array( |
139 | - 'function' => function ($rowData) use ($txt) |
|
139 | + 'function' => function($rowData) use ($txt) |
|
140 | 140 | { |
141 | 141 | // Recurring every year or just a single year? |
142 | 142 | $year = $rowData['year'] == '1004' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year']; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | checkSession(); |
219 | 219 | |
220 | 220 | // Not too long good sir? |
221 | - $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
221 | + $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
222 | 222 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
223 | 223 | |
224 | 224 | if (isset($_REQUEST['delete'])) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main controlling function doesn't have much to do... yet. |
@@ -43,8 +44,7 @@ discard block |
||
43 | 44 | 'settings' => 'ModifyCalendarSettings' |
44 | 45 | ); |
45 | 46 | $default = 'holidays'; |
46 | - } |
|
47 | - else |
|
47 | + } else |
|
48 | 48 | { |
49 | 49 | $subActions = array( |
50 | 50 | 'settings' => 'ModifyCalendarSettings' |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | 'help' => 'calendar', |
61 | 61 | 'description' => $txt['calendar_settings_desc'], |
62 | 62 | ); |
63 | - if (!empty($modSettings['cal_enabled'])) |
|
64 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
63 | + if (!empty($modSettings['cal_enabled'])) { |
|
64 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
65 | 65 | 'holidays' => array( |
66 | 66 | 'description' => $txt['manage_holidays_desc'], |
67 | 67 | ), |
@@ -69,6 +69,7 @@ discard block |
||
69 | 69 | 'description' => $txt['calendar_settings_desc'], |
70 | 70 | ), |
71 | 71 | ); |
72 | + } |
|
72 | 73 | |
73 | 74 | call_integration_hook('integrate_manage_calendar', array(&$subActions)); |
74 | 75 | |
@@ -88,8 +89,9 @@ discard block |
||
88 | 89 | checkSession(); |
89 | 90 | validateToken('admin-mc'); |
90 | 91 | |
91 | - foreach ($_REQUEST['holiday'] as $id => $value) |
|
92 | - $_REQUEST['holiday'][$id] = (int) $id; |
|
92 | + foreach ($_REQUEST['holiday'] as $id => $value) { |
|
93 | + $_REQUEST['holiday'][$id] = (int) $id; |
|
94 | + } |
|
93 | 95 | |
94 | 96 | // Now the IDs are "safe" do the delete... |
95 | 97 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -209,8 +211,9 @@ discard block |
||
209 | 211 | $context['sub_template'] = 'edit_holiday'; |
210 | 212 | |
211 | 213 | // Cast this for safety... |
212 | - if (isset($_REQUEST['holiday'])) |
|
213 | - $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
214 | + if (isset($_REQUEST['holiday'])) { |
|
215 | + $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
216 | + } |
|
214 | 217 | |
215 | 218 | // Submitting? |
216 | 219 | if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != '')) |
@@ -221,19 +224,19 @@ discard block |
||
221 | 224 | $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
222 | 225 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
223 | 226 | |
224 | - if (isset($_REQUEST['delete'])) |
|
225 | - $smcFunc['db_query']('', ' |
|
227 | + if (isset($_REQUEST['delete'])) { |
|
228 | + $smcFunc['db_query']('', ' |
|
226 | 229 | DELETE FROM {db_prefix}calendar_holidays |
227 | 230 | WHERE id_holiday = {int:selected_holiday}', |
228 | 231 | array( |
229 | 232 | 'selected_holiday' => $_REQUEST['holiday'], |
230 | 233 | ) |
231 | 234 | ); |
232 | - else |
|
235 | + } else |
|
233 | 236 | { |
234 | 237 | $date = strftime($_REQUEST['year'] <= 1004 ? '1004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year'])); |
235 | - if (isset($_REQUEST['edit'])) |
|
236 | - $smcFunc['db_query']('', ' |
|
238 | + if (isset($_REQUEST['edit'])) { |
|
239 | + $smcFunc['db_query']('', ' |
|
237 | 240 | UPDATE {db_prefix}calendar_holidays |
238 | 241 | SET event_date = {date:holiday_date}, title = {string:holiday_title} |
239 | 242 | WHERE id_holiday = {int:selected_holiday}', |
@@ -243,8 +246,8 @@ discard block |
||
243 | 246 | 'holiday_title' => $_REQUEST['title'], |
244 | 247 | ) |
245 | 248 | ); |
246 | - else |
|
247 | - $smcFunc['db_insert']('', |
|
249 | + } else { |
|
250 | + $smcFunc['db_insert']('', |
|
248 | 251 | '{db_prefix}calendar_holidays', |
249 | 252 | array( |
250 | 253 | 'event_date' => 'date', 'title' => 'string-60', |
@@ -254,6 +257,7 @@ discard block |
||
254 | 257 | ), |
255 | 258 | array('id_holiday') |
256 | 259 | ); |
260 | + } |
|
257 | 261 | } |
258 | 262 | |
259 | 263 | updateSettings(array( |
@@ -265,14 +269,15 @@ discard block |
||
265 | 269 | } |
266 | 270 | |
267 | 271 | // Default states... |
268 | - if ($context['is_new']) |
|
269 | - $context['holiday'] = array( |
|
272 | + if ($context['is_new']) { |
|
273 | + $context['holiday'] = array( |
|
270 | 274 | 'id' => 0, |
271 | 275 | 'day' => date('d'), |
272 | 276 | 'month' => date('m'), |
273 | 277 | 'year' => '0000', |
274 | 278 | 'title' => '' |
275 | 279 | ); |
280 | + } |
|
276 | 281 | // If it's not new load the data. |
277 | 282 | else |
278 | 283 | { |
@@ -285,14 +290,15 @@ discard block |
||
285 | 290 | 'selected_holiday' => $_REQUEST['holiday'], |
286 | 291 | ) |
287 | 292 | ); |
288 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
289 | - $context['holiday'] = array( |
|
293 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
294 | + $context['holiday'] = array( |
|
290 | 295 | 'id' => $row['id_holiday'], |
291 | 296 | 'day' => $row['day'], |
292 | 297 | 'month' => $row['month'], |
293 | 298 | 'year' => $row['year'] <= 4 ? 0 : $row['year'], |
294 | 299 | 'title' => $row['title'] |
295 | 300 | ); |
301 | + } |
|
296 | 302 | $smcFunc['db_free_result']($request); |
297 | 303 | } |
298 | 304 | |
@@ -319,16 +325,17 @@ discard block |
||
319 | 325 | array( |
320 | 326 | ) |
321 | 327 | ); |
322 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
323 | - $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
329 | + $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
330 | + } |
|
324 | 331 | $smcFunc['db_free_result']($request); |
325 | 332 | |
326 | 333 | require_once($sourcedir . '/Subs-Boards.php'); |
327 | 334 | sortBoards($boards); |
328 | 335 | |
329 | 336 | // Look, all the calendar settings - of which there are many! |
330 | - if (!empty($modSettings['cal_enabled'])) |
|
331 | - $config_vars = array( |
|
337 | + if (!empty($modSettings['cal_enabled'])) { |
|
338 | + $config_vars = array( |
|
332 | 339 | array('check', 'cal_enabled'), |
333 | 340 | '', |
334 | 341 | // All the permissions: |
@@ -371,14 +378,16 @@ discard block |
||
371 | 378 | array('check', 'cal_short_days'), |
372 | 379 | array('check', 'cal_short_months'), |
373 | 380 | ); |
374 | - else |
|
375 | - $config_vars = array( |
|
381 | + } else { |
|
382 | + $config_vars = array( |
|
376 | 383 | array('check', 'cal_enabled'), |
377 | 384 | ); |
385 | + } |
|
378 | 386 | |
379 | 387 | call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars)); |
380 | - if ($return_config) |
|
381 | - return $config_vars; |
|
388 | + if ($return_config) { |
|
389 | + return $config_vars; |
|
390 | + } |
|
382 | 391 | |
383 | 392 | // Get the settings template fired up. |
384 | 393 | require_once($sourcedir . '/ManageServer.php'); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * Make files writable. First try to use regular chmod, but if that fails, try to use FTP. |
83 | 83 | * |
84 | - * @param $files |
|
84 | + * @param string[] $files |
|
85 | 85 | * @return bool |
86 | 86 | */ |
87 | 87 | function makeFilesWritable(&$files) |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | /** |
323 | 323 | * Prints an error to stderr. |
324 | 324 | * |
325 | - * @param $message |
|
325 | + * @param string $message |
|
326 | 326 | * @param bool $fatal |
327 | 327 | */ |
328 | 328 | function print_error($message, $fatal = false) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * This file contains helper functions for upgrade.php |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF_VERSION')) |
|
16 | +if (!defined('SMF_VERSION')) { |
|
17 | 17 | die('No direct access!'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | global $smcFunc; |
46 | 47 | static $member_groups = array(); |
47 | 48 | |
48 | - if (!empty($member_groups)) |
|
49 | - return $member_groups; |
|
49 | + if (!empty($member_groups)) { |
|
50 | + return $member_groups; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $request = $smcFunc['db_query']('', ' |
52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | ) |
72 | 74 | ); |
73 | 75 | } |
74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
75 | - $member_groups[trim($row[0])] = $row[1]; |
|
76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
77 | + $member_groups[trim($row[0])] = $row[1]; |
|
78 | + } |
|
76 | 79 | $smcFunc['db_free_result']($request); |
77 | 80 | |
78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | { |
89 | 92 | global $upcontext, $boarddir, $sourcedir; |
90 | 93 | |
91 | - if (empty($files)) |
|
92 | - return true; |
|
94 | + if (empty($files)) { |
|
95 | + return true; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | $failure = false; |
95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -100,22 +104,25 @@ discard block |
||
100 | 104 | foreach ($files as $k => $file) |
101 | 105 | { |
102 | 106 | // Some files won't exist, try to address up front |
103 | - if (!file_exists($file)) |
|
104 | - @touch($file); |
|
107 | + if (!file_exists($file)) { |
|
108 | + @touch($file); |
|
109 | + } |
|
105 | 110 | // NOW do the writable check... |
106 | 111 | if (!is_writable($file)) |
107 | 112 | { |
108 | 113 | @chmod($file, 0755); |
109 | 114 | |
110 | 115 | // Well, 755 hopefully worked... if not, try 777. |
111 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
112 | - $failure = true; |
|
116 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
117 | + $failure = true; |
|
118 | + } |
|
113 | 119 | // Otherwise remove it as it's good! |
114 | - else |
|
115 | - unset($files[$k]); |
|
120 | + else { |
|
121 | + unset($files[$k]); |
|
122 | + } |
|
123 | + } else { |
|
124 | + unset($files[$k]); |
|
116 | 125 | } |
117 | - else |
|
118 | - unset($files[$k]); |
|
119 | 126 | } |
120 | 127 | } |
121 | 128 | // Windows is trickier. Let's try opening for r+... |
@@ -126,30 +133,35 @@ discard block |
||
126 | 133 | foreach ($files as $k => $file) |
127 | 134 | { |
128 | 135 | // Folders can't be opened for write... but the index.php in them can ;). |
129 | - if (is_dir($file)) |
|
130 | - $file .= '/index.php'; |
|
136 | + if (is_dir($file)) { |
|
137 | + $file .= '/index.php'; |
|
138 | + } |
|
131 | 139 | |
132 | 140 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
133 | 141 | @chmod($file, 0777); |
134 | 142 | $fp = @fopen($file, 'r+'); |
135 | 143 | |
136 | 144 | // Hmm, okay, try just for write in that case... |
137 | - if (!$fp) |
|
138 | - $fp = @fopen($file, 'w'); |
|
145 | + if (!$fp) { |
|
146 | + $fp = @fopen($file, 'w'); |
|
147 | + } |
|
139 | 148 | |
140 | - if (!$fp) |
|
141 | - $failure = true; |
|
142 | - else |
|
143 | - unset($files[$k]); |
|
149 | + if (!$fp) { |
|
150 | + $failure = true; |
|
151 | + } else { |
|
152 | + unset($files[$k]); |
|
153 | + } |
|
144 | 154 | @fclose($fp); |
145 | 155 | } |
146 | 156 | } |
147 | 157 | |
148 | - if (empty($files)) |
|
149 | - return true; |
|
158 | + if (empty($files)) { |
|
159 | + return true; |
|
160 | + } |
|
150 | 161 | |
151 | - if (!isset($_SERVER)) |
|
152 | - return !$failure; |
|
162 | + if (!isset($_SERVER)) { |
|
163 | + return !$failure; |
|
164 | + } |
|
153 | 165 | |
154 | 166 | // What still needs to be done? |
155 | 167 | $upcontext['chmod']['files'] = $files; |
@@ -201,36 +213,40 @@ discard block |
||
201 | 213 | |
202 | 214 | if (!isset($ftp) || $ftp->error !== false) |
203 | 215 | { |
204 | - if (!isset($ftp)) |
|
205 | - $ftp = new ftp_connection(null); |
|
216 | + if (!isset($ftp)) { |
|
217 | + $ftp = new ftp_connection(null); |
|
218 | + } |
|
206 | 219 | // Save the error so we can mess with listing... |
207 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
208 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
220 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
221 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
222 | + } |
|
209 | 223 | |
210 | 224 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
211 | 225 | |
212 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
213 | - $upcontext['chmod']['path'] = $detect_path; |
|
226 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
227 | + $upcontext['chmod']['path'] = $detect_path; |
|
228 | + } |
|
214 | 229 | |
215 | - if (!isset($upcontext['chmod']['username'])) |
|
216 | - $upcontext['chmod']['username'] = $username; |
|
230 | + if (!isset($upcontext['chmod']['username'])) { |
|
231 | + $upcontext['chmod']['username'] = $username; |
|
232 | + } |
|
217 | 233 | |
218 | 234 | // Don't forget the login token. |
219 | 235 | $upcontext += createToken('login'); |
220 | 236 | |
221 | 237 | return false; |
222 | - } |
|
223 | - else |
|
238 | + } else |
|
224 | 239 | { |
225 | 240 | // We want to do a relative path for FTP. |
226 | 241 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
227 | 242 | { |
228 | 243 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
229 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
230 | - $ftp_root = substr($ftp_root, 0, -1); |
|
244 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
245 | + $ftp_root = substr($ftp_root, 0, -1); |
|
246 | + } |
|
247 | + } else { |
|
248 | + $ftp_root = $boarddir; |
|
231 | 249 | } |
232 | - else |
|
233 | - $ftp_root = $boarddir; |
|
234 | 250 | |
235 | 251 | // Save the info for next time! |
236 | 252 | $_SESSION['installer_temp_ftp'] = array( |
@@ -244,10 +260,12 @@ discard block |
||
244 | 260 | |
245 | 261 | foreach ($files as $k => $file) |
246 | 262 | { |
247 | - if (!is_writable($file)) |
|
248 | - $ftp->chmod($file, 0755); |
|
249 | - if (!is_writable($file)) |
|
250 | - $ftp->chmod($file, 0777); |
|
263 | + if (!is_writable($file)) { |
|
264 | + $ftp->chmod($file, 0755); |
|
265 | + } |
|
266 | + if (!is_writable($file)) { |
|
267 | + $ftp->chmod($file, 0777); |
|
268 | + } |
|
251 | 269 | |
252 | 270 | // Assuming that didn't work calculate the path without the boarddir. |
253 | 271 | if (!is_writable($file)) |
@@ -256,19 +274,23 @@ discard block |
||
256 | 274 | { |
257 | 275 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
258 | 276 | $ftp->chmod($ftp_file, 0755); |
259 | - if (!is_writable($file)) |
|
260 | - $ftp->chmod($ftp_file, 0777); |
|
277 | + if (!is_writable($file)) { |
|
278 | + $ftp->chmod($ftp_file, 0777); |
|
279 | + } |
|
261 | 280 | // Sometimes an extra slash can help... |
262 | 281 | $ftp_file = '/' . $ftp_file; |
263 | - if (!is_writable($file)) |
|
264 | - $ftp->chmod($ftp_file, 0755); |
|
265 | - if (!is_writable($file)) |
|
266 | - $ftp->chmod($ftp_file, 0777); |
|
282 | + if (!is_writable($file)) { |
|
283 | + $ftp->chmod($ftp_file, 0755); |
|
284 | + } |
|
285 | + if (!is_writable($file)) { |
|
286 | + $ftp->chmod($ftp_file, 0777); |
|
287 | + } |
|
267 | 288 | } |
268 | 289 | } |
269 | 290 | |
270 | - if (is_writable($file)) |
|
271 | - unset($files[$k]); |
|
291 | + if (is_writable($file)) { |
|
292 | + unset($files[$k]); |
|
293 | + } |
|
272 | 294 | } |
273 | 295 | |
274 | 296 | $ftp->close(); |
@@ -278,8 +300,9 @@ discard block |
||
278 | 300 | // What remains? |
279 | 301 | $upcontext['chmod']['files'] = $files; |
280 | 302 | |
281 | - if (empty($files)) |
|
282 | - return true; |
|
303 | + if (empty($files)) { |
|
304 | + return true; |
|
305 | + } |
|
283 | 306 | |
284 | 307 | return false; |
285 | 308 | } |
@@ -293,12 +316,14 @@ discard block |
||
293 | 316 | function quickFileWritable($file) |
294 | 317 | { |
295 | 318 | // Some files won't exist, try to address up front |
296 | - if (!file_exists($file)) |
|
297 | - @touch($file); |
|
319 | + if (!file_exists($file)) { |
|
320 | + @touch($file); |
|
321 | + } |
|
298 | 322 | |
299 | 323 | // NOW do the writable check... |
300 | - if (is_writable($file)) |
|
301 | - return true; |
|
324 | + if (is_writable($file)) { |
|
325 | + return true; |
|
326 | + } |
|
302 | 327 | |
303 | 328 | @chmod($file, 0755); |
304 | 329 | |
@@ -308,10 +333,11 @@ discard block |
||
308 | 333 | foreach ($chmod_values as $val) |
309 | 334 | { |
310 | 335 | // If it's writable, break out of the loop |
311 | - if (is_writable($file)) |
|
312 | - break; |
|
313 | - else |
|
314 | - @chmod($file, $val); |
|
336 | + if (is_writable($file)) { |
|
337 | + break; |
|
338 | + } else { |
|
339 | + @chmod($file, $val); |
|
340 | + } |
|
315 | 341 | } |
316 | 342 | |
317 | 343 | return is_writable($file); |
@@ -338,14 +364,16 @@ discard block |
||
338 | 364 | { |
339 | 365 | static $fp = null; |
340 | 366 | |
341 | - if ($fp === null) |
|
342 | - $fp = fopen('php://stderr', 'wb'); |
|
367 | + if ($fp === null) { |
|
368 | + $fp = fopen('php://stderr', 'wb'); |
|
369 | + } |
|
343 | 370 | |
344 | 371 | fwrite($fp, $message . "\n"); |
345 | 372 | |
346 | - if ($fatal) |
|
347 | - exit; |
|
348 | -} |
|
373 | + if ($fatal) { |
|
374 | + exit; |
|
375 | + } |
|
376 | + } |
|
349 | 377 | |
350 | 378 | /** |
351 | 379 | * Throws a graphical error message. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for this section. |
@@ -38,8 +39,7 @@ discard block |
||
38 | 39 | 'stats' => 'SpiderStats', |
39 | 40 | ); |
40 | 41 | $default = 'stats'; |
41 | - } |
|
42 | - else |
|
42 | + } else |
|
43 | 43 | { |
44 | 44 | $subActions = array( |
45 | 45 | 'settings' => 'ManageSearchEngineSettings', |
@@ -90,11 +90,12 @@ discard block |
||
90 | 90 | { |
91 | 91 | disabledState = document.getElementById(\'spider_mode\').value == 0;'; |
92 | 92 | |
93 | - foreach ($config_vars as $variable) |
|
94 | - if ($variable[1] != 'spider_mode') |
|
93 | + foreach ($config_vars as $variable) { |
|
94 | + if ($variable[1] != 'spider_mode') |
|
95 | 95 | $javascript_function .= ' |
96 | 96 | if (document.getElementById(\'' . $variable[1] . '\')) |
97 | 97 | document.getElementById(\'' . $variable[1] . '\').disabled = disabledState;'; |
98 | + } |
|
98 | 99 | |
99 | 100 | $javascript_function .= ' |
100 | 101 | } |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | |
103 | 104 | call_integration_hook('integrate_modify_search_engine_settings', array(&$config_vars)); |
104 | 105 | |
105 | - if ($return_config) |
|
106 | - return $config_vars; |
|
106 | + if ($return_config) { |
|
107 | + return $config_vars; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | // We need to load the groups for the spider group thingy. |
109 | 111 | $request = $smcFunc['db_query']('', ' |
@@ -116,13 +118,15 @@ discard block |
||
116 | 118 | 'moderator_group' => 3, |
117 | 119 | ) |
118 | 120 | ); |
119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
120 | - $config_vars['spider_group'][2][$row['id_group']] = $row['group_name']; |
|
121 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
122 | + $config_vars['spider_group'][2][$row['id_group']] = $row['group_name']; |
|
123 | + } |
|
121 | 124 | $smcFunc['db_free_result']($request); |
122 | 125 | |
123 | 126 | // Make sure it's valid - note that regular members are given id_group = 1 which is reversed in Load.php - no admins here! |
124 | - if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) |
|
125 | - $_POST['spider_group'] = 0; |
|
127 | + if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) { |
|
128 | + $_POST['spider_group'] = 0; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | // We'll want this for our easy save. |
128 | 132 | require_once($sourcedir . '/ManageServer.php'); |
@@ -166,8 +170,9 @@ discard block |
||
166 | 170 | } |
167 | 171 | |
168 | 172 | // Are we adding a new one? |
169 | - if (!empty($_POST['addSpider'])) |
|
170 | - return EditSpider(); |
|
173 | + if (!empty($_POST['addSpider'])) { |
|
174 | + return EditSpider(); |
|
175 | + } |
|
171 | 176 | // User pressed the 'remove selection button'. |
172 | 177 | elseif (!empty($_POST['removeSpiders']) && !empty($_POST['remove']) && is_array($_POST['remove'])) |
173 | 178 | { |
@@ -175,8 +180,9 @@ discard block |
||
175 | 180 | validateToken('admin-ser'); |
176 | 181 | |
177 | 182 | // Make sure every entry is a proper integer. |
178 | - foreach ($_POST['remove'] as $index => $spider_id) |
|
179 | - $_POST['remove'][(int) $index] = (int) $spider_id; |
|
183 | + foreach ($_POST['remove'] as $index => $spider_id) { |
|
184 | + $_POST['remove'][(int) $index] = (int) $spider_id; |
|
185 | + } |
|
180 | 186 | |
181 | 187 | // Delete them all! |
182 | 188 | $smcFunc['db_query']('', ' |
@@ -215,8 +221,9 @@ discard block |
||
215 | 221 | ); |
216 | 222 | |
217 | 223 | $context['spider_last_seen'] = array(); |
218 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
219 | - $context['spider_last_seen'][$row['id_spider']] = $row['last_seen_time']; |
|
224 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
225 | + $context['spider_last_seen'][$row['id_spider']] = $row['last_seen_time']; |
|
226 | + } |
|
220 | 227 | $smcFunc['db_free_result']($request); |
221 | 228 | |
222 | 229 | createToken('admin-ser'); |
@@ -346,8 +353,9 @@ discard block |
||
346 | 353 | ) |
347 | 354 | ); |
348 | 355 | $spiders = array(); |
349 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
350 | - $spiders[$row['id_spider']] = $row; |
|
356 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
357 | + $spiders[$row['id_spider']] = $row; |
|
358 | + } |
|
351 | 359 | $smcFunc['db_free_result']($request); |
352 | 360 | |
353 | 361 | return $spiders; |
@@ -397,14 +405,15 @@ discard block |
||
397 | 405 | foreach ($ip_sets as $set) |
398 | 406 | { |
399 | 407 | $test = ip2range(trim($set)); |
400 | - if (!empty($test)) |
|
401 | - $ips[] = $set; |
|
408 | + if (!empty($test)) { |
|
409 | + $ips[] = $set; |
|
410 | + } |
|
402 | 411 | } |
403 | 412 | $ips = implode(',', $ips); |
404 | 413 | |
405 | 414 | // Goes in as it is... |
406 | - if ($context['id_spider']) |
|
407 | - $smcFunc['db_query']('', ' |
|
415 | + if ($context['id_spider']) { |
|
416 | + $smcFunc['db_query']('', ' |
|
408 | 417 | UPDATE {db_prefix}spiders |
409 | 418 | SET spider_name = {string:spider_name}, user_agent = {string:spider_agent}, |
410 | 419 | ip_info = {string:ip_info} |
@@ -416,8 +425,8 @@ discard block |
||
416 | 425 | 'ip_info' => $ips, |
417 | 426 | ) |
418 | 427 | ); |
419 | - else |
|
420 | - $smcFunc['db_insert']('insert', |
|
428 | + } else { |
|
429 | + $smcFunc['db_insert']('insert', |
|
421 | 430 | '{db_prefix}spiders', |
422 | 431 | array( |
423 | 432 | 'spider_name' => 'string', 'user_agent' => 'string', 'ip_info' => 'string', |
@@ -427,6 +436,7 @@ discard block |
||
427 | 436 | ), |
428 | 437 | array('id_spider') |
429 | 438 | ); |
439 | + } |
|
430 | 440 | |
431 | 441 | |
432 | 442 | cache_put_data('spider_search', null); |
@@ -454,13 +464,14 @@ discard block |
||
454 | 464 | 'current_spider' => $context['id_spider'], |
455 | 465 | ) |
456 | 466 | ); |
457 | - if ($row = $smcFunc['db_fetch_assoc']($request)) |
|
458 | - $context['spider'] = array( |
|
467 | + if ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
468 | + $context['spider'] = array( |
|
459 | 469 | 'id' => $row['id_spider'], |
460 | 470 | 'name' => $row['spider_name'], |
461 | 471 | 'agent' => $row['user_agent'], |
462 | 472 | 'ip_info' => $row['ip_info'], |
463 | 473 | ); |
474 | + } |
|
464 | 475 | $smcFunc['db_free_result']($request); |
465 | 476 | } |
466 | 477 | |
@@ -477,8 +488,9 @@ discard block |
||
477 | 488 | { |
478 | 489 | global $modSettings, $smcFunc; |
479 | 490 | |
480 | - if (isset($_SESSION['id_robot'])) |
|
481 | - unset($_SESSION['id_robot']); |
|
491 | + if (isset($_SESSION['id_robot'])) { |
|
492 | + unset($_SESSION['id_robot']); |
|
493 | + } |
|
482 | 494 | $_SESSION['robot_check'] = time(); |
483 | 495 | |
484 | 496 | // We cache the spider data for ten minutes if we can. |
@@ -492,15 +504,17 @@ discard block |
||
492 | 504 | ) |
493 | 505 | ); |
494 | 506 | $spider_data = array(); |
495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
496 | - $spider_data[] = $row; |
|
507 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
508 | + $spider_data[] = $row; |
|
509 | + } |
|
497 | 510 | $smcFunc['db_free_result']($request); |
498 | 511 | |
499 | 512 | cache_put_data('spider_search', $spider_data, 600); |
500 | 513 | } |
501 | 514 | |
502 | - if (empty($spider_data)) |
|
503 | - return false; |
|
515 | + if (empty($spider_data)) { |
|
516 | + return false; |
|
517 | + } |
|
504 | 518 | |
505 | 519 | // Only do these bits once. |
506 | 520 | $ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); |
@@ -508,33 +522,38 @@ discard block |
||
508 | 522 | foreach ($spider_data as $spider) |
509 | 523 | { |
510 | 524 | // User agent is easy. |
511 | - if (!empty($spider['user_agent']) && strpos($ci_user_agent, strtolower($spider['user_agent'])) !== false) |
|
512 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
525 | + if (!empty($spider['user_agent']) && strpos($ci_user_agent, strtolower($spider['user_agent'])) !== false) { |
|
526 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
527 | + } |
|
513 | 528 | // IP stuff is harder. |
514 | 529 | elseif ($_SERVER['REMOTE_ADDR']) |
515 | 530 | { |
516 | 531 | $ips = explode(',', $spider['ip_info']); |
517 | 532 | foreach ($ips as $ip) |
518 | 533 | { |
519 | - if ($ip === '') |
|
520 | - continue; |
|
534 | + if ($ip === '') { |
|
535 | + continue; |
|
536 | + } |
|
521 | 537 | |
522 | 538 | $ip = ip2range($ip); |
523 | 539 | if (!empty($ip)) |
524 | 540 | { |
525 | - if (inet_ptod($ip['low']) <= inet_ptod($_SERVER['REMOTE_ADDR']) && inet_ptod($ip['high']) >= inet_ptod($_SERVER['REMOTE_ADDR'])) |
|
526 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
541 | + if (inet_ptod($ip['low']) <= inet_ptod($_SERVER['REMOTE_ADDR']) && inet_ptod($ip['high']) >= inet_ptod($_SERVER['REMOTE_ADDR'])) { |
|
542 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
543 | + } |
|
527 | 544 | } |
528 | 545 | } |
529 | 546 | } |
530 | 547 | |
531 | - if (isset($_SESSION['id_robot'])) |
|
532 | - break; |
|
548 | + if (isset($_SESSION['id_robot'])) { |
|
549 | + break; |
|
550 | + } |
|
533 | 551 | } |
534 | 552 | |
535 | 553 | // If this is low server tracking then log the spider here as opposed to the main logging function. |
536 | - if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) |
|
537 | - logSpider(); |
|
554 | + if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) { |
|
555 | + logSpider(); |
|
556 | + } |
|
538 | 557 | |
539 | 558 | return !empty($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
540 | 559 | } |
@@ -548,8 +567,9 @@ discard block |
||
548 | 567 | { |
549 | 568 | global $smcFunc, $modSettings, $context; |
550 | 569 | |
551 | - if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) |
|
552 | - return; |
|
570 | + if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) { |
|
571 | + return; |
|
572 | + } |
|
553 | 573 | |
554 | 574 | // Attempt to update today's entry. |
555 | 575 | if ($modSettings['spider_mode'] == 1) |
@@ -590,9 +610,9 @@ discard block |
||
590 | 610 | $url = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
591 | 611 | unset($url['sesc'], $url[$context['session_var']]); |
592 | 612 | $url = $smcFunc['json_encode']($url); |
613 | + } else { |
|
614 | + $url = ''; |
|
593 | 615 | } |
594 | - else |
|
595 | - $url = ''; |
|
596 | 616 | |
597 | 617 | $smcFunc['db_insert']('insert', |
598 | 618 | '{db_prefix}log_spider_hits', |
@@ -620,12 +640,14 @@ discard block |
||
620 | 640 | ) |
621 | 641 | ); |
622 | 642 | $spider_hits = array(); |
623 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
624 | - $spider_hits[] = $row; |
|
643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
644 | + $spider_hits[] = $row; |
|
645 | + } |
|
625 | 646 | $smcFunc['db_free_result']($request); |
626 | 647 | |
627 | - if (empty($spider_hits)) |
|
628 | - return; |
|
648 | + if (empty($spider_hits)) { |
|
649 | + return; |
|
650 | + } |
|
629 | 651 | |
630 | 652 | // Attempt to update the master data. |
631 | 653 | $stat_inserts = array(); |
@@ -646,18 +668,20 @@ discard block |
||
646 | 668 | 'hits' => $stat['num_hits'], |
647 | 669 | ) |
648 | 670 | ); |
649 | - if ($smcFunc['db_affected_rows']() == 0) |
|
650 | - $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
671 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
672 | + $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
673 | + } |
|
651 | 674 | } |
652 | 675 | |
653 | 676 | // New stats? |
654 | - if (!empty($stat_inserts)) |
|
655 | - $smcFunc['db_insert']('ignore', |
|
677 | + if (!empty($stat_inserts)) { |
|
678 | + $smcFunc['db_insert']('ignore', |
|
656 | 679 | '{db_prefix}log_spider_stats', |
657 | 680 | array('stat_date' => 'date', 'id_spider' => 'int', 'page_hits' => 'int', 'last_seen' => 'int'), |
658 | 681 | $stat_inserts, |
659 | 682 | array('stat_date', 'id_spider') |
660 | 683 | ); |
684 | + } |
|
661 | 685 | |
662 | 686 | // All processed. |
663 | 687 | $smcFunc['db_query']('', ' |
@@ -700,8 +724,7 @@ discard block |
||
700 | 724 | 'delete_period' => $deleteTime, |
701 | 725 | ) |
702 | 726 | ); |
703 | - } |
|
704 | - else |
|
727 | + } else |
|
705 | 728 | { |
706 | 729 | // Deleting all of them |
707 | 730 | $smcFunc['db_query']('', ' |
@@ -791,10 +814,11 @@ discard block |
||
791 | 814 | foreach ($context['spider_logs']['rows'] as $k => $row) |
792 | 815 | { |
793 | 816 | // Feature disabled? |
794 | - if (empty($row['data']['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) |
|
795 | - $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; |
|
796 | - else |
|
797 | - $urls[$k] = array($row['data']['viewing']['value'], -1); |
|
817 | + if (empty($row['data']['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) { |
|
818 | + $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; |
|
819 | + } else { |
|
820 | + $urls[$k] = array($row['data']['viewing']['value'], -1); |
|
821 | + } |
|
798 | 822 | } |
799 | 823 | |
800 | 824 | // Now stick in the new URLs. |
@@ -836,8 +860,9 @@ discard block |
||
836 | 860 | ) |
837 | 861 | ); |
838 | 862 | $spider_logs = array(); |
839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
840 | - $spider_logs[] = $row; |
|
863 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
864 | + $spider_logs[] = $row; |
|
865 | + } |
|
841 | 866 | $smcFunc['db_free_result']($request); |
842 | 867 | |
843 | 868 | return $spider_logs; |
@@ -913,14 +938,18 @@ discard block |
||
913 | 938 | |
914 | 939 | // Prepare the dates for the drop down. |
915 | 940 | $date_choices = array(); |
916 | - for ($y = $min_year; $y <= $max_year; $y++) |
|
917 | - for ($m = 1; $m <= 12; $m++) |
|
941 | + for ($y = $min_year; $y <= $max_year; $y++) { |
|
942 | + for ($m = 1; |
|
943 | + } |
|
944 | + $m <= 12; $m++) |
|
918 | 945 | { |
919 | 946 | // This doesn't count? |
920 | - if ($y == $min_year && $m < $min_month) |
|
921 | - continue; |
|
922 | - if ($y == $max_year && $m > $max_month) |
|
923 | - break; |
|
947 | + if ($y == $min_year && $m < $min_month) { |
|
948 | + continue; |
|
949 | + } |
|
950 | + if ($y == $max_year && $m > $max_month) { |
|
951 | + break; |
|
952 | + } |
|
924 | 953 | |
925 | 954 | $date_choices[$y . $m] = $txt['months_short'][$m] . ' ' . $y; |
926 | 955 | } |
@@ -933,13 +962,14 @@ discard block |
||
933 | 962 | ' . $txt['spider_stats_select_month'] . ': |
934 | 963 | <select name="new_date" onchange="document.spider_stat_list.submit();">'; |
935 | 964 | |
936 | - if (empty($date_choices)) |
|
937 | - $date_select .= ' |
|
965 | + if (empty($date_choices)) { |
|
966 | + $date_select .= ' |
|
938 | 967 | <option></option>'; |
939 | - else |
|
940 | - foreach ($date_choices as $id => $text) |
|
968 | + } else { |
|
969 | + foreach ($date_choices as $id => $text) |
|
941 | 970 | $date_select .= ' |
942 | 971 | <option value="' . $id . '"' . ($current_date == $id ? ' selected' : '') . '>' . $text . '</option>'; |
972 | + } |
|
943 | 973 | |
944 | 974 | $date_select .= ' |
945 | 975 | </select> |
@@ -1063,8 +1093,9 @@ discard block |
||
1063 | 1093 | ) |
1064 | 1094 | ); |
1065 | 1095 | $spider_stats = array(); |
1066 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1067 | - $spider_stats[] = $row; |
|
1096 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1097 | + $spider_stats[] = $row; |
|
1098 | + } |
|
1068 | 1099 | $smcFunc['db_free_result']($request); |
1069 | 1100 | |
1070 | 1101 | return $spider_stats; |
@@ -1105,8 +1136,9 @@ discard block |
||
1105 | 1136 | array() |
1106 | 1137 | ); |
1107 | 1138 | $spiders = array(); |
1108 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1109 | - $spiders[$row['id_spider']] = $row['spider_name']; |
|
1139 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1140 | + $spiders[$row['id_spider']] = $row['spider_name']; |
|
1141 | + } |
|
1110 | 1142 | $smcFunc['db_free_result']($request); |
1111 | 1143 | |
1112 | 1144 | updateSettings(array('spider_name_cache' => $smcFunc['json_encode']($spiders))); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
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 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
35 | 36 | isAllowedTo('who_view'); |
36 | 37 | |
37 | 38 | // You can't do anything if this is off. |
38 | - if (empty($modSettings['who_enabled'])) |
|
39 | - fatal_lang_error('who_off', false); |
|
39 | + if (empty($modSettings['who_enabled'])) { |
|
40 | + fatal_lang_error('who_off', false); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // Load the 'Who' template. |
42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
77 | + unset($_SESSION['who_online_filter']); |
|
74 | 78 | } |
75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
76 | - unset($_SESSION['who_online_filter']); |
|
77 | 79 | |
78 | 80 | // Does the user prefer a different sort direction? |
79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
98 | 100 | |
99 | 101 | $conditions = array(); |
100 | - if (!allowedTo('moderate_forum')) |
|
101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
102 | + if (!allowedTo('moderate_forum')) { |
|
103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
104 | + } |
|
102 | 105 | |
103 | 106 | // Fallback to top filter? |
104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
109 | + } |
|
106 | 110 | // Does the user wish to apply a filter? |
107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
113 | + } |
|
109 | 114 | // Perhaps we saved a filter earlier in the session? |
110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
112 | - else |
|
113 | - $context['show_by'] = 'members'; |
|
115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
117 | + } else { |
|
118 | + $context['show_by'] = 'members'; |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
157 | 163 | { |
158 | 164 | $actions = $smcFunc['json_decode']($row['url'], true); |
159 | - if ($actions === false) |
|
160 | - continue; |
|
165 | + if ($actions === false) { |
|
166 | + continue; |
|
167 | + } |
|
161 | 168 | |
162 | 169 | // Send the information to the template. |
163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
195 | 202 | $spiderContext = array(); |
196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
197 | 204 | { |
198 | - foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) |
|
199 | - $spiderContext[$id] = array( |
|
205 | + foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) { |
|
206 | + $spiderContext[$id] = array( |
|
200 | 207 | 'id' => 0, |
201 | 208 | 'name' => $name, |
202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
205 | 212 | 'email' => $name, |
206 | 213 | 'is_guest' => true |
207 | 214 | ); |
215 | + } |
|
208 | 216 | } |
209 | 217 | |
210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
219 | 227 | // Put it in the context variables. |
220 | 228 | foreach ($context['members'] as $i => $member) |
221 | 229 | { |
222 | - if ($member['id'] != 0) |
|
223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
230 | + if ($member['id'] != 0) { |
|
231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
232 | + } |
|
224 | 233 | |
225 | 234 | // Keep the IP that came from the database. |
226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
230 | - else |
|
231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
239 | + } else { |
|
240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
241 | + } |
|
232 | 242 | } |
233 | 243 | |
234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
263 | 273 | { |
264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
265 | 275 | |
266 | - if (!allowedTo('who_view')) |
|
267 | - return array(); |
|
276 | + if (!allowedTo('who_view')) { |
|
277 | + return array(); |
|
278 | + } |
|
268 | 279 | loadLanguage('Who'); |
269 | 280 | |
270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
292 | 303 | ); |
293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
294 | 305 | |
295 | - if (!is_array($urls)) |
|
296 | - $url_list = array(array($urls, $user_info['id'])); |
|
297 | - else |
|
298 | - $url_list = $urls; |
|
306 | + if (!is_array($urls)) { |
|
307 | + $url_list = array(array($urls, $user_info['id'])); |
|
308 | + } else { |
|
309 | + $url_list = $urls; |
|
310 | + } |
|
299 | 311 | |
300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
307 | 319 | { |
308 | 320 | // Get the request parameters.. |
309 | 321 | $actions = $smcFunc['json_decode']($url[0], true); |
310 | - if ($actions === false) |
|
311 | - continue; |
|
322 | + if ($actions === false) { |
|
323 | + continue; |
|
324 | + } |
|
312 | 325 | |
313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
315 | - $actions['action'] = $actions['area']; |
|
327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
328 | + $actions['action'] = $actions['area']; |
|
329 | + } |
|
316 | 330 | |
317 | 331 | // Check if there was no action or the action is display. |
318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
333 | 347 | } |
334 | 348 | // It's the board index!! It must be! |
335 | - else |
|
336 | - $data[$k] = $txt['who_index']; |
|
349 | + else { |
|
350 | + $data[$k] = $txt['who_index']; |
|
351 | + } |
|
337 | 352 | } |
338 | 353 | // Probably an error or some goon? |
339 | - elseif ($actions['action'] == '') |
|
340 | - $data[$k] = $txt['who_index']; |
|
354 | + elseif ($actions['action'] == '') { |
|
355 | + $data[$k] = $txt['who_index']; |
|
356 | + } |
|
341 | 357 | // Some other normal action...? |
342 | 358 | else |
343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
345 | 361 | if ($actions['action'] == 'profile') |
346 | 362 | { |
347 | 363 | // Whose? Their own? |
348 | - if (empty($actions['u'])) |
|
349 | - $actions['u'] = $url[1]; |
|
364 | + if (empty($actions['u'])) { |
|
365 | + $actions['u'] = $url[1]; |
|
366 | + } |
|
350 | 367 | |
351 | 368 | $data[$k] = $txt['who_hidden']; |
352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
353 | - } |
|
354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
355 | 371 | { |
356 | 372 | $data[$k] = $txt['who_hidden']; |
357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
358 | 374 | } |
359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
378 | + } |
|
362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
382 | + } |
|
365 | 383 | // Viewable if and only if they can see the board... |
366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
370 | 388 | |
371 | 389 | $data[$k] = $txt['who_hidden']; |
372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
373 | - } |
|
374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
375 | 392 | { |
376 | 393 | // Find out what message they are accessing. |
377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
395 | 412 | $smcFunc['db_free_result']($result); |
396 | 413 | |
397 | - if (empty($id_topic)) |
|
398 | - $data[$k] = $txt['who_hidden']; |
|
414 | + if (empty($id_topic)) { |
|
415 | + $data[$k] = $txt['who_hidden']; |
|
416 | + } |
|
399 | 417 | } |
400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
421 | + } |
|
403 | 422 | // Viewable by permission level. |
404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
405 | 424 | { |
406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
409 | - $data[$k] = $txt['who_moderate']; |
|
410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
411 | - $data[$k] = $txt['who_admin']; |
|
412 | - else |
|
413 | - $data[$k] = $txt['who_hidden']; |
|
425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
428 | + $data[$k] = $txt['who_moderate']; |
|
429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
430 | + $data[$k] = $txt['who_admin']; |
|
431 | + } else { |
|
432 | + $data[$k] = $txt['who_hidden']; |
|
433 | + } |
|
434 | + } elseif (!empty($actions['action'])) { |
|
435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
436 | + } else { |
|
437 | + $data[$k] = $txt['who_unknown']; |
|
414 | 438 | } |
415 | - elseif (!empty($actions['action'])) |
|
416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
417 | - else |
|
418 | - $data[$k] = $txt['who_unknown']; |
|
419 | 439 | } |
420 | 440 | |
421 | 441 | if (isset($actions['error'])) |
422 | 442 | { |
423 | - if (isset($txt[$actions['error']])) |
|
424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
425 | - elseif ($actions['error'] == 'guest_login') |
|
426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
427 | - else |
|
428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
429 | - |
|
430 | - if (!empty($error_message)) |
|
431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
443 | + if (isset($txt[$actions['error']])) { |
|
444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
445 | + } elseif ($actions['error'] == 'guest_login') { |
|
446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
447 | + } else { |
|
448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
449 | + } |
|
450 | + |
|
451 | + if (!empty($error_message)) { |
|
452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
453 | + } |
|
432 | 454 | } |
433 | 455 | |
434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
439 | 461 | if (!empty($integrate_action)) |
440 | 462 | { |
441 | 463 | $data[$k] = $integrate_action; |
442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
466 | + } |
|
467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
469 | + } |
|
470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
472 | + } |
|
448 | 473 | break; |
449 | 474 | } |
450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
473 | 498 | { |
474 | 499 | // Show the topic's subject for each of the actions. |
475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
502 | + } |
|
477 | 503 | } |
478 | 504 | $smcFunc['db_free_result']($result); |
479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
496 | 522 | { |
497 | 523 | // Put the board name into the string for each member... |
498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
526 | + } |
|
500 | 527 | } |
501 | 528 | $smcFunc['db_free_result']($result); |
502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
519 | 546 | { |
520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
522 | - continue; |
|
548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
549 | + continue; |
|
550 | + } |
|
523 | 551 | |
524 | 552 | // Set their action on each - session/text to sprintf. |
525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
555 | + } |
|
527 | 556 | } |
528 | 557 | $smcFunc['db_free_result']($result); |
529 | 558 | } |
530 | 559 | |
531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
532 | 561 | |
533 | - if (!is_array($urls)) |
|
534 | - return isset($data[0]) ? $data[0] : false; |
|
535 | - else |
|
536 | - return $data; |
|
537 | -} |
|
562 | + if (!is_array($urls)) { |
|
563 | + return isset($data[0]) ? $data[0] : false; |
|
564 | + } else { |
|
565 | + return $data; |
|
566 | + } |
|
567 | + } |
|
538 | 568 | |
539 | 569 | /** |
540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -710,8 +740,8 @@ discard block |
||
710 | 740 | ); |
711 | 741 | |
712 | 742 | // Give the translators some credit for their hard work. |
713 | - if (!empty($txt['translation_credits'])) |
|
714 | - $context['credits'][] = array( |
|
743 | + if (!empty($txt['translation_credits'])) { |
|
744 | + $context['credits'][] = array( |
|
715 | 745 | 'title' => $txt['credits_groups_translation'], |
716 | 746 | 'groups' => array( |
717 | 747 | array( |
@@ -720,6 +750,7 @@ discard block |
||
720 | 750 | ), |
721 | 751 | ), |
722 | 752 | ); |
753 | + } |
|
723 | 754 | |
724 | 755 | $context['credits'][] = array( |
725 | 756 | 'title' => $txt['credits_special'], |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | 'Jessica "Suki" González', |
593 | 593 | 'Karl "RegularExpression" Benson', |
594 | 594 | 'Matthew "Labradoodle-360" Kerle', |
595 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
595 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
596 | 596 | 'Michael "Thantos" Miller', |
597 | 597 | 'Norv', |
598 | 598 | 'Peter "Arantor" Spicer', |
@@ -824,13 +824,13 @@ discard block |
||
824 | 824 | $credit_info = $smcFunc['json_decode']($row['credits'], true); |
825 | 825 | |
826 | 826 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
827 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
827 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
828 | 828 | $version = $txt['credits_version'] . ' ' . $row['version']; |
829 | 829 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
830 | 830 | |
831 | 831 | // build this one out and stash it away |
832 | 832 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
833 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
833 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
834 | 834 | } |
835 | 835 | cache_put_data('mods_credits', $mods, 86400); |
836 | 836 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | loadLanguage('Drafts'); |
21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
34 | 35 | |
35 | 36 | // can you be, should you be ... here? |
36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
37 | - return false; |
|
37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
38 | + return false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | // read in what they sent us, if anything |
40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
47 | 49 | |
48 | 50 | // since we were called from the autosave function, send something back |
49 | - if (!empty($id_draft)) |
|
50 | - XmlDraft($id_draft); |
|
51 | + if (!empty($id_draft)) { |
|
52 | + XmlDraft($id_draft); |
|
53 | + } |
|
51 | 54 | |
52 | 55 | return true; |
53 | 56 | } |
54 | 57 | |
55 | - if (!isset($_POST['message'])) |
|
56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
58 | + if (!isset($_POST['message'])) { |
|
59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
60 | + } |
|
57 | 61 | |
58 | 62 | // prepare any data from the form |
59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
66 | 70 | |
67 | 71 | // message and subject still need a bit more work |
68 | 72 | preparsecode($draft['body']); |
69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
75 | + } |
|
71 | 76 | |
72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
148 | 153 | { |
149 | 154 | $context['draft_saved'] = true; |
150 | 155 | $context['id_draft'] = $id_draft; |
156 | + } else { |
|
157 | + $post_errors[] = 'draft_not_saved'; |
|
151 | 158 | } |
152 | - else |
|
153 | - $post_errors[] = 'draft_not_saved'; |
|
154 | 159 | |
155 | 160 | // cleanup |
156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
181 | 186 | |
182 | 187 | // PM survey says ... can you stay or must you go |
183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
184 | - return false; |
|
188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
189 | + return false; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | // read in what you sent us |
187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
194 | 200 | |
195 | 201 | // Send something back to the javascript caller |
196 | - if (!empty($id_draft)) |
|
197 | - XmlDraft($id_draft); |
|
202 | + if (!empty($id_draft)) { |
|
203 | + XmlDraft($id_draft); |
|
204 | + } |
|
198 | 205 | |
199 | 206 | return true; |
200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
204 | 211 | { |
205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
215 | + $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
207 | 216 | } |
208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
209 | - $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
210 | 217 | |
211 | 218 | // prepare the data we got from the form |
212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | |
216 | 223 | // message and subject always need a bit more work |
217 | 224 | preparsecode($draft['body']); |
218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | // Modifying an existing PM draft? |
222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
280 | 288 | { |
281 | 289 | $context['draft_saved'] = true; |
282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
291 | + } else { |
|
292 | + $post_errors[] = 'draft_not_saved'; |
|
283 | 293 | } |
284 | - else |
|
285 | - $post_errors[] = 'draft_not_saved'; |
|
286 | 294 | } |
287 | 295 | |
288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
315 | 323 | $type = (int) $type; |
316 | 324 | |
317 | 325 | // nothing to read, nothing to do |
318 | - if (empty($id_draft)) |
|
319 | - return false; |
|
326 | + if (empty($id_draft)) { |
|
327 | + return false; |
|
328 | + } |
|
320 | 329 | |
321 | 330 | // load in this draft from the DB |
322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
337 | 346 | ); |
338 | 347 | |
339 | 348 | // no results? |
340 | - if (!$smcFunc['db_num_rows']($request)) |
|
341 | - return false; |
|
349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
350 | + return false; |
|
351 | + } |
|
342 | 352 | |
343 | 353 | // load up the data |
344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
361 | - } |
|
362 | - elseif ($type === 1) |
|
371 | + } elseif ($type === 1) |
|
363 | 372 | { |
364 | 373 | // one of those pm drafts? then set it up like we have an error |
365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
395 | 404 | global $user_info, $smcFunc; |
396 | 405 | |
397 | 406 | // Only a single draft. |
398 | - if (is_numeric($id_draft)) |
|
399 | - $id_draft = array($id_draft); |
|
407 | + if (is_numeric($id_draft)) { |
|
408 | + $id_draft = array($id_draft); |
|
409 | + } |
|
400 | 410 | |
401 | 411 | // can't delete nothing |
402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
403 | - return false; |
|
412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
413 | + return false; |
|
414 | + } |
|
404 | 415 | |
405 | 416 | $smcFunc['db_query']('', ' |
406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
430 | 441 | |
431 | 442 | // Permissions |
432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
433 | - return false; |
|
443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
444 | + return false; |
|
445 | + } |
|
434 | 446 | |
435 | 447 | $context['drafts'] = array(); |
436 | 448 | |
437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
452 | + } |
|
440 | 453 | |
441 | 454 | // load the drafts this user has available |
442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
459 | 472 | // add them to the draft array for display |
460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
461 | 474 | { |
462 | - if (empty($row['subject'])) |
|
463 | - $row['subject'] = $txt['no_subject']; |
|
475 | + if (empty($row['subject'])) { |
|
476 | + $row['subject'] = $txt['no_subject']; |
|
477 | + } |
|
464 | 478 | |
465 | 479 | // Post drafts |
466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | } |
546 | 560 | |
547 | 561 | // Default to 10. |
548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
549 | - $_REQUEST['viewscount'] = 10; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = 10; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
612 | 627 | { |
613 | 628 | // Censor.... |
614 | - if (empty($row['body'])) |
|
615 | - $row['body'] = ''; |
|
629 | + if (empty($row['body'])) { |
|
630 | + $row['body'] = ''; |
|
631 | + } |
|
616 | 632 | |
617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
618 | - if (empty($row['subject'])) |
|
619 | - $row['subject'] = $txt['no_subject']; |
|
634 | + if (empty($row['subject'])) { |
|
635 | + $row['subject'] = $txt['no_subject']; |
|
636 | + } |
|
620 | 637 | |
621 | 638 | censorText($row['body']); |
622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
648 | 665 | $smcFunc['db_free_result']($request); |
649 | 666 | |
650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
651 | - if ($reverse) |
|
652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
668 | + if ($reverse) { |
|
669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
670 | + } |
|
653 | 671 | |
654 | 672 | // Menu tab |
655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
707 | 725 | } |
708 | 726 | |
709 | 727 | // Default to 10. |
710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
711 | - $_REQUEST['viewscount'] = 10; |
|
728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
729 | + $_REQUEST['viewscount'] = 10; |
|
730 | + } |
|
712 | 731 | |
713 | 732 | // Get the count of applicable drafts |
714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
768 | 787 | { |
769 | 788 | // Censor.... |
770 | - if (empty($row['body'])) |
|
771 | - $row['body'] = ''; |
|
789 | + if (empty($row['body'])) { |
|
790 | + $row['body'] = ''; |
|
791 | + } |
|
772 | 792 | |
773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
774 | - if (empty($row['subject'])) |
|
775 | - $row['subject'] = $txt['no_subject']; |
|
794 | + if (empty($row['subject'])) { |
|
795 | + $row['subject'] = $txt['no_subject']; |
|
796 | + } |
|
776 | 797 | |
777 | 798 | censorText($row['body']); |
778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
827 | 848 | $smcFunc['db_free_result']($request); |
828 | 849 | |
829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
830 | - if ($reverse) |
|
831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
851 | + if ($reverse) { |
|
852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
853 | + } |
|
832 | 854 | |
833 | 855 | // off to the template we go |
834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param string $post_errors A string of info about errors encountered trying to save this draft |
175 | 175 | * @param array $recipientList An array of data about who this PM is being sent to |
176 | - * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
176 | + * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
177 | 177 | */ |
178 | 178 | function SavePMDraft(&$post_errors, $recipientList) |
179 | 179 | { |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param int $id_draft The ID of the draft to delete |
390 | 390 | * @param boolean $check Whether or not to check that the draft belongs to the current user |
391 | - * @return boolean False if it couldn't be deleted (doesn't return anything otherwise) |
|
391 | + * @return false|null False if it couldn't be deleted (doesn't return anything otherwise) |
|
392 | 392 | */ |
393 | 393 | function DeleteDraft($id_draft, $check = true) |
394 | 394 | { |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param int $member_id ID of the member to show drafts for |
423 | 423 | * @param boolean|integer $topic If $type is 1, this can be set to only load drafts for posts in the specific topic |
424 | 424 | * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts |
425 | - * @return boolean False if the drafts couldn't be loaded, nothing otherwise |
|
425 | + * @return false|null False if the drafts couldn't be loaded, nothing otherwise |
|
426 | 426 | */ |
427 | 427 | function ShowDrafts($member_id, $topic = false, $draft_type = 0) |
428 | 428 | { |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | // Start things rolling by getting SMF alive... |
18 | 18 | $ssi_guest_access = true; |
19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
20 | 20 | die('Cannot find SSI.php'); |
21 | +} |
|
21 | 22 | |
22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
35 | 36 | } |
36 | 37 | |
37 | 38 | // I assume we're even active? |
38 | -if (empty($modSettings['paid_enabled'])) |
|
39 | +if (empty($modSettings['paid_enabled'])) { |
|
39 | 40 | exit; |
41 | +} |
|
40 | 42 | |
41 | 43 | // If we have some custom people who find out about problems load them here. |
42 | 44 | $notify_users = array(); |
43 | 45 | if (!empty($modSettings['paid_email_to'])) |
44 | 46 | { |
45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
46 | - $notify_users[] = array( |
|
47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
48 | + $notify_users[] = array( |
|
47 | 49 | 'email' => $email, |
48 | 50 | 'name' => $txt['who_member'], |
49 | 51 | 'id' => 0, |
50 | 52 | ); |
51 | -} |
|
53 | + } |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // We need to see whether we can find the correct payment gateway, |
54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | } |
66 | 69 | } |
67 | 70 | |
68 | -if (empty($txnType)) |
|
71 | +if (empty($txnType)) { |
|
69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
73 | +} |
|
70 | 74 | |
71 | 75 | // Get the subscription and member ID amoungst others... |
72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
76 | 80 | $member_id = (int) $member_id; |
77 | 81 | |
78 | 82 | // This would be bad... |
79 | -if (empty($member_id)) |
|
83 | +if (empty($member_id)) { |
|
80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
85 | +} |
|
81 | 86 | |
82 | 87 | // Verify the member. |
83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
89 | 94 | ) |
90 | 95 | ); |
91 | 96 | // Didn't find them? |
92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
99 | +} |
|
94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
95 | 101 | $smcFunc['db_free_result']($request); |
96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | ); |
106 | 112 | |
107 | 113 | // Didn't find it? |
108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
116 | +} |
|
110 | 117 | |
111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
123 | 130 | 'current_member' => $member_id, |
124 | 131 | ) |
125 | 132 | ); |
126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
135 | +} |
|
128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
129 | 137 | $smcFunc['db_free_result']($request); |
130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
139 | 147 | removeSubscription($subscription_id, $member_id); |
140 | 148 | $subscription_act = time(); |
141 | 149 | $status = 0; |
142 | - } |
|
143 | - else |
|
150 | + } else |
|
144 | 151 | { |
145 | 152 | loadSubscriptions(); |
146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
188 | 195 | if (!$gatewayClass->isSubscription()) |
189 | 196 | { |
190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
191 | - if (empty($real_details)) |
|
192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
198 | + if (empty($real_details)) { |
|
199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Now we just try to find anything pending. |
195 | 203 | // We don't really care which it is as security happens later. |
196 | 204 | foreach ($real_details as $id => $detail) |
197 | 205 | { |
198 | 206 | unset($real_details[$id]); |
199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
200 | - $subscription_info['payments_pending']--; |
|
207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
208 | + $subscription_info['payments_pending']--; |
|
209 | + } |
|
201 | 210 | break; |
202 | 211 | } |
203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
223 | 232 | // This is a little harder, can we find the right duration? |
224 | 233 | foreach ($cost as $duration => $value) |
225 | 234 | { |
226 | - if ($duration == 'fixed') |
|
227 | - continue; |
|
228 | - elseif ((float) $value == (float) $total_cost) |
|
229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
235 | + if ($duration == 'fixed') { |
|
236 | + continue; |
|
237 | + } elseif ((float) $value == (float) $total_cost) { |
|
238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
239 | + } |
|
230 | 240 | } |
231 | 241 | |
232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
235 | 245 | $notify = true; |
236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
237 | 247 | } |
238 | - } |
|
239 | - else |
|
248 | + } else |
|
240 | 249 | { |
241 | 250 | $actual_cost = $cost['fixed']; |
242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
269 | 278 | elseif ($gatewayClass->isCancellation()) |
270 | 279 | { |
271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
273 | -} |
|
274 | -else |
|
280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
282 | + } |
|
283 | + } else |
|
275 | 284 | { |
276 | 285 | // Some other "valid" transaction such as: |
277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
308 | 317 | // Maybe we can try to give them the post data? |
309 | 318 | if (!empty($_POST)) |
310 | 319 | { |
311 | - foreach ($_POST as $key => $val) |
|
312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
320 | + foreach ($_POST as $key => $val) { |
|
321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
322 | + } |
|
313 | 323 | } |
314 | 324 | |
315 | 325 | // Then just log and die. |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | // We already load the basic stuff? |
1745 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
1745 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
1746 | 1746 | { |
1747 | 1747 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1748 | 1748 | |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | SELECT variable, value, id_member, id_theme |
1768 | 1768 | FROM {db_prefix}themes |
1769 | 1769 | WHERE id_member' . (empty($themeData[0]) ? ' IN (-1, 0, {int:id_member})' : ' = {int:id_member}') . ' |
1770 | - AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') .' |
|
1770 | + AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') . ' |
|
1771 | 1771 | ORDER BY id_theme asc', |
1772 | 1772 | array( |
1773 | 1773 | 'id_theme' => $id_theme, |
@@ -1997,7 +1997,7 @@ discard block |
||
1997 | 1997 | if (!isset($context['javascript_vars'])) |
1998 | 1998 | $context['javascript_vars'] = array(); |
1999 | 1999 | |
2000 | - $context['login_url'] = $scripturl . '?action=login2'; |
|
2000 | + $context['login_url'] = $scripturl . '?action=login2'; |
|
2001 | 2001 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
2002 | 2002 | $context['session_var'] = $_SESSION['session_var']; |
2003 | 2003 | $context['session_id'] = $_SESSION['session_value']; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We explicitly do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -405,9 +422,9 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
@@ -415,8 +432,9 @@ discard block |
||
415 | 432 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
416 | 433 | |
417 | 434 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
418 | - if (empty($cookie_data)) |
|
419 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + if (empty($cookie_data)) { |
|
436 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
437 | + } |
|
420 | 438 | |
421 | 439 | list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, ''); |
422 | 440 | |
@@ -424,16 +442,17 @@ discard block |
||
424 | 442 | |
425 | 443 | // Make sure the cookie is set to the correct domain and path |
426 | 444 | require_once($sourcedir . '/Subs-Auth.php'); |
427 | - if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
428 | - setLoginCookie((int) $login_span - time(), $id_member); |
|
429 | - } |
|
430 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
445 | + if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
446 | + setLoginCookie((int) $login_span - time(), $id_member); |
|
447 | + } |
|
448 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
431 | 449 | { |
432 | 450 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
433 | 451 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
434 | 452 | |
435 | - if (empty($cookie_data)) |
|
436 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
453 | + if (empty($cookie_data)) { |
|
454 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
455 | + } |
|
437 | 456 | |
438 | 457 | list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, ''); |
439 | 458 | $id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0; |
@@ -458,30 +477,34 @@ discard block |
||
458 | 477 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
459 | 478 | $smcFunc['db_free_result']($request); |
460 | 479 | |
461 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
462 | - $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
480 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
481 | + $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
482 | + } |
|
463 | 483 | |
464 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
465 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
484 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
485 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
486 | + } |
|
466 | 487 | } |
467 | 488 | |
468 | 489 | // Did we find 'im? If not, junk it. |
469 | 490 | if (!empty($user_settings)) |
470 | 491 | { |
471 | 492 | // As much as the password should be right, we can assume the integration set things up. |
472 | - if (!empty($already_verified) && $already_verified === true) |
|
473 | - $check = true; |
|
493 | + if (!empty($already_verified) && $already_verified === true) { |
|
494 | + $check = true; |
|
495 | + } |
|
474 | 496 | // SHA-512 hash should be 128 characters long. |
475 | - elseif (strlen($password) == 128) |
|
476 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
477 | - else |
|
478 | - $check = false; |
|
497 | + elseif (strlen($password) == 128) { |
|
498 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
499 | + } else { |
|
500 | + $check = false; |
|
501 | + } |
|
479 | 502 | |
480 | 503 | // Wrong password or not activated - either way, you're going nowhere. |
481 | 504 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
505 | + } else { |
|
506 | + $id_member = 0; |
|
482 | 507 | } |
483 | - else |
|
484 | - $id_member = 0; |
|
485 | 508 | |
486 | 509 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
487 | 510 | if (!$id_member) |
@@ -510,8 +533,9 @@ discard block |
||
510 | 533 | |
511 | 534 | list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, ''); |
512 | 535 | |
513 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
514 | - $tfasecret = null; |
|
536 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
537 | + $tfasecret = null; |
|
538 | + } |
|
515 | 539 | } |
516 | 540 | |
517 | 541 | // They didn't finish logging in before coming here? Then they're no one to us. |
@@ -533,10 +557,12 @@ discard block |
||
533 | 557 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
534 | 558 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
535 | 559 | { |
536 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
560 | + if ($modSettings['tfa_mode'] == 2) { |
|
561 | + //only do this if we are just forcing SOME membergroups |
|
537 | 562 | { |
538 | 563 | //Build an array of ALL user membergroups. |
539 | 564 | $full_groups = array($user_settings['id_group']); |
565 | + } |
|
540 | 566 | if (!empty($user_settings['additional_groups'])) |
541 | 567 | { |
542 | 568 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -556,15 +582,17 @@ discard block |
||
556 | 582 | ); |
557 | 583 | $row = $smcFunc['db_fetch_assoc']($request); |
558 | 584 | $smcFunc['db_free_result']($request); |
585 | + } else { |
|
586 | + $row['total'] = 1; |
|
559 | 587 | } |
560 | - else |
|
561 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
588 | + //simplifies logics in the next "if" |
|
562 | 589 | |
563 | 590 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
564 | 591 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
565 | 592 | |
566 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
567 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
593 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
594 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
595 | + } |
|
568 | 596 | } |
569 | 597 | } |
570 | 598 | |
@@ -601,29 +629,32 @@ discard block |
||
601 | 629 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
602 | 630 | $user_settings['last_login'] = time(); |
603 | 631 | |
604 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
605 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
632 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
633 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
634 | + } |
|
606 | 635 | |
607 | - if (!empty($modSettings['cache_enable'])) |
|
608 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
636 | + if (!empty($modSettings['cache_enable'])) { |
|
637 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
638 | + } |
|
609 | 639 | } |
640 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
641 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
610 | 642 | } |
611 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
612 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
613 | 643 | |
614 | 644 | $username = $user_settings['member_name']; |
615 | 645 | |
616 | - if (empty($user_settings['additional_groups'])) |
|
617 | - $user_info = array( |
|
646 | + if (empty($user_settings['additional_groups'])) { |
|
647 | + $user_info = array( |
|
618 | 648 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
619 | 649 | ); |
620 | - else |
|
621 | - $user_info = array( |
|
650 | + } else { |
|
651 | + $user_info = array( |
|
622 | 652 | 'groups' => array_merge( |
623 | 653 | array($user_settings['id_group'], $user_settings['id_post_group']), |
624 | 654 | explode(',', $user_settings['additional_groups']) |
625 | 655 | ) |
626 | 656 | ); |
657 | + } |
|
627 | 658 | |
628 | 659 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
629 | 660 | $user_info['groups'] = array_map('intval', $user_info['groups']); |
@@ -640,8 +671,7 @@ discard block |
||
640 | 671 | $time_system = new DateTime('now', $tz_system); |
641 | 672 | $time_user = new DateTime('now', $tz_user); |
642 | 673 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
643 | - } |
|
644 | - else |
|
674 | + } else |
|
645 | 675 | { |
646 | 676 | // !!! Compatibility. |
647 | 677 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -655,8 +685,9 @@ discard block |
||
655 | 685 | $user_info = array('groups' => array(-1)); |
656 | 686 | $user_settings = array(); |
657 | 687 | |
658 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
659 | - $_COOKIE[$cookiename] = ''; |
|
688 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
689 | + $_COOKIE[$cookiename] = ''; |
|
690 | + } |
|
660 | 691 | |
661 | 692 | // Expire the 2FA cookie |
662 | 693 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -673,19 +704,20 @@ discard block |
||
673 | 704 | } |
674 | 705 | |
675 | 706 | // Create a login token if it doesn't exist yet. |
676 | - if (!isset($_SESSION['token']['post-login'])) |
|
677 | - createToken('login'); |
|
678 | - else |
|
679 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
707 | + if (!isset($_SESSION['token']['post-login'])) { |
|
708 | + createToken('login'); |
|
709 | + } else { |
|
710 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
711 | + } |
|
680 | 712 | |
681 | 713 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
682 | 714 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
683 | 715 | { |
684 | 716 | require_once($sourcedir . '/ManageSearchEngines.php'); |
685 | 717 | $user_info['possibly_robot'] = SpiderCheck(); |
718 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
719 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
686 | 720 | } |
687 | - elseif (!empty($modSettings['spider_mode'])) |
|
688 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
689 | 721 | // If we haven't turned on proper spider hunts then have a guess! |
690 | 722 | else |
691 | 723 | { |
@@ -733,8 +765,9 @@ discard block |
||
733 | 765 | $user_info['groups'] = array_unique($user_info['groups']); |
734 | 766 | |
735 | 767 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
736 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
737 | - unset($user_info['ignoreboards'][$tmp]); |
|
768 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
769 | + unset($user_info['ignoreboards'][$tmp]); |
|
770 | + } |
|
738 | 771 | |
739 | 772 | // Allow the user to change their language. |
740 | 773 | if (!empty($modSettings['userLanguage'])) |
@@ -747,13 +780,14 @@ discard block |
||
747 | 780 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
748 | 781 | |
749 | 782 | // Make it permanent for members. |
750 | - if (!empty($user_info['id'])) |
|
751 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
752 | - else |
|
753 | - $_SESSION['language'] = $user_info['language']; |
|
783 | + if (!empty($user_info['id'])) { |
|
784 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
785 | + } else { |
|
786 | + $_SESSION['language'] = $user_info['language']; |
|
787 | + } |
|
788 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
789 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
754 | 790 | } |
755 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
756 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
757 | 791 | } |
758 | 792 | |
759 | 793 | $temp = build_query_board($user_info['id']); |
@@ -816,9 +850,9 @@ discard block |
||
816 | 850 | } |
817 | 851 | |
818 | 852 | // Remember redirection is the key to avoiding fallout from your bosses. |
819 | - if (!empty($topic)) |
|
820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
821 | - else |
|
853 | + if (!empty($topic)) { |
|
854 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
855 | + } else |
|
822 | 856 | { |
823 | 857 | loadPermissions(); |
824 | 858 | loadTheme(); |
@@ -836,10 +870,11 @@ discard block |
||
836 | 870 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
837 | 871 | { |
838 | 872 | // @todo SLOW? |
839 | - if (!empty($topic)) |
|
840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
841 | - else |
|
842 | - $temp = cache_get_data('board-' . $board, 120); |
|
873 | + if (!empty($topic)) { |
|
874 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
875 | + } else { |
|
876 | + $temp = cache_get_data('board-' . $board, 120); |
|
877 | + } |
|
843 | 878 | |
844 | 879 | if (!empty($temp)) |
845 | 880 | { |
@@ -877,8 +912,9 @@ discard block |
||
877 | 912 | $row = $smcFunc['db_fetch_assoc']($request); |
878 | 913 | |
879 | 914 | // Set the current board. |
880 | - if (!empty($row['id_board'])) |
|
881 | - $board = $row['id_board']; |
|
915 | + if (!empty($row['id_board'])) { |
|
916 | + $board = $row['id_board']; |
|
917 | + } |
|
882 | 918 | |
883 | 919 | // Basic operating information. (globals... :/) |
884 | 920 | $board_info = array( |
@@ -914,21 +950,23 @@ discard block |
||
914 | 950 | |
915 | 951 | do |
916 | 952 | { |
917 | - if (!empty($row['id_moderator'])) |
|
918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
953 | + if (!empty($row['id_moderator'])) { |
|
954 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
919 | 955 | 'id' => $row['id_moderator'], |
920 | 956 | 'name' => $row['real_name'], |
921 | 957 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
922 | 958 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
923 | 959 | ); |
960 | + } |
|
924 | 961 | |
925 | - if (!empty($row['id_moderator_group'])) |
|
926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
962 | + if (!empty($row['id_moderator_group'])) { |
|
963 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
927 | 964 | 'id' => $row['id_moderator_group'], |
928 | 965 | 'name' => $row['group_name'], |
929 | 966 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
930 | 967 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
931 | 968 | ); |
969 | + } |
|
932 | 970 | } |
933 | 971 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
934 | 972 | |
@@ -960,12 +998,12 @@ discard block |
||
960 | 998 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
961 | 999 | { |
962 | 1000 | // @todo SLOW? |
963 | - if (!empty($topic)) |
|
964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1001 | + if (!empty($topic)) { |
|
1002 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1003 | + } |
|
965 | 1004 | cache_put_data('board-' . $board, $board_info, 120); |
966 | 1005 | } |
967 | - } |
|
968 | - else |
|
1006 | + } else |
|
969 | 1007 | { |
970 | 1008 | // Otherwise the topic is invalid, there are no moderators, etc. |
971 | 1009 | $board_info = array( |
@@ -979,8 +1017,9 @@ discard block |
||
979 | 1017 | $smcFunc['db_free_result']($request); |
980 | 1018 | } |
981 | 1019 | |
982 | - if (!empty($topic)) |
|
983 | - $_GET['board'] = (int) $board; |
|
1020 | + if (!empty($topic)) { |
|
1021 | + $_GET['board'] = (int) $board; |
|
1022 | + } |
|
984 | 1023 | |
985 | 1024 | if (!empty($board)) |
986 | 1025 | { |
@@ -990,10 +1029,12 @@ discard block |
||
990 | 1029 | // Now check if the user is a moderator. |
991 | 1030 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
992 | 1031 | |
993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
994 | - $board_info['error'] = 'access'; |
|
995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
996 | - $board_info['error'] = 'access'; |
|
1032 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1033 | + $board_info['error'] = 'access'; |
|
1034 | + } |
|
1035 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1036 | + $board_info['error'] = 'access'; |
|
1037 | + } |
|
997 | 1038 | |
998 | 1039 | // Build up the linktree. |
999 | 1040 | $context['linktree'] = array_merge( |
@@ -1016,8 +1057,9 @@ discard block |
||
1016 | 1057 | $context['current_board'] = $board; |
1017 | 1058 | |
1018 | 1059 | // No posting in redirection boards! |
1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1020 | - $board_info['error'] == 'post_in_redirect'; |
|
1060 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1061 | + $board_info['error'] == 'post_in_redirect'; |
|
1062 | + } |
|
1021 | 1063 | |
1022 | 1064 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1023 | 1065 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1085,23 @@ discard block |
||
1043 | 1085 | ob_end_clean(); |
1044 | 1086 | header('HTTP/1.1 403 Forbidden'); |
1045 | 1087 | die; |
1046 | - } |
|
1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1088 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1048 | 1089 | { |
1049 | 1090 | // Slightly different error message here... |
1050 | 1091 | fatal_lang_error('cannot_post_redirect', false); |
1051 | - } |
|
1052 | - elseif ($user_info['is_guest']) |
|
1092 | + } elseif ($user_info['is_guest']) |
|
1053 | 1093 | { |
1054 | 1094 | loadLanguage('Errors'); |
1055 | 1095 | is_not_guest($txt['topic_gone']); |
1096 | + } else { |
|
1097 | + fatal_lang_error('topic_gone', false); |
|
1056 | 1098 | } |
1057 | - else |
|
1058 | - fatal_lang_error('topic_gone', false); |
|
1059 | 1099 | } |
1060 | 1100 | |
1061 | - if ($user_info['is_mod']) |
|
1062 | - $user_info['groups'][] = 3; |
|
1063 | -} |
|
1101 | + if ($user_info['is_mod']) { |
|
1102 | + $user_info['groups'][] = 3; |
|
1103 | + } |
|
1104 | + } |
|
1064 | 1105 | |
1065 | 1106 | /** |
1066 | 1107 | * Load this user's permissions. |
@@ -1081,8 +1122,9 @@ discard block |
||
1081 | 1122 | asort($cache_groups); |
1082 | 1123 | $cache_groups = implode(',', $cache_groups); |
1083 | 1124 | // If it's a spider then cache it different. |
1084 | - if ($user_info['possibly_robot']) |
|
1085 | - $cache_groups .= '-spider'; |
|
1125 | + if ($user_info['possibly_robot']) { |
|
1126 | + $cache_groups .= '-spider'; |
|
1127 | + } |
|
1086 | 1128 | |
1087 | 1129 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1088 | 1130 | { |
@@ -1090,9 +1132,9 @@ discard block |
||
1090 | 1132 | banPermissions(); |
1091 | 1133 | |
1092 | 1134 | return; |
1135 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1136 | + list ($user_info['permissions'], $removals) = $temp; |
|
1093 | 1137 | } |
1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
1096 | 1138 | } |
1097 | 1139 | |
1098 | 1140 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1156,26 @@ discard block |
||
1114 | 1156 | $removals = array(); |
1115 | 1157 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1116 | 1158 | { |
1117 | - if (empty($row['add_deny'])) |
|
1118 | - $removals[] = $row['permission']; |
|
1119 | - else |
|
1120 | - $user_info['permissions'][] = $row['permission']; |
|
1159 | + if (empty($row['add_deny'])) { |
|
1160 | + $removals[] = $row['permission']; |
|
1161 | + } else { |
|
1162 | + $user_info['permissions'][] = $row['permission']; |
|
1163 | + } |
|
1121 | 1164 | } |
1122 | 1165 | $smcFunc['db_free_result']($request); |
1123 | 1166 | |
1124 | - if (isset($cache_groups)) |
|
1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1167 | + if (isset($cache_groups)) { |
|
1168 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1169 | + } |
|
1126 | 1170 | } |
1127 | 1171 | |
1128 | 1172 | // Get the board permissions. |
1129 | 1173 | if (!empty($board)) |
1130 | 1174 | { |
1131 | 1175 | // Make sure the board (if any) has been loaded by loadBoard(). |
1132 | - if (!isset($board_info['profile'])) |
|
1133 | - fatal_lang_error('no_board'); |
|
1176 | + if (!isset($board_info['profile'])) { |
|
1177 | + fatal_lang_error('no_board'); |
|
1178 | + } |
|
1134 | 1179 | |
1135 | 1180 | $request = $smcFunc['db_query']('', ' |
1136 | 1181 | SELECT permission, add_deny |
@@ -1146,20 +1191,23 @@ discard block |
||
1146 | 1191 | ); |
1147 | 1192 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1148 | 1193 | { |
1149 | - if (empty($row['add_deny'])) |
|
1150 | - $removals[] = $row['permission']; |
|
1151 | - else |
|
1152 | - $user_info['permissions'][] = $row['permission']; |
|
1194 | + if (empty($row['add_deny'])) { |
|
1195 | + $removals[] = $row['permission']; |
|
1196 | + } else { |
|
1197 | + $user_info['permissions'][] = $row['permission']; |
|
1198 | + } |
|
1153 | 1199 | } |
1154 | 1200 | $smcFunc['db_free_result']($request); |
1155 | 1201 | } |
1156 | 1202 | |
1157 | 1203 | // Remove all the permissions they shouldn't have ;). |
1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1204 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1205 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1206 | + } |
|
1160 | 1207 | |
1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1208 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1209 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1210 | + } |
|
1163 | 1211 | |
1164 | 1212 | // Banned? Watch, don't touch.. |
1165 | 1213 | banPermissions(); |
@@ -1171,17 +1219,18 @@ discard block |
||
1171 | 1219 | { |
1172 | 1220 | require_once($sourcedir . '/Subs-Auth.php'); |
1173 | 1221 | rebuildModCache(); |
1222 | + } else { |
|
1223 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1174 | 1224 | } |
1175 | - else |
|
1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1177 | 1225 | |
1178 | 1226 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1179 | 1227 | // For example this drastically simplifies certain changes to the profile area. |
1180 | 1228 | $user_info['permissions'][] = 'is_not_guest'; |
1181 | 1229 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1182 | 1230 | $user_info['permissions'][] = 'profile_view_own'; |
1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1231 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1232 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1233 | + } |
|
1185 | 1234 | } |
1186 | 1235 | } |
1187 | 1236 | |
@@ -1199,8 +1248,9 @@ discard block |
||
1199 | 1248 | global $image_proxy_enabled, $user_info; |
1200 | 1249 | |
1201 | 1250 | // Can't just look for no users :P. |
1202 | - if (empty($users)) |
|
1203 | - return array(); |
|
1251 | + if (empty($users)) { |
|
1252 | + return array(); |
|
1253 | + } |
|
1204 | 1254 | |
1205 | 1255 | // Pass the set value |
1206 | 1256 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1265,9 @@ discard block |
||
1215 | 1265 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1216 | 1266 | { |
1217 | 1267 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1218 | - if ($data == null) |
|
1219 | - continue; |
|
1268 | + if ($data == null) { |
|
1269 | + continue; |
|
1270 | + } |
|
1220 | 1271 | |
1221 | 1272 | $loaded_ids[] = $data['id_member']; |
1222 | 1273 | $user_profile[$data['id_member']] = $data; |
@@ -1283,16 +1334,19 @@ discard block |
||
1283 | 1334 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1284 | 1335 | |
1285 | 1336 | // Take care of proxying avatar if required, do this here for maximum reach |
1286 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
1287 | - $row['avatar'] = get_proxied_url($row['avatar']); |
|
1337 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
1338 | + $row['avatar'] = get_proxied_url($row['avatar']); |
|
1339 | + } |
|
1288 | 1340 | |
1289 | 1341 | // Keep track of the member's normal member group |
1290 | 1342 | $row['primary_group'] = !empty($row['member_group']) ? $row['member_group'] : ''; |
1291 | 1343 | |
1292 | - if (isset($row['member_ip'])) |
|
1293 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1294 | - if (isset($row['member_ip2'])) |
|
1295 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1344 | + if (isset($row['member_ip'])) { |
|
1345 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1346 | + } |
|
1347 | + if (isset($row['member_ip2'])) { |
|
1348 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1349 | + } |
|
1296 | 1350 | $new_loaded_ids[] = $row['id_member']; |
1297 | 1351 | $loaded_ids[] = $row['id_member']; |
1298 | 1352 | $row['options'] = array(); |
@@ -1311,8 +1365,9 @@ discard block |
||
1311 | 1365 | 'loaded_ids' => $new_loaded_ids, |
1312 | 1366 | ) |
1313 | 1367 | ); |
1314 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1315 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1368 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1369 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1370 | + } |
|
1316 | 1371 | $smcFunc['db_free_result']($request); |
1317 | 1372 | } |
1318 | 1373 | |
@@ -1323,10 +1378,11 @@ discard block |
||
1323 | 1378 | { |
1324 | 1379 | foreach ($loaded_ids as $a_member) |
1325 | 1380 | { |
1326 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1327 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1328 | - else |
|
1329 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1381 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1382 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1383 | + } else { |
|
1384 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1385 | + } |
|
1330 | 1386 | |
1331 | 1387 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1332 | 1388 | |
@@ -1339,8 +1395,9 @@ discard block |
||
1339 | 1395 | |
1340 | 1396 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1341 | 1397 | { |
1342 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1343 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1398 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1399 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1400 | + } |
|
1344 | 1401 | } |
1345 | 1402 | |
1346 | 1403 | // Are we loading any moderators? If so, fix their group data... |
@@ -1366,14 +1423,17 @@ discard block |
||
1366 | 1423 | foreach ($temp_mods as $id) |
1367 | 1424 | { |
1368 | 1425 | // By popular demand, don't show admins or global moderators as moderators. |
1369 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1370 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1426 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1427 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1428 | + } |
|
1371 | 1429 | |
1372 | 1430 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1373 | - if (!empty($row['icons'])) |
|
1374 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1375 | - if (!empty($row['member_group_color'])) |
|
1376 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1431 | + if (!empty($row['icons'])) { |
|
1432 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1433 | + } |
|
1434 | + if (!empty($row['member_group_color'])) { |
|
1435 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1436 | + } |
|
1377 | 1437 | } |
1378 | 1438 | } |
1379 | 1439 | |
@@ -1395,12 +1455,14 @@ discard block |
||
1395 | 1455 | static $loadedLanguages = array(); |
1396 | 1456 | |
1397 | 1457 | // If this person's data is already loaded, skip it. |
1398 | - if (isset($dataLoaded[$user])) |
|
1399 | - return true; |
|
1458 | + if (isset($dataLoaded[$user])) { |
|
1459 | + return true; |
|
1460 | + } |
|
1400 | 1461 | |
1401 | 1462 | // We can't load guests or members not loaded by loadMemberData()! |
1402 | - if ($user == 0) |
|
1403 | - return false; |
|
1463 | + if ($user == 0) { |
|
1464 | + return false; |
|
1465 | + } |
|
1404 | 1466 | if (!isset($user_profile[$user])) |
1405 | 1467 | { |
1406 | 1468 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1426,12 +1488,16 @@ discard block |
||
1426 | 1488 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1427 | 1489 | |
1428 | 1490 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1429 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1491 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1492 | + //icon is set and exists |
|
1430 | 1493 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1431 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1494 | + } elseif (isset($profile['icons'][1])) { |
|
1495 | + //icon is set and doesn't exist, fallback to default |
|
1432 | 1496 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1433 | - else //not set, bye bye |
|
1497 | + } else { |
|
1498 | + //not set, bye bye |
|
1434 | 1499 | $group_icon_url = ''; |
1500 | + } |
|
1435 | 1501 | |
1436 | 1502 | // These minimal values are always loaded |
1437 | 1503 | $memberContext[$user] = array( |
@@ -1450,8 +1516,9 @@ discard block |
||
1450 | 1516 | if ($context['loadMemberContext_set'] != 'minimal') |
1451 | 1517 | { |
1452 | 1518 | // Go the extra mile and load the user's native language name. |
1453 | - if (empty($loadedLanguages)) |
|
1454 | - $loadedLanguages = getLanguages(); |
|
1519 | + if (empty($loadedLanguages)) { |
|
1520 | + $loadedLanguages = getLanguages(); |
|
1521 | + } |
|
1455 | 1522 | |
1456 | 1523 | $memberContext[$user] += array( |
1457 | 1524 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1506,31 +1573,33 @@ discard block |
||
1506 | 1573 | { |
1507 | 1574 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1508 | 1575 | { |
1509 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1510 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1511 | - else |
|
1512 | - $image = get_gravatar_url($profile['email_address']); |
|
1513 | - } |
|
1514 | - else |
|
1576 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1577 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1578 | + } else { |
|
1579 | + $image = get_gravatar_url($profile['email_address']); |
|
1580 | + } |
|
1581 | + } else |
|
1515 | 1582 | { |
1516 | 1583 | // So it's stored in the member table? |
1517 | 1584 | if (!empty($profile['avatar'])) |
1518 | 1585 | { |
1519 | 1586 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1587 | + } elseif (!empty($profile['filename'])) { |
|
1588 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1520 | 1589 | } |
1521 | - elseif (!empty($profile['filename'])) |
|
1522 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1523 | 1590 | // Right... no avatar...use the default one |
1524 | - else |
|
1525 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1591 | + else { |
|
1592 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1593 | + } |
|
1526 | 1594 | } |
1527 | - if (!empty($image)) |
|
1528 | - $memberContext[$user]['avatar'] = array( |
|
1595 | + if (!empty($image)) { |
|
1596 | + $memberContext[$user]['avatar'] = array( |
|
1529 | 1597 | 'name' => $profile['avatar'], |
1530 | 1598 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1531 | 1599 | 'href' => $image, |
1532 | 1600 | 'url' => $image, |
1533 | 1601 | ); |
1602 | + } |
|
1534 | 1603 | } |
1535 | 1604 | |
1536 | 1605 | // Are we also loading the members custom fields into context? |
@@ -1538,13 +1607,15 @@ discard block |
||
1538 | 1607 | { |
1539 | 1608 | $memberContext[$user]['custom_fields'] = array(); |
1540 | 1609 | |
1541 | - if (!isset($context['display_fields'])) |
|
1542 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1610 | + if (!isset($context['display_fields'])) { |
|
1611 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1612 | + } |
|
1543 | 1613 | |
1544 | 1614 | foreach ($context['display_fields'] as $custom) |
1545 | 1615 | { |
1546 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1547 | - continue; |
|
1616 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1617 | + continue; |
|
1618 | + } |
|
1548 | 1619 | |
1549 | 1620 | $value = $profile['options'][$custom['col_name']]; |
1550 | 1621 | |
@@ -1552,31 +1623,36 @@ discard block |
||
1552 | 1623 | $currentKey = 0; |
1553 | 1624 | |
1554 | 1625 | // Create a key => value array for multiple options fields |
1555 | - if (!empty($custom['options'])) |
|
1556 | - foreach ($custom['options'] as $k => $v) |
|
1626 | + if (!empty($custom['options'])) { |
|
1627 | + foreach ($custom['options'] as $k => $v) |
|
1557 | 1628 | { |
1558 | 1629 | $fieldOptions[] = $v; |
1559 | - if (empty($currentKey)) |
|
1560 | - $currentKey = $v == $value ? $k : 0; |
|
1630 | + } |
|
1631 | + if (empty($currentKey)) { |
|
1632 | + $currentKey = $v == $value ? $k : 0; |
|
1633 | + } |
|
1561 | 1634 | } |
1562 | 1635 | |
1563 | 1636 | // BBC? |
1564 | - if ($custom['bbc']) |
|
1565 | - $value = parse_bbc($value); |
|
1637 | + if ($custom['bbc']) { |
|
1638 | + $value = parse_bbc($value); |
|
1639 | + } |
|
1566 | 1640 | |
1567 | 1641 | // ... or checkbox? |
1568 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1569 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1642 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1643 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1644 | + } |
|
1570 | 1645 | |
1571 | 1646 | // Enclosing the user input within some other text? |
1572 | - if (!empty($custom['enclose'])) |
|
1573 | - $value = strtr($custom['enclose'], array( |
|
1647 | + if (!empty($custom['enclose'])) { |
|
1648 | + $value = strtr($custom['enclose'], array( |
|
1574 | 1649 | '{SCRIPTURL}' => $scripturl, |
1575 | 1650 | '{IMAGES_URL}' => $settings['images_url'], |
1576 | 1651 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1577 | 1652 | '{INPUT}' => $value, |
1578 | 1653 | '{KEY}' => $currentKey, |
1579 | 1654 | )); |
1655 | + } |
|
1580 | 1656 | |
1581 | 1657 | $memberContext[$user]['custom_fields'][] = array( |
1582 | 1658 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1603,8 +1679,9 @@ discard block |
||
1603 | 1679 | global $smcFunc, $txt, $scripturl, $settings; |
1604 | 1680 | |
1605 | 1681 | // Do not waste my time... |
1606 | - if (empty($users) || empty($params)) |
|
1607 | - return false; |
|
1682 | + if (empty($users) || empty($params)) { |
|
1683 | + return false; |
|
1684 | + } |
|
1608 | 1685 | |
1609 | 1686 | // Make sure it's an array. |
1610 | 1687 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1631,41 +1708,48 @@ discard block |
||
1631 | 1708 | $currentKey = 0; |
1632 | 1709 | |
1633 | 1710 | // Create a key => value array for multiple options fields |
1634 | - if (!empty($row['field_options'])) |
|
1635 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1711 | + if (!empty($row['field_options'])) { |
|
1712 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
1636 | 1713 | { |
1637 | 1714 | $fieldOptions[] = $v; |
1638 | - if (empty($currentKey)) |
|
1639 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
1715 | + } |
|
1716 | + if (empty($currentKey)) { |
|
1717 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
1718 | + } |
|
1640 | 1719 | } |
1641 | 1720 | |
1642 | 1721 | // BBC? |
1643 | - if (!empty($row['bbc'])) |
|
1644 | - $row['value'] = parse_bbc($row['value']); |
|
1722 | + if (!empty($row['bbc'])) { |
|
1723 | + $row['value'] = parse_bbc($row['value']); |
|
1724 | + } |
|
1645 | 1725 | |
1646 | 1726 | // ... or checkbox? |
1647 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1648 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1727 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1728 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1729 | + } |
|
1649 | 1730 | |
1650 | 1731 | // Enclosing the user input within some other text? |
1651 | - if (!empty($row['enclose'])) |
|
1652 | - $row['value'] = strtr($row['enclose'], array( |
|
1732 | + if (!empty($row['enclose'])) { |
|
1733 | + $row['value'] = strtr($row['enclose'], array( |
|
1653 | 1734 | '{SCRIPTURL}' => $scripturl, |
1654 | 1735 | '{IMAGES_URL}' => $settings['images_url'], |
1655 | 1736 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1656 | 1737 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1657 | 1738 | '{KEY}' => $currentKey, |
1658 | 1739 | )); |
1740 | + } |
|
1659 | 1741 | |
1660 | 1742 | // Send a simple array if there is just 1 param |
1661 | - if (count($params) == 1) |
|
1662 | - $return[$row['id_member']] = $row; |
|
1743 | + if (count($params) == 1) { |
|
1744 | + $return[$row['id_member']] = $row; |
|
1745 | + } |
|
1663 | 1746 | |
1664 | 1747 | // More than 1? knock yourself out... |
1665 | 1748 | else |
1666 | 1749 | { |
1667 | - if (!isset($return[$row['id_member']])) |
|
1668 | - $return[$row['id_member']] = array(); |
|
1750 | + if (!isset($return[$row['id_member']])) { |
|
1751 | + $return[$row['id_member']] = array(); |
|
1752 | + } |
|
1669 | 1753 | |
1670 | 1754 | $return[$row['id_member']][$row['variable']] = $row; |
1671 | 1755 | } |
@@ -1699,8 +1783,9 @@ discard block |
||
1699 | 1783 | global $context; |
1700 | 1784 | |
1701 | 1785 | // Don't know any browser! |
1702 | - if (empty($context['browser'])) |
|
1703 | - detectBrowser(); |
|
1786 | + if (empty($context['browser'])) { |
|
1787 | + detectBrowser(); |
|
1788 | + } |
|
1704 | 1789 | |
1705 | 1790 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1706 | 1791 | } |
@@ -1718,8 +1803,9 @@ discard block |
||
1718 | 1803 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1719 | 1804 | |
1720 | 1805 | // The theme was specified by parameter. |
1721 | - if (!empty($id_theme)) |
|
1722 | - $id_theme = (int) $id_theme; |
|
1806 | + if (!empty($id_theme)) { |
|
1807 | + $id_theme = (int) $id_theme; |
|
1808 | + } |
|
1723 | 1809 | // The theme was specified by REQUEST. |
1724 | 1810 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1725 | 1811 | { |
@@ -1727,32 +1813,38 @@ discard block |
||
1727 | 1813 | $_SESSION['id_theme'] = $id_theme; |
1728 | 1814 | } |
1729 | 1815 | // The theme was specified by REQUEST... previously. |
1730 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1731 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1816 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1817 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1818 | + } |
|
1732 | 1819 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1733 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1734 | - $id_theme = $user_info['theme']; |
|
1820 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1821 | + $id_theme = $user_info['theme']; |
|
1822 | + } |
|
1735 | 1823 | // The theme was specified by the board. |
1736 | - elseif (!empty($board_info['theme'])) |
|
1737 | - $id_theme = $board_info['theme']; |
|
1824 | + elseif (!empty($board_info['theme'])) { |
|
1825 | + $id_theme = $board_info['theme']; |
|
1826 | + } |
|
1738 | 1827 | // The theme is the forum's default. |
1739 | - else |
|
1740 | - $id_theme = $modSettings['theme_guests']; |
|
1828 | + else { |
|
1829 | + $id_theme = $modSettings['theme_guests']; |
|
1830 | + } |
|
1741 | 1831 | |
1742 | 1832 | // Verify the id_theme... no foul play. |
1743 | 1833 | // Always allow the board specific theme, if they are overriding. |
1744 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1745 | - $id_theme = $board_info['theme']; |
|
1834 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1835 | + $id_theme = $board_info['theme']; |
|
1836 | + } |
|
1746 | 1837 | // If they have specified a particular theme to use with SSI allow it to be used. |
1747 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1748 | - $id_theme = (int) $id_theme; |
|
1749 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1838 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1839 | + $id_theme = (int) $id_theme; |
|
1840 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1750 | 1841 | { |
1751 | 1842 | $themes = explode(',', $modSettings['enableThemes']); |
1752 | - if (!in_array($id_theme, $themes)) |
|
1753 | - $id_theme = $modSettings['theme_guests']; |
|
1754 | - else |
|
1755 | - $id_theme = (int) $id_theme; |
|
1843 | + if (!in_array($id_theme, $themes)) { |
|
1844 | + $id_theme = $modSettings['theme_guests']; |
|
1845 | + } else { |
|
1846 | + $id_theme = (int) $id_theme; |
|
1847 | + } |
|
1756 | 1848 | } |
1757 | 1849 | |
1758 | 1850 | // We already load the basic stuff? |
@@ -1761,18 +1853,19 @@ discard block |
||
1761 | 1853 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1762 | 1854 | |
1763 | 1855 | // Disable image proxy if we don't have SSL enabled |
1764 | - if (empty($modSettings['force_ssl'])) |
|
1765 | - $image_proxy_enabled = false; |
|
1856 | + if (empty($modSettings['force_ssl'])) { |
|
1857 | + $image_proxy_enabled = false; |
|
1858 | + } |
|
1766 | 1859 | |
1767 | 1860 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1768 | 1861 | { |
1769 | 1862 | $themeData = $temp; |
1770 | 1863 | $flag = true; |
1864 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1865 | + $themeData = $temp + array($member => array()); |
|
1866 | + } else { |
|
1867 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1771 | 1868 | } |
1772 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1773 | - $themeData = $temp + array($member => array()); |
|
1774 | - else |
|
1775 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1776 | 1869 | |
1777 | 1870 | if (empty($flag)) |
1778 | 1871 | { |
@@ -1792,31 +1885,37 @@ discard block |
||
1792 | 1885 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1793 | 1886 | { |
1794 | 1887 | // There are just things we shouldn't be able to change as members. |
1795 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1796 | - continue; |
|
1888 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1889 | + continue; |
|
1890 | + } |
|
1797 | 1891 | |
1798 | 1892 | // If this is the theme_dir of the default theme, store it. |
1799 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1800 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1893 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1894 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1895 | + } |
|
1801 | 1896 | |
1802 | 1897 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1803 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1804 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1898 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1899 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1900 | + } |
|
1805 | 1901 | } |
1806 | 1902 | $smcFunc['db_free_result']($result); |
1807 | 1903 | |
1808 | - if (!empty($themeData[-1])) |
|
1809 | - foreach ($themeData[-1] as $k => $v) |
|
1904 | + if (!empty($themeData[-1])) { |
|
1905 | + foreach ($themeData[-1] as $k => $v) |
|
1810 | 1906 | { |
1811 | 1907 | if (!isset($themeData[$member][$k])) |
1812 | 1908 | $themeData[$member][$k] = $v; |
1909 | + } |
|
1813 | 1910 | } |
1814 | 1911 | |
1815 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1816 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1912 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1913 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1914 | + } |
|
1817 | 1915 | // Only if we didn't already load that part of the cache... |
1818 | - elseif (!isset($temp)) |
|
1819 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1916 | + elseif (!isset($temp)) { |
|
1917 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1918 | + } |
|
1820 | 1919 | } |
1821 | 1920 | |
1822 | 1921 | $settings = $themeData[0]; |
@@ -1833,17 +1932,20 @@ discard block |
||
1833 | 1932 | $settings['template_dirs'][] = $settings['theme_dir']; |
1834 | 1933 | |
1835 | 1934 | // Based on theme (if there is one). |
1836 | - if (!empty($settings['base_theme_dir'])) |
|
1837 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1935 | + if (!empty($settings['base_theme_dir'])) { |
|
1936 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1937 | + } |
|
1838 | 1938 | |
1839 | 1939 | // Lastly the default theme. |
1840 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1841 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1940 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1941 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1942 | + } |
|
1842 | 1943 | } |
1843 | 1944 | |
1844 | 1945 | |
1845 | - if (!$initialize) |
|
1846 | - return; |
|
1946 | + if (!$initialize) { |
|
1947 | + return; |
|
1948 | + } |
|
1847 | 1949 | |
1848 | 1950 | // Check to see if we're forcing SSL |
1849 | 1951 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && |
@@ -1864,8 +1966,9 @@ discard block |
||
1864 | 1966 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
1865 | 1967 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1866 | 1968 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1867 | - if ($temp != '/') |
|
1868 | - $detected_url .= $temp; |
|
1969 | + if ($temp != '/') { |
|
1970 | + $detected_url .= $temp; |
|
1971 | + } |
|
1869 | 1972 | } |
1870 | 1973 | if (isset($detected_url) && $detected_url != $boardurl) |
1871 | 1974 | { |
@@ -1877,8 +1980,9 @@ discard block |
||
1877 | 1980 | foreach ($aliases as $alias) |
1878 | 1981 | { |
1879 | 1982 | // Rip off all the boring parts, spaces, etc. |
1880 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1881 | - $do_fix = true; |
|
1983 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1984 | + $do_fix = true; |
|
1985 | + } |
|
1882 | 1986 | } |
1883 | 1987 | } |
1884 | 1988 | |
@@ -1886,21 +1990,23 @@ discard block |
||
1886 | 1990 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1887 | 1991 | { |
1888 | 1992 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1889 | - if (empty($_GET)) |
|
1890 | - redirectexit('wwwRedirect'); |
|
1891 | - else |
|
1993 | + if (empty($_GET)) { |
|
1994 | + redirectexit('wwwRedirect'); |
|
1995 | + } else |
|
1892 | 1996 | { |
1893 | 1997 | $k = key($_GET); |
1894 | 1998 | $v = current($_GET); |
1895 | 1999 | |
1896 | - if ($k != 'wwwRedirect') |
|
1897 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
2000 | + if ($k != 'wwwRedirect') { |
|
2001 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
2002 | + } |
|
1898 | 2003 | } |
1899 | 2004 | } |
1900 | 2005 | |
1901 | 2006 | // #3 is just a check for SSL... |
1902 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1903 | - $do_fix = true; |
|
2007 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
2008 | + $do_fix = true; |
|
2009 | + } |
|
1904 | 2010 | |
1905 | 2011 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1906 | 2012 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1935,8 +2041,9 @@ discard block |
||
1935 | 2041 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1936 | 2042 | } |
1937 | 2043 | } |
1938 | - foreach ($context['linktree'] as $k => $dummy) |
|
1939 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2044 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2045 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2046 | + } |
|
1940 | 2047 | } |
1941 | 2048 | } |
1942 | 2049 | // Set up the contextual user array. |
@@ -1955,16 +2062,16 @@ discard block |
||
1955 | 2062 | 'email' => $user_info['email'], |
1956 | 2063 | 'ignoreusers' => $user_info['ignoreusers'], |
1957 | 2064 | ); |
1958 | - if (!$context['user']['is_guest']) |
|
1959 | - $context['user']['name'] = $user_info['name']; |
|
1960 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1961 | - $context['user']['name'] = $txt['guest_title']; |
|
2065 | + if (!$context['user']['is_guest']) { |
|
2066 | + $context['user']['name'] = $user_info['name']; |
|
2067 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2068 | + $context['user']['name'] = $txt['guest_title']; |
|
2069 | + } |
|
1962 | 2070 | |
1963 | 2071 | // Determine the current smiley set. |
1964 | 2072 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1965 | 2073 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1966 | - } |
|
1967 | - else |
|
2074 | + } else |
|
1968 | 2075 | { |
1969 | 2076 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1970 | 2077 | $context['user'] = array( |
@@ -1998,18 +2105,24 @@ discard block |
||
1998 | 2105 | } |
1999 | 2106 | |
2000 | 2107 | // Some basic information... |
2001 | - if (!isset($context['html_headers'])) |
|
2002 | - $context['html_headers'] = ''; |
|
2003 | - if (!isset($context['javascript_files'])) |
|
2004 | - $context['javascript_files'] = array(); |
|
2005 | - if (!isset($context['css_files'])) |
|
2006 | - $context['css_files'] = array(); |
|
2007 | - if (!isset($context['css_header'])) |
|
2008 | - $context['css_header'] = array(); |
|
2009 | - if (!isset($context['javascript_inline'])) |
|
2010 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2011 | - if (!isset($context['javascript_vars'])) |
|
2012 | - $context['javascript_vars'] = array(); |
|
2108 | + if (!isset($context['html_headers'])) { |
|
2109 | + $context['html_headers'] = ''; |
|
2110 | + } |
|
2111 | + if (!isset($context['javascript_files'])) { |
|
2112 | + $context['javascript_files'] = array(); |
|
2113 | + } |
|
2114 | + if (!isset($context['css_files'])) { |
|
2115 | + $context['css_files'] = array(); |
|
2116 | + } |
|
2117 | + if (!isset($context['css_header'])) { |
|
2118 | + $context['css_header'] = array(); |
|
2119 | + } |
|
2120 | + if (!isset($context['javascript_inline'])) { |
|
2121 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2122 | + } |
|
2123 | + if (!isset($context['javascript_vars'])) { |
|
2124 | + $context['javascript_vars'] = array(); |
|
2125 | + } |
|
2013 | 2126 | |
2014 | 2127 | $context['login_url'] = $scripturl . '?action=login2'; |
2015 | 2128 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2021,16 +2134,18 @@ discard block |
||
2021 | 2134 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
2022 | 2135 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
2023 | 2136 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
2024 | - if (isset($modSettings['load_average'])) |
|
2025 | - $context['load_average'] = $modSettings['load_average']; |
|
2137 | + if (isset($modSettings['load_average'])) { |
|
2138 | + $context['load_average'] = $modSettings['load_average']; |
|
2139 | + } |
|
2026 | 2140 | |
2027 | 2141 | // Detect the browser. This is separated out because it's also used in attachment downloads |
2028 | 2142 | detectBrowser(); |
2029 | 2143 | |
2030 | 2144 | // Set the top level linktree up. |
2031 | 2145 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2032 | - if (empty($context['linktree'])) |
|
2033 | - $context['linktree'] = array(); |
|
2146 | + if (empty($context['linktree'])) { |
|
2147 | + $context['linktree'] = array(); |
|
2148 | + } |
|
2034 | 2149 | array_unshift($context['linktree'], array( |
2035 | 2150 | 'url' => $scripturl, |
2036 | 2151 | 'name' => $context['forum_name_html_safe'] |
@@ -2039,8 +2154,9 @@ discard block |
||
2039 | 2154 | // This allows sticking some HTML on the page output - useful for controls. |
2040 | 2155 | $context['insert_after_template'] = ''; |
2041 | 2156 | |
2042 | - if (!isset($txt)) |
|
2043 | - $txt = array(); |
|
2157 | + if (!isset($txt)) { |
|
2158 | + $txt = array(); |
|
2159 | + } |
|
2044 | 2160 | |
2045 | 2161 | $simpleActions = array( |
2046 | 2162 | 'findmember', |
@@ -2086,9 +2202,10 @@ discard block |
||
2086 | 2202 | |
2087 | 2203 | // See if theres any extra param to check. |
2088 | 2204 | $requiresXML = false; |
2089 | - foreach ($extraParams as $key => $extra) |
|
2090 | - if (isset($_REQUEST[$extra])) |
|
2205 | + foreach ($extraParams as $key => $extra) { |
|
2206 | + if (isset($_REQUEST[$extra])) |
|
2091 | 2207 | $requiresXML = true; |
2208 | + } |
|
2092 | 2209 | |
2093 | 2210 | // Output is fully XML, so no need for the index template. |
2094 | 2211 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2103,37 +2220,39 @@ discard block |
||
2103 | 2220 | { |
2104 | 2221 | loadLanguage('index+Modifications'); |
2105 | 2222 | $context['template_layers'] = array(); |
2106 | - } |
|
2107 | - |
|
2108 | - else |
|
2223 | + } else |
|
2109 | 2224 | { |
2110 | 2225 | // Custom templates to load, or just default? |
2111 | - if (isset($settings['theme_templates'])) |
|
2112 | - $templates = explode(',', $settings['theme_templates']); |
|
2113 | - else |
|
2114 | - $templates = array('index'); |
|
2226 | + if (isset($settings['theme_templates'])) { |
|
2227 | + $templates = explode(',', $settings['theme_templates']); |
|
2228 | + } else { |
|
2229 | + $templates = array('index'); |
|
2230 | + } |
|
2115 | 2231 | |
2116 | 2232 | // Load each template... |
2117 | - foreach ($templates as $template) |
|
2118 | - loadTemplate($template); |
|
2233 | + foreach ($templates as $template) { |
|
2234 | + loadTemplate($template); |
|
2235 | + } |
|
2119 | 2236 | |
2120 | 2237 | // ...and attempt to load their associated language files. |
2121 | 2238 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2122 | 2239 | loadLanguage($required_files, '', false); |
2123 | 2240 | |
2124 | 2241 | // Custom template layers? |
2125 | - if (isset($settings['theme_layers'])) |
|
2126 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2127 | - else |
|
2128 | - $context['template_layers'] = array('html', 'body'); |
|
2242 | + if (isset($settings['theme_layers'])) { |
|
2243 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2244 | + } else { |
|
2245 | + $context['template_layers'] = array('html', 'body'); |
|
2246 | + } |
|
2129 | 2247 | } |
2130 | 2248 | |
2131 | 2249 | // Initialize the theme. |
2132 | 2250 | loadSubTemplate('init', 'ignore'); |
2133 | 2251 | |
2134 | 2252 | // Allow overriding the board wide time/number formats. |
2135 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2136 | - $user_info['time_format'] = $txt['time_format']; |
|
2253 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2254 | + $user_info['time_format'] = $txt['time_format']; |
|
2255 | + } |
|
2137 | 2256 | |
2138 | 2257 | // Set the character set from the template. |
2139 | 2258 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2141,12 +2260,14 @@ discard block |
||
2141 | 2260 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2142 | 2261 | |
2143 | 2262 | // Guests may still need a name. |
2144 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2145 | - $context['user']['name'] = $txt['guest_title']; |
|
2263 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2264 | + $context['user']['name'] = $txt['guest_title']; |
|
2265 | + } |
|
2146 | 2266 | |
2147 | 2267 | // Any theme-related strings that need to be loaded? |
2148 | - if (!empty($settings['require_theme_strings'])) |
|
2149 | - loadLanguage('ThemeStrings', '', false); |
|
2268 | + if (!empty($settings['require_theme_strings'])) { |
|
2269 | + loadLanguage('ThemeStrings', '', false); |
|
2270 | + } |
|
2150 | 2271 | |
2151 | 2272 | // Make a special URL for the language. |
2152 | 2273 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2157,8 +2278,9 @@ discard block |
||
2157 | 2278 | // Here is my luvly Responsive CSS |
2158 | 2279 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive'); |
2159 | 2280 | |
2160 | - if ($context['right_to_left']) |
|
2161 | - loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
2281 | + if ($context['right_to_left']) { |
|
2282 | + loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
2283 | + } |
|
2162 | 2284 | |
2163 | 2285 | // We allow theme variants, because we're cool. |
2164 | 2286 | $context['theme_variant'] = ''; |
@@ -2166,14 +2288,17 @@ discard block |
||
2166 | 2288 | if (!empty($settings['theme_variants'])) |
2167 | 2289 | { |
2168 | 2290 | // Overriding - for previews and that ilk. |
2169 | - if (!empty($_REQUEST['variant'])) |
|
2170 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2291 | + if (!empty($_REQUEST['variant'])) { |
|
2292 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2293 | + } |
|
2171 | 2294 | // User selection? |
2172 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2173 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2295 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2296 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2297 | + } |
|
2174 | 2298 | // If not a user variant, select the default. |
2175 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2176 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2299 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2300 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2301 | + } |
|
2177 | 2302 | |
2178 | 2303 | // Do this to keep things easier in the templates. |
2179 | 2304 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2182,20 +2307,23 @@ discard block |
||
2182 | 2307 | if (!empty($context['theme_variant'])) |
2183 | 2308 | { |
2184 | 2309 | loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']); |
2185 | - if ($context['right_to_left']) |
|
2186 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
2310 | + if ($context['right_to_left']) { |
|
2311 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
2312 | + } |
|
2187 | 2313 | } |
2188 | 2314 | } |
2189 | 2315 | |
2190 | 2316 | // Let's be compatible with old themes! |
2191 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2192 | - $context['template_layers'] = array('main'); |
|
2317 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2318 | + $context['template_layers'] = array('main'); |
|
2319 | + } |
|
2193 | 2320 | |
2194 | 2321 | $context['tabindex'] = 1; |
2195 | 2322 | |
2196 | 2323 | // Compatibility. |
2197 | - if (!isset($settings['theme_version'])) |
|
2198 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2324 | + if (!isset($settings['theme_version'])) { |
|
2325 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2326 | + } |
|
2199 | 2327 | |
2200 | 2328 | // Default JS variables for use in every theme |
2201 | 2329 | $context['javascript_vars'] = array( |
@@ -2215,18 +2343,18 @@ discard block |
||
2215 | 2343 | ); |
2216 | 2344 | |
2217 | 2345 | // Add the JQuery library to the list of files to load. |
2218 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2219 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2220 | - |
|
2221 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2222 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2223 | - |
|
2224 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2225 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2346 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2347 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2348 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2349 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2350 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2351 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2352 | + } |
|
2226 | 2353 | |
2227 | 2354 | // Auto loading? template_javascript() will take care of the local half of this. |
2228 | - else |
|
2229 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2355 | + else { |
|
2356 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2357 | + } |
|
2230 | 2358 | |
2231 | 2359 | // Queue our JQuery plugins! |
2232 | 2360 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2249,12 +2377,12 @@ discard block |
||
2249 | 2377 | require_once($sourcedir . '/ScheduledTasks.php'); |
2250 | 2378 | |
2251 | 2379 | // What to do, what to do?! |
2252 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2253 | - AutoTask(); |
|
2254 | - else |
|
2255 | - ReduceMailQueue(); |
|
2256 | - } |
|
2257 | - else |
|
2380 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2381 | + AutoTask(); |
|
2382 | + } else { |
|
2383 | + ReduceMailQueue(); |
|
2384 | + } |
|
2385 | + } else |
|
2258 | 2386 | { |
2259 | 2387 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2260 | 2388 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2305,8 +2433,9 @@ discard block |
||
2305 | 2433 | foreach ($theme_includes as $include) |
2306 | 2434 | { |
2307 | 2435 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2308 | - if (file_exists($include)) |
|
2309 | - require_once($include); |
|
2436 | + if (file_exists($include)) { |
|
2437 | + require_once($include); |
|
2438 | + } |
|
2310 | 2439 | } |
2311 | 2440 | } |
2312 | 2441 | |
@@ -2336,16 +2465,19 @@ discard block |
||
2336 | 2465 | // Do any style sheets first, cause we're easy with those. |
2337 | 2466 | if (!empty($style_sheets)) |
2338 | 2467 | { |
2339 | - if (!is_array($style_sheets)) |
|
2340 | - $style_sheets = array($style_sheets); |
|
2468 | + if (!is_array($style_sheets)) { |
|
2469 | + $style_sheets = array($style_sheets); |
|
2470 | + } |
|
2341 | 2471 | |
2342 | - foreach ($style_sheets as $sheet) |
|
2343 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2472 | + foreach ($style_sheets as $sheet) { |
|
2473 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2474 | + } |
|
2344 | 2475 | } |
2345 | 2476 | |
2346 | 2477 | // No template to load? |
2347 | - if ($template_name === false) |
|
2348 | - return true; |
|
2478 | + if ($template_name === false) { |
|
2479 | + return true; |
|
2480 | + } |
|
2349 | 2481 | |
2350 | 2482 | $loaded = false; |
2351 | 2483 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2360,12 +2492,14 @@ discard block |
||
2360 | 2492 | |
2361 | 2493 | if ($loaded) |
2362 | 2494 | { |
2363 | - if ($db_show_debug === true) |
|
2364 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2495 | + if ($db_show_debug === true) { |
|
2496 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2497 | + } |
|
2365 | 2498 | |
2366 | 2499 | // If they have specified an initialization function for this template, go ahead and call it now. |
2367 | - if (function_exists('template_' . $template_name . '_init')) |
|
2368 | - call_user_func('template_' . $template_name . '_init'); |
|
2500 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2501 | + call_user_func('template_' . $template_name . '_init'); |
|
2502 | + } |
|
2369 | 2503 | } |
2370 | 2504 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2371 | 2505 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2385,13 +2519,14 @@ discard block |
||
2385 | 2519 | loadTemplate($template_name); |
2386 | 2520 | } |
2387 | 2521 | // Cause an error otherwise. |
2388 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2389 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2390 | - elseif ($fatal) |
|
2391 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2392 | - else |
|
2393 | - return false; |
|
2394 | -} |
|
2522 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2523 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2524 | + } elseif ($fatal) { |
|
2525 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2526 | + } else { |
|
2527 | + return false; |
|
2528 | + } |
|
2529 | + } |
|
2395 | 2530 | |
2396 | 2531 | /** |
2397 | 2532 | * Load a sub-template. |
@@ -2409,17 +2544,19 @@ discard block |
||
2409 | 2544 | { |
2410 | 2545 | global $context, $txt, $db_show_debug; |
2411 | 2546 | |
2412 | - if ($db_show_debug === true) |
|
2413 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2547 | + if ($db_show_debug === true) { |
|
2548 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2549 | + } |
|
2414 | 2550 | |
2415 | 2551 | // Figure out what the template function is named. |
2416 | 2552 | $theme_function = 'template_' . $sub_template_name; |
2417 | - if (function_exists($theme_function)) |
|
2418 | - $theme_function(); |
|
2419 | - elseif ($fatal === false) |
|
2420 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2421 | - elseif ($fatal !== 'ignore') |
|
2422 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2553 | + if (function_exists($theme_function)) { |
|
2554 | + $theme_function(); |
|
2555 | + } elseif ($fatal === false) { |
|
2556 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2557 | + } elseif ($fatal !== 'ignore') { |
|
2558 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2559 | + } |
|
2423 | 2560 | |
2424 | 2561 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2425 | 2562 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2449,8 +2586,9 @@ discard block |
||
2449 | 2586 | { |
2450 | 2587 | global $settings, $context, $modSettings; |
2451 | 2588 | |
2452 | - if (empty($context['css_files_order'])) |
|
2453 | - $context['css_files_order'] = array(); |
|
2589 | + if (empty($context['css_files_order'])) { |
|
2590 | + $context['css_files_order'] = array(); |
|
2591 | + } |
|
2454 | 2592 | |
2455 | 2593 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : ''); |
2456 | 2594 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
@@ -2461,8 +2599,9 @@ discard block |
||
2461 | 2599 | $params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000; |
2462 | 2600 | |
2463 | 2601 | // If this is an external file, automatically set this to false. |
2464 | - if (!empty($params['external'])) |
|
2465 | - $params['minimize'] = false; |
|
2602 | + if (!empty($params['external'])) { |
|
2603 | + $params['minimize'] = false; |
|
2604 | + } |
|
2466 | 2605 | |
2467 | 2606 | // Account for shorthand like admin.css?alp21 filenames |
2468 | 2607 | $has_seed = strpos($fileName, '.css?'); |
@@ -2479,16 +2618,12 @@ discard block |
||
2479 | 2618 | { |
2480 | 2619 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2481 | 2620 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2482 | - } |
|
2483 | - |
|
2484 | - else |
|
2621 | + } else |
|
2485 | 2622 | { |
2486 | 2623 | $fileUrl = false; |
2487 | 2624 | $filePath = false; |
2488 | 2625 | } |
2489 | - } |
|
2490 | - |
|
2491 | - else |
|
2626 | + } else |
|
2492 | 2627 | { |
2493 | 2628 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2494 | 2629 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2506,16 +2641,18 @@ discard block |
||
2506 | 2641 | if (!empty($fileName)) |
2507 | 2642 | { |
2508 | 2643 | // find a free number/position |
2509 | - while (isset($context['css_files_order'][$params['order_pos']])) |
|
2510 | - $params['order_pos']++; |
|
2644 | + while (isset($context['css_files_order'][$params['order_pos']])) { |
|
2645 | + $params['order_pos']++; |
|
2646 | + } |
|
2511 | 2647 | $context['css_files_order'][$params['order_pos']] = $id; |
2512 | 2648 | |
2513 | 2649 | $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
2514 | 2650 | } |
2515 | 2651 | |
2516 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2517 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2518 | -} |
|
2652 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2653 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2654 | + } |
|
2655 | + } |
|
2519 | 2656 | |
2520 | 2657 | /** |
2521 | 2658 | * Add a block of inline css code to be executed later |
@@ -2532,8 +2669,9 @@ discard block |
||
2532 | 2669 | global $context; |
2533 | 2670 | |
2534 | 2671 | // Gotta add something... |
2535 | - if (empty($css)) |
|
2536 | - return false; |
|
2672 | + if (empty($css)) { |
|
2673 | + return false; |
|
2674 | + } |
|
2537 | 2675 | |
2538 | 2676 | $context['css_header'][] = $css; |
2539 | 2677 | } |
@@ -2569,8 +2707,9 @@ discard block |
||
2569 | 2707 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2570 | 2708 | |
2571 | 2709 | // If this is an external file, automatically set this to false. |
2572 | - if (!empty($params['external'])) |
|
2573 | - $params['minimize'] = false; |
|
2710 | + if (!empty($params['external'])) { |
|
2711 | + $params['minimize'] = false; |
|
2712 | + } |
|
2574 | 2713 | |
2575 | 2714 | // Account for shorthand like admin.js?alp21 filenames |
2576 | 2715 | $has_seed = strpos($fileName, '.js?'); |
@@ -2587,16 +2726,12 @@ discard block |
||
2587 | 2726 | { |
2588 | 2727 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2589 | 2728 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2590 | - } |
|
2591 | - |
|
2592 | - else |
|
2729 | + } else |
|
2593 | 2730 | { |
2594 | 2731 | $fileUrl = false; |
2595 | 2732 | $filePath = false; |
2596 | 2733 | } |
2597 | - } |
|
2598 | - |
|
2599 | - else |
|
2734 | + } else |
|
2600 | 2735 | { |
2601 | 2736 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2602 | 2737 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2611,9 +2746,10 @@ discard block |
||
2611 | 2746 | } |
2612 | 2747 | |
2613 | 2748 | // Add it to the array for use in the template |
2614 | - if (!empty($fileName)) |
|
2615 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2616 | -} |
|
2749 | + if (!empty($fileName)) { |
|
2750 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2751 | + } |
|
2752 | + } |
|
2617 | 2753 | |
2618 | 2754 | /** |
2619 | 2755 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2627,9 +2763,10 @@ discard block |
||
2627 | 2763 | { |
2628 | 2764 | global $context; |
2629 | 2765 | |
2630 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2631 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2632 | -} |
|
2766 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2767 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2768 | + } |
|
2769 | + } |
|
2633 | 2770 | |
2634 | 2771 | /** |
2635 | 2772 | * Add a block of inline Javascript code to be executed later |
@@ -2646,8 +2783,9 @@ discard block |
||
2646 | 2783 | { |
2647 | 2784 | global $context; |
2648 | 2785 | |
2649 | - if (empty($javascript)) |
|
2650 | - return false; |
|
2786 | + if (empty($javascript)) { |
|
2787 | + return false; |
|
2788 | + } |
|
2651 | 2789 | |
2652 | 2790 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2653 | 2791 | } |
@@ -2668,15 +2806,18 @@ discard block |
||
2668 | 2806 | static $already_loaded = array(); |
2669 | 2807 | |
2670 | 2808 | // Default to the user's language. |
2671 | - if ($lang == '') |
|
2672 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2809 | + if ($lang == '') { |
|
2810 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2811 | + } |
|
2673 | 2812 | |
2674 | 2813 | // Do we want the English version of language file as fallback? |
2675 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2676 | - loadLanguage($template_name, 'english', false); |
|
2814 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2815 | + loadLanguage($template_name, 'english', false); |
|
2816 | + } |
|
2677 | 2817 | |
2678 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2679 | - return $lang; |
|
2818 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2819 | + return $lang; |
|
2820 | + } |
|
2680 | 2821 | |
2681 | 2822 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2682 | 2823 | if (empty($settings['default_theme_dir'])) |
@@ -2687,8 +2828,9 @@ discard block |
||
2687 | 2828 | |
2688 | 2829 | // What theme are we in? |
2689 | 2830 | $theme_name = basename($settings['theme_url']); |
2690 | - if (empty($theme_name)) |
|
2691 | - $theme_name = 'unknown'; |
|
2831 | + if (empty($theme_name)) { |
|
2832 | + $theme_name = 'unknown'; |
|
2833 | + } |
|
2692 | 2834 | |
2693 | 2835 | // For each file open it up and write it out! |
2694 | 2836 | foreach (explode('+', $template_name) as $template) |
@@ -2730,8 +2872,9 @@ discard block |
||
2730 | 2872 | $found = true; |
2731 | 2873 | |
2732 | 2874 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2733 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2734 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2875 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2876 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2877 | + } |
|
2735 | 2878 | |
2736 | 2879 | break; |
2737 | 2880 | } |
@@ -2771,8 +2914,9 @@ discard block |
||
2771 | 2914 | } |
2772 | 2915 | |
2773 | 2916 | // Keep track of what we're up to soldier. |
2774 | - if ($db_show_debug === true) |
|
2775 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2917 | + if ($db_show_debug === true) { |
|
2918 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2919 | + } |
|
2776 | 2920 | |
2777 | 2921 | // Remember what we have loaded, and in which language. |
2778 | 2922 | $already_loaded[$template_name] = $lang; |
@@ -2818,8 +2962,9 @@ discard block |
||
2818 | 2962 | ) |
2819 | 2963 | ); |
2820 | 2964 | // In the EXTREMELY unlikely event this happens, give an error message. |
2821 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2822 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2965 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2966 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2967 | + } |
|
2823 | 2968 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2824 | 2969 | { |
2825 | 2970 | if (!isset($boards[$row['id_board']])) |
@@ -2836,8 +2981,8 @@ discard block |
||
2836 | 2981 | ); |
2837 | 2982 | } |
2838 | 2983 | // If a moderator exists for this board, add that moderator for all children too. |
2839 | - if (!empty($row['id_moderator'])) |
|
2840 | - foreach ($boards as $id => $dummy) |
|
2984 | + if (!empty($row['id_moderator'])) { |
|
2985 | + foreach ($boards as $id => $dummy) |
|
2841 | 2986 | { |
2842 | 2987 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2843 | 2988 | 'id' => $row['id_moderator'], |
@@ -2845,11 +2990,12 @@ discard block |
||
2845 | 2990 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2846 | 2991 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2847 | 2992 | ); |
2993 | + } |
|
2848 | 2994 | } |
2849 | 2995 | |
2850 | 2996 | // If a moderator group exists for this board, add that moderator group for all children too |
2851 | - if (!empty($row['id_moderator_group'])) |
|
2852 | - foreach ($boards as $id => $dummy) |
|
2997 | + if (!empty($row['id_moderator_group'])) { |
|
2998 | + foreach ($boards as $id => $dummy) |
|
2853 | 2999 | { |
2854 | 3000 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2855 | 3001 | 'id' => $row['id_moderator_group'], |
@@ -2857,6 +3003,7 @@ discard block |
||
2857 | 3003 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2858 | 3004 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2859 | 3005 | ); |
3006 | + } |
|
2860 | 3007 | } |
2861 | 3008 | } |
2862 | 3009 | $smcFunc['db_free_result']($result); |
@@ -2883,23 +3030,27 @@ discard block |
||
2883 | 3030 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2884 | 3031 | { |
2885 | 3032 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2886 | - if (empty($smcFunc['ucwords'])) |
|
2887 | - reloadSettings(); |
|
3033 | + if (empty($smcFunc['ucwords'])) { |
|
3034 | + reloadSettings(); |
|
3035 | + } |
|
2888 | 3036 | |
2889 | 3037 | // If we don't have our theme information yet, let's get it. |
2890 | - if (empty($settings['default_theme_dir'])) |
|
2891 | - loadTheme(0, false); |
|
3038 | + if (empty($settings['default_theme_dir'])) { |
|
3039 | + loadTheme(0, false); |
|
3040 | + } |
|
2892 | 3041 | |
2893 | 3042 | // Default language directories to try. |
2894 | 3043 | $language_directories = array( |
2895 | 3044 | $settings['default_theme_dir'] . '/languages', |
2896 | 3045 | ); |
2897 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2898 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3046 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
3047 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3048 | + } |
|
2899 | 3049 | |
2900 | 3050 | // We possibly have a base theme directory. |
2901 | - if (!empty($settings['base_theme_dir'])) |
|
2902 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3051 | + if (!empty($settings['base_theme_dir'])) { |
|
3052 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3053 | + } |
|
2903 | 3054 | |
2904 | 3055 | // Remove any duplicates. |
2905 | 3056 | $language_directories = array_unique($language_directories); |
@@ -2913,20 +3064,21 @@ discard block |
||
2913 | 3064 | foreach ($language_directories as $language_dir) |
2914 | 3065 | { |
2915 | 3066 | // Can't look in here... doesn't exist! |
2916 | - if (!file_exists($language_dir)) |
|
2917 | - continue; |
|
3067 | + if (!file_exists($language_dir)) { |
|
3068 | + continue; |
|
3069 | + } |
|
2918 | 3070 | |
2919 | 3071 | $dir = dir($language_dir); |
2920 | 3072 | while ($entry = $dir->read()) |
2921 | 3073 | { |
2922 | 3074 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2923 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2924 | - continue; |
|
2925 | - |
|
2926 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2927 | - $langName = $langList[$matches[1]]; |
|
3075 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3076 | + continue; |
|
3077 | + } |
|
2928 | 3078 | |
2929 | - else |
|
3079 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3080 | + $langName = $langList[$matches[1]]; |
|
3081 | + } else |
|
2930 | 3082 | { |
2931 | 3083 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2932 | 3084 | |
@@ -2967,12 +3119,14 @@ discard block |
||
2967 | 3119 | } |
2968 | 3120 | |
2969 | 3121 | // Do we need to store the lang list? |
2970 | - if (empty($langList)) |
|
2971 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3122 | + if (empty($langList)) { |
|
3123 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3124 | + } |
|
2972 | 3125 | |
2973 | 3126 | // Let's cash in on this deal. |
2974 | - if (!empty($modSettings['cache_enable'])) |
|
2975 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3127 | + if (!empty($modSettings['cache_enable'])) { |
|
3128 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3129 | + } |
|
2976 | 3130 | } |
2977 | 3131 | |
2978 | 3132 | return $context['languages']; |
@@ -2995,8 +3149,9 @@ discard block |
||
2995 | 3149 | global $modSettings, $options, $txt; |
2996 | 3150 | static $censor_vulgar = null, $censor_proper; |
2997 | 3151 | |
2998 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2999 | - return $text; |
|
3152 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3153 | + return $text; |
|
3154 | + } |
|
3000 | 3155 | |
3001 | 3156 | // If they haven't yet been loaded, load them. |
3002 | 3157 | if ($censor_vulgar == null) |
@@ -3027,9 +3182,9 @@ discard block |
||
3027 | 3182 | { |
3028 | 3183 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
3029 | 3184 | $text = $func($censor_vulgar, $censor_proper, $text); |
3185 | + } else { |
|
3186 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3030 | 3187 | } |
3031 | - else |
|
3032 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3033 | 3188 | |
3034 | 3189 | return $text; |
3035 | 3190 | } |
@@ -3055,30 +3210,35 @@ discard block |
||
3055 | 3210 | @ini_set('track_errors', '1'); |
3056 | 3211 | |
3057 | 3212 | // Don't include the file more than once, if $once is true. |
3058 | - if ($once && in_array($filename, $templates)) |
|
3059 | - return; |
|
3213 | + if ($once && in_array($filename, $templates)) { |
|
3214 | + return; |
|
3215 | + } |
|
3060 | 3216 | // Add this file to the include list, whether $once is true or not. |
3061 | - else |
|
3062 | - $templates[] = $filename; |
|
3217 | + else { |
|
3218 | + $templates[] = $filename; |
|
3219 | + } |
|
3063 | 3220 | |
3064 | 3221 | |
3065 | 3222 | $file_found = file_exists($filename); |
3066 | 3223 | |
3067 | - if ($once && $file_found) |
|
3068 | - require_once($filename); |
|
3069 | - elseif ($file_found) |
|
3070 | - require($filename); |
|
3224 | + if ($once && $file_found) { |
|
3225 | + require_once($filename); |
|
3226 | + } elseif ($file_found) { |
|
3227 | + require($filename); |
|
3228 | + } |
|
3071 | 3229 | |
3072 | 3230 | if ($file_found !== true) |
3073 | 3231 | { |
3074 | 3232 | ob_end_clean(); |
3075 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3076 | - @ob_start('ob_gzhandler'); |
|
3077 | - else |
|
3078 | - ob_start(); |
|
3233 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3234 | + @ob_start('ob_gzhandler'); |
|
3235 | + } else { |
|
3236 | + ob_start(); |
|
3237 | + } |
|
3079 | 3238 | |
3080 | - if (isset($_GET['debug'])) |
|
3081 | - header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3239 | + if (isset($_GET['debug'])) { |
|
3240 | + header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3241 | + } |
|
3082 | 3242 | |
3083 | 3243 | // Don't cache error pages!! |
3084 | 3244 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3097,12 +3257,13 @@ discard block |
||
3097 | 3257 | echo '<!DOCTYPE html> |
3098 | 3258 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3099 | 3259 | <head>'; |
3100 | - if (isset($context['character_set'])) |
|
3101 | - echo ' |
|
3260 | + if (isset($context['character_set'])) { |
|
3261 | + echo ' |
|
3102 | 3262 | <meta charset="', $context['character_set'], '">'; |
3263 | + } |
|
3103 | 3264 | |
3104 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3105 | - echo ' |
|
3265 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3266 | + echo ' |
|
3106 | 3267 | <title>', $mtitle, '</title> |
3107 | 3268 | </head> |
3108 | 3269 | <body> |
@@ -3110,8 +3271,8 @@ discard block |
||
3110 | 3271 | ', $mmessage, ' |
3111 | 3272 | </body> |
3112 | 3273 | </html>'; |
3113 | - elseif (!allowedTo('admin_forum')) |
|
3114 | - echo ' |
|
3274 | + } elseif (!allowedTo('admin_forum')) { |
|
3275 | + echo ' |
|
3115 | 3276 | <title>', $txt['template_parse_error'], '</title> |
3116 | 3277 | </head> |
3117 | 3278 | <body> |
@@ -3119,14 +3280,16 @@ discard block |
||
3119 | 3280 | ', $txt['template_parse_error_message'], ' |
3120 | 3281 | </body> |
3121 | 3282 | </html>'; |
3122 | - else |
|
3283 | + } else |
|
3123 | 3284 | { |
3124 | 3285 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3125 | 3286 | $error_array = error_get_last(); |
3126 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3127 | - $error = $error_array['message']; |
|
3128 | - if (empty($error)) |
|
3129 | - $error = $txt['template_parse_errmsg']; |
|
3287 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3288 | + $error = $error_array['message']; |
|
3289 | + } |
|
3290 | + if (empty($error)) { |
|
3291 | + $error = $txt['template_parse_errmsg']; |
|
3292 | + } |
|
3130 | 3293 | |
3131 | 3294 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3132 | 3295 | |
@@ -3137,11 +3300,12 @@ discard block |
||
3137 | 3300 | <h3>', $txt['template_parse_error'], '</h3> |
3138 | 3301 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3139 | 3302 | |
3140 | - if (!empty($error)) |
|
3141 | - echo ' |
|
3303 | + if (!empty($error)) { |
|
3304 | + echo ' |
|
3142 | 3305 | <hr> |
3143 | 3306 | |
3144 | 3307 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3308 | + } |
|
3145 | 3309 | |
3146 | 3310 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3147 | 3311 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3151,10 +3315,11 @@ discard block |
||
3151 | 3315 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3152 | 3316 | |
3153 | 3317 | // Fix the PHP code stuff... |
3154 | - if (!isBrowser('gecko')) |
|
3155 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3156 | - else |
|
3157 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3318 | + if (!isBrowser('gecko')) { |
|
3319 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3320 | + } else { |
|
3321 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3322 | + } |
|
3158 | 3323 | |
3159 | 3324 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3160 | 3325 | $j = -1; |
@@ -3162,8 +3327,9 @@ discard block |
||
3162 | 3327 | { |
3163 | 3328 | $j++; |
3164 | 3329 | |
3165 | - if (substr_count($line, '<br>') == 0) |
|
3166 | - continue; |
|
3330 | + if (substr_count($line, '<br>') == 0) { |
|
3331 | + continue; |
|
3332 | + } |
|
3167 | 3333 | |
3168 | 3334 | $n = substr_count($line, '<br>'); |
3169 | 3335 | for ($i = 0; $i < $n; $i++) |
@@ -3182,38 +3348,42 @@ discard block |
||
3182 | 3348 | // Figure out what the color coding was before... |
3183 | 3349 | $line = max($match[1] - 9, 1); |
3184 | 3350 | $last_line = ''; |
3185 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3186 | - if (strpos($data2[$line2], '<') !== false) |
|
3351 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3352 | + if (strpos($data2[$line2], '<') !== false) |
|
3187 | 3353 | { |
3188 | 3354 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3189 | 3355 | $last_line = $color_match[1]; |
3356 | + } |
|
3190 | 3357 | break; |
3191 | 3358 | } |
3192 | 3359 | |
3193 | 3360 | // Show the relevant lines... |
3194 | 3361 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3195 | 3362 | { |
3196 | - if ($line == $match[1]) |
|
3197 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3363 | + if ($line == $match[1]) { |
|
3364 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3365 | + } |
|
3198 | 3366 | |
3199 | 3367 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3200 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3201 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3368 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3369 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3370 | + } |
|
3202 | 3371 | |
3203 | 3372 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3204 | 3373 | { |
3205 | 3374 | $last_line = $color_match[1]; |
3206 | 3375 | echo '</', substr($last_line, 1, 4), '>'; |
3376 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3377 | + $last_line = ''; |
|
3378 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3379 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3207 | 3380 | } |
3208 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3209 | - $last_line = ''; |
|
3210 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3211 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3212 | 3381 | |
3213 | - if ($line == $match[1]) |
|
3214 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3215 | - else |
|
3216 | - echo "\n"; |
|
3382 | + if ($line == $match[1]) { |
|
3383 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3384 | + } else { |
|
3385 | + echo "\n"; |
|
3386 | + } |
|
3217 | 3387 | } |
3218 | 3388 | |
3219 | 3389 | echo '</pre></div>'; |
@@ -3237,8 +3407,9 @@ discard block |
||
3237 | 3407 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port, $db_mb4; |
3238 | 3408 | |
3239 | 3409 | // Figure out what type of database we are using. |
3240 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3241 | - $db_type = 'mysql'; |
|
3410 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3411 | + $db_type = 'mysql'; |
|
3412 | + } |
|
3242 | 3413 | |
3243 | 3414 | // Load the file for the database. |
3244 | 3415 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3246,11 +3417,13 @@ discard block |
||
3246 | 3417 | $db_options = array(); |
3247 | 3418 | |
3248 | 3419 | // Add in the port if needed |
3249 | - if (!empty($db_port)) |
|
3250 | - $db_options['port'] = $db_port; |
|
3420 | + if (!empty($db_port)) { |
|
3421 | + $db_options['port'] = $db_port; |
|
3422 | + } |
|
3251 | 3423 | |
3252 | - if (!empty($db_mb4)) |
|
3253 | - $db_options['db_mb4'] = $db_mb4; |
|
3424 | + if (!empty($db_mb4)) { |
|
3425 | + $db_options['db_mb4'] = $db_mb4; |
|
3426 | + } |
|
3254 | 3427 | |
3255 | 3428 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3256 | 3429 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3269,13 +3442,15 @@ discard block |
||
3269 | 3442 | } |
3270 | 3443 | |
3271 | 3444 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3272 | - if (!$db_connection) |
|
3273 | - display_db_error(); |
|
3445 | + if (!$db_connection) { |
|
3446 | + display_db_error(); |
|
3447 | + } |
|
3274 | 3448 | |
3275 | 3449 | // If in SSI mode fix up the prefix. |
3276 | - if (SMF == 'SSI') |
|
3277 | - db_fix_prefix($db_prefix, $db_name); |
|
3278 | -} |
|
3450 | + if (SMF == 'SSI') { |
|
3451 | + db_fix_prefix($db_prefix, $db_name); |
|
3452 | + } |
|
3453 | + } |
|
3279 | 3454 | |
3280 | 3455 | /** |
3281 | 3456 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3289,10 +3464,11 @@ discard block |
||
3289 | 3464 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3290 | 3465 | |
3291 | 3466 | // Not overriding this and we have a cacheAPI, send it back. |
3292 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3293 | - return $cacheAPI; |
|
3294 | - elseif (is_null($cacheAPI)) |
|
3295 | - $cacheAPI = false; |
|
3467 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3468 | + return $cacheAPI; |
|
3469 | + } elseif (is_null($cacheAPI)) { |
|
3470 | + $cacheAPI = false; |
|
3471 | + } |
|
3296 | 3472 | |
3297 | 3473 | // Make sure our class is in session. |
3298 | 3474 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3313,8 +3489,9 @@ discard block |
||
3313 | 3489 | if (!$testAPI->isSupported()) |
3314 | 3490 | { |
3315 | 3491 | // Can we save ourselves? |
3316 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3317 | - return loadCacheAccelerator(null, false); |
|
3492 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3493 | + return loadCacheAccelerator(null, false); |
|
3494 | + } |
|
3318 | 3495 | return false; |
3319 | 3496 | } |
3320 | 3497 | |
@@ -3326,9 +3503,9 @@ discard block |
||
3326 | 3503 | { |
3327 | 3504 | $cacheAPI = $testAPI; |
3328 | 3505 | return $cacheAPI; |
3506 | + } else { |
|
3507 | + return $testAPI; |
|
3329 | 3508 | } |
3330 | - else |
|
3331 | - return $testAPI; |
|
3332 | 3509 | } |
3333 | 3510 | } |
3334 | 3511 | |
@@ -3348,8 +3525,9 @@ discard block |
||
3348 | 3525 | |
3349 | 3526 | // @todo Why are we doing this if caching is disabled? |
3350 | 3527 | |
3351 | - if (function_exists('call_integration_hook')) |
|
3352 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3528 | + if (function_exists('call_integration_hook')) { |
|
3529 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3530 | + } |
|
3353 | 3531 | |
3354 | 3532 | /* Refresh the cache if either: |
3355 | 3533 | 1. Caching is disabled. |
@@ -3363,16 +3541,19 @@ discard block |
||
3363 | 3541 | require_once($sourcedir . '/' . $file); |
3364 | 3542 | $cache_block = call_user_func_array($function, $params); |
3365 | 3543 | |
3366 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3367 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3544 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3545 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3546 | + } |
|
3368 | 3547 | } |
3369 | 3548 | |
3370 | 3549 | // Some cached data may need a freshening up after retrieval. |
3371 | - if (!empty($cache_block['post_retri_eval'])) |
|
3372 | - eval($cache_block['post_retri_eval']); |
|
3550 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3551 | + eval($cache_block['post_retri_eval']); |
|
3552 | + } |
|
3373 | 3553 | |
3374 | - if (function_exists('call_integration_hook')) |
|
3375 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3554 | + if (function_exists('call_integration_hook')) { |
|
3555 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3556 | + } |
|
3376 | 3557 | |
3377 | 3558 | return $cache_block['data']; |
3378 | 3559 | } |
@@ -3399,8 +3580,9 @@ discard block |
||
3399 | 3580 | global $smcFunc, $cache_enable, $cacheAPI; |
3400 | 3581 | global $cache_hits, $cache_count, $db_show_debug; |
3401 | 3582 | |
3402 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3403 | - return; |
|
3583 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3584 | + return; |
|
3585 | + } |
|
3404 | 3586 | |
3405 | 3587 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3406 | 3588 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3413,12 +3595,14 @@ discard block |
||
3413 | 3595 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3414 | 3596 | $cacheAPI->putData($key, $value, $ttl); |
3415 | 3597 | |
3416 | - if (function_exists('call_integration_hook')) |
|
3417 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3598 | + if (function_exists('call_integration_hook')) { |
|
3599 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3600 | + } |
|
3418 | 3601 | |
3419 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3420 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3421 | -} |
|
3602 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3603 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3604 | + } |
|
3605 | + } |
|
3422 | 3606 | |
3423 | 3607 | /** |
3424 | 3608 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3434,8 +3618,9 @@ discard block |
||
3434 | 3618 | global $smcFunc, $cache_enable, $cacheAPI; |
3435 | 3619 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3436 | 3620 | |
3437 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3438 | - return; |
|
3621 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3622 | + return; |
|
3623 | + } |
|
3439 | 3624 | |
3440 | 3625 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3441 | 3626 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3455,16 +3640,18 @@ discard block |
||
3455 | 3640 | |
3456 | 3641 | if (empty($value)) |
3457 | 3642 | { |
3458 | - if (!is_array($cache_misses)) |
|
3459 | - $cache_misses = array(); |
|
3643 | + if (!is_array($cache_misses)) { |
|
3644 | + $cache_misses = array(); |
|
3645 | + } |
|
3460 | 3646 | |
3461 | 3647 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3462 | 3648 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3463 | 3649 | } |
3464 | 3650 | } |
3465 | 3651 | |
3466 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3467 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3652 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3653 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3654 | + } |
|
3468 | 3655 | |
3469 | 3656 | return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3470 | 3657 | } |
@@ -3486,8 +3673,9 @@ discard block |
||
3486 | 3673 | global $cacheAPI; |
3487 | 3674 | |
3488 | 3675 | // If we can't get to the API, can't do this. |
3489 | - if (empty($cacheAPI)) |
|
3490 | - return; |
|
3676 | + if (empty($cacheAPI)) { |
|
3677 | + return; |
|
3678 | + } |
|
3491 | 3679 | |
3492 | 3680 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3493 | 3681 | $cacheAPI->cleanCache($type); |
@@ -3512,8 +3700,9 @@ discard block |
||
3512 | 3700 | global $modSettings, $smcFunc, $image_proxy_enabled, $user_info; |
3513 | 3701 | |
3514 | 3702 | // Come on! |
3515 | - if (empty($data)) |
|
3516 | - return array(); |
|
3703 | + if (empty($data)) { |
|
3704 | + return array(); |
|
3705 | + } |
|
3517 | 3706 | |
3518 | 3707 | // Set a nice default var. |
3519 | 3708 | $image = ''; |
@@ -3521,11 +3710,11 @@ discard block |
||
3521 | 3710 | // Gravatar has been set as mandatory! |
3522 | 3711 | if (!empty($modSettings['gravatarOverride'])) |
3523 | 3712 | { |
3524 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3525 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3526 | - |
|
3527 | - else if (!empty($data['email'])) |
|
3528 | - $image = get_gravatar_url($data['email']); |
|
3713 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3714 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3715 | + } else if (!empty($data['email'])) { |
|
3716 | + $image = get_gravatar_url($data['email']); |
|
3717 | + } |
|
3529 | 3718 | } |
3530 | 3719 | |
3531 | 3720 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3537,54 +3726,60 @@ discard block |
||
3537 | 3726 | // Gravatar. |
3538 | 3727 | if (stristr($data['avatar'], 'gravatar://')) |
3539 | 3728 | { |
3540 | - if ($data['avatar'] == 'gravatar://') |
|
3541 | - $image = get_gravatar_url($data['email']); |
|
3542 | - |
|
3543 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3544 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3729 | + if ($data['avatar'] == 'gravatar://') { |
|
3730 | + $image = get_gravatar_url($data['email']); |
|
3731 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3732 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3733 | + } |
|
3545 | 3734 | } |
3546 | 3735 | |
3547 | 3736 | // External url. |
3548 | 3737 | else |
3549 | 3738 | { |
3550 | 3739 | // Using ssl? |
3551 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
3552 | - $image = get_proxied_url($data['avatar']); |
|
3740 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
3741 | + $image = get_proxied_url($data['avatar']); |
|
3742 | + } |
|
3553 | 3743 | |
3554 | 3744 | // Just a plain external url. |
3555 | - else |
|
3556 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3745 | + else { |
|
3746 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3747 | + } |
|
3557 | 3748 | } |
3558 | 3749 | } |
3559 | 3750 | |
3560 | 3751 | // Perhaps this user has an attachment as avatar... |
3561 | - else if (!empty($data['filename'])) |
|
3562 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3752 | + else if (!empty($data['filename'])) { |
|
3753 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3754 | + } |
|
3563 | 3755 | |
3564 | 3756 | // Right... no avatar... use our default image. |
3565 | - else |
|
3566 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3757 | + else { |
|
3758 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3759 | + } |
|
3567 | 3760 | } |
3568 | 3761 | |
3569 | 3762 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3570 | 3763 | |
3571 | 3764 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3572 | - if (!empty($image)) |
|
3573 | - return array( |
|
3765 | + if (!empty($image)) { |
|
3766 | + return array( |
|
3574 | 3767 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3575 | 3768 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3576 | 3769 | 'href' => $image, |
3577 | 3770 | 'url' => $image, |
3578 | 3771 | ); |
3772 | + } |
|
3579 | 3773 | |
3580 | 3774 | // Fallback to make life easier for everyone... |
3581 | - else |
|
3582 | - return array( |
|
3775 | + else { |
|
3776 | + return array( |
|
3583 | 3777 | 'name' => '', |
3584 | 3778 | 'image' => '', |
3585 | 3779 | 'href' => '', |
3586 | 3780 | 'url' => '', |
3587 | 3781 | ); |
3588 | -} |
|
3782 | + } |
|
3783 | + } |
|
3589 | 3784 | |
3590 | 3785 | ?> |
3591 | 3786 | \ No newline at end of file |