@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | 'Shitiz "Dragooon" Garg', |
591 | 591 | 'Karl "RegularExpression" Benson', |
592 | 592 | 'Matthew "Labradoodle-360" Kerle', |
593 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
593 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
594 | 594 | 'Michael "Thantos" Miller', |
595 | 595 | 'Norv', |
596 | 596 | 'Peter "Arantor" Spicer', |
@@ -813,13 +813,13 @@ discard block |
||
813 | 813 | $credit_info = smf_json_decode($row['credits'], true); |
814 | 814 | |
815 | 815 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
816 | - $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'])); |
|
816 | + $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'])); |
|
817 | 817 | $version = $txt['credits_version'] . ' ' . $row['version']; |
818 | 818 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
819 | 819 | |
820 | 820 | // build this one out and stash it away |
821 | 821 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
822 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
822 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
823 | 823 | } |
824 | 824 | cache_put_data('mods_credits', $mods, 86400); |
825 | 825 | } |
@@ -673,7 +673,7 @@ |
||
673 | 673 | 'Nikola "Dzonny" Novaković', |
674 | 674 | // Localizers |
675 | 675 | 'Dr. Deejay', |
676 | - 'd3vcho', |
|
676 | + 'd3vcho', |
|
677 | 677 | // Former Localizers |
678 | 678 | 'Relyana', |
679 | 679 | ), |
@@ -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 = smf_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 (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
199 | - $spiderContext[$id] = array( |
|
205 | + foreach (smf_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 = smf_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'], |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | { |
182 | 182 | collapsedDiv.show(\'slow\'); |
183 | 183 | icon.removeClass(\'toggle_down\').addClass(\'toggle_up\'); |
184 | - icon.prop(\'title\', '. JavaScriptEscape($txt['hide']) .'); |
|
184 | + icon.prop(\'title\', '. JavaScriptEscape($txt['hide']) . '); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | else |
188 | 188 | { |
189 | 189 | collapsedDiv.hide(\'slow\'); |
190 | 190 | icon.removeClass(\'toggle_up\').addClass(\'toggle_down\'); |
191 | - icon.prop(\'title\', '. JavaScriptEscape($txt['show']) .'); |
|
191 | + icon.prop(\'title\', '. JavaScriptEscape($txt['show']) . '); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | });', true); |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | |
642 | 642 | // Setup the correct template, even though I'll admit we ain't downloading ;) |
643 | 643 | $context['sub_template'] = 'downloaded'; |
644 | - $allowext = array('.zip','.tgz','.gz'); |
|
644 | + $allowext = array('.zip', '.tgz', '.gz'); |
|
645 | 645 | // @todo Use FTP if the Packages directory is not writable. |
646 | 646 | |
647 | 647 | // Check the file was even sent! |
@@ -653,13 +653,13 @@ discard block |
||
653 | 653 | // Make sure it has a sane filename. |
654 | 654 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
655 | 655 | $extension = substr(strrchr(strtolower($_FILES['package']['name']), '.'), 0); |
656 | - if(!in_array($extension, $allowext)) |
|
656 | + if (!in_array($extension, $allowext)) |
|
657 | 657 | { |
658 | 658 | fatal_lang_error('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
659 | 659 | } |
660 | 660 | |
661 | 661 | // We only need the filename... |
662 | - $extension = ($extension == '.gz') ? '.tar.gz' : $extension ; |
|
662 | + $extension = ($extension == '.gz') ? '.tar.gz' : $extension; |
|
663 | 663 | $packageName = time() . $extension; |
664 | 664 | |
665 | 665 | // Setup the destination and throw an error if the file is already there! |
@@ -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 | * Browse the list of package servers, add servers... |
@@ -43,13 +44,15 @@ discard block |
||
43 | 44 | ); |
44 | 45 | |
45 | 46 | // Now let's decide where we are taking this... |
46 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
47 | - $context['sub_action'] = $_REQUEST['sa']; |
|
47 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
48 | + $context['sub_action'] = $_REQUEST['sa']; |
|
49 | + } |
|
48 | 50 | // We need to support possible old javascript links... |
49 | - elseif (isset($_GET['pgdownload'])) |
|
50 | - $context['sub_action'] = 'download'; |
|
51 | - else |
|
52 | - $context['sub_action'] = 'servers'; |
|
51 | + elseif (isset($_GET['pgdownload'])) { |
|
52 | + $context['sub_action'] = 'download'; |
|
53 | + } else { |
|
54 | + $context['sub_action'] = 'servers'; |
|
55 | + } |
|
53 | 56 | |
54 | 57 | // We need to force the "Download" tab as selected. |
55 | 58 | $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'packageget'; |
@@ -141,17 +144,19 @@ discard block |
||
141 | 144 | { |
142 | 145 | require_once($sourcedir . '/Class-Package.php'); |
143 | 146 | $ftp = new ftp_connection(null); |
147 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
148 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
144 | 149 | } |
145 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
146 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
147 | 150 | |
148 | 151 | list ($username, $detect_path, $found_path) = $ftp->detect_path($packagesdir); |
149 | 152 | |
150 | - if ($found_path || !isset($_POST['ftp_path'])) |
|
151 | - $_POST['ftp_path'] = $detect_path; |
|
153 | + if ($found_path || !isset($_POST['ftp_path'])) { |
|
154 | + $_POST['ftp_path'] = $detect_path; |
|
155 | + } |
|
152 | 156 | |
153 | - if (!isset($_POST['ftp_username'])) |
|
154 | - $_POST['ftp_username'] = $username; |
|
157 | + if (!isset($_POST['ftp_username'])) { |
|
158 | + $_POST['ftp_username'] = $username; |
|
159 | + } |
|
155 | 160 | |
156 | 161 | $context['package_ftp'] = array( |
157 | 162 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -160,8 +165,7 @@ discard block |
||
160 | 165 | 'path' => $_POST['ftp_path'], |
161 | 166 | 'error' => empty($ftp_error) ? null : $ftp_error, |
162 | 167 | ); |
163 | - } |
|
164 | - else |
|
168 | + } else |
|
165 | 169 | { |
166 | 170 | $context['package_download_broken'] = false; |
167 | 171 | |
@@ -203,8 +207,9 @@ discard block |
||
203 | 207 | |
204 | 208 | if (isset($_GET['server'])) |
205 | 209 | { |
206 | - if ($_GET['server'] == '') |
|
207 | - redirectexit('action=admin;area=packages;get'); |
|
210 | + if ($_GET['server'] == '') { |
|
211 | + redirectexit('action=admin;area=packages;get'); |
|
212 | + } |
|
208 | 213 | |
209 | 214 | $server = (int) $_GET['server']; |
210 | 215 | |
@@ -222,17 +227,18 @@ discard block |
||
222 | 227 | $smcFunc['db_free_result']($request); |
223 | 228 | |
224 | 229 | // If the server does not exist, dump out. |
225 | - if (empty($url)) |
|
226 | - fatal_lang_error('couldnt_connect', false); |
|
230 | + if (empty($url)) { |
|
231 | + fatal_lang_error('couldnt_connect', false); |
|
232 | + } |
|
227 | 233 | |
228 | 234 | // If there is a relative link, append to the stored server url. |
229 | - if (isset($_GET['relative'])) |
|
230 | - $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
235 | + if (isset($_GET['relative'])) { |
|
236 | + $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
237 | + } |
|
231 | 238 | |
232 | 239 | // Clear any "absolute" URL. Since "server" is present, "absolute" is garbage. |
233 | 240 | unset($_GET['absolute']); |
234 | - } |
|
235 | - elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
241 | + } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
236 | 242 | { |
237 | 243 | // Initialize the requried variables. |
238 | 244 | $server = ''; |
@@ -256,16 +262,19 @@ discard block |
||
256 | 262 | } |
257 | 263 | } |
258 | 264 | // Minimum required parameter did not exist so dump out. |
259 | - else |
|
260 | - fatal_lang_error('couldnt_connect', false); |
|
265 | + else { |
|
266 | + fatal_lang_error('couldnt_connect', false); |
|
267 | + } |
|
261 | 268 | |
262 | 269 | // Attempt to connect. If unsuccessful... try the URL. |
263 | - if (!isset($_GET['package']) || file_exists($_GET['package'])) |
|
264 | - $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
270 | + if (!isset($_GET['package']) || file_exists($_GET['package'])) { |
|
271 | + $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
272 | + } |
|
265 | 273 | |
266 | 274 | // Check to be sure the packages.xml file actually exists where it is should be... or dump out. |
267 | - if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) |
|
268 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
275 | + if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) { |
|
276 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
277 | + } |
|
269 | 278 | |
270 | 279 | // Might take some time. |
271 | 280 | @set_time_limit(600); |
@@ -275,8 +284,9 @@ discard block |
||
275 | 284 | $listing = new xmlArray(fetch_web_data($_GET['package']), true); |
276 | 285 | |
277 | 286 | // Errm.... empty file? Try the URL.... |
278 | - if (!$listing->exists('package-list')) |
|
279 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
287 | + if (!$listing->exists('package-list')) { |
|
288 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
289 | + } |
|
280 | 290 | |
281 | 291 | // List out the packages... |
282 | 292 | $context['package_list'] = array(); |
@@ -284,8 +294,9 @@ discard block |
||
284 | 294 | $listing = $listing->path('package-list[0]'); |
285 | 295 | |
286 | 296 | // Use the package list's name if it exists. |
287 | - if ($listing->exists('list-title')) |
|
288 | - $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
297 | + if ($listing->exists('list-title')) { |
|
298 | + $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
299 | + } |
|
289 | 300 | |
290 | 301 | // Pick the correct template. |
291 | 302 | $context['sub_template'] = 'package_list'; |
@@ -300,28 +311,32 @@ discard block |
||
300 | 311 | |
301 | 312 | $installed_mods = array(); |
302 | 313 | // Look through the list of installed mods... |
303 | - foreach ($instmods as $installed_mod) |
|
304 | - $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
314 | + foreach ($instmods as $installed_mod) { |
|
315 | + $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
316 | + } |
|
305 | 317 | |
306 | 318 | // Get default author and email if they exist. |
307 | 319 | if ($listing->exists('default-author')) |
308 | 320 | { |
309 | 321 | $default_author = $smcFunc['htmlspecialchars']($listing->fetch('default-author')); |
310 | - if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) |
|
311 | - $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
322 | + if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
323 | + $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
324 | + } |
|
312 | 325 | } |
313 | 326 | |
314 | 327 | // Get default web site if it exists. |
315 | 328 | if ($listing->exists('default-website')) |
316 | 329 | { |
317 | 330 | $default_website = $smcFunc['htmlspecialchars']($listing->fetch('default-website')); |
318 | - if ($listing->exists('default-website/@title')) |
|
319 | - $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
331 | + if ($listing->exists('default-website/@title')) { |
|
332 | + $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
333 | + } |
|
320 | 334 | } |
321 | 335 | |
322 | 336 | $the_version = strtr($forum_version, array('SMF ' => '')); |
323 | - if (!empty($_SESSION['version_emulate'])) |
|
324 | - $the_version = $_SESSION['version_emulate']; |
|
337 | + if (!empty($_SESSION['version_emulate'])) { |
|
338 | + $the_version = $_SESSION['version_emulate']; |
|
339 | + } |
|
325 | 340 | |
326 | 341 | $packageNum = 0; |
327 | 342 | $packageSection = 0; |
@@ -342,11 +357,13 @@ discard block |
||
342 | 357 | 'type' => $thisPackage->name(), |
343 | 358 | ); |
344 | 359 | |
345 | - if (in_array($package['type'], array('title', 'text'))) |
|
346 | - $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
360 | + if (in_array($package['type'], array('title', 'text'))) { |
|
361 | + $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
362 | + } |
|
347 | 363 | // It's a Title, Heading, Rule or Text. |
348 | - elseif (in_array($package['type'], array('heading', 'rule'))) |
|
349 | - $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
364 | + elseif (in_array($package['type'], array('heading', 'rule'))) { |
|
365 | + $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
366 | + } |
|
350 | 367 | // It's a Remote link. |
351 | 368 | elseif ($package['type'] == 'remote') |
352 | 369 | { |
@@ -354,20 +371,21 @@ discard block |
||
354 | 371 | |
355 | 372 | if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://' && substr($thisPackage->fetch('@href'), 0, 8) != 'https://') |
356 | 373 | { |
357 | - if (isset($_GET['absolute'])) |
|
358 | - $current_url = $_GET['absolute'] . '/'; |
|
359 | - elseif (isset($_GET['relative'])) |
|
360 | - $current_url = $_GET['relative'] . '/'; |
|
361 | - else |
|
362 | - $current_url = ''; |
|
374 | + if (isset($_GET['absolute'])) { |
|
375 | + $current_url = $_GET['absolute'] . '/'; |
|
376 | + } elseif (isset($_GET['relative'])) { |
|
377 | + $current_url = $_GET['relative'] . '/'; |
|
378 | + } else { |
|
379 | + $current_url = ''; |
|
380 | + } |
|
363 | 381 | |
364 | 382 | $current_url .= $thisPackage->fetch('@href'); |
365 | - if (isset($_GET['absolute'])) |
|
366 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
367 | - else |
|
368 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
369 | - } |
|
370 | - else |
|
383 | + if (isset($_GET['absolute'])) { |
|
384 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
385 | + } else { |
|
386 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
387 | + } |
|
388 | + } else |
|
371 | 389 | { |
372 | 390 | $current_url = $thisPackage->fetch('@href'); |
373 | 391 | $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
@@ -379,25 +397,28 @@ discard block |
||
379 | 397 | // It's a package... |
380 | 398 | else |
381 | 399 | { |
382 | - if (isset($_GET['absolute'])) |
|
383 | - $current_url = $_GET['absolute'] . '/'; |
|
384 | - elseif (isset($_GET['relative'])) |
|
385 | - $current_url = $_GET['relative'] . '/'; |
|
386 | - else |
|
387 | - $current_url = ''; |
|
400 | + if (isset($_GET['absolute'])) { |
|
401 | + $current_url = $_GET['absolute'] . '/'; |
|
402 | + } elseif (isset($_GET['relative'])) { |
|
403 | + $current_url = $_GET['relative'] . '/'; |
|
404 | + } else { |
|
405 | + $current_url = ''; |
|
406 | + } |
|
388 | 407 | |
389 | 408 | $server_att = $server != '' ? ';server=' . $server : ''; |
390 | 409 | |
391 | 410 | $package += $thisPackage->to_array(); |
392 | 411 | |
393 | - if (isset($package['website'])) |
|
394 | - unset($package['website']); |
|
412 | + if (isset($package['website'])) { |
|
413 | + unset($package['website']); |
|
414 | + } |
|
395 | 415 | $package['author'] = array(); |
396 | 416 | |
397 | - if ($package['description'] == '') |
|
398 | - $package['description'] = $txt['package_no_description']; |
|
399 | - else |
|
400 | - $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
417 | + if ($package['description'] == '') { |
|
418 | + $package['description'] = $txt['package_no_description']; |
|
419 | + } else { |
|
420 | + $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
421 | + } |
|
401 | 422 | |
402 | 423 | $package['is_installed'] = isset($installed_mods[$package['id']]); |
403 | 424 | $package['is_current'] = $package['is_installed'] && ($installed_mods[$package['id']] == $package['version']); |
@@ -406,12 +427,14 @@ discard block |
||
406 | 427 | // This package is either not installed, or installed but old. Is it supported on this version of SMF? |
407 | 428 | if (!$package['is_installed'] || (!$package['is_current'] && !$package['is_newer'])) |
408 | 429 | { |
409 | - if ($thisPackage->exists('version/@for')) |
|
410 | - $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
430 | + if ($thisPackage->exists('version/@for')) { |
|
431 | + $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
432 | + } |
|
411 | 433 | } |
412 | 434 | // Okay, it's already installed AND up to date. |
413 | - else |
|
414 | - $package['can_install'] = false; |
|
435 | + else { |
|
436 | + $package['can_install'] = false; |
|
437 | + } |
|
415 | 438 | |
416 | 439 | $already_exists = getPackageInfo(basename($package['filename'])); |
417 | 440 | $package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version']; |
@@ -423,40 +446,44 @@ discard block |
||
423 | 446 | |
424 | 447 | if ($thisPackage->exists('author') || isset($default_author)) |
425 | 448 | { |
426 | - if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) |
|
427 | - $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
428 | - elseif (isset($default_email)) |
|
429 | - $package['author']['email'] = $default_email; |
|
430 | - |
|
431 | - if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') |
|
432 | - $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
433 | - else |
|
434 | - $package['author']['name'] = $default_author; |
|
435 | - |
|
436 | - if (!empty($package['author']['email'])) |
|
437 | - $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
449 | + if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
450 | + $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
451 | + } elseif (isset($default_email)) { |
|
452 | + $package['author']['email'] = $default_email; |
|
453 | + } |
|
454 | + |
|
455 | + if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') { |
|
456 | + $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
457 | + } else { |
|
458 | + $package['author']['name'] = $default_author; |
|
459 | + } |
|
460 | + |
|
461 | + if (!empty($package['author']['email'])) { |
|
462 | + $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
463 | + } |
|
438 | 464 | } |
439 | 465 | |
440 | 466 | if ($thisPackage->exists('website') || isset($default_website)) |
441 | 467 | { |
442 | - if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) |
|
443 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
444 | - elseif (isset($default_title)) |
|
445 | - $package['author']['website']['name'] = $default_title; |
|
446 | - elseif ($thisPackage->exists('website')) |
|
447 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
448 | - else |
|
449 | - $package['author']['website']['name'] = $default_website; |
|
450 | - |
|
451 | - if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') |
|
452 | - $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
453 | - else |
|
454 | - $authorhompage = $default_website; |
|
468 | + if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) { |
|
469 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
470 | + } elseif (isset($default_title)) { |
|
471 | + $package['author']['website']['name'] = $default_title; |
|
472 | + } elseif ($thisPackage->exists('website')) { |
|
473 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
474 | + } else { |
|
475 | + $package['author']['website']['name'] = $default_website; |
|
476 | + } |
|
477 | + |
|
478 | + if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') { |
|
479 | + $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
480 | + } else { |
|
481 | + $authorhompage = $default_website; |
|
482 | + } |
|
455 | 483 | |
456 | 484 | $package['author']['website']['href'] = $authorhompage; |
457 | 485 | $package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>'; |
458 | - } |
|
459 | - else |
|
486 | + } else |
|
460 | 487 | { |
461 | 488 | $package['author']['website']['href'] = ''; |
462 | 489 | $package['author']['website']['link'] = ''; |
@@ -472,11 +499,13 @@ discard block |
||
472 | 499 | $packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1; |
473 | 500 | $package['count'] = $packageNum; |
474 | 501 | |
475 | - if (!in_array($package['type'], array('title', 'text'))) |
|
476 | - $context['package_list'][$packageSection]['items'][] = $package; |
|
502 | + if (!in_array($package['type'], array('title', 'text'))) { |
|
503 | + $context['package_list'][$packageSection]['items'][] = $package; |
|
504 | + } |
|
477 | 505 | |
478 | - if ($package['count'] > 1) |
|
479 | - $context['list_type'] = 'ol'; |
|
506 | + if ($package['count'] > 1) { |
|
507 | + $context['list_type'] = 'ol'; |
|
508 | + } |
|
480 | 509 | } |
481 | 510 | |
482 | 511 | $packageSection++; |
@@ -489,8 +518,9 @@ discard block |
||
489 | 518 | { |
490 | 519 | foreach ($packageSection['items'] as $i => $package) |
491 | 520 | { |
492 | - if ($package['count'] == 0 || isset($package['can_install'])) |
|
493 | - continue; |
|
521 | + if ($package['count'] == 0 || isset($package['can_install'])) { |
|
522 | + continue; |
|
523 | + } |
|
494 | 524 | |
495 | 525 | $context['package_list'][$ps_id]['items'][$i]['can_install'] = false; |
496 | 526 | |
@@ -539,8 +569,9 @@ discard block |
||
539 | 569 | checkSession('get'); |
540 | 570 | |
541 | 571 | // To download something, we need a valid server or url. |
542 | - if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) |
|
543 | - fatal_lang_error('package_get_error_is_zero', false); |
|
572 | + if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) { |
|
573 | + fatal_lang_error('package_get_error_is_zero', false); |
|
574 | + } |
|
544 | 575 | |
545 | 576 | if (isset($_GET['server'])) |
546 | 577 | { |
@@ -560,22 +591,23 @@ discard block |
||
560 | 591 | $smcFunc['db_free_result']($request); |
561 | 592 | |
562 | 593 | // If server does not exist then dump out. |
563 | - if (empty($url)) |
|
564 | - fatal_lang_error('couldnt_connect', false); |
|
594 | + if (empty($url)) { |
|
595 | + fatal_lang_error('couldnt_connect', false); |
|
596 | + } |
|
565 | 597 | |
566 | 598 | $url = $url . '/'; |
567 | - } |
|
568 | - else |
|
599 | + } else |
|
569 | 600 | { |
570 | 601 | // Initialize the requried variables. |
571 | 602 | $server = ''; |
572 | 603 | $url = ''; |
573 | 604 | } |
574 | 605 | |
575 | - if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) |
|
576 | - $package_name = basename($_REQUEST['filename']); |
|
577 | - else |
|
578 | - $package_name = basename($_REQUEST['package']); |
|
606 | + if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) { |
|
607 | + $package_name = basename($_REQUEST['filename']); |
|
608 | + } else { |
|
609 | + $package_name = basename($_REQUEST['package']); |
|
610 | + } |
|
579 | 611 | |
580 | 612 | if (isset($_REQUEST['conflict']) || (isset($_REQUEST['auto']) && file_exists($packagesdir . '/' . $package_name))) |
581 | 613 | { |
@@ -584,14 +616,15 @@ discard block |
||
584 | 616 | { |
585 | 617 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
586 | 618 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
619 | + } else { |
|
620 | + $ext = ''; |
|
587 | 621 | } |
588 | - else |
|
589 | - $ext = ''; |
|
590 | 622 | |
591 | 623 | // Find the first available. |
592 | 624 | $i = 1; |
593 | - while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) |
|
594 | - $i++; |
|
625 | + while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) { |
|
626 | + $i++; |
|
627 | + } |
|
595 | 628 | |
596 | 629 | $package_name = $package_name . $i . $ext; |
597 | 630 | } |
@@ -602,25 +635,28 @@ discard block |
||
602 | 635 | |
603 | 636 | // Done! Did we get this package automatically? |
604 | 637 | // @ TODO: These are usually update packages. Allowing both for now until more testing has been done. |
605 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) |
|
606 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
638 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) { |
|
639 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
640 | + } |
|
607 | 641 | |
608 | 642 | // You just downloaded a mod from SERVER_NAME_GOES_HERE. |
609 | 643 | $context['package_server'] = $server; |
610 | 644 | |
611 | 645 | $context['package'] = getPackageInfo($package_name); |
612 | 646 | |
613 | - if (!is_array($context['package'])) |
|
614 | - fatal_lang_error('package_cant_download', false); |
|
647 | + if (!is_array($context['package'])) { |
|
648 | + fatal_lang_error('package_cant_download', false); |
|
649 | + } |
|
615 | 650 | |
616 | - if ($context['package']['type'] == 'modification') |
|
617 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
618 | - elseif ($context['package']['type'] == 'avatar') |
|
619 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
620 | - elseif ($context['package']['type'] == 'language') |
|
621 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
622 | - else |
|
623 | - $context['package']['install']['link'] = ''; |
|
651 | + if ($context['package']['type'] == 'modification') { |
|
652 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
653 | + } elseif ($context['package']['type'] == 'avatar') { |
|
654 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
655 | + } elseif ($context['package']['type'] == 'language') { |
|
656 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
657 | + } else { |
|
658 | + $context['package']['install']['link'] = ''; |
|
659 | + } |
|
624 | 660 | |
625 | 661 | // Does a 3rd party hook want to do some additional changes? |
626 | 662 | call_integration_hook('integrate_package_download'); |
@@ -646,10 +682,11 @@ discard block |
||
646 | 682 | // @todo Use FTP if the Packages directory is not writable. |
647 | 683 | |
648 | 684 | // Check the file was even sent! |
649 | - if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
|
650 | - fatal_lang_error('package_upload_error_nofile'); |
|
651 | - elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
|
652 | - fatal_lang_error('package_upload_error_failed'); |
|
685 | + if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') { |
|
686 | + fatal_lang_error('package_upload_error_nofile'); |
|
687 | + } elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) { |
|
688 | + fatal_lang_error('package_upload_error_failed'); |
|
689 | + } |
|
653 | 690 | |
654 | 691 | // Make sure it has a sane filename. |
655 | 692 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
@@ -666,8 +703,9 @@ discard block |
||
666 | 703 | // Setup the destination and throw an error if the file is already there! |
667 | 704 | $destination = $packagesdir . '/' . $packageName; |
668 | 705 | // @todo Maybe just roll it like we do for downloads? |
669 | - if (file_exists($destination)) |
|
670 | - fatal_lang_error('package_upload_error_exists'); |
|
706 | + if (file_exists($destination)) { |
|
707 | + fatal_lang_error('package_upload_error_exists'); |
|
708 | + } |
|
671 | 709 | |
672 | 710 | // Now move the file. |
673 | 711 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -690,12 +728,14 @@ discard block |
||
690 | 728 | { |
691 | 729 | while ($package = readdir($dir)) |
692 | 730 | { |
693 | - if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
694 | - continue; |
|
731 | + if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
732 | + continue; |
|
733 | + } |
|
695 | 734 | |
696 | 735 | $packageInfo = getPackageInfo($package); |
697 | - if (!is_array($packageInfo)) |
|
698 | - continue; |
|
736 | + if (!is_array($packageInfo)) { |
|
737 | + continue; |
|
738 | + } |
|
699 | 739 | |
700 | 740 | if ($packageInfo['id'] == $context['package']['id'] && $packageInfo['version'] == $context['package']['version']) |
701 | 741 | { |
@@ -707,14 +747,15 @@ discard block |
||
707 | 747 | closedir($dir); |
708 | 748 | } |
709 | 749 | |
710 | - if ($context['package']['type'] == 'modification') |
|
711 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
712 | - elseif ($context['package']['type'] == 'avatar') |
|
713 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
714 | - elseif ($context['package']['type'] == 'language') |
|
715 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
716 | - else |
|
717 | - $context['package']['install']['link'] = ''; |
|
750 | + if ($context['package']['type'] == 'modification') { |
|
751 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
752 | + } elseif ($context['package']['type'] == 'avatar') { |
|
753 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
754 | + } elseif ($context['package']['type'] == 'language') { |
|
755 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
756 | + } else { |
|
757 | + $context['package']['install']['link'] = ''; |
|
758 | + } |
|
718 | 759 | |
719 | 760 | // Does a 3rd party hook want to do some additional changes? |
720 | 761 | call_integration_hook('integrate_package_upload'); |
@@ -737,16 +778,18 @@ discard block |
||
737 | 778 | checkSession(); |
738 | 779 | |
739 | 780 | // If they put a slash on the end, get rid of it. |
740 | - if (substr($_POST['serverurl'], -1) == '/') |
|
741 | - $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
781 | + if (substr($_POST['serverurl'], -1) == '/') { |
|
782 | + $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
783 | + } |
|
742 | 784 | |
743 | 785 | // Are they both nice and clean? |
744 | 786 | $servername = trim($smcFunc['htmlspecialchars']($_POST['servername'])); |
745 | 787 | $serverurl = trim($smcFunc['htmlspecialchars']($_POST['serverurl'])); |
746 | 788 | |
747 | 789 | // Make sure the URL has the correct prefix. |
748 | - if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) |
|
749 | - $serverurl = 'http://' . $serverurl; |
|
790 | + if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) { |
|
791 | + $serverurl = 'http://' . $serverurl; |
|
792 | + } |
|
750 | 793 | |
751 | 794 | $smcFunc['db_insert']('', |
752 | 795 | '{db_prefix}package_servers', |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | |
660 | 660 | // Remove the phrase parts and extract the words. |
661 | 661 | $wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']); |
662 | - $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES)); |
|
662 | + $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES)); |
|
663 | 663 | |
664 | 664 | // A minus sign in front of a word excludes the word.... so... |
665 | 665 | $excludedWords = array(); |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | SELECT |
1105 | 1105 | {int:id_search}, |
1106 | 1106 | t.id_topic, |
1107 | - ' . $relevance. ', |
|
1107 | + ' . $relevance . ', |
|
1108 | 1108 | ' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ', |
1109 | 1109 | 1 |
1110 | 1110 | FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : ' |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | if (empty($subject_query['where'])) |
1340 | 1340 | continue; |
1341 | 1341 | |
1342 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
|
1342 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? (' |
|
1343 | 1343 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
1344 | 1344 | (' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . ' |
1345 | 1345 | SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | $main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance'; |
1570 | 1570 | |
1571 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( ' |
|
1571 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? (' |
|
1572 | 1572 | INSERT IGNORE INTO ' . '{db_prefix}log_search_results |
1573 | 1573 | (' . implode(', ', array_keys($main_query['select'])) . ')') : '') . ' |
1574 | 1574 | SELECT |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
1637 | 1637 | |
1638 | 1638 | $usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts)); |
1639 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( ' |
|
1639 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? (' |
|
1640 | 1640 | INSERT IGNORE INTO {db_prefix}log_search_results |
1641 | 1641 | (id_search, id_topic, relevance, id_msg, num_matches)') : '') . ' |
1642 | 1642 | SELECT |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | $query = trim($query, "\*+"); |
2103 | 2103 | $query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\'')); |
2104 | 2104 | |
2105 | - $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m) |
|
2105 | + $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m) |
|
2106 | 2106 | { |
2107 | 2107 | return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>"; |
2108 | 2108 | }, $body_highlighted); |
@@ -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 | // This defines two version types for checking the API's are compatible with this version of SMF. |
20 | 21 | $GLOBALS['search_versions'] = array( |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir; |
40 | 41 | |
41 | 42 | // Is the load average too high to allow searching just now? |
42 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
43 | - fatal_lang_error('loadavg_search_disabled', false); |
|
43 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
44 | + fatal_lang_error('loadavg_search_disabled', false); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | loadLanguage('Search'); |
46 | 48 | // Don't load this in XML mode. |
@@ -88,23 +90,30 @@ discard block |
||
88 | 90 | @list ($k, $v) = explode('|\'|', $data); |
89 | 91 | $context['search_params'][$k] = $v; |
90 | 92 | } |
91 | - if (isset($context['search_params']['brd'])) |
|
92 | - $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
93 | + if (isset($context['search_params']['brd'])) { |
|
94 | + $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
95 | + } |
|
93 | 96 | } |
94 | 97 | |
95 | - if (isset($_REQUEST['search'])) |
|
96 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
98 | + if (isset($_REQUEST['search'])) { |
|
99 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
100 | + } |
|
97 | 101 | |
98 | - if (isset($context['search_params']['search'])) |
|
99 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
100 | - if (isset($context['search_params']['userspec'])) |
|
101 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
102 | - if (!empty($context['search_params']['searchtype'])) |
|
103 | - $context['search_params']['searchtype'] = 2; |
|
104 | - if (!empty($context['search_params']['minage'])) |
|
105 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
106 | - if (!empty($context['search_params']['maxage'])) |
|
107 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
102 | + if (isset($context['search_params']['search'])) { |
|
103 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
104 | + } |
|
105 | + if (isset($context['search_params']['userspec'])) { |
|
106 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
107 | + } |
|
108 | + if (!empty($context['search_params']['searchtype'])) { |
|
109 | + $context['search_params']['searchtype'] = 2; |
|
110 | + } |
|
111 | + if (!empty($context['search_params']['minage'])) { |
|
112 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
113 | + } |
|
114 | + if (!empty($context['search_params']['maxage'])) { |
|
115 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
116 | + } |
|
108 | 117 | |
109 | 118 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
110 | 119 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -116,11 +125,13 @@ discard block |
||
116 | 125 | $context['search_errors']['messages'] = array(); |
117 | 126 | foreach ($context['search_errors'] as $search_error => $dummy) |
118 | 127 | { |
119 | - if ($search_error === 'messages') |
|
120 | - continue; |
|
128 | + if ($search_error === 'messages') { |
|
129 | + continue; |
|
130 | + } |
|
121 | 131 | |
122 | - if ($search_error == 'string_too_long') |
|
123 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
132 | + if ($search_error == 'string_too_long') { |
|
133 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
134 | + } |
|
124 | 135 | |
125 | 136 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
126 | 137 | } |
@@ -143,12 +154,13 @@ discard block |
||
143 | 154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
144 | 155 | { |
145 | 156 | // This category hasn't been set up yet.. |
146 | - if (!isset($context['categories'][$row['id_cat']])) |
|
147 | - $context['categories'][$row['id_cat']] = array( |
|
157 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
158 | + $context['categories'][$row['id_cat']] = array( |
|
148 | 159 | 'id' => $row['id_cat'], |
149 | 160 | 'name' => $row['cat_name'], |
150 | 161 | 'boards' => array() |
151 | 162 | ); |
163 | + } |
|
152 | 164 | |
153 | 165 | // Set this board up, and let the template know when it's a child. (indent them..) |
154 | 166 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -159,8 +171,9 @@ discard block |
||
159 | 171 | ); |
160 | 172 | |
161 | 173 | // If a board wasn't checked that probably should have been ensure the board selection is selected, yo! |
162 | - if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) |
|
163 | - $context['boards_check_all'] = false; |
|
174 | + if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) { |
|
175 | + $context['boards_check_all'] = false; |
|
176 | + } |
|
164 | 177 | } |
165 | 178 | $smcFunc['db_free_result']($request); |
166 | 179 | |
@@ -182,18 +195,20 @@ discard block |
||
182 | 195 | } |
183 | 196 | |
184 | 197 | $max_boards = ceil(count($temp_boards) / 2); |
185 | - if ($max_boards == 1) |
|
186 | - $max_boards = 2; |
|
198 | + if ($max_boards == 1) { |
|
199 | + $max_boards = 2; |
|
200 | + } |
|
187 | 201 | |
188 | 202 | // Now, alternate them so they can be shown left and right ;). |
189 | 203 | $context['board_columns'] = array(); |
190 | 204 | for ($i = 0; $i < $max_boards; $i++) |
191 | 205 | { |
192 | 206 | $context['board_columns'][] = $temp_boards[$i]; |
193 | - if (isset($temp_boards[$i + $max_boards])) |
|
194 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
195 | - else |
|
196 | - $context['board_columns'][] = array(); |
|
207 | + if (isset($temp_boards[$i + $max_boards])) { |
|
208 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
209 | + } else { |
|
210 | + $context['board_columns'][] = array(); |
|
211 | + } |
|
197 | 212 | } |
198 | 213 | |
199 | 214 | if (!empty($_REQUEST['topic'])) |
@@ -225,8 +240,9 @@ discard block |
||
225 | 240 | ) |
226 | 241 | ); |
227 | 242 | |
228 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
229 | - fatal_lang_error('topic_gone', false); |
|
243 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
244 | + fatal_lang_error('topic_gone', false); |
|
245 | + } |
|
230 | 246 | |
231 | 247 | list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request); |
232 | 248 | $smcFunc['db_free_result']($request); |
@@ -256,11 +272,13 @@ discard block |
||
256 | 272 | global $excludedWords, $participants, $smcFunc; |
257 | 273 | |
258 | 274 | // if comming from the quick search box, and we want to search on members, well we need to do that ;) |
259 | - if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') |
|
260 | - redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
275 | + if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') { |
|
276 | + redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
277 | + } |
|
261 | 278 | |
262 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
263 | - fatal_lang_error('loadavg_search_disabled', false); |
|
279 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
280 | + fatal_lang_error('loadavg_search_disabled', false); |
|
281 | + } |
|
264 | 282 | |
265 | 283 | // No, no, no... this is a bit hard on the server, so don't you go prefetching it! |
266 | 284 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -307,8 +325,9 @@ discard block |
||
307 | 325 | } |
308 | 326 | |
309 | 327 | // Zero weight. Weightless :P. |
310 | - if (empty($weight_total)) |
|
311 | - fatal_lang_error('search_invalid_weights'); |
|
328 | + if (empty($weight_total)) { |
|
329 | + fatal_lang_error('search_invalid_weights'); |
|
330 | + } |
|
312 | 331 | |
313 | 332 | // These vars don't require an interface, they're just here for tweaking. |
314 | 333 | $recentPercentage = 0.30; |
@@ -326,11 +345,13 @@ discard block |
||
326 | 345 | $context['search_string_limit'] = 100; |
327 | 346 | |
328 | 347 | loadLanguage('Search'); |
329 | - if (!isset($_REQUEST['xml'])) |
|
330 | - loadTemplate('Search'); |
|
348 | + if (!isset($_REQUEST['xml'])) { |
|
349 | + loadTemplate('Search'); |
|
350 | + } |
|
331 | 351 | //If we're doing XML we need to use the results template regardless really. |
332 | - else |
|
333 | - $context['sub_template'] = 'results'; |
|
352 | + else { |
|
353 | + $context['sub_template'] = 'results'; |
|
354 | + } |
|
334 | 355 | |
335 | 356 | // Are you allowed? |
336 | 357 | isAllowedTo('search_posts'); |
@@ -363,34 +384,39 @@ discard block |
||
363 | 384 | $search_params[$k] = $v; |
364 | 385 | } |
365 | 386 | |
366 | - if (isset($search_params['brd'])) |
|
367 | - $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
387 | + if (isset($search_params['brd'])) { |
|
388 | + $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
389 | + } |
|
368 | 390 | } |
369 | 391 | |
370 | 392 | // Store whether simple search was used (needed if the user wants to do another query). |
371 | - if (!isset($search_params['advanced'])) |
|
372 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
393 | + if (!isset($search_params['advanced'])) { |
|
394 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
395 | + } |
|
373 | 396 | |
374 | 397 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
375 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
376 | - $search_params['searchtype'] = 2; |
|
398 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
399 | + $search_params['searchtype'] = 2; |
|
400 | + } |
|
377 | 401 | |
378 | 402 | // Minimum age of messages. Default to zero (don't set param in that case). |
379 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
380 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
403 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
404 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
405 | + } |
|
381 | 406 | |
382 | 407 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
383 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) |
|
384 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
408 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) { |
|
409 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
410 | + } |
|
385 | 411 | |
386 | 412 | // Searching a specific topic? |
387 | 413 | if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic')) |
388 | 414 | { |
389 | 415 | $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : ''); |
390 | 416 | $search_params['show_complete'] = true; |
417 | + } elseif (!empty($search_params['topic'])) { |
|
418 | + $search_params['topic'] = (int) $search_params['topic']; |
|
391 | 419 | } |
392 | - elseif (!empty($search_params['topic'])) |
|
393 | - $search_params['topic'] = (int) $search_params['topic']; |
|
394 | 420 | |
395 | 421 | if (!empty($search_params['minage']) || !empty($search_params['maxage'])) |
396 | 422 | { |
@@ -408,19 +434,21 @@ discard block |
||
408 | 434 | ) |
409 | 435 | ); |
410 | 436 | list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request); |
411 | - if ($minMsgID < 0 || $maxMsgID < 0) |
|
412 | - $context['search_errors']['no_messages_in_time_frame'] = true; |
|
437 | + if ($minMsgID < 0 || $maxMsgID < 0) { |
|
438 | + $context['search_errors']['no_messages_in_time_frame'] = true; |
|
439 | + } |
|
413 | 440 | $smcFunc['db_free_result']($request); |
414 | 441 | } |
415 | 442 | |
416 | 443 | // Default the user name to a wildcard matching every user (*). |
417 | - if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
418 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
444 | + if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
445 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
446 | + } |
|
419 | 447 | |
420 | 448 | // If there's no specific user, then don't mention it in the main query. |
421 | - if (empty($search_params['userspec'])) |
|
422 | - $userQuery = ''; |
|
423 | - else |
|
449 | + if (empty($search_params['userspec'])) { |
|
450 | + $userQuery = ''; |
|
451 | + } else |
|
424 | 452 | { |
425 | 453 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
426 | 454 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -432,19 +460,21 @@ discard block |
||
432 | 460 | { |
433 | 461 | $possible_users[$k] = trim($possible_users[$k]); |
434 | 462 | |
435 | - if (strlen($possible_users[$k]) == 0) |
|
436 | - unset($possible_users[$k]); |
|
463 | + if (strlen($possible_users[$k]) == 0) { |
|
464 | + unset($possible_users[$k]); |
|
465 | + } |
|
437 | 466 | } |
438 | 467 | |
439 | 468 | // Create a list of database-escaped search names. |
440 | 469 | $realNameMatches = array(); |
441 | - foreach ($possible_users as $possible_user) |
|
442 | - $realNameMatches[] = $smcFunc['db_quote']( |
|
470 | + foreach ($possible_users as $possible_user) { |
|
471 | + $realNameMatches[] = $smcFunc['db_quote']( |
|
443 | 472 | '{string:possible_user}', |
444 | 473 | array( |
445 | 474 | 'possible_user' => $possible_user |
446 | 475 | ) |
447 | 476 | ); |
477 | + } |
|
448 | 478 | |
449 | 479 | // Retrieve a list of possible members. |
450 | 480 | $request = $smcFunc['db_query']('', ' |
@@ -456,9 +486,9 @@ discard block |
||
456 | 486 | ) |
457 | 487 | ); |
458 | 488 | // Simply do nothing if there're too many members matching the criteria. |
459 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
460 | - $userQuery = ''; |
|
461 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
489 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
490 | + $userQuery = ''; |
|
491 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
462 | 492 | { |
463 | 493 | $userQuery = $smcFunc['db_quote']( |
464 | 494 | 'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})', |
@@ -467,12 +497,12 @@ discard block |
||
467 | 497 | 'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches), |
468 | 498 | ) |
469 | 499 | ); |
470 | - } |
|
471 | - else |
|
500 | + } else |
|
472 | 501 | { |
473 | 502 | $memberlist = array(); |
474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
475 | - $memberlist[] = $row['id_member']; |
|
503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
504 | + $memberlist[] = $row['id_member']; |
|
505 | + } |
|
476 | 506 | $userQuery = $smcFunc['db_quote']( |
477 | 507 | '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))', |
478 | 508 | array( |
@@ -486,22 +516,25 @@ discard block |
||
486 | 516 | } |
487 | 517 | |
488 | 518 | // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST. |
489 | - if (!empty($search_params['brd']) && is_array($search_params['brd'])) |
|
490 | - $_REQUEST['brd'] = $search_params['brd']; |
|
519 | + if (!empty($search_params['brd']) && is_array($search_params['brd'])) { |
|
520 | + $_REQUEST['brd'] = $search_params['brd']; |
|
521 | + } |
|
491 | 522 | |
492 | 523 | // Ensure that brd is an array. |
493 | 524 | if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board')) |
494 | 525 | { |
495 | - if (!empty($_REQUEST['brd'])) |
|
496 | - $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
497 | - else |
|
498 | - $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
526 | + if (!empty($_REQUEST['brd'])) { |
|
527 | + $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
528 | + } else { |
|
529 | + $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
530 | + } |
|
499 | 531 | } |
500 | 532 | |
501 | 533 | // Make sure all boards are integers. |
502 | - if (!empty($_REQUEST['brd'])) |
|
503 | - foreach ($_REQUEST['brd'] as $id => $brd) |
|
534 | + if (!empty($_REQUEST['brd'])) { |
|
535 | + foreach ($_REQUEST['brd'] as $id => $brd) |
|
504 | 536 | $_REQUEST['brd'][$id] = (int) $brd; |
537 | + } |
|
505 | 538 | |
506 | 539 | // Special case for boards: searching just one topic? |
507 | 540 | if (!empty($search_params['topic'])) |
@@ -520,17 +553,18 @@ discard block |
||
520 | 553 | ) |
521 | 554 | ); |
522 | 555 | |
523 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
524 | - fatal_lang_error('topic_gone', false); |
|
556 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
557 | + fatal_lang_error('topic_gone', false); |
|
558 | + } |
|
525 | 559 | |
526 | 560 | $search_params['brd'] = array(); |
527 | 561 | list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request); |
528 | 562 | $smcFunc['db_free_result']($request); |
529 | 563 | } |
530 | 564 | // Select all boards you've selected AND are allowed to see. |
531 | - elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) |
|
532 | - $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
533 | - else |
|
565 | + elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) { |
|
566 | + $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
567 | + } else |
|
534 | 568 | { |
535 | 569 | $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board'; |
536 | 570 | $request = $smcFunc['db_query']('', ' |
@@ -548,19 +582,22 @@ discard block |
||
548 | 582 | ) |
549 | 583 | ); |
550 | 584 | $search_params['brd'] = array(); |
551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
552 | - $search_params['brd'][] = $row['id_board']; |
|
585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
586 | + $search_params['brd'][] = $row['id_board']; |
|
587 | + } |
|
553 | 588 | $smcFunc['db_free_result']($request); |
554 | 589 | |
555 | 590 | // This error should pro'bly only happen for hackers. |
556 | - if (empty($search_params['brd'])) |
|
557 | - $context['search_errors']['no_boards_selected'] = true; |
|
591 | + if (empty($search_params['brd'])) { |
|
592 | + $context['search_errors']['no_boards_selected'] = true; |
|
593 | + } |
|
558 | 594 | } |
559 | 595 | |
560 | 596 | if (count($search_params['brd']) != 0) |
561 | 597 | { |
562 | - foreach ($search_params['brd'] as $k => $v) |
|
563 | - $search_params['brd'][$k] = (int) $v; |
|
598 | + foreach ($search_params['brd'] as $k => $v) { |
|
599 | + $search_params['brd'][$k] = (int) $v; |
|
600 | + } |
|
564 | 601 | |
565 | 602 | // If we've selected all boards, this parameter can be left empty. |
566 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -574,15 +611,16 @@ discard block |
||
574 | 611 | list ($num_boards) = $smcFunc['db_fetch_row']($request); |
575 | 612 | $smcFunc['db_free_result']($request); |
576 | 613 | |
577 | - if (count($search_params['brd']) == $num_boards) |
|
614 | + if (count($search_params['brd']) == $num_boards) { |
|
615 | + $boardQuery = ''; |
|
616 | + } elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) { |
|
617 | + $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
618 | + } else { |
|
619 | + $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
620 | + } |
|
621 | + } else { |
|
578 | 622 | $boardQuery = ''; |
579 | - elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) |
|
580 | - $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
581 | - else |
|
582 | - $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
583 | 623 | } |
584 | - else |
|
585 | - $boardQuery = ''; |
|
586 | 624 | |
587 | 625 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
588 | 626 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
@@ -596,11 +634,13 @@ discard block |
||
596 | 634 | 'id_msg', |
597 | 635 | ); |
598 | 636 | call_integration_hook('integrate_search_sort_columns', array(&$sort_columns)); |
599 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
600 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
637 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
638 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
639 | + } |
|
601 | 640 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance'; |
602 | - if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') |
|
603 | - $search_params['sort'] = 'id_msg'; |
|
641 | + if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') { |
|
642 | + $search_params['sort'] = 'id_msg'; |
|
643 | + } |
|
604 | 644 | |
605 | 645 | // Sorting direction: descending unless stated otherwise. |
606 | 646 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
@@ -624,17 +664,19 @@ discard block |
||
624 | 664 | // What are we searching for? |
625 | 665 | if (empty($search_params['search'])) |
626 | 666 | { |
627 | - if (isset($_GET['search'])) |
|
628 | - $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
629 | - elseif (isset($_POST['search'])) |
|
630 | - $search_params['search'] = $_POST['search']; |
|
631 | - else |
|
632 | - $search_params['search'] = ''; |
|
667 | + if (isset($_GET['search'])) { |
|
668 | + $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
669 | + } elseif (isset($_POST['search'])) { |
|
670 | + $search_params['search'] = $_POST['search']; |
|
671 | + } else { |
|
672 | + $search_params['search'] = ''; |
|
673 | + } |
|
633 | 674 | } |
634 | 675 | |
635 | 676 | // Nothing?? |
636 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
637 | - $context['search_errors']['invalid_search_string'] = true; |
|
677 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
678 | + $context['search_errors']['invalid_search_string'] = true; |
|
679 | + } |
|
638 | 680 | // Too long? |
639 | 681 | elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit']) |
640 | 682 | { |
@@ -648,8 +690,9 @@ discard block |
||
648 | 690 | $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query)); |
649 | 691 | |
650 | 692 | // This (hidden) setting will do fulltext searching in the most basic way. |
651 | - if (!empty($modSettings['search_simple_fulltext'])) |
|
652 | - $stripped_query = strtr($stripped_query, array('"' => '')); |
|
693 | + if (!empty($modSettings['search_simple_fulltext'])) { |
|
694 | + $stripped_query = strtr($stripped_query, array('"' => '')); |
|
695 | + } |
|
653 | 696 | |
654 | 697 | $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1; |
655 | 698 | |
@@ -672,8 +715,9 @@ discard block |
||
672 | 715 | { |
673 | 716 | if ($word === '-') |
674 | 717 | { |
675 | - if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
676 | - $excludedWords[] = $word; |
|
718 | + if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
719 | + $excludedWords[] = $word; |
|
720 | + } |
|
677 | 721 | unset($phraseArray[$index]); |
678 | 722 | } |
679 | 723 | } |
@@ -683,8 +727,9 @@ discard block |
||
683 | 727 | { |
684 | 728 | if (strpos(trim($word), '-') === 0) |
685 | 729 | { |
686 | - if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
687 | - $excludedWords[] = $word; |
|
730 | + if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
731 | + $excludedWords[] = $word; |
|
732 | + } |
|
688 | 733 | unset($wordArray[$index]); |
689 | 734 | } |
690 | 735 | } |
@@ -697,8 +742,9 @@ discard block |
||
697 | 742 | foreach ($searchArray as $index => $value) |
698 | 743 | { |
699 | 744 | // Skip anything practically empty. |
700 | - if (($searchArray[$index] = trim($value, '-_\' ')) === '') |
|
701 | - unset($searchArray[$index]); |
|
745 | + if (($searchArray[$index] = trim($value, '-_\' ')) === '') { |
|
746 | + unset($searchArray[$index]); |
|
747 | + } |
|
702 | 748 | // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing. |
703 | 749 | elseif (in_array($searchArray[$index], $blacklisted_words)) |
704 | 750 | { |
@@ -716,31 +762,37 @@ discard block |
||
716 | 762 | |
717 | 763 | // Create an array of replacements for highlighting. |
718 | 764 | $context['mark'] = array(); |
719 | - foreach ($searchArray as $word) |
|
720 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
765 | + foreach ($searchArray as $word) { |
|
766 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
767 | + } |
|
721 | 768 | |
722 | 769 | // Initialize two arrays storing the words that have to be searched for. |
723 | 770 | $orParts = array(); |
724 | 771 | $searchWords = array(); |
725 | 772 | |
726 | 773 | // Make sure at least one word is being searched for. |
727 | - if (empty($searchArray)) |
|
728 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
774 | + if (empty($searchArray)) { |
|
775 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
776 | + } |
|
729 | 777 | // All words/sentences must match. |
730 | - elseif (empty($search_params['searchtype'])) |
|
731 | - $orParts[0] = $searchArray; |
|
778 | + elseif (empty($search_params['searchtype'])) { |
|
779 | + $orParts[0] = $searchArray; |
|
780 | + } |
|
732 | 781 | // Any word/sentence must match. |
733 | - else |
|
734 | - foreach ($searchArray as $index => $value) |
|
782 | + else { |
|
783 | + foreach ($searchArray as $index => $value) |
|
735 | 784 | $orParts[$index] = array($value); |
785 | + } |
|
736 | 786 | |
737 | 787 | // Don't allow duplicate error messages if one string is too short. |
738 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
739 | - unset($context['search_errors']['invalid_search_string']); |
|
788 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
789 | + unset($context['search_errors']['invalid_search_string']); |
|
790 | + } |
|
740 | 791 | // Make sure the excluded words are in all or-branches. |
741 | - foreach ($orParts as $orIndex => $andParts) |
|
742 | - foreach ($excludedWords as $word) |
|
792 | + foreach ($orParts as $orIndex => $andParts) { |
|
793 | + foreach ($excludedWords as $word) |
|
743 | 794 | $orParts[$orIndex][] = $word; |
795 | + } |
|
744 | 796 | |
745 | 797 | // Determine the or-branches and the fulltext search words. |
746 | 798 | foreach ($orParts as $orIndex => $andParts) |
@@ -754,8 +806,9 @@ discard block |
||
754 | 806 | ); |
755 | 807 | |
756 | 808 | // Sort the indexed words (large words -> small words -> excluded words). |
757 | - if ($searchAPI->supportsMethod('searchSort')) |
|
758 | - usort($orParts[$orIndex], 'searchSort'); |
|
809 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
810 | + usort($orParts[$orIndex], 'searchSort'); |
|
811 | + } |
|
759 | 812 | |
760 | 813 | foreach ($orParts[$orIndex] as $word) |
761 | 814 | { |
@@ -767,15 +820,17 @@ discard block |
||
767 | 820 | if (!$is_excluded || count($subjectWords) === 1) |
768 | 821 | { |
769 | 822 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
770 | - if ($is_excluded) |
|
771 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
823 | + if ($is_excluded) { |
|
824 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
825 | + } |
|
826 | + } else { |
|
827 | + $excludedPhrases[] = $word; |
|
772 | 828 | } |
773 | - else |
|
774 | - $excludedPhrases[] = $word; |
|
775 | 829 | |
776 | 830 | // Have we got indexes to prepare? |
777 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
778 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
831 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
832 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
833 | + } |
|
779 | 834 | } |
780 | 835 | |
781 | 836 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -783,8 +838,7 @@ discard block |
||
783 | 838 | { |
784 | 839 | $context['search_errors']['query_not_specific_enough'] = true; |
785 | 840 | break; |
786 | - } |
|
787 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
841 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
788 | 842 | { |
789 | 843 | $context['search_errors']['query_not_specific_enough'] = true; |
790 | 844 | break; |
@@ -812,8 +866,9 @@ discard block |
||
812 | 866 | $found_misspelling = false; |
813 | 867 | foreach ($searchArray as $word) |
814 | 868 | { |
815 | - if (empty($link)) |
|
816 | - continue; |
|
869 | + if (empty($link)) { |
|
870 | + continue; |
|
871 | + } |
|
817 | 872 | |
818 | 873 | // Don't check phrases. |
819 | 874 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -828,8 +883,7 @@ discard block |
||
828 | 883 | $did_you_mean['search'][] = $word; |
829 | 884 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
830 | 885 | continue; |
831 | - } |
|
832 | - elseif (spell_check($link, $word)) |
|
886 | + } elseif (spell_check($link, $word)) |
|
833 | 887 | { |
834 | 888 | $did_you_mean['search'][] = $word; |
835 | 889 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -840,11 +894,13 @@ discard block |
||
840 | 894 | foreach ($suggestions as $i => $s) |
841 | 895 | { |
842 | 896 | // Search is case insensitive. |
843 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
844 | - unset($suggestions[$i]); |
|
897 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
898 | + unset($suggestions[$i]); |
|
899 | + } |
|
845 | 900 | // Plus, don't suggest something the user thinks is rude! |
846 | - elseif ($suggestions[$i] != censorText($s)) |
|
847 | - unset($suggestions[$i]); |
|
901 | + elseif ($suggestions[$i] != censorText($s)) { |
|
902 | + unset($suggestions[$i]); |
|
903 | + } |
|
848 | 904 | } |
849 | 905 | |
850 | 906 | // Anything found? If so, correct it! |
@@ -854,8 +910,7 @@ discard block |
||
854 | 910 | $did_you_mean['search'][] = $suggestions[0]; |
855 | 911 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
856 | 912 | $found_misspelling = true; |
857 | - } |
|
858 | - else |
|
913 | + } else |
|
859 | 914 | { |
860 | 915 | $did_you_mean['search'][] = $word; |
861 | 916 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -872,8 +927,7 @@ discard block |
||
872 | 927 | { |
873 | 928 | $temp_excluded['search'][] = '-"' . $word . '"'; |
874 | 929 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
875 | - } |
|
876 | - else |
|
930 | + } else |
|
877 | 931 | { |
878 | 932 | $temp_excluded['search'][] = '-' . $word; |
879 | 933 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -885,11 +939,13 @@ discard block |
||
885 | 939 | |
886 | 940 | $temp_params = $search_params; |
887 | 941 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
888 | - if (isset($temp_params['brd'])) |
|
889 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
942 | + if (isset($temp_params['brd'])) { |
|
943 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
944 | + } |
|
890 | 945 | $context['params'] = array(); |
891 | - foreach ($temp_params as $k => $v) |
|
892 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
946 | + foreach ($temp_params as $k => $v) { |
|
947 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
948 | + } |
|
893 | 949 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
894 | 950 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
895 | 951 | } |
@@ -897,18 +953,20 @@ discard block |
||
897 | 953 | |
898 | 954 | // Let the user adjust the search query, should they wish? |
899 | 955 | $context['search_params'] = $search_params; |
900 | - if (isset($context['search_params']['search'])) |
|
901 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
902 | - if (isset($context['search_params']['userspec'])) |
|
903 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
956 | + if (isset($context['search_params']['search'])) { |
|
957 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
958 | + } |
|
959 | + if (isset($context['search_params']['userspec'])) { |
|
960 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
961 | + } |
|
904 | 962 | |
905 | 963 | // Do we have captcha enabled? |
906 | 964 | if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])) |
907 | 965 | { |
908 | 966 | // If we come from another search box tone down the error... |
909 | - if (!isset($_REQUEST['search_vv'])) |
|
910 | - $context['search_errors']['need_verification_code'] = true; |
|
911 | - else |
|
967 | + if (!isset($_REQUEST['search_vv'])) { |
|
968 | + $context['search_errors']['need_verification_code'] = true; |
|
969 | + } else |
|
912 | 970 | { |
913 | 971 | require_once($sourcedir . '/Subs-Editor.php'); |
914 | 972 | $verificationOptions = array( |
@@ -918,12 +976,14 @@ discard block |
||
918 | 976 | |
919 | 977 | if (is_array($context['require_verification'])) |
920 | 978 | { |
921 | - foreach ($context['require_verification'] as $error) |
|
922 | - $context['search_errors'][$error] = true; |
|
979 | + foreach ($context['require_verification'] as $error) { |
|
980 | + $context['search_errors'][$error] = true; |
|
981 | + } |
|
923 | 982 | } |
924 | 983 | // Don't keep asking for it - they've proven themselves worthy. |
925 | - else |
|
926 | - $_SESSION['ss_vv_passed'] = true; |
|
984 | + else { |
|
985 | + $_SESSION['ss_vv_passed'] = true; |
|
986 | + } |
|
927 | 987 | } |
928 | 988 | } |
929 | 989 | |
@@ -931,19 +991,22 @@ discard block |
||
931 | 991 | |
932 | 992 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
933 | 993 | $temp_params = $search_params; |
934 | - if (isset($temp_params['brd'])) |
|
935 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
994 | + if (isset($temp_params['brd'])) { |
|
995 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
996 | + } |
|
936 | 997 | $context['params'] = array(); |
937 | - foreach ($temp_params as $k => $v) |
|
938 | - $context['params'][] = $k . '|\'|' . $v; |
|
998 | + foreach ($temp_params as $k => $v) { |
|
999 | + $context['params'][] = $k . '|\'|' . $v; |
|
1000 | + } |
|
939 | 1001 | |
940 | 1002 | if (!empty($context['params'])) |
941 | 1003 | { |
942 | 1004 | // Due to old IE's 2083 character limit, we have to compress long search strings |
943 | 1005 | $params = @gzcompress(implode('|"|', $context['params'])); |
944 | 1006 | // Gzcompress failed, use try non-gz |
945 | - if (empty($params)) |
|
946 | - $params = implode('|"|', $context['params']); |
|
1007 | + if (empty($params)) { |
|
1008 | + $params = implode('|"|', $context['params']); |
|
1009 | + } |
|
947 | 1010 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
948 | 1011 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
949 | 1012 | } |
@@ -969,8 +1032,9 @@ discard block |
||
969 | 1032 | } |
970 | 1033 | |
971 | 1034 | // Spam me not, Spam-a-lot? |
972 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
973 | - spamProtection('search'); |
|
1035 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
1036 | + spamProtection('search'); |
|
1037 | + } |
|
974 | 1038 | // Store the last search string to allow pages of results to be browsed. |
975 | 1039 | $_SESSION['last_ss'] = $search_params['search']; |
976 | 1040 | |
@@ -1030,8 +1094,9 @@ discard block |
||
1030 | 1094 | 'where' => array(), |
1031 | 1095 | ); |
1032 | 1096 | |
1033 | - if ($modSettings['postmod_active']) |
|
1034 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1097 | + if ($modSettings['postmod_active']) { |
|
1098 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1099 | + } |
|
1035 | 1100 | |
1036 | 1101 | $numTables = 0; |
1037 | 1102 | $prev_join = 0; |
@@ -1043,8 +1108,7 @@ discard block |
||
1043 | 1108 | { |
1044 | 1109 | $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)'; |
1045 | 1110 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1046 | - } |
|
1047 | - else |
|
1111 | + } else |
|
1048 | 1112 | { |
1049 | 1113 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
1050 | 1114 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1062,14 +1126,18 @@ discard block |
||
1062 | 1126 | } |
1063 | 1127 | $subject_query['where'][] = $userQuery; |
1064 | 1128 | } |
1065 | - if (!empty($search_params['topic'])) |
|
1066 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1067 | - if (!empty($minMsgID)) |
|
1068 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1069 | - if (!empty($maxMsgID)) |
|
1070 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1071 | - if (!empty($boardQuery)) |
|
1072 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1129 | + if (!empty($search_params['topic'])) { |
|
1130 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1131 | + } |
|
1132 | + if (!empty($minMsgID)) { |
|
1133 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1134 | + } |
|
1135 | + if (!empty($maxMsgID)) { |
|
1136 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1137 | + } |
|
1138 | + if (!empty($boardQuery)) { |
|
1139 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1140 | + } |
|
1073 | 1141 | if (!empty($excludedPhrases)) |
1074 | 1142 | { |
1075 | 1143 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1089,8 +1157,9 @@ discard block |
||
1089 | 1157 | foreach ($weight_factors as $type => $value) |
1090 | 1158 | { |
1091 | 1159 | $relevance .= $weight[$type]; |
1092 | - if (!empty($value['results'])) |
|
1093 | - $relevance .= ' * ' . $value['results']; |
|
1160 | + if (!empty($value['results'])) { |
|
1161 | + $relevance .= ' * ' . $value['results']; |
|
1162 | + } |
|
1094 | 1163 | $relevance .= ' + '; |
1095 | 1164 | } |
1096 | 1165 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1128,20 +1197,23 @@ discard block |
||
1128 | 1197 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1129 | 1198 | { |
1130 | 1199 | // No duplicates! |
1131 | - if (isset($inserts[$row[1]])) |
|
1132 | - continue; |
|
1200 | + if (isset($inserts[$row[1]])) { |
|
1201 | + continue; |
|
1202 | + } |
|
1133 | 1203 | |
1134 | - foreach ($row as $key => $value) |
|
1135 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
1204 | + foreach ($row as $key => $value) { |
|
1205 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
1206 | + } |
|
1136 | 1207 | } |
1137 | 1208 | $smcFunc['db_free_result']($ignoreRequest); |
1138 | 1209 | $numSubjectResults = count($inserts); |
1210 | + } else { |
|
1211 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1139 | 1212 | } |
1140 | - else |
|
1141 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1142 | 1213 | |
1143 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1144 | - break; |
|
1214 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1215 | + break; |
|
1216 | + } |
|
1145 | 1217 | } |
1146 | 1218 | |
1147 | 1219 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1156,8 +1228,7 @@ discard block |
||
1156 | 1228 | } |
1157 | 1229 | |
1158 | 1230 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
1159 | - } |
|
1160 | - else |
|
1231 | + } else |
|
1161 | 1232 | { |
1162 | 1233 | $main_query = array( |
1163 | 1234 | 'select' => array( |
@@ -1189,8 +1260,7 @@ discard block |
||
1189 | 1260 | $main_query['weights'] = $weight_factors; |
1190 | 1261 | |
1191 | 1262 | $main_query['group_by'][] = 't.id_topic'; |
1192 | - } |
|
1193 | - else |
|
1263 | + } else |
|
1194 | 1264 | { |
1195 | 1265 | // This is outrageous! |
1196 | 1266 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1211,8 +1281,9 @@ discard block |
||
1211 | 1281 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
1212 | 1282 | $main_query['parameters']['topic'] = $search_params['topic']; |
1213 | 1283 | } |
1214 | - if (!empty($search_params['show_complete'])) |
|
1215 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1284 | + if (!empty($search_params['show_complete'])) { |
|
1285 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1286 | + } |
|
1216 | 1287 | } |
1217 | 1288 | |
1218 | 1289 | // *** Get the subject results. |
@@ -1239,14 +1310,15 @@ discard block |
||
1239 | 1310 | ) !== false; |
1240 | 1311 | |
1241 | 1312 | // Clean up some previous cache. |
1242 | - if (!$createTemporary) |
|
1243 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1313 | + if (!$createTemporary) { |
|
1314 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1244 | 1315 | DELETE FROM {db_prefix}log_search_topics |
1245 | 1316 | WHERE id_search = {int:search_id}', |
1246 | 1317 | array( |
1247 | 1318 | 'search_id' => $_SESSION['search_cache']['id_search'], |
1248 | 1319 | ) |
1249 | 1320 | ); |
1321 | + } |
|
1250 | 1322 | |
1251 | 1323 | foreach ($searchWords as $orIndex => $words) |
1252 | 1324 | { |
@@ -1278,8 +1350,7 @@ discard block |
||
1278 | 1350 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1279 | 1351 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
1280 | 1352 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
1281 | - } |
|
1282 | - else |
|
1353 | + } else |
|
1283 | 1354 | { |
1284 | 1355 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
1285 | 1356 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1334,8 +1405,9 @@ discard block |
||
1334 | 1405 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
1335 | 1406 | |
1336 | 1407 | // Nothing to search for? |
1337 | - if (empty($subject_query['where'])) |
|
1338 | - continue; |
|
1408 | + if (empty($subject_query['where'])) { |
|
1409 | + continue; |
|
1410 | + } |
|
1339 | 1411 | |
1340 | 1412 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
1341 | 1413 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1358,19 +1430,21 @@ discard block |
||
1358 | 1430 | { |
1359 | 1431 | $ind = $createTemporary ? 0 : 1; |
1360 | 1432 | // No duplicates! |
1361 | - if (isset($inserts[$row[$ind]])) |
|
1362 | - continue; |
|
1433 | + if (isset($inserts[$row[$ind]])) { |
|
1434 | + continue; |
|
1435 | + } |
|
1363 | 1436 | |
1364 | 1437 | $inserts[$row[$ind]] = $row; |
1365 | 1438 | } |
1366 | 1439 | $smcFunc['db_free_result']($ignoreRequest); |
1367 | 1440 | $numSubjectResults = count($inserts); |
1441 | + } else { |
|
1442 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1368 | 1443 | } |
1369 | - else |
|
1370 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1371 | 1444 | |
1372 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1373 | - break; |
|
1445 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1446 | + break; |
|
1447 | + } |
|
1374 | 1448 | } |
1375 | 1449 | |
1376 | 1450 | // Got some non-MySQL data to plonk in? |
@@ -1388,8 +1462,9 @@ discard block |
||
1388 | 1462 | { |
1389 | 1463 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
1390 | 1464 | $main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)'; |
1391 | - if (!$createTemporary) |
|
1392 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1465 | + if (!$createTemporary) { |
|
1466 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1467 | + } |
|
1393 | 1468 | } |
1394 | 1469 | } |
1395 | 1470 | |
@@ -1417,14 +1492,15 @@ discard block |
||
1417 | 1492 | ) !== false; |
1418 | 1493 | |
1419 | 1494 | // Clear, all clear! |
1420 | - if (!$createTemporary) |
|
1421 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1495 | + if (!$createTemporary) { |
|
1496 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1422 | 1497 | DELETE FROM {db_prefix}log_search_messages |
1423 | 1498 | WHERE id_search = {int:id_search}', |
1424 | 1499 | array( |
1425 | 1500 | 'id_search' => $_SESSION['search_cache']['id_search'], |
1426 | 1501 | ) |
1427 | 1502 | ); |
1503 | + } |
|
1428 | 1504 | |
1429 | 1505 | foreach ($searchWords as $orIndex => $words) |
1430 | 1506 | { |
@@ -1458,19 +1534,21 @@ discard block |
||
1458 | 1534 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1459 | 1535 | { |
1460 | 1536 | // No duplicates! |
1461 | - if (isset($inserts[$row[0]])) |
|
1462 | - continue; |
|
1537 | + if (isset($inserts[$row[0]])) { |
|
1538 | + continue; |
|
1539 | + } |
|
1463 | 1540 | |
1464 | 1541 | $inserts[$row[0]] = $row; |
1465 | 1542 | } |
1466 | 1543 | $smcFunc['db_free_result']($ignoreRequest); |
1467 | 1544 | $indexedResults = count($inserts); |
1545 | + } else { |
|
1546 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
1468 | 1547 | } |
1469 | - else |
|
1470 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
1471 | 1548 | |
1472 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
1473 | - break; |
|
1549 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
1550 | + break; |
|
1551 | + } |
|
1474 | 1552 | } |
1475 | 1553 | } |
1476 | 1554 | |
@@ -1490,8 +1568,7 @@ discard block |
||
1490 | 1568 | $context['search_errors']['query_not_specific_enough'] = true; |
1491 | 1569 | $_REQUEST['params'] = $context['params']; |
1492 | 1570 | return PlushSearch1(); |
1493 | - } |
|
1494 | - elseif (!empty($indexedResults)) |
|
1571 | + } elseif (!empty($indexedResults)) |
|
1495 | 1572 | { |
1496 | 1573 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
1497 | 1574 | if (!$createTemporary) |
@@ -1513,15 +1590,18 @@ discard block |
||
1513 | 1590 | foreach ($words['all_words'] as $regularWord) |
1514 | 1591 | { |
1515 | 1592 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
1516 | - if (in_array($regularWord, $excludedWords)) |
|
1517 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1593 | + if (in_array($regularWord, $excludedWords)) { |
|
1594 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1595 | + } |
|
1518 | 1596 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
1519 | 1597 | } |
1520 | - if (!empty($where)) |
|
1521 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1598 | + if (!empty($where)) { |
|
1599 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1600 | + } |
|
1601 | + } |
|
1602 | + if (!empty($orWhere)) { |
|
1603 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1522 | 1604 | } |
1523 | - if (!empty($orWhere)) |
|
1524 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1525 | 1605 | |
1526 | 1606 | if (!empty($userQuery)) |
1527 | 1607 | { |
@@ -1559,8 +1639,9 @@ discard block |
||
1559 | 1639 | foreach ($main_query['weights'] as $type => $value) |
1560 | 1640 | { |
1561 | 1641 | $relevance .= $weight[$type]; |
1562 | - if (!empty($value['search'])) |
|
1563 | - $relevance .= ' * ' . $value['search']; |
|
1642 | + if (!empty($value['search'])) { |
|
1643 | + $relevance .= ' * ' . $value['search']; |
|
1644 | + } |
|
1564 | 1645 | $relevance .= ' + '; |
1565 | 1646 | $new_weight_total += $weight[$type]; |
1566 | 1647 | } |
@@ -1591,11 +1672,13 @@ discard block |
||
1591 | 1672 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1592 | 1673 | { |
1593 | 1674 | // No duplicates! |
1594 | - if (isset($inserts[$row[2]])) |
|
1595 | - continue; |
|
1675 | + if (isset($inserts[$row[2]])) { |
|
1676 | + continue; |
|
1677 | + } |
|
1596 | 1678 | |
1597 | - foreach ($row as $key => $value) |
|
1598 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
1679 | + foreach ($row as $key => $value) { |
|
1680 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
1681 | + } |
|
1599 | 1682 | } |
1600 | 1683 | $smcFunc['db_free_result']($ignoreRequest); |
1601 | 1684 | |
@@ -1603,8 +1686,9 @@ discard block |
||
1603 | 1686 | if (!empty($inserts)) |
1604 | 1687 | { |
1605 | 1688 | $query_columns = array(); |
1606 | - foreach ($main_query['select'] as $k => $v) |
|
1607 | - $query_columns[$k] = 'int'; |
|
1689 | + foreach ($main_query['select'] as $k => $v) { |
|
1690 | + $query_columns[$k] = 'int'; |
|
1691 | + } |
|
1608 | 1692 | |
1609 | 1693 | $smcFunc['db_insert']('', |
1610 | 1694 | '{db_prefix}log_search_results', |
@@ -1614,21 +1698,23 @@ discard block |
||
1614 | 1698 | ); |
1615 | 1699 | } |
1616 | 1700 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1701 | + } else { |
|
1702 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1617 | 1703 | } |
1618 | - else |
|
1619 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1620 | 1704 | } |
1621 | 1705 | |
1622 | 1706 | // Insert subject-only matches. |
1623 | 1707 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
1624 | 1708 | { |
1625 | 1709 | $relevance = '1000 * ('; |
1626 | - foreach ($weight_factors as $type => $value) |
|
1627 | - if (isset($value['results'])) |
|
1710 | + foreach ($weight_factors as $type => $value) { |
|
1711 | + if (isset($value['results'])) |
|
1628 | 1712 | { |
1629 | 1713 | $relevance .= $weight[$type]; |
1630 | - if (!empty($value['results'])) |
|
1631 | - $relevance .= ' * ' . $value['results']; |
|
1714 | + } |
|
1715 | + if (!empty($value['results'])) { |
|
1716 | + $relevance .= ' * ' . $value['results']; |
|
1717 | + } |
|
1632 | 1718 | $relevance .= ' + '; |
1633 | 1719 | } |
1634 | 1720 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1662,8 +1748,9 @@ discard block |
||
1662 | 1748 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1663 | 1749 | { |
1664 | 1750 | // No duplicates! |
1665 | - if (isset($usedIDs[$row[1]])) |
|
1666 | - continue; |
|
1751 | + if (isset($usedIDs[$row[1]])) { |
|
1752 | + continue; |
|
1753 | + } |
|
1667 | 1754 | |
1668 | 1755 | $usedIDs[$row[1]] = true; |
1669 | 1756 | $inserts[] = $row; |
@@ -1681,12 +1768,12 @@ discard block |
||
1681 | 1768 | ); |
1682 | 1769 | } |
1683 | 1770 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1771 | + } else { |
|
1772 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1684 | 1773 | } |
1685 | - else |
|
1686 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1774 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
1775 | + $_SESSION['search_cache']['num_results'] = 0; |
|
1687 | 1776 | } |
1688 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
1689 | - $_SESSION['search_cache']['num_results'] = 0; |
|
1690 | 1777 | } |
1691 | 1778 | } |
1692 | 1779 | |
@@ -1756,14 +1843,16 @@ discard block |
||
1756 | 1843 | ) |
1757 | 1844 | ); |
1758 | 1845 | $posters = array(); |
1759 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1760 | - $posters[] = $row['id_member']; |
|
1846 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1847 | + $posters[] = $row['id_member']; |
|
1848 | + } |
|
1761 | 1849 | $smcFunc['db_free_result']($request); |
1762 | 1850 | |
1763 | 1851 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
1764 | 1852 | |
1765 | - if (!empty($posters)) |
|
1766 | - loadMemberData(array_unique($posters)); |
|
1853 | + if (!empty($posters)) { |
|
1854 | + loadMemberData(array_unique($posters)); |
|
1855 | + } |
|
1767 | 1856 | |
1768 | 1857 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
1769 | 1858 | $messages_request = $smcFunc['db_query']('', ' |
@@ -1797,8 +1886,9 @@ discard block |
||
1797 | 1886 | ); |
1798 | 1887 | |
1799 | 1888 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
1800 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
1801 | - $context['topics'] = array(); |
|
1889 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
1890 | + $context['topics'] = array(); |
|
1891 | + } |
|
1802 | 1892 | |
1803 | 1893 | // If we want to know who participated in what then load this now. |
1804 | 1894 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1816,8 +1906,9 @@ discard block |
||
1816 | 1906 | 'limit' => count($participants), |
1817 | 1907 | ) |
1818 | 1908 | ); |
1819 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1820 | - $participants[$row['id_topic']] = true; |
|
1909 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1910 | + $participants[$row['id_topic']] = true; |
|
1911 | + } |
|
1821 | 1912 | $smcFunc['db_free_result']($result); |
1822 | 1913 | } |
1823 | 1914 | } |
@@ -1826,15 +1917,17 @@ discard block |
||
1826 | 1917 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
1827 | 1918 | |
1828 | 1919 | // Consider the search complete! |
1829 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1830 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1920 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1921 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1922 | + } |
|
1831 | 1923 | |
1832 | 1924 | $context['key_words'] = &$searchArray; |
1833 | 1925 | |
1834 | 1926 | // Setup the default topic icons... for checking they exist and the like! |
1835 | 1927 | $context['icon_sources'] = array(); |
1836 | - foreach ($context['stable_icons'] as $icon) |
|
1837 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1928 | + foreach ($context['stable_icons'] as $icon) { |
|
1929 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1930 | + } |
|
1838 | 1931 | |
1839 | 1932 | $context['sub_template'] = 'results'; |
1840 | 1933 | $context['page_title'] = $txt['search_results']; |
@@ -1865,26 +1958,31 @@ discard block |
||
1865 | 1958 | global $boards_can, $participants, $smcFunc; |
1866 | 1959 | static $recycle_board = null; |
1867 | 1960 | |
1868 | - if ($recycle_board === null) |
|
1869 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1961 | + if ($recycle_board === null) { |
|
1962 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1963 | + } |
|
1870 | 1964 | |
1871 | 1965 | // Remember which message this is. (ie. reply #83) |
1872 | 1966 | static $counter = null; |
1873 | - if ($counter == null || $reset) |
|
1874 | - $counter = $_REQUEST['start'] + 1; |
|
1967 | + if ($counter == null || $reset) { |
|
1968 | + $counter = $_REQUEST['start'] + 1; |
|
1969 | + } |
|
1875 | 1970 | |
1876 | 1971 | // If the query returned false, bail. |
1877 | - if ($messages_request == false) |
|
1878 | - return false; |
|
1972 | + if ($messages_request == false) { |
|
1973 | + return false; |
|
1974 | + } |
|
1879 | 1975 | |
1880 | 1976 | // Start from the beginning... |
1881 | - if ($reset) |
|
1882 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1977 | + if ($reset) { |
|
1978 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1979 | + } |
|
1883 | 1980 | |
1884 | 1981 | // Attempt to get the next message. |
1885 | 1982 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1886 | - if (!$message) |
|
1887 | - return false; |
|
1983 | + if (!$message) { |
|
1984 | + return false; |
|
1985 | + } |
|
1888 | 1986 | |
1889 | 1987 | // Can't have an empty subject can we? |
1890 | 1988 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1923,9 +2021,9 @@ discard block |
||
1923 | 2021 | |
1924 | 2022 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
1925 | 2023 | { |
1926 | - if (empty($context['key_words'])) |
|
1927 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
1928 | - else |
|
2024 | + if (empty($context['key_words'])) { |
|
2025 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
2026 | + } else |
|
1929 | 2027 | { |
1930 | 2028 | $matchString = ''; |
1931 | 2029 | $force_partial_word = false; |
@@ -1934,18 +2032,20 @@ discard block |
||
1934 | 2032 | $keyword = un_htmlspecialchars($keyword); |
1935 | 2033 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
1936 | 2034 | |
1937 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
1938 | - $force_partial_word = true; |
|
2035 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
2036 | + $force_partial_word = true; |
|
2037 | + } |
|
1939 | 2038 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
1940 | 2039 | } |
1941 | 2040 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
1942 | 2041 | |
1943 | 2042 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
1944 | 2043 | |
1945 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
1946 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
1947 | - else |
|
1948 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2044 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
2045 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2046 | + } else { |
|
2047 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2048 | + } |
|
1949 | 2049 | |
1950 | 2050 | $message['body'] = ''; |
1951 | 2051 | foreach ($matches[0] as $index => $match) |
@@ -1958,8 +2058,7 @@ discard block |
||
1958 | 2058 | // Re-fix the international characters. |
1959 | 2059 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
1960 | 2060 | } |
1961 | - } |
|
1962 | - else |
|
2061 | + } else |
|
1963 | 2062 | { |
1964 | 2063 | // Run BBC interpreter on the message. |
1965 | 2064 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1978,21 +2077,26 @@ discard block |
||
1978 | 2077 | // Sadly, we need to check the icon ain't broke. |
1979 | 2078 | if (!empty($modSettings['messageIconChecks_enable'])) |
1980 | 2079 | { |
1981 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1982 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1983 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1984 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1985 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1986 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1987 | - } |
|
1988 | - else |
|
2080 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2081 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2082 | + } |
|
2083 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2084 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2085 | + } |
|
2086 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2087 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2088 | + } |
|
2089 | + } else |
|
1989 | 2090 | { |
1990 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1991 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
1992 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1993 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
1994 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1995 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2091 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2092 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2093 | + } |
|
2094 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2095 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2096 | + } |
|
2097 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2098 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2099 | + } |
|
1996 | 2100 | } |
1997 | 2101 | |
1998 | 2102 | // Do we have quote tag enabled? |
@@ -2002,12 +2106,14 @@ discard block |
||
2002 | 2106 | $colorClass = 'windowbg'; |
2003 | 2107 | |
2004 | 2108 | // Sticky topics should get a different color, too. |
2005 | - if ($message['is_sticky']) |
|
2006 | - $colorClass .= ' sticky'; |
|
2109 | + if ($message['is_sticky']) { |
|
2110 | + $colorClass .= ' sticky'; |
|
2111 | + } |
|
2007 | 2112 | |
2008 | 2113 | // Locked topics get special treatment as well. |
2009 | - if ($message['locked']) |
|
2010 | - $colorClass .= ' locked'; |
|
2114 | + if ($message['locked']) { |
|
2115 | + $colorClass .= ' locked'; |
|
2116 | + } |
|
2011 | 2117 | |
2012 | 2118 | $output = array_merge($context['topics'][$message['id_msg']], array( |
2013 | 2119 | 'id' => $message['id_topic'], |
@@ -2151,8 +2257,9 @@ discard block |
||
2151 | 2257 | |
2152 | 2258 | // Load up the search API we are going to use. |
2153 | 2259 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
2154 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
2155 | - fatal_lang_error('search_api_missing'); |
|
2260 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
2261 | + fatal_lang_error('search_api_missing'); |
|
2262 | + } |
|
2156 | 2263 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
2157 | 2264 | |
2158 | 2265 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
93 | 93 | |
94 | - $pg_tables = array('pg_catalog','information_schema'); |
|
94 | + $pg_tables = array('pg_catalog', 'information_schema'); |
|
95 | 95 | |
96 | 96 | $request = $smcFunc['db_query']('', ' |
97 | 97 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | { |
290 | 290 | static $ver; |
291 | 291 | |
292 | - if(!empty($ver)) |
|
292 | + if (!empty($ver)) |
|
293 | 293 | return $ver; |
294 | 294 | |
295 | 295 | global $smcFunc; |
@@ -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 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_engine' => 'smf_db_get_engine', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -48,13 +50,14 @@ discard block |
||
48 | 50 | |
49 | 51 | // Do we need to drop it first? |
50 | 52 | $tables = smf_db_list_tables(false, $backup_table); |
51 | - if (!empty($tables)) |
|
52 | - $smcFunc['db_query']('', ' |
|
53 | + if (!empty($tables)) { |
|
54 | + $smcFunc['db_query']('', ' |
|
53 | 55 | DROP TABLE {raw:backup_table}', |
54 | 56 | array( |
55 | 57 | 'backup_table' => $backup_table, |
56 | 58 | ) |
57 | 59 | ); |
60 | + } |
|
58 | 61 | |
59 | 62 | /** |
60 | 63 | * @todo Should we create backups of sequences as well? |
@@ -117,8 +120,9 @@ discard block |
||
117 | 120 | ) |
118 | 121 | ); |
119 | 122 | |
120 | - if (!$request) |
|
121 | - return -1; |
|
123 | + if (!$request) { |
|
124 | + return -1; |
|
125 | + } |
|
122 | 126 | |
123 | 127 | $request = $smcFunc['db_query']('', ' |
124 | 128 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -136,11 +140,12 @@ discard block |
||
136 | 140 | $row = $smcFunc['db_fetch_assoc']($request); |
137 | 141 | $smcFunc['db_free_result']($request); |
138 | 142 | |
139 | - if (isset($row['size'])) |
|
140 | - return ($old_size - $row['size']) / 1024; |
|
141 | - else |
|
142 | - return 0; |
|
143 | -} |
|
143 | + if (isset($row['size'])) { |
|
144 | + return ($old_size - $row['size']) / 1024; |
|
145 | + } else { |
|
146 | + return 0; |
|
147 | + } |
|
148 | + } |
|
144 | 149 | |
145 | 150 | /** |
146 | 151 | * This function lists all tables in the database. |
@@ -167,8 +172,9 @@ discard block |
||
167 | 172 | ); |
168 | 173 | |
169 | 174 | $tables = array(); |
170 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
171 | - $tables[] = $row[0]; |
|
175 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
176 | + $tables[] = $row[0]; |
|
177 | + } |
|
172 | 178 | $smcFunc['db_free_result']($request); |
173 | 179 | |
174 | 180 | return $tables; |
@@ -209,12 +215,14 @@ discard block |
||
209 | 215 | ); |
210 | 216 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
211 | 217 | { |
212 | - if ($row['data_type'] == 'character varying') |
|
213 | - $row['data_type'] = 'varchar'; |
|
214 | - elseif ($row['data_type'] == 'character') |
|
215 | - $row['data_type'] = 'char'; |
|
216 | - if ($row['character_maximum_length']) |
|
217 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
218 | + if ($row['data_type'] == 'character varying') { |
|
219 | + $row['data_type'] = 'varchar'; |
|
220 | + } elseif ($row['data_type'] == 'character') { |
|
221 | + $row['data_type'] = 'char'; |
|
222 | + } |
|
223 | + if ($row['character_maximum_length']) { |
|
224 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
225 | + } |
|
218 | 226 | |
219 | 227 | // Make the CREATE for this column. |
220 | 228 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -265,13 +273,14 @@ discard block |
||
265 | 273 | { |
266 | 274 | if ($row['is_primary']) |
267 | 275 | { |
268 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
269 | - continue; |
|
276 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
277 | + continue; |
|
278 | + } |
|
270 | 279 | |
271 | 280 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
281 | + } else { |
|
282 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
272 | 283 | } |
273 | - else |
|
274 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
275 | 284 | } |
276 | 285 | $smcFunc['db_free_result']($result); |
277 | 286 | |
@@ -289,8 +298,9 @@ discard block |
||
289 | 298 | { |
290 | 299 | static $ver; |
291 | 300 | |
292 | - if(!empty($ver)) |
|
293 | - return $ver; |
|
301 | + if(!empty($ver)) { |
|
302 | + return $ver; |
|
303 | + } |
|
294 | 304 | |
295 | 305 | global $smcFunc; |
296 | 306 |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | if (!$this->connection) |
794 | 794 | { |
795 | 795 | $this->error = 'bad_server'; |
796 | - $this->last_message = 'Invalid Server'; |
|
796 | + $this->last_message = 'Invalid Server'; |
|
797 | 797 | return; |
798 | 798 | } |
799 | 799 | |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | if (!$this->check_response(220)) |
802 | 802 | { |
803 | 803 | $this->error = 'bad_response'; |
804 | - $this->last_message = 'Bad Response'; |
|
804 | + $this->last_message = 'Bad Response'; |
|
805 | 805 | return; |
806 | 806 | } |
807 | 807 |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * of elements, an array of xmlArray's is returned for use with foreach. |
258 | 258 | * Example use: |
259 | 259 | * foreach ($xml->set('html/body/p') as $p) |
260 | - * @param $path string The path to search for. |
|
260 | + * @param string $path string The path to search for. |
|
261 | 261 | * @return xmlArray[] An array of xmlArray objects |
262 | 262 | */ |
263 | 263 | public function set($path) |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | * Changes a files atrributes (chmod) |
856 | 856 | * |
857 | 857 | * @param string $ftp_file The file to CHMOD |
858 | - * @param int|string $chmod The value for the CHMOD operation |
|
858 | + * @param integer $chmod The value for the CHMOD operation |
|
859 | 859 | * @return boolean Whether or not the operation was successful |
860 | 860 | */ |
861 | 861 | public function chmod($ftp_file, $chmod) |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | * |
1026 | 1026 | * @param string $ftp_path The path to the directory |
1027 | 1027 | * @param bool $search Whether or not to get a recursive directory listing |
1028 | - * @return string|boolean The results of the command or false if unsuccessful |
|
1028 | + * @return false|string The results of the command or false if unsuccessful |
|
1029 | 1029 | */ |
1030 | 1030 | public function list_dir($ftp_path = '', $search = false) |
1031 | 1031 | { |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | * |
1071 | 1071 | * @param string $file The name of a file |
1072 | 1072 | * @param string $listing A directory listing or null to generate one |
1073 | - * @return string|boolean The name of the file or false if it wasn't found |
|
1073 | + * @return string|false The name of the file or false if it wasn't found |
|
1074 | 1074 | */ |
1075 | 1075 | public function locate($file, $listing = null) |
1076 | 1076 | { |
@@ -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 | * Class xmlArray |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | } |
66 | 67 | |
67 | 68 | // Is the input an array? (ie. passed from file()?) |
68 | - if (is_array($data)) |
|
69 | - $data = implode('', $data); |
|
69 | + if (is_array($data)) { |
|
70 | + $data = implode('', $data); |
|
71 | + } |
|
70 | 72 | |
71 | 73 | // Remove any xml declaration or doctype, and parse out comments and CDATA. |
72 | 74 | $data = preg_replace('/<!--.*?-->/s', '', $this->_to_cdata(preg_replace(array('/^<\?xml.+?\?' . '>/is', '/<!DOCTYPE[^>]+?' . '>/s'), '', $data))); |
@@ -101,8 +103,9 @@ discard block |
||
101 | 103 | // Get the element, in array form. |
102 | 104 | $array = $this->path($path); |
103 | 105 | |
104 | - if ($array === false) |
|
105 | - return false; |
|
106 | + if ($array === false) { |
|
107 | + return false; |
|
108 | + } |
|
106 | 109 | |
107 | 110 | // Getting elements into this is a bit complicated... |
108 | 111 | if ($get_elements && !is_string($array)) |
@@ -113,8 +116,9 @@ discard block |
||
113 | 116 | foreach ($array->array as $val) |
114 | 117 | { |
115 | 118 | // Skip the name and any attributes. |
116 | - if (is_array($val)) |
|
117 | - $temp .= $this->_xml($val, null); |
|
119 | + if (is_array($val)) { |
|
120 | + $temp .= $this->_xml($val, null); |
|
121 | + } |
|
118 | 122 | } |
119 | 123 | |
120 | 124 | // Just get the XML data and then take out the CDATAs. |
@@ -156,32 +160,35 @@ discard block |
||
156 | 160 | elseif (substr($el, 0, 1) == '@') |
157 | 161 | { |
158 | 162 | // It simplifies things if the attribute is already there ;). |
159 | - if (isset($array[$el])) |
|
160 | - return $array[$el]; |
|
161 | - else |
|
163 | + if (isset($array[$el])) { |
|
164 | + return $array[$el]; |
|
165 | + } else |
|
162 | 166 | { |
163 | 167 | $trace = debug_backtrace(); |
164 | 168 | $i = 0; |
165 | - while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) |
|
166 | - $i++; |
|
169 | + while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) { |
|
170 | + $i++; |
|
171 | + } |
|
167 | 172 | $debug = ' (from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'] . ')'; |
168 | 173 | |
169 | 174 | // Cause an error. |
170 | - if ($this->debug_level & E_NOTICE) |
|
171 | - trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE); |
|
175 | + if ($this->debug_level & E_NOTICE) { |
|
176 | + trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE); |
|
177 | + } |
|
172 | 178 | return false; |
173 | 179 | } |
180 | + } else { |
|
181 | + $lvl = null; |
|
174 | 182 | } |
175 | - else |
|
176 | - $lvl = null; |
|
177 | 183 | |
178 | 184 | // Find this element. |
179 | 185 | $array = $this->_path($array, $el, $lvl); |
180 | 186 | } |
181 | 187 | |
182 | 188 | // Clean up after $lvl, for $return_full. |
183 | - if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) |
|
184 | - $array = array('name' => $el . '[]', $array); |
|
189 | + if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) { |
|
190 | + $array = array('name' => $el . '[]', $array); |
|
191 | + } |
|
185 | 192 | |
186 | 193 | // Create the right type of class... |
187 | 194 | $newClass = get_class($this); |
@@ -216,10 +223,11 @@ discard block |
||
216 | 223 | $el = substr($el, 0, strpos($el, '[')); |
217 | 224 | } |
218 | 225 | // Find an attribute. |
219 | - elseif (substr($el, 0, 1) == '@') |
|
220 | - return isset($array[$el]); |
|
221 | - else |
|
222 | - $lvl = null; |
|
226 | + elseif (substr($el, 0, 1) == '@') { |
|
227 | + return isset($array[$el]); |
|
228 | + } else { |
|
229 | + $lvl = null; |
|
230 | + } |
|
223 | 231 | |
224 | 232 | // Find this element. |
225 | 233 | $array = $this->_path($array, $el, $lvl, true); |
@@ -244,8 +252,9 @@ discard block |
||
244 | 252 | $i = 0; |
245 | 253 | foreach ($temp->array as $item) |
246 | 254 | { |
247 | - if (is_array($item)) |
|
248 | - $i++; |
|
255 | + if (is_array($item)) { |
|
256 | + $i++; |
|
257 | + } |
|
249 | 258 | } |
250 | 259 | |
251 | 260 | return $i; |
@@ -269,8 +278,9 @@ discard block |
||
269 | 278 | foreach ($xml->array as $val) |
270 | 279 | { |
271 | 280 | // Skip these, they aren't elements. |
272 | - if (!is_array($val) || $val['name'] == '!') |
|
273 | - continue; |
|
281 | + if (!is_array($val) || $val['name'] == '!') { |
|
282 | + continue; |
|
283 | + } |
|
274 | 284 | |
275 | 285 | // Create the right type of class... |
276 | 286 | $newClass = get_class($this); |
@@ -297,14 +307,16 @@ discard block |
||
297 | 307 | $path = $this->path($path); |
298 | 308 | |
299 | 309 | // The path was not found |
300 | - if ($path === false) |
|
301 | - return false; |
|
310 | + if ($path === false) { |
|
311 | + return false; |
|
312 | + } |
|
302 | 313 | |
303 | 314 | $path = $path->array; |
304 | 315 | } |
305 | 316 | // Just use the current array. |
306 | - else |
|
307 | - $path = $this->array; |
|
317 | + else { |
|
318 | + $path = $this->array; |
|
319 | + } |
|
308 | 320 | |
309 | 321 | // Add the xml declaration to the front. |
310 | 322 | return '<?xml version="1.0"?' . '>' . $this->_xml($path, 0); |
@@ -326,14 +338,16 @@ discard block |
||
326 | 338 | $path = $this->path($path); |
327 | 339 | |
328 | 340 | // The path was not found |
329 | - if ($path === false) |
|
330 | - return false; |
|
341 | + if ($path === false) { |
|
342 | + return false; |
|
343 | + } |
|
331 | 344 | |
332 | 345 | $path = $path->array; |
333 | 346 | } |
334 | 347 | // No, so just use the current array. |
335 | - else |
|
336 | - $path = $this->array; |
|
348 | + else { |
|
349 | + $path = $this->array; |
|
350 | + } |
|
337 | 351 | |
338 | 352 | return $this->_array($path); |
339 | 353 | } |
@@ -355,8 +369,9 @@ discard block |
||
355 | 369 | { |
356 | 370 | // Find and remove the next tag. |
357 | 371 | preg_match('/\A<([\w\-:]+)((?:\s+.+?)?)([\s]?\/)?' . '>/', $data, $match); |
358 | - if (isset($match[0])) |
|
359 | - $data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1); |
|
372 | + if (isset($match[0])) { |
|
373 | + $data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1); |
|
374 | + } |
|
360 | 375 | |
361 | 376 | // Didn't find a tag? Keep looping.... |
362 | 377 | if (!isset($match[1]) || $match[1] == '') |
@@ -367,11 +382,12 @@ discard block |
||
367 | 382 | $text_value = $this->_from_cdata($data); |
368 | 383 | $data = ''; |
369 | 384 | |
370 | - if ($text_value != '') |
|
371 | - $current[] = array( |
|
385 | + if ($text_value != '') { |
|
386 | + $current[] = array( |
|
372 | 387 | 'name' => '!', |
373 | 388 | 'value' => $text_value |
374 | 389 | ); |
390 | + } |
|
375 | 391 | } |
376 | 392 | // If the < isn't immediately next to the current position... more data. |
377 | 393 | elseif (strpos($data, '<') > 0) |
@@ -379,11 +395,12 @@ discard block |
||
379 | 395 | $text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<'))); |
380 | 396 | $data = substr($data, strpos($data, '<')); |
381 | 397 | |
382 | - if ($text_value != '') |
|
383 | - $current[] = array( |
|
398 | + if ($text_value != '') { |
|
399 | + $current[] = array( |
|
384 | 400 | 'name' => '!', |
385 | 401 | 'value' => $text_value |
386 | 402 | ); |
403 | + } |
|
387 | 404 | } |
388 | 405 | // If we're looking at a </something> with no start, kill it. |
389 | 406 | elseif (strpos($data, '<') !== false && strpos($data, '<') == 0) |
@@ -393,22 +410,23 @@ discard block |
||
393 | 410 | $text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<', 1))); |
394 | 411 | $data = substr($data, strpos($data, '<', 1)); |
395 | 412 | |
396 | - if ($text_value != '') |
|
397 | - $current[] = array( |
|
413 | + if ($text_value != '') { |
|
414 | + $current[] = array( |
|
398 | 415 | 'name' => '!', |
399 | 416 | 'value' => $text_value |
400 | 417 | ); |
401 | - } |
|
402 | - else |
|
418 | + } |
|
419 | + } else |
|
403 | 420 | { |
404 | 421 | $text_value = $this->_from_cdata($data); |
405 | 422 | $data = ''; |
406 | 423 | |
407 | - if ($text_value != '') |
|
408 | - $current[] = array( |
|
424 | + if ($text_value != '') { |
|
425 | + $current[] = array( |
|
409 | 426 | 'name' => '!', |
410 | 427 | 'value' => $text_value |
411 | 428 | ); |
429 | + } |
|
412 | 430 | } |
413 | 431 | } |
414 | 432 | |
@@ -425,8 +443,9 @@ discard block |
||
425 | 443 | { |
426 | 444 | // Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way. |
427 | 445 | $last_tag_end = strpos($data, '</' . $match[1] . '>'); |
428 | - if ($last_tag_end === false) |
|
429 | - continue; |
|
446 | + if ($last_tag_end === false) { |
|
447 | + continue; |
|
448 | + } |
|
430 | 449 | |
431 | 450 | $offset = 0; |
432 | 451 | while (1 == 1) |
@@ -434,16 +453,17 @@ discard block |
||
434 | 453 | // Where is the next start tag? |
435 | 454 | $next_tag_start = strpos($data, '<' . $match[1], $offset); |
436 | 455 | // If the next start tag is after the last end tag then we've found the right close. |
437 | - if ($next_tag_start === false || $next_tag_start > $last_tag_end) |
|
438 | - break; |
|
456 | + if ($next_tag_start === false || $next_tag_start > $last_tag_end) { |
|
457 | + break; |
|
458 | + } |
|
439 | 459 | |
440 | 460 | // If not then find the next ending tag. |
441 | 461 | $next_tag_end = strpos($data, '</' . $match[1] . '>', $offset); |
442 | 462 | |
443 | 463 | // Didn't find one? Then just use the last and sod it. |
444 | - if ($next_tag_end === false) |
|
445 | - break; |
|
446 | - else |
|
464 | + if ($next_tag_end === false) { |
|
465 | + break; |
|
466 | + } else |
|
447 | 467 | { |
448 | 468 | $last_tag_end = $next_tag_end; |
449 | 469 | $offset = $next_tag_start + 1; |
@@ -457,16 +477,17 @@ discard block |
||
457 | 477 | if (!empty($inner_match)) |
458 | 478 | { |
459 | 479 | // Parse the inner data. |
460 | - if (strpos($inner_match, '<') !== false) |
|
461 | - $el += $this->_parse($inner_match); |
|
462 | - elseif (trim($inner_match) != '') |
|
480 | + if (strpos($inner_match, '<') !== false) { |
|
481 | + $el += $this->_parse($inner_match); |
|
482 | + } elseif (trim($inner_match) != '') |
|
463 | 483 | { |
464 | 484 | $text_value = $this->_from_cdata($inner_match); |
465 | - if ($text_value != '') |
|
466 | - $el[] = array( |
|
485 | + if ($text_value != '') { |
|
486 | + $el[] = array( |
|
467 | 487 | 'name' => '!', |
468 | 488 | 'value' => $text_value |
469 | 489 | ); |
490 | + } |
|
470 | 491 | } |
471 | 492 | } |
472 | 493 | } |
@@ -478,8 +499,9 @@ discard block |
||
478 | 499 | preg_match_all('/([\w:]+)="(.+?)"/', $match[2], $attr, PREG_SET_ORDER); |
479 | 500 | |
480 | 501 | // Set them as @attribute-name. |
481 | - foreach ($attr as $match_attr) |
|
482 | - $el['@' . $match_attr[1]] = $match_attr[2]; |
|
502 | + foreach ($attr as $match_attr) { |
|
503 | + $el['@' . $match_attr[1]] = $match_attr[2]; |
|
504 | + } |
|
483 | 505 | } |
484 | 506 | } |
485 | 507 | |
@@ -503,16 +525,18 @@ discard block |
||
503 | 525 | if (is_array($array) && !isset($array['name'])) |
504 | 526 | { |
505 | 527 | $temp = ''; |
506 | - foreach ($array as $val) |
|
507 | - $temp .= $this->_xml($val, $indent); |
|
528 | + foreach ($array as $val) { |
|
529 | + $temp .= $this->_xml($val, $indent); |
|
530 | + } |
|
508 | 531 | return $temp; |
509 | 532 | } |
510 | 533 | |
511 | 534 | // This is just text! |
512 | - if ($array['name'] == '!') |
|
513 | - return $indentation . '<![CDATA[' . $array['value'] . ']]>'; |
|
514 | - elseif (substr($array['name'], -2) == '[]') |
|
515 | - $array['name'] = substr($array['name'], 0, -2); |
|
535 | + if ($array['name'] == '!') { |
|
536 | + return $indentation . '<![CDATA[' . $array['value'] . ']]>'; |
|
537 | + } elseif (substr($array['name'], -2) == '[]') { |
|
538 | + $array['name'] = substr($array['name'], 0, -2); |
|
539 | + } |
|
516 | 540 | |
517 | 541 | // Start the element. |
518 | 542 | $output = $indentation . '<' . $array['name']; |
@@ -523,9 +547,9 @@ discard block |
||
523 | 547 | // Run through and recursively output all the elements or attrbutes inside this. |
524 | 548 | foreach ($array as $k => $v) |
525 | 549 | { |
526 | - if (substr($k, 0, 1) == '@') |
|
527 | - $output .= ' ' . substr($k, 1) . '="' . $v . '"'; |
|
528 | - elseif (is_array($v)) |
|
550 | + if (substr($k, 0, 1) == '@') { |
|
551 | + $output .= ' ' . substr($k, 1) . '="' . $v . '"'; |
|
552 | + } elseif (is_array($v)) |
|
529 | 553 | { |
530 | 554 | $output_el .= $this->_xml($v, $indent === null ? null : $indent + 1); |
531 | 555 | $inside_elements = true; |
@@ -533,10 +557,11 @@ discard block |
||
533 | 557 | } |
534 | 558 | |
535 | 559 | // Indent, if necessary.... then close the tag. |
536 | - if ($inside_elements) |
|
537 | - $output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>'; |
|
538 | - else |
|
539 | - $output .= ' />'; |
|
560 | + if ($inside_elements) { |
|
561 | + $output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>'; |
|
562 | + } else { |
|
563 | + $output .= ' />'; |
|
564 | + } |
|
540 | 565 | |
541 | 566 | return $output; |
542 | 567 | } |
@@ -553,19 +578,22 @@ discard block |
||
553 | 578 | $text = ''; |
554 | 579 | foreach ($array as $value) |
555 | 580 | { |
556 | - if (!is_array($value) || !isset($value['name'])) |
|
557 | - continue; |
|
581 | + if (!is_array($value) || !isset($value['name'])) { |
|
582 | + continue; |
|
583 | + } |
|
558 | 584 | |
559 | - if ($value['name'] == '!') |
|
560 | - $text .= $value['value']; |
|
561 | - else |
|
562 | - $return[$value['name']] = $this->_array($value); |
|
585 | + if ($value['name'] == '!') { |
|
586 | + $text .= $value['value']; |
|
587 | + } else { |
|
588 | + $return[$value['name']] = $this->_array($value); |
|
589 | + } |
|
563 | 590 | } |
564 | 591 | |
565 | - if (empty($return)) |
|
566 | - return $text; |
|
567 | - else |
|
568 | - return $return; |
|
592 | + if (empty($return)) { |
|
593 | + return $text; |
|
594 | + } else { |
|
595 | + return $return; |
|
596 | + } |
|
569 | 597 | } |
570 | 598 | |
571 | 599 | /** |
@@ -583,24 +611,28 @@ discard block |
||
583 | 611 | foreach ($parts as $part) |
584 | 612 | { |
585 | 613 | // Handle XML comments. |
586 | - if (!$inCdata && $part === '<!--') |
|
587 | - $inComment = true; |
|
588 | - if ($inComment && $part === '-->') |
|
589 | - $inComment = false; |
|
590 | - elseif ($inComment) |
|
591 | - continue; |
|
614 | + if (!$inCdata && $part === '<!--') { |
|
615 | + $inComment = true; |
|
616 | + } |
|
617 | + if ($inComment && $part === '-->') { |
|
618 | + $inComment = false; |
|
619 | + } elseif ($inComment) { |
|
620 | + continue; |
|
621 | + } |
|
592 | 622 | |
593 | 623 | // Handle Cdata blocks. |
594 | - elseif (!$inComment && $part === '<![CDATA[') |
|
595 | - $inCdata = true; |
|
596 | - elseif ($inCdata && $part === ']]>') |
|
597 | - $inCdata = false; |
|
598 | - elseif ($inCdata) |
|
599 | - $output .= htmlentities($part, ENT_QUOTES); |
|
624 | + elseif (!$inComment && $part === '<![CDATA[') { |
|
625 | + $inCdata = true; |
|
626 | + } elseif ($inCdata && $part === ']]>') { |
|
627 | + $inCdata = false; |
|
628 | + } elseif ($inCdata) { |
|
629 | + $output .= htmlentities($part, ENT_QUOTES); |
|
630 | + } |
|
600 | 631 | |
601 | 632 | // Everything else is kept as is. |
602 | - else |
|
603 | - $output .= $part; |
|
633 | + else { |
|
634 | + $output .= $part; |
|
635 | + } |
|
604 | 636 | } |
605 | 637 | |
606 | 638 | return $output; |
@@ -635,22 +667,26 @@ discard block |
||
635 | 667 | protected function _fetch($array) |
636 | 668 | { |
637 | 669 | // Don't return anything if this is just a string. |
638 | - if (is_string($array)) |
|
639 | - return ''; |
|
670 | + if (is_string($array)) { |
|
671 | + return ''; |
|
672 | + } |
|
640 | 673 | |
641 | 674 | $temp = ''; |
642 | 675 | foreach ($array as $text) |
643 | 676 | { |
644 | 677 | // This means it's most likely an attribute or the name itself. |
645 | - if (!isset($text['name'])) |
|
646 | - continue; |
|
678 | + if (!isset($text['name'])) { |
|
679 | + continue; |
|
680 | + } |
|
647 | 681 | |
648 | 682 | // This is text! |
649 | - if ($text['name'] == '!') |
|
650 | - $temp .= $text['value']; |
|
683 | + if ($text['name'] == '!') { |
|
684 | + $temp .= $text['value']; |
|
685 | + } |
|
651 | 686 | // Another element - dive in ;). |
652 | - else |
|
653 | - $temp .= $this->_fetch($text); |
|
687 | + else { |
|
688 | + $temp .= $this->_fetch($text); |
|
689 | + } |
|
654 | 690 | } |
655 | 691 | |
656 | 692 | // Return all the bits and pieces we've put together. |
@@ -669,12 +705,14 @@ discard block |
||
669 | 705 | protected function _path($array, $path, $level, $no_error = false) |
670 | 706 | { |
671 | 707 | // Is $array even an array? It might be false! |
672 | - if (!is_array($array)) |
|
673 | - return false; |
|
708 | + if (!is_array($array)) { |
|
709 | + return false; |
|
710 | + } |
|
674 | 711 | |
675 | 712 | // Asking for *no* path? |
676 | - if ($path == '' || $path == '.') |
|
677 | - return $array; |
|
713 | + if ($path == '' || $path == '.') { |
|
714 | + return $array; |
|
715 | + } |
|
678 | 716 | $paths = explode('|', $path); |
679 | 717 | |
680 | 718 | // A * means all elements of any name. |
@@ -685,16 +723,18 @@ discard block |
||
685 | 723 | // Check each element. |
686 | 724 | foreach ($array as $value) |
687 | 725 | { |
688 | - if (!is_array($value) || $value['name'] === '!') |
|
689 | - continue; |
|
726 | + if (!is_array($value) || $value['name'] === '!') { |
|
727 | + continue; |
|
728 | + } |
|
690 | 729 | |
691 | 730 | if ($show_all || in_array($value['name'], $paths)) |
692 | 731 | { |
693 | 732 | // Skip elements before "the one". |
694 | - if ($level !== null && $level > 0) |
|
695 | - $level--; |
|
696 | - else |
|
697 | - $results[] = $value; |
|
733 | + if ($level !== null && $level > 0) { |
|
734 | + $level--; |
|
735 | + } else { |
|
736 | + $results[] = $value; |
|
737 | + } |
|
698 | 738 | } |
699 | 739 | } |
700 | 740 | |
@@ -703,21 +743,25 @@ discard block |
||
703 | 743 | { |
704 | 744 | $trace = debug_backtrace(); |
705 | 745 | $i = 0; |
706 | - while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) |
|
707 | - $i++; |
|
746 | + while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) { |
|
747 | + $i++; |
|
748 | + } |
|
708 | 749 | $debug = ' from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line']; |
709 | 750 | |
710 | 751 | // Cause an error. |
711 | - if ($this->debug_level & E_NOTICE && !$no_error) |
|
712 | - trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE); |
|
752 | + if ($this->debug_level & E_NOTICE && !$no_error) { |
|
753 | + trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE); |
|
754 | + } |
|
713 | 755 | return false; |
714 | 756 | } |
715 | 757 | // Only one result. |
716 | - elseif (count($results) == 1 || $level !== null) |
|
717 | - return $results[0]; |
|
758 | + elseif (count($results) == 1 || $level !== null) { |
|
759 | + return $results[0]; |
|
760 | + } |
|
718 | 761 | // Return the result set. |
719 | - else |
|
720 | - return $results + array('name' => $path . '[]'); |
|
762 | + else { |
|
763 | + return $results + array('name' => $path . '[]'); |
|
764 | + } |
|
721 | 765 | } |
722 | 766 | } |
723 | 767 | |
@@ -764,8 +808,9 @@ discard block |
||
764 | 808 | $this->error = false; |
765 | 809 | $this->pasv = array(); |
766 | 810 | |
767 | - if ($ftp_server !== null) |
|
768 | - $this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass); |
|
811 | + if ($ftp_server !== null) { |
|
812 | + $this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass); |
|
813 | + } |
|
769 | 814 | } |
770 | 815 | |
771 | 816 | /** |
@@ -778,14 +823,16 @@ discard block |
||
778 | 823 | */ |
779 | 824 | public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]') |
780 | 825 | { |
781 | - if (strpos($ftp_server, 'ftp://') === 0) |
|
782 | - $ftp_server = substr($ftp_server, 6); |
|
783 | - elseif (strpos($ftp_server, 'ftps://') === 0) |
|
784 | - $ftp_server = 'ssl://' . substr($ftp_server, 7); |
|
785 | - if (strpos($ftp_server, 'http://') === 0) |
|
786 | - $ftp_server = substr($ftp_server, 7); |
|
787 | - elseif (strpos($ftp_server, 'https://') === 0) |
|
788 | - $ftp_server = substr($ftp_server, 8); |
|
826 | + if (strpos($ftp_server, 'ftp://') === 0) { |
|
827 | + $ftp_server = substr($ftp_server, 6); |
|
828 | + } elseif (strpos($ftp_server, 'ftps://') === 0) { |
|
829 | + $ftp_server = 'ssl://' . substr($ftp_server, 7); |
|
830 | + } |
|
831 | + if (strpos($ftp_server, 'http://') === 0) { |
|
832 | + $ftp_server = substr($ftp_server, 7); |
|
833 | + } elseif (strpos($ftp_server, 'https://') === 0) { |
|
834 | + $ftp_server = substr($ftp_server, 8); |
|
835 | + } |
|
789 | 836 | $ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => '')); |
790 | 837 | |
791 | 838 | // Connect to the FTP server. |
@@ -834,12 +881,14 @@ discard block |
||
834 | 881 | */ |
835 | 882 | public function chdir($ftp_path) |
836 | 883 | { |
837 | - if (!is_resource($this->connection)) |
|
838 | - return false; |
|
884 | + if (!is_resource($this->connection)) { |
|
885 | + return false; |
|
886 | + } |
|
839 | 887 | |
840 | 888 | // No slash on the end, please... |
841 | - if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') |
|
842 | - $ftp_path = substr($ftp_path, 0, -1); |
|
889 | + if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') { |
|
890 | + $ftp_path = substr($ftp_path, 0, -1); |
|
891 | + } |
|
843 | 892 | |
844 | 893 | fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n"); |
845 | 894 | if (!$this->check_response(250)) |
@@ -860,11 +909,13 @@ discard block |
||
860 | 909 | */ |
861 | 910 | public function chmod($ftp_file, $chmod) |
862 | 911 | { |
863 | - if (!is_resource($this->connection)) |
|
864 | - return false; |
|
912 | + if (!is_resource($this->connection)) { |
|
913 | + return false; |
|
914 | + } |
|
865 | 915 | |
866 | - if ($ftp_file == '') |
|
867 | - $ftp_file = '.'; |
|
916 | + if ($ftp_file == '') { |
|
917 | + $ftp_file = '.'; |
|
918 | + } |
|
868 | 919 | |
869 | 920 | // Do we have a file or a dir? |
870 | 921 | $is_dir = is_dir($ftp_file); |
@@ -880,9 +931,7 @@ discard block |
||
880 | 931 | { |
881 | 932 | $is_writable = true; |
882 | 933 | break; |
883 | - } |
|
884 | - |
|
885 | - else |
|
934 | + } else |
|
886 | 935 | { |
887 | 936 | // Convert the chmod value from octal (0777) to text ("777"). |
888 | 937 | fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n"); |
@@ -905,8 +954,9 @@ discard block |
||
905 | 954 | public function unlink($ftp_file) |
906 | 955 | { |
907 | 956 | // We are actually connected, right? |
908 | - if (!is_resource($this->connection)) |
|
909 | - return false; |
|
957 | + if (!is_resource($this->connection)) { |
|
958 | + return false; |
|
959 | + } |
|
910 | 960 | |
911 | 961 | // Delete file X. |
912 | 962 | fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n"); |
@@ -935,9 +985,9 @@ discard block |
||
935 | 985 | { |
936 | 986 | // Wait for a response that isn't continued with -, but don't wait too long. |
937 | 987 | $time = time(); |
938 | - do |
|
939 | - $this->last_message = fgets($this->connection, 1024); |
|
940 | - while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5); |
|
988 | + do { |
|
989 | + $this->last_message = fgets($this->connection, 1024); |
|
990 | + } while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5); |
|
941 | 991 | |
942 | 992 | // Was the desired response returned? |
943 | 993 | return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired; |
@@ -951,15 +1001,16 @@ discard block |
||
951 | 1001 | public function passive() |
952 | 1002 | { |
953 | 1003 | // We can't create a passive data connection without a primary one first being there. |
954 | - if (!is_resource($this->connection)) |
|
955 | - return false; |
|
1004 | + if (!is_resource($this->connection)) { |
|
1005 | + return false; |
|
1006 | + } |
|
956 | 1007 | |
957 | 1008 | // Request a passive connection - this means, we'll talk to you, you don't talk to us. |
958 | 1009 | @fwrite($this->connection, 'PASV' . "\r\n"); |
959 | 1010 | $time = time(); |
960 | - do |
|
961 | - $response = fgets($this->connection, 1024); |
|
962 | - while (strpos($response, ' ', 3) !== 3 && time() - $time < 5); |
|
1011 | + do { |
|
1012 | + $response = fgets($this->connection, 1024); |
|
1013 | + } while (strpos($response, ' ', 3) !== 3 && time() - $time < 5); |
|
963 | 1014 | |
964 | 1015 | // If it's not 227, we weren't given an IP and port, which means it failed. |
965 | 1016 | if (strpos($response, '227 ') !== 0) |
@@ -990,12 +1041,14 @@ discard block |
||
990 | 1041 | public function create_file($ftp_file) |
991 | 1042 | { |
992 | 1043 | // First, we have to be connected... very important. |
993 | - if (!is_resource($this->connection)) |
|
994 | - return false; |
|
1044 | + if (!is_resource($this->connection)) { |
|
1045 | + return false; |
|
1046 | + } |
|
995 | 1047 | |
996 | 1048 | // I'd like one passive mode, please! |
997 | - if (!$this->passive()) |
|
998 | - return false; |
|
1049 | + if (!$this->passive()) { |
|
1050 | + return false; |
|
1051 | + } |
|
999 | 1052 | |
1000 | 1053 | // Seems logical enough, so far... |
1001 | 1054 | fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n"); |
@@ -1030,12 +1083,14 @@ discard block |
||
1030 | 1083 | public function list_dir($ftp_path = '', $search = false) |
1031 | 1084 | { |
1032 | 1085 | // Are we even connected...? |
1033 | - if (!is_resource($this->connection)) |
|
1034 | - return false; |
|
1086 | + if (!is_resource($this->connection)) { |
|
1087 | + return false; |
|
1088 | + } |
|
1035 | 1089 | |
1036 | 1090 | // Passive... non-agressive... |
1037 | - if (!$this->passive()) |
|
1038 | - return false; |
|
1091 | + if (!$this->passive()) { |
|
1092 | + return false; |
|
1093 | + } |
|
1039 | 1094 | |
1040 | 1095 | // Get the listing! |
1041 | 1096 | fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n"); |
@@ -1051,8 +1106,9 @@ discard block |
||
1051 | 1106 | |
1052 | 1107 | // Read in the file listing. |
1053 | 1108 | $data = ''; |
1054 | - while (!feof($fp)) |
|
1055 | - $data .= fread($fp, 4096); |
|
1109 | + while (!feof($fp)) { |
|
1110 | + $data .= fread($fp, 4096); |
|
1111 | + } |
|
1056 | 1112 | fclose($fp); |
1057 | 1113 | |
1058 | 1114 | // Everything go okay? |
@@ -1074,21 +1130,23 @@ discard block |
||
1074 | 1130 | */ |
1075 | 1131 | public function locate($file, $listing = null) |
1076 | 1132 | { |
1077 | - if ($listing === null) |
|
1078 | - $listing = $this->list_dir('', true); |
|
1133 | + if ($listing === null) { |
|
1134 | + $listing = $this->list_dir('', true); |
|
1135 | + } |
|
1079 | 1136 | $listing = explode("\n", $listing); |
1080 | 1137 | |
1081 | 1138 | @fwrite($this->connection, 'PWD' . "\r\n"); |
1082 | 1139 | $time = time(); |
1083 | - do |
|
1084 | - $response = fgets($this->connection, 1024); |
|
1085 | - while ($response[3] != ' ' && time() - $time < 5); |
|
1140 | + do { |
|
1141 | + $response = fgets($this->connection, 1024); |
|
1142 | + } while ($response[3] != ' ' && time() - $time < 5); |
|
1086 | 1143 | |
1087 | 1144 | // Check for 257! |
1088 | - if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) |
|
1089 | - $current_dir = strtr($match[1], array('""' => '"')); |
|
1090 | - else |
|
1091 | - $current_dir = ''; |
|
1145 | + if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) { |
|
1146 | + $current_dir = strtr($match[1], array('""' => '"')); |
|
1147 | + } else { |
|
1148 | + $current_dir = ''; |
|
1149 | + } |
|
1092 | 1150 | |
1093 | 1151 | for ($i = 0, $n = count($listing); $i < $n; $i++) |
1094 | 1152 | { |
@@ -1101,12 +1159,15 @@ discard block |
||
1101 | 1159 | // Okay, this file's name is: |
1102 | 1160 | $listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]); |
1103 | 1161 | |
1104 | - if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) |
|
1105 | - return $listing[$i]; |
|
1106 | - if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) |
|
1107 | - return $listing[$i]; |
|
1108 | - if (basename($listing[$i]) == $file || $listing[$i] == $file) |
|
1109 | - return $listing[$i]; |
|
1162 | + if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) { |
|
1163 | + return $listing[$i]; |
|
1164 | + } |
|
1165 | + if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) { |
|
1166 | + return $listing[$i]; |
|
1167 | + } |
|
1168 | + if (basename($listing[$i]) == $file || $listing[$i] == $file) { |
|
1169 | + return $listing[$i]; |
|
1170 | + } |
|
1110 | 1171 | } |
1111 | 1172 | |
1112 | 1173 | return false; |
@@ -1121,8 +1182,9 @@ discard block |
||
1121 | 1182 | public function create_dir($ftp_dir) |
1122 | 1183 | { |
1123 | 1184 | // We must be connected to the server to do something. |
1124 | - if (!is_resource($this->connection)) |
|
1125 | - return false; |
|
1185 | + if (!is_resource($this->connection)) { |
|
1186 | + return false; |
|
1187 | + } |
|
1126 | 1188 | |
1127 | 1189 | // Make this new beautiful directory! |
1128 | 1190 | fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n"); |
@@ -1154,35 +1216,40 @@ discard block |
||
1154 | 1216 | |
1155 | 1217 | $path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => '')); |
1156 | 1218 | |
1157 | - if (substr($path, -1) == '/') |
|
1158 | - $path = substr($path, 0, -1); |
|
1219 | + if (substr($path, -1) == '/') { |
|
1220 | + $path = substr($path, 0, -1); |
|
1221 | + } |
|
1159 | 1222 | |
1160 | - if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) |
|
1161 | - $path .= dirname($_SERVER['PHP_SELF']); |
|
1223 | + if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) { |
|
1224 | + $path .= dirname($_SERVER['PHP_SELF']); |
|
1225 | + } |
|
1226 | + } elseif (strpos($filesystem_path, '/var/www/') === 0) { |
|
1227 | + $path = substr($filesystem_path, 8); |
|
1228 | + } else { |
|
1229 | + $path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => '')); |
|
1162 | 1230 | } |
1163 | - elseif (strpos($filesystem_path, '/var/www/') === 0) |
|
1164 | - $path = substr($filesystem_path, 8); |
|
1165 | - else |
|
1166 | - $path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => '')); |
|
1231 | + } else { |
|
1232 | + $path = ''; |
|
1167 | 1233 | } |
1168 | - else |
|
1169 | - $path = ''; |
|
1170 | 1234 | |
1171 | 1235 | if (is_resource($this->connection) && $this->list_dir($path) == '') |
1172 | 1236 | { |
1173 | 1237 | $data = $this->list_dir('', true); |
1174 | 1238 | |
1175 | - if ($lookup_file === null) |
|
1176 | - $lookup_file = $_SERVER['PHP_SELF']; |
|
1239 | + if ($lookup_file === null) { |
|
1240 | + $lookup_file = $_SERVER['PHP_SELF']; |
|
1241 | + } |
|
1177 | 1242 | |
1178 | 1243 | $found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data)); |
1179 | - if ($found_path == false) |
|
1180 | - $found_path = dirname($this->locate(basename($lookup_file))); |
|
1181 | - if ($found_path != false) |
|
1182 | - $path = $found_path; |
|
1244 | + if ($found_path == false) { |
|
1245 | + $found_path = dirname($this->locate(basename($lookup_file))); |
|
1246 | + } |
|
1247 | + if ($found_path != false) { |
|
1248 | + $path = $found_path; |
|
1249 | + } |
|
1250 | + } elseif (is_resource($this->connection)) { |
|
1251 | + $found_path = true; |
|
1183 | 1252 | } |
1184 | - elseif (is_resource($this->connection)) |
|
1185 | - $found_path = true; |
|
1186 | 1253 | |
1187 | 1254 | return array($username, $path, isset($found_path)); |
1188 | 1255 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | $members = array(); |
53 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
54 | - $members[$row['id_member']] = array( |
|
53 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
54 | + $members[$row['id_member']] = array( |
|
55 | 55 | 'id' => $row['id_member'], |
56 | 56 | 'real_name' => $row['real_name'], |
57 | 57 | 'email_address' => $row['email_address'], |
@@ -62,6 +62,7 @@ discard block |
||
62 | 62 | ), |
63 | 63 | 'lngfile' => $row['lngfile'], |
64 | 64 | ); |
65 | + } |
|
65 | 66 | $smcFunc['db_free_result']($request); |
66 | 67 | |
67 | 68 | return $members; |
@@ -83,13 +84,14 @@ discard block |
||
83 | 84 | |
84 | 85 | call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); |
85 | 86 | |
86 | - foreach ($members as $member) |
|
87 | - $smcFunc['db_insert']('ignore', |
|
87 | + foreach ($members as $member) { |
|
88 | + $smcFunc['db_insert']('ignore', |
|
88 | 89 | '{db_prefix}mentions', |
89 | 90 | array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), |
90 | 91 | array((int) $content_id, $content_type, $id_member, $member['id'], time()), |
91 | 92 | array('content_id', 'content_type', 'id_mentioned') |
92 | 93 | ); |
94 | + } |
|
93 | 95 | } |
94 | 96 | |
95 | 97 | /** |
@@ -103,8 +105,9 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public static function getBody($body, array $members) |
105 | 107 | { |
106 | - foreach ($members as $member) |
|
107 | - $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
108 | + foreach ($members as $member) { |
|
109 | + $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
110 | + } |
|
108 | 111 | |
109 | 112 | return $body; |
110 | 113 | } |
@@ -123,8 +126,9 @@ discard block |
||
123 | 126 | |
124 | 127 | $possible_names = self::getPossibleMentions($body); |
125 | 128 | |
126 | - if (empty($possible_names) || !allowedTo('mention')) |
|
127 | - return array(); |
|
129 | + if (empty($possible_names) || !allowedTo('mention')) { |
|
130 | + return array(); |
|
131 | + } |
|
128 | 132 | |
129 | 133 | $request = $smcFunc['db_query']('', ' |
130 | 134 | SELECT id_member, real_name |
@@ -140,8 +144,9 @@ discard block |
||
140 | 144 | $members = array(); |
141 | 145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
142 | 146 | { |
143 | - if (stripos($body, static::$char . $row['real_name']) === false) |
|
144 | - continue; |
|
147 | + if (stripos($body, static::$char . $row['real_name']) === false) { |
|
148 | + continue; |
|
149 | + } |
|
145 | 150 | |
146 | 151 | $members[$row['id_member']] = array( |
147 | 152 | 'id' => $row['id_member'], |
@@ -185,8 +190,9 @@ discard block |
||
185 | 190 | $body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace(' ', ' ', $body)), ENT_QUOTES); |
186 | 191 | |
187 | 192 | // Remove quotes, we don't want to get double mentions. |
188 | - while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) |
|
189 | - $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
193 | + while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) { |
|
194 | + $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
195 | + } |
|
190 | 196 | |
191 | 197 | $matches = array(); |
192 | 198 | $string = str_split($body); |
@@ -197,9 +203,9 @@ discard block |
||
197 | 203 | { |
198 | 204 | $depth++; |
199 | 205 | $matches[] = array(); |
206 | + } elseif ($char == "\n") { |
|
207 | + $depth = 0; |
|
200 | 208 | } |
201 | - elseif ($char == "\n") |
|
202 | - $depth = 0; |
|
203 | 209 | |
204 | 210 | for ($i = $depth; $i > 0; $i--) |
205 | 211 | { |
@@ -212,8 +218,9 @@ discard block |
||
212 | 218 | } |
213 | 219 | } |
214 | 220 | |
215 | - foreach ($matches as $k => $match) |
|
216 | - $matches[$k] = substr(implode('', $match), 1); |
|
221 | + foreach ($matches as $k => $match) { |
|
222 | + $matches[$k] = substr(implode('', $match), 1); |
|
223 | + } |
|
217 | 224 | |
218 | 225 | // Names can have spaces, other breaks, or they can't...we try to match every possible |
219 | 226 | // combination. |
@@ -223,8 +230,9 @@ discard block |
||
223 | 230 | $match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE); |
224 | 231 | $count = count($match); |
225 | 232 | |
226 | - for ($i = 1; $i <= $count; $i++) |
|
227 | - $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
233 | + for ($i = 1; $i <= $count; $i++) { |
|
234 | + $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
235 | + } |
|
228 | 236 | } |
229 | 237 | |
230 | 238 | $names = array_unique($names); |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | 'class' => 'centercol', |
1327 | 1327 | ), |
1328 | 1328 | 'data' => array( |
1329 | - 'function' => function ($rowData) |
|
1329 | + 'function' => function($rowData) |
|
1330 | 1330 | { |
1331 | 1331 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1332 | 1332 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | 'class' => 'centercol', |
1343 | 1343 | ), |
1344 | 1344 | 'data' => array( |
1345 | - 'function' => function ($rowData) |
|
1345 | + 'function' => function($rowData) |
|
1346 | 1346 | { |
1347 | 1347 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1348 | 1348 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1389,15 +1389,15 @@ discard block |
||
1389 | 1389 | 'value' => $txt['custom_profile_fieldorder'], |
1390 | 1390 | ), |
1391 | 1391 | 'data' => array( |
1392 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1392 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1393 | 1393 | { |
1394 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
|
1394 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />'; |
|
1395 | 1395 | |
1396 | 1396 | if ($rowData['field_order'] > 1) |
1397 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1397 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1398 | 1398 | |
1399 | 1399 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1400 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1400 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1401 | 1401 | |
1402 | 1402 | $return .= '</p>'; |
1403 | 1403 | |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | 'value' => $txt['custom_profile_fieldname'], |
1416 | 1416 | ), |
1417 | 1417 | 'data' => array( |
1418 | - 'function' => function ($rowData) use ($scripturl) |
|
1418 | + 'function' => function($rowData) use ($scripturl) |
|
1419 | 1419 | { |
1420 | 1420 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1421 | 1421 | }, |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | 'value' => $txt['custom_profile_fieldtype'], |
1432 | 1432 | ), |
1433 | 1433 | 'data' => array( |
1434 | - 'function' => function ($rowData) use ($txt) |
|
1434 | + 'function' => function($rowData) use ($txt) |
|
1435 | 1435 | { |
1436 | 1436 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1437 | 1437 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | 'value' => $txt['custom_profile_active'], |
1450 | 1450 | ), |
1451 | 1451 | 'data' => array( |
1452 | - 'function' => function ($rowData) use ($txt) |
|
1452 | + 'function' => function($rowData) use ($txt) |
|
1453 | 1453 | { |
1454 | 1454 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1455 | 1455 | }, |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | 'value' => $txt['custom_profile_placement'], |
1467 | 1467 | ), |
1468 | 1468 | 'data' => array( |
1469 | - 'function' => function ($rowData) |
|
1469 | + 'function' => function($rowData) |
|
1470 | 1470 | { |
1471 | 1471 | global $txt, $context; |
1472 | 1472 | |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1702 | 1702 | |
1703 | 1703 | // All good, proceed. |
1704 | - $smcFunc['db_query']('',' |
|
1704 | + $smcFunc['db_query']('', ' |
|
1705 | 1705 | UPDATE {db_prefix}custom_fields |
1706 | 1706 | SET field_order = {int:old_order} |
1707 | 1707 | WHERE field_order = {int:new_order}', |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | 'old_order' => $context['field']['order'], |
1711 | 1711 | ) |
1712 | 1712 | ); |
1713 | - $smcFunc['db_query']('',' |
|
1713 | + $smcFunc['db_query']('', ' |
|
1714 | 1714 | UPDATE {db_prefix}custom_fields |
1715 | 1715 | SET field_order = {int:new_order} |
1716 | 1716 | WHERE id_field = {int:id_field}', |
@@ -1812,7 +1812,7 @@ discard block |
||
1812 | 1812 | $smcFunc['db_free_result']($request); |
1813 | 1813 | |
1814 | 1814 | $unique = false; |
1815 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1815 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1816 | 1816 | { |
1817 | 1817 | if (!in_array($col_name, $current_fields)) |
1818 | 1818 | $unique = true; |
@@ -1985,7 +1985,7 @@ discard block |
||
1985 | 1985 | ); |
1986 | 1986 | |
1987 | 1987 | // Re-arrange the order. |
1988 | - $smcFunc['db_query']('',' |
|
1988 | + $smcFunc['db_query']('', ' |
|
1989 | 1989 | UPDATE {db_prefix}custom_fields |
1990 | 1990 | SET field_order = field_order - 1 |
1991 | 1991 | WHERE field_order > {int:current_order}', |
@@ -2249,7 +2249,7 @@ discard block |
||
2249 | 2249 | $context['token_check'] = 'noti-admin'; |
2250 | 2250 | |
2251 | 2251 | // Specify our action since we'll want to post back here instead of the profile |
2252 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2252 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2253 | 2253 | |
2254 | 2254 | loadTemplate('Profile'); |
2255 | 2255 | loadLanguage('Profile'); |
@@ -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 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = json_encode($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | 'class' => 'centercol', |
394 | 394 | ), |
395 | 395 | 'data' => array( |
396 | - 'function' => function ($rowData) |
|
396 | + 'function' => function($rowData) |
|
397 | 397 | { |
398 | 398 | return $rowData['selected'] ? '<span class="generic_icons valid"></span>' : ''; |
399 | 399 | }, |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | 'class' => 'centercol', |
454 | 454 | ), |
455 | 455 | 'data' => array( |
456 | - 'function' => function ($rowData) |
|
456 | + 'function' => function($rowData) |
|
457 | 457 | { |
458 | 458 | return $rowData['selected'] ? '' : sprintf('<input type="checkbox" name="smiley_set[%1$d]" class="input_check">', $rowData['id']); |
459 | 459 | }, |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | 'value' => $txt['smileys_location'], |
998 | 998 | ), |
999 | 999 | 'data' => array( |
1000 | - 'function' => function ($rowData) use ($txt) |
|
1000 | + 'function' => function($rowData) use ($txt) |
|
1001 | 1001 | { |
1002 | 1002 | if (empty($rowData['hidden'])) |
1003 | 1003 | return $txt['smileys_location_form']; |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | 'value' => $txt['smileys_description'], |
1018 | 1018 | ), |
1019 | 1019 | 'data' => array( |
1020 | - 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
1020 | + 'function' => function($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
1021 | 1021 | { |
1022 | 1022 | if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
1023 | 1023 | return $smcFunc['htmlspecialchars']($rowData['description']); |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
1558 | 1558 | ); |
1559 | 1559 | |
1560 | - $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
1560 | + $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
1561 | 1561 | if (isset($action['filename']) && (!file_exists($file) || !is_writable(dirname($action['destination'])))) |
1562 | 1562 | { |
1563 | 1563 | $context['has_failure'] = true; |
@@ -1601,7 +1601,7 @@ discard block |
||
1601 | 1601 | { |
1602 | 1602 | updateSettings(array( |
1603 | 1603 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . basename($action['action']), |
1604 | - 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
1604 | + 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
1605 | 1605 | )); |
1606 | 1606 | } |
1607 | 1607 | |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | '{db_prefix}log_packages', |
1614 | 1614 | array( |
1615 | 1615 | 'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', |
1616 | - 'id_member_installed' => 'int', 'member_installed' => 'string','time_installed' => 'int', |
|
1616 | + 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', |
|
1617 | 1617 | 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', |
1618 | 1618 | 'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string', |
1619 | 1619 | ), |
@@ -1862,7 +1862,7 @@ discard block |
||
1862 | 1862 | 'columns' => array( |
1863 | 1863 | 'icon' => array( |
1864 | 1864 | 'data' => array( |
1865 | - 'function' => function ($rowData) use ($settings, $smcFunc) |
|
1865 | + 'function' => function($rowData) use ($settings, $smcFunc) |
|
1866 | 1866 | { |
1867 | 1867 | $images_url = $settings[file_exists(sprintf('%1$s/images/post/%2$s.png', $settings['theme_dir'], $rowData['filename'])) ? 'actual_images_url' : 'default_images_url']; |
1868 | 1868 | return sprintf('<img src="%1$s/post/%2$s.png" alt="%3$s">', $images_url, $rowData['filename'], $smcFunc['htmlspecialchars']($rowData['title'])); |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | 'value' => $txt['icons_board'], |
1897 | 1897 | ), |
1898 | 1898 | 'data' => array( |
1899 | - 'function' => function ($rowData) use ($txt) |
|
1899 | + 'function' => function($rowData) use ($txt) |
|
1900 | 1900 | { |
1901 | 1901 | return empty($rowData['board_name']) ? $txt['icons_edit_icons_all_boards'] : $rowData['board_name']; |
1902 | 1902 | }, |
@@ -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 | * This is the dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | ); |
92 | 93 | |
93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
94 | - if (empty($modSettings['messageIcons_enable'])) |
|
95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
97 | + } |
|
96 | 98 | if (empty($modSettings['smiley_enable'])) |
97 | 99 | { |
98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
126 | 128 | |
127 | 129 | $smiley_context = array(); |
128 | - foreach ($smiley_sets as $i => $set) |
|
129 | - $smiley_context[$set] = $set_names[$i]; |
|
130 | + foreach ($smiley_sets as $i => $set) { |
|
131 | + $smiley_context[$set] = $set_names[$i]; |
|
132 | + } |
|
130 | 133 | |
131 | 134 | // All the settings for the page... |
132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
147 | 150 | |
148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
149 | 152 | |
150 | - if ($return_config) |
|
151 | - return $config_vars; |
|
153 | + if ($return_config) { |
|
154 | + return $config_vars; |
|
155 | + } |
|
152 | 156 | |
153 | 157 | // Setup the basics of the settings template. |
154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
208 | 212 | { |
209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
211 | - unset($set_paths[$id], $set_names[$id]); |
|
214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
215 | + unset($set_paths[$id], $set_names[$id]); |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | |
214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
222 | 227 | )); |
223 | 228 | } |
224 | 229 | // Add a new smiley set. |
225 | - elseif (!empty($_POST['add'])) |
|
226 | - $context['sub_action'] = 'modifyset'; |
|
230 | + elseif (!empty($_POST['add'])) { |
|
231 | + $context['sub_action'] = 'modifyset'; |
|
232 | + } |
|
227 | 233 | // Create or modify a smiley set. |
228 | 234 | elseif (isset($_POST['set'])) |
229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
233 | 239 | // Create a new smiley set. |
234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
235 | 241 | { |
236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
237 | - fatal_lang_error('smiley_set_already_exists'); |
|
242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
243 | + fatal_lang_error('smiley_set_already_exists'); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | updateSettings(array( |
240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
246 | 253 | else |
247 | 254 | { |
248 | 255 | // Make sure the smiley set exists. |
249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
250 | - fatal_lang_error('smiley_set_not_found'); |
|
256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
257 | + fatal_lang_error('smiley_set_not_found'); |
|
258 | + } |
|
251 | 259 | |
252 | 260 | // Make sure the path is not yet used by another smileyset. |
253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
263 | + } |
|
255 | 264 | |
256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
263 | 272 | } |
264 | 273 | |
265 | 274 | // The user might have checked to also import smileys. |
266 | - if (!empty($_POST['smiley_sets_import'])) |
|
267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | cache_put_data('parsing_smileys', null, 480); |
270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
273 | 283 | // Load all available smileysets... |
274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
277 | - $context['smiley_sets'][$i] = array( |
|
286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
287 | + $context['smiley_sets'][$i] = array( |
|
278 | 288 | 'id' => $i, |
279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
282 | 292 | ); |
293 | + } |
|
283 | 294 | |
284 | 295 | // Importing any smileys from an existing set? |
285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
290 | 301 | $_GET['set'] = (int) $_GET['set']; |
291 | 302 | |
292 | 303 | // Sanity check - then import. |
293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
306 | + } |
|
295 | 307 | |
296 | 308 | // Force the process to continue. |
297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
301 | 313 | if ($context['sub_action'] == 'modifyset') |
302 | 314 | { |
303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
305 | - $context['current_set'] = array( |
|
316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
317 | + $context['current_set'] = array( |
|
306 | 318 | 'id' => '-1', |
307 | 319 | 'path' => '', |
308 | 320 | 'name' => '', |
309 | 321 | 'selected' => false, |
310 | 322 | 'is_new' => true, |
311 | 323 | ); |
312 | - else |
|
324 | + } else |
|
313 | 325 | { |
314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
322 | 334 | while ($entry = $dir->read()) |
323 | 335 | { |
324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
325 | - $smileys[strtolower($entry)] = $entry; |
|
336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
337 | + $smileys[strtolower($entry)] = $entry; |
|
338 | + } |
|
326 | 339 | } |
327 | 340 | $dir->close(); |
328 | 341 | |
329 | - if (empty($smileys)) |
|
330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
342 | + if (empty($smileys)) { |
|
343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
344 | + } |
|
331 | 345 | |
332 | 346 | // Exclude the smileys that are already in the database. |
333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
338 | 352 | 'smiley_list' => $smileys, |
339 | 353 | ) |
340 | 354 | ); |
341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
343 | 357 | unset($smileys[strtolower($row['filename'])]); |
358 | + } |
|
344 | 359 | $smcFunc['db_free_result']($request); |
345 | 360 | |
346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
355 | 370 | $dir = dir($modSettings['smileys_dir']); |
356 | 371 | while ($entry = $dir->read()) |
357 | 372 | { |
358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
359 | - $context['smiley_set_dirs'][] = array( |
|
373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
374 | + $context['smiley_set_dirs'][] = array( |
|
360 | 375 | 'id' => $entry, |
361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
363 | 378 | 'current' => $entry == $context['current_set']['path'], |
364 | 379 | ); |
380 | + } |
|
365 | 381 | } |
366 | 382 | $dir->close(); |
367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
371 | 387 | createToken('admin-mss', 'request'); |
372 | 388 | |
373 | 389 | // In case we need to import smileys, we need to add the token in now. |
374 | - if (isset($context['current_set']['import_url'])) |
|
375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
390 | + if (isset($context['current_set']['import_url'])) { |
|
391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
392 | + } |
|
376 | 393 | |
377 | 394 | $listOptions = array( |
378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
510 | 527 | $cols['name'][] = $set_names[$i]; |
511 | 528 | } |
512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
513 | - if (substr($sort, 0, 4) === 'name') |
|
514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
515 | - elseif (substr($sort, 0, 4) === 'path') |
|
516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
517 | - else |
|
518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
530 | + if (substr($sort, 0, 4) === 'name') { |
|
531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
534 | + } else { |
|
535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
536 | + } |
|
519 | 537 | |
520 | 538 | $smiley_sets = array(); |
521 | - foreach ($cols['id'] as $i => $id) |
|
522 | - $smiley_sets[] = array( |
|
539 | + foreach ($cols['id'] as $i => $id) { |
|
540 | + $smiley_sets[] = array( |
|
523 | 541 | 'id' => $id, |
524 | 542 | 'path' => $cols['path'][$i], |
525 | 543 | 'name' => $cols['name'][$i], |
526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
527 | 545 | ); |
546 | + } |
|
528 | 547 | |
529 | 548 | return $smiley_sets; |
530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
557 | - $context['smiley_sets'][$i] = array( |
|
575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
576 | + $context['smiley_sets'][$i] = array( |
|
558 | 577 | 'id' => $i, |
559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
562 | 581 | ); |
582 | + } |
|
563 | 583 | |
564 | 584 | // Submitting a form? |
565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
576 | 596 | |
577 | 597 | // Make sure some code was entered. |
578 | - if (empty($_POST['smiley_code'])) |
|
579 | - fatal_lang_error('smiley_has_no_code'); |
|
598 | + if (empty($_POST['smiley_code'])) { |
|
599 | + fatal_lang_error('smiley_has_no_code'); |
|
600 | + } |
|
580 | 601 | |
581 | 602 | // Check whether the new code has duplicates. It should be unique. |
582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
589 | 610 | ) |
590 | 611 | ); |
591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
592 | - fatal_lang_error('smiley_not_unique'); |
|
612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
613 | + fatal_lang_error('smiley_not_unique'); |
|
614 | + } |
|
593 | 615 | $smcFunc['db_free_result']($request); |
594 | 616 | |
595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
598 | 620 | $writeErrors = array(); |
599 | 621 | foreach ($context['smiley_sets'] as $set) |
600 | 622 | { |
601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
602 | - $writeErrors[] = $set['path']; |
|
623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
624 | + $writeErrors[] = $set['path']; |
|
625 | + } |
|
626 | + } |
|
627 | + if (!empty($writeErrors)) { |
|
628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
603 | 629 | } |
604 | - if (!empty($writeErrors)) |
|
605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Uploading just one smiley for all of them? |
609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
610 | 634 | { |
611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
612 | - fatal_lang_error('smileys_upload_error'); |
|
635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
636 | + fatal_lang_error('smileys_upload_error'); |
|
637 | + } |
|
613 | 638 | |
614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
616 | 641 | |
617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
645 | + } |
|
620 | 646 | |
621 | 647 | // We only need the filename... |
622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
623 | 649 | |
624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
653 | + } |
|
627 | 654 | |
628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
629 | 656 | $i = 0; |
630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
632 | - $i++; |
|
658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
659 | + $i++; |
|
660 | + } |
|
633 | 661 | |
634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
645 | 673 | |
646 | 674 | // The file is already there! Don't overwrite it! |
647 | - if (file_exists($currentPath)) |
|
648 | - continue; |
|
675 | + if (file_exists($currentPath)) { |
|
676 | + continue; |
|
677 | + } |
|
649 | 678 | |
650 | 679 | // Okay, so copy the first one we made to here. |
651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
662 | 691 | $newName = ''; |
663 | 692 | foreach ($_FILES as $name => $data) |
664 | 693 | { |
665 | - if ($_FILES[$name]['name'] == '') |
|
666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
694 | + if ($_FILES[$name]['name'] == '') { |
|
695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
696 | + } |
|
667 | 697 | |
668 | - if (empty($newName)) |
|
669 | - $newName = basename($_FILES[$name]['name']); |
|
670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
671 | - fatal_lang_error('smileys_upload_error_name'); |
|
698 | + if (empty($newName)) { |
|
699 | + $newName = basename($_FILES[$name]['name']); |
|
700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
701 | + fatal_lang_error('smileys_upload_error_name'); |
|
702 | + } |
|
672 | 703 | } |
673 | 704 | |
674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
678 | 709 | |
679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
680 | - continue; |
|
710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
711 | + continue; |
|
712 | + } |
|
681 | 713 | |
682 | 714 | // Got one... |
683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
684 | - fatal_lang_error('smileys_upload_error'); |
|
715 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
716 | + fatal_lang_error('smileys_upload_error'); |
|
717 | + } |
|
685 | 718 | |
686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
688 | 721 | |
689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
725 | + } |
|
692 | 726 | |
693 | 727 | // We only need the filename... |
694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
695 | 729 | |
696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
733 | + } |
|
699 | 734 | |
700 | 735 | // If the file exists - ignore it. |
701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
702 | - if (file_exists($smileyLocation)) |
|
703 | - continue; |
|
737 | + if (file_exists($smileyLocation)) { |
|
738 | + continue; |
|
739 | + } |
|
704 | 740 | |
705 | 741 | // Finally - move the image! |
706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
712 | 748 | } |
713 | 749 | |
714 | 750 | // Also make sure a filename was given. |
715 | - if (empty($_POST['smiley_filename'])) |
|
716 | - fatal_lang_error('smiley_has_no_filename'); |
|
751 | + if (empty($_POST['smiley_filename'])) { |
|
752 | + fatal_lang_error('smiley_has_no_filename'); |
|
753 | + } |
|
717 | 754 | |
718 | 755 | // Find the position on the right. |
719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
733 | 770 | $smcFunc['db_free_result']($request); |
734 | 771 | |
735 | - if (empty($smiley_order)) |
|
736 | - $smiley_order = '0'; |
|
772 | + if (empty($smiley_order)) { |
|
773 | + $smiley_order = '0'; |
|
774 | + } |
|
737 | 775 | } |
738 | 776 | $smcFunc['db_insert']('', |
739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
761 | 799 | { |
762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
763 | 801 | { |
764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
765 | - continue; |
|
802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
803 | + continue; |
|
804 | + } |
|
766 | 805 | |
767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
768 | 807 | while ($entry = $dir->read()) |
769 | 808 | { |
770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
771 | - $context['filenames'][strtolower($entry)] = array( |
|
809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
810 | + $context['filenames'][strtolower($entry)] = array( |
|
772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
773 | 812 | 'selected' => false, |
774 | 813 | ); |
814 | + } |
|
775 | 815 | } |
776 | 816 | $dir->close(); |
777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
809 | 849 | // Changing the selected smileys? |
810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
811 | 851 | { |
812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
854 | + } |
|
814 | 855 | |
815 | - if ($_POST['smiley_action'] == 'delete') |
|
816 | - $smcFunc['db_query']('', ' |
|
856 | + if ($_POST['smiley_action'] == 'delete') { |
|
857 | + $smcFunc['db_query']('', ' |
|
817 | 858 | DELETE FROM {db_prefix}smileys |
818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
819 | 860 | array( |
820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
821 | 862 | ) |
822 | 863 | ); |
864 | + } |
|
823 | 865 | // Changing the status of the smiley? |
824 | 866 | else |
825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
829 | 871 | 'hidden' => 1, |
830 | 872 | 'popup' => 2 |
831 | 873 | ); |
832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
833 | - $smcFunc['db_query']('', ' |
|
874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
875 | + $smcFunc['db_query']('', ' |
|
834 | 876 | UPDATE {db_prefix}smileys |
835 | 877 | SET hidden = {int:display_type} |
836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
840 | 882 | ) |
841 | 883 | ); |
884 | + } |
|
842 | 885 | } |
843 | 886 | } |
844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
865 | 908 | |
866 | 909 | // Make sure some code was entered. |
867 | - if (empty($_POST['smiley_code'])) |
|
868 | - fatal_lang_error('smiley_has_no_code'); |
|
910 | + if (empty($_POST['smiley_code'])) { |
|
911 | + fatal_lang_error('smiley_has_no_code'); |
|
912 | + } |
|
869 | 913 | |
870 | 914 | // Also make sure a filename was given. |
871 | - if (empty($_POST['smiley_filename'])) |
|
872 | - fatal_lang_error('smiley_has_no_filename'); |
|
915 | + if (empty($_POST['smiley_filename'])) { |
|
916 | + fatal_lang_error('smiley_has_no_filename'); |
|
917 | + } |
|
873 | 918 | |
874 | 919 | // Check whether the new code has duplicates. It should be unique. |
875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
884 | 929 | ) |
885 | 930 | ); |
886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
887 | - fatal_lang_error('smiley_not_unique'); |
|
931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
932 | + fatal_lang_error('smiley_not_unique'); |
|
933 | + } |
|
888 | 934 | $smcFunc['db_free_result']($request); |
889 | 935 | |
890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
913 | 959 | // Load all known smiley sets. |
914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
917 | - $context['smiley_sets'][$i] = array( |
|
962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
963 | + $context['smiley_sets'][$i] = array( |
|
918 | 964 | 'id' => $i, |
919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
922 | 968 | ); |
969 | + } |
|
923 | 970 | |
924 | 971 | // Prepare overview of all (custom) smileys. |
925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
935 | 982 | // Create a list of options for selecting smiley sets. |
936 | 983 | $smileyset_option_list = ' |
937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
939 | - $smileyset_option_list .= ' |
|
985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
986 | + $smileyset_option_list .= ' |
|
940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
988 | + } |
|
941 | 989 | $smileyset_option_list .= ' |
942 | 990 | </select>'; |
943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
999 | 1047 | 'data' => array( |
1000 | 1048 | 'function' => function ($rowData) use ($txt) |
1001 | 1049 | { |
1002 | - if (empty($rowData['hidden'])) |
|
1003 | - return $txt['smileys_location_form']; |
|
1004 | - elseif ($rowData['hidden'] == 1) |
|
1005 | - return $txt['smileys_location_hidden']; |
|
1006 | - else |
|
1007 | - return $txt['smileys_location_popup']; |
|
1050 | + if (empty($rowData['hidden'])) { |
|
1051 | + return $txt['smileys_location_form']; |
|
1052 | + } elseif ($rowData['hidden'] == 1) { |
|
1053 | + return $txt['smileys_location_hidden']; |
|
1054 | + } else { |
|
1055 | + return $txt['smileys_location_popup']; |
|
1056 | + } |
|
1008 | 1057 | }, |
1009 | 1058 | ), |
1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
1019 | 1068 | 'data' => array( |
1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
1021 | 1070 | { |
1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1073 | + } |
|
1024 | 1074 | |
1025 | 1075 | // Check if there are smileys missing in some sets. |
1026 | 1076 | $missing_sets = array(); |
1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
1080 | + } |
|
1030 | 1081 | |
1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
1032 | 1083 | |
1033 | - if (!empty($missing_sets)) |
|
1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1084 | + if (!empty($missing_sets)) { |
|
1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1086 | + } |
|
1035 | 1087 | |
1036 | 1088 | return $description; |
1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
1151 | - $context['smiley_sets'][$i] = array( |
|
1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
1203 | + $context['smiley_sets'][$i] = array( |
|
1152 | 1204 | 'id' => $i, |
1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
1156 | 1208 | ); |
1209 | + } |
|
1157 | 1210 | |
1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
1163 | 1216 | { |
1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
1165 | 1218 | { |
1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
1167 | - continue; |
|
1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
1220 | + continue; |
|
1221 | + } |
|
1168 | 1222 | |
1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
1170 | 1224 | while ($entry = $dir->read()) |
1171 | 1225 | { |
1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1173 | - $context['filenames'][strtolower($entry)] = array( |
|
1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1227 | + $context['filenames'][strtolower($entry)] = array( |
|
1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
1175 | 1229 | 'selected' => false, |
1176 | 1230 | ); |
1231 | + } |
|
1177 | 1232 | } |
1178 | 1233 | $dir->close(); |
1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
1189 | 1244 | ) |
1190 | 1245 | ); |
1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1192 | - fatal_lang_error('smiley_not_found'); |
|
1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1247 | + fatal_lang_error('smiley_not_found'); |
|
1248 | + } |
|
1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
1194 | 1250 | $smcFunc['db_free_result']($request); |
1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
1199 | 1255 | |
1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1258 | + } |
|
1202 | 1259 | } |
1203 | 1260 | } |
1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
1223 | 1280 | ) |
1224 | 1281 | ); |
1225 | 1282 | $smileys = array(); |
1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1227 | - $smileys[] = $row; |
|
1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1284 | + $smileys[] = $row; |
|
1285 | + } |
|
1228 | 1286 | $smcFunc['db_free_result']($request); |
1229 | 1287 | |
1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
1266 | 1324 | |
1267 | - if (empty($_GET['source'])) |
|
1268 | - fatal_lang_error('smiley_not_found'); |
|
1325 | + if (empty($_GET['source'])) { |
|
1326 | + fatal_lang_error('smiley_not_found'); |
|
1327 | + } |
|
1269 | 1328 | |
1270 | 1329 | if (!empty($_GET['after'])) |
1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
1281 | 1340 | 'after_smiley' => $_GET['after'], |
1282 | 1341 | ) |
1283 | 1342 | ); |
1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1285 | - fatal_lang_error('smiley_not_found'); |
|
1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1344 | + fatal_lang_error('smiley_not_found'); |
|
1345 | + } |
|
1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
1287 | 1347 | $smcFunc['db_free_result']($request); |
1288 | - } |
|
1289 | - else |
|
1348 | + } else |
|
1290 | 1349 | { |
1291 | 1350 | $smiley_row = (int) $_GET['row']; |
1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
1361 | 1420 | |
1362 | 1421 | // Make sure all rows are sequential. |
1363 | - foreach (array_keys($context['smileys']) as $location) |
|
1364 | - $context['smileys'][$location] = array( |
|
1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
1423 | + $context['smileys'][$location] = array( |
|
1365 | 1424 | 'id' => $location, |
1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
1370 | 1429 | ); |
1430 | + } |
|
1371 | 1431 | |
1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
1393 | 1453 | } |
1394 | 1454 | // Make sure the smiley order is always sequential. |
1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
1396 | - if ($order_id != $smiley['order']) |
|
1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
1456 | + if ($order_id != $smiley['order']) |
|
1397 | 1457 | $smcFunc['db_query']('', ' |
1398 | 1458 | UPDATE {db_prefix}smileys |
1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
1403 | 1463 | 'current_smiley' => $smiley['id'], |
1404 | 1464 | ) |
1405 | 1465 | ); |
1466 | + } |
|
1406 | 1467 | } |
1407 | 1468 | } |
1408 | 1469 | |
@@ -1436,19 +1497,20 @@ discard block |
||
1436 | 1497 | |
1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
1438 | 1499 | // @ TODO: Our current xml files serve http links. Allowing both for now until we serve https. |
1439 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
1440 | - fatal_lang_error('not_on_simplemachines'); |
|
1500 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
1501 | + fatal_lang_error('not_on_simplemachines'); |
|
1502 | + } |
|
1441 | 1503 | |
1442 | 1504 | $destination = $packagesdir . '/' . $base_name; |
1443 | 1505 | |
1444 | - if (file_exists($destination)) |
|
1445 | - fatal_lang_error('package_upload_error_exists'); |
|
1506 | + if (file_exists($destination)) { |
|
1507 | + fatal_lang_error('package_upload_error_exists'); |
|
1508 | + } |
|
1446 | 1509 | |
1447 | 1510 | // Let's copy it to the Packages directory |
1448 | 1511 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
1449 | 1512 | $testing = true; |
1450 | - } |
|
1451 | - elseif (isset($_REQUEST['package'])) |
|
1513 | + } elseif (isset($_REQUEST['package'])) |
|
1452 | 1514 | { |
1453 | 1515 | $base_name = basename($_REQUEST['package']); |
1454 | 1516 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1457,12 +1519,14 @@ discard block |
||
1457 | 1519 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
1458 | 1520 | } |
1459 | 1521 | |
1460 | - if (empty($destination) || !file_exists($destination)) |
|
1461 | - fatal_lang_error('package_no_file', false); |
|
1522 | + if (empty($destination) || !file_exists($destination)) { |
|
1523 | + fatal_lang_error('package_no_file', false); |
|
1524 | + } |
|
1462 | 1525 | |
1463 | 1526 | // Make sure temp directory exists and is empty. |
1464 | - if (file_exists($packagesdir . '/temp')) |
|
1465 | - deltree($packagesdir . '/temp', false); |
|
1527 | + if (file_exists($packagesdir . '/temp')) { |
|
1528 | + deltree($packagesdir . '/temp', false); |
|
1529 | + } |
|
1466 | 1530 | |
1467 | 1531 | if (!mktree($packagesdir . '/temp', 0755)) |
1468 | 1532 | { |
@@ -1474,31 +1538,37 @@ discard block |
||
1474 | 1538 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
1475 | 1539 | |
1476 | 1540 | deltree($packagesdir . '/temp', false); |
1477 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
1478 | - fatal_lang_error('package_cant_download', false); |
|
1541 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
1542 | + fatal_lang_error('package_cant_download', false); |
|
1543 | + } |
|
1479 | 1544 | } |
1480 | 1545 | } |
1481 | 1546 | |
1482 | 1547 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
1483 | - if (!$extracted) |
|
1484 | - fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1485 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
1486 | - foreach ($extracted as $file) |
|
1548 | + if (!$extracted) { |
|
1549 | + fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1550 | + } |
|
1551 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
1552 | + foreach ($extracted as $file) |
|
1487 | 1553 | if (basename($file['filename']) == 'package-info.xml') |
1488 | 1554 | { |
1489 | 1555 | $base_path = dirname($file['filename']) . '/'; |
1556 | + } |
|
1490 | 1557 | break; |
1491 | 1558 | } |
1492 | 1559 | |
1493 | - if (!isset($base_path)) |
|
1494 | - $base_path = ''; |
|
1560 | + if (!isset($base_path)) { |
|
1561 | + $base_path = ''; |
|
1562 | + } |
|
1495 | 1563 | |
1496 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
1497 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
1564 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
1565 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
1566 | + } |
|
1498 | 1567 | |
1499 | 1568 | $smileyInfo = getPackageInfo($context['filename']); |
1500 | - if (!is_array($smileyInfo)) |
|
1501 | - fatal_lang_error($smileyInfo); |
|
1569 | + if (!is_array($smileyInfo)) { |
|
1570 | + fatal_lang_error($smileyInfo); |
|
1571 | + } |
|
1502 | 1572 | |
1503 | 1573 | // See if it is installed? |
1504 | 1574 | $request = $smcFunc['db_query']('', ' |
@@ -1514,8 +1584,9 @@ discard block |
||
1514 | 1584 | ) |
1515 | 1585 | ); |
1516 | 1586 | |
1517 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1518 | - fatal_lang_error('package_installed_warning1'); |
|
1587 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1588 | + fatal_lang_error('package_installed_warning1'); |
|
1589 | + } |
|
1519 | 1590 | |
1520 | 1591 | // Everything is fine, now it's time to do something |
1521 | 1592 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1530,23 +1601,23 @@ discard block |
||
1530 | 1601 | if ($action['type'] == 'readme' || $action['type'] == 'license') |
1531 | 1602 | { |
1532 | 1603 | $type = 'package_' . $action['type']; |
1533 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
1534 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1535 | - elseif (file_exists($action['filename'])) |
|
1536 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1604 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
1605 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1606 | + } elseif (file_exists($action['filename'])) { |
|
1607 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1608 | + } |
|
1537 | 1609 | |
1538 | 1610 | if (!empty($action['parse_bbc'])) |
1539 | 1611 | { |
1540 | 1612 | require_once($sourcedir . '/Subs-Post.php'); |
1541 | 1613 | preparsecode($context[$type]); |
1542 | 1614 | $context[$type] = parse_bbc($context[$type]); |
1615 | + } else { |
|
1616 | + $context[$type] = nl2br($context[$type]); |
|
1543 | 1617 | } |
1544 | - else |
|
1545 | - $context[$type] = nl2br($context[$type]); |
|
1546 | 1618 | |
1547 | 1619 | continue; |
1548 | - } |
|
1549 | - elseif ($action['type'] == 'require-dir') |
|
1620 | + } elseif ($action['type'] == 'require-dir') |
|
1550 | 1621 | { |
1551 | 1622 | // Do this one... |
1552 | 1623 | $thisAction = array( |
@@ -1565,12 +1636,12 @@ discard block |
||
1565 | 1636 | ); |
1566 | 1637 | } |
1567 | 1638 | // @todo None given? |
1568 | - if (empty($thisAction['description'])) |
|
1569 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1639 | + if (empty($thisAction['description'])) { |
|
1640 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1641 | + } |
|
1570 | 1642 | |
1571 | 1643 | $context['actions'][] = $thisAction; |
1572 | - } |
|
1573 | - elseif ($action['type'] == 'credits') |
|
1644 | + } elseif ($action['type'] == 'credits') |
|
1574 | 1645 | { |
1575 | 1646 | // Time to build the billboard |
1576 | 1647 | $credits_tag = array( |
@@ -1630,12 +1701,14 @@ discard block |
||
1630 | 1701 | cache_put_data('posting_smileys', null, 480); |
1631 | 1702 | } |
1632 | 1703 | |
1633 | - if (file_exists($packagesdir . '/temp')) |
|
1634 | - deltree($packagesdir . '/temp'); |
|
1704 | + if (file_exists($packagesdir . '/temp')) { |
|
1705 | + deltree($packagesdir . '/temp'); |
|
1706 | + } |
|
1635 | 1707 | |
1636 | - if (!$testing) |
|
1637 | - redirectexit('action=admin;area=smileys'); |
|
1638 | -} |
|
1708 | + if (!$testing) { |
|
1709 | + redirectexit('action=admin;area=smileys'); |
|
1710 | + } |
|
1711 | + } |
|
1639 | 1712 | |
1640 | 1713 | /** |
1641 | 1714 | * A function to import new smileys from an existing directory into the database. |
@@ -1646,15 +1719,17 @@ discard block |
||
1646 | 1719 | { |
1647 | 1720 | global $modSettings, $smcFunc; |
1648 | 1721 | |
1649 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
1650 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
1722 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
1723 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
1724 | + } |
|
1651 | 1725 | |
1652 | 1726 | $smileys = array(); |
1653 | 1727 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
1654 | 1728 | while ($entry = $dir->read()) |
1655 | 1729 | { |
1656 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1657 | - $smileys[strtolower($entry)] = $entry; |
|
1730 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1731 | + $smileys[strtolower($entry)] = $entry; |
|
1732 | + } |
|
1658 | 1733 | } |
1659 | 1734 | $dir->close(); |
1660 | 1735 | |
@@ -1667,9 +1742,10 @@ discard block |
||
1667 | 1742 | 'smiley_list' => $smileys, |
1668 | 1743 | ) |
1669 | 1744 | ); |
1670 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1671 | - if (isset($smileys[strtolower($row['filename'])])) |
|
1745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1746 | + if (isset($smileys[strtolower($row['filename'])])) |
|
1672 | 1747 | unset($smileys[strtolower($row['filename'])]); |
1748 | + } |
|
1673 | 1749 | $smcFunc['db_free_result']($request); |
1674 | 1750 | |
1675 | 1751 | $request = $smcFunc['db_query']('', ' |
@@ -1686,9 +1762,10 @@ discard block |
||
1686 | 1762 | $smcFunc['db_free_result']($request); |
1687 | 1763 | |
1688 | 1764 | $new_smileys = array(); |
1689 | - foreach ($smileys as $smiley) |
|
1690 | - if (strlen($smiley) <= 48) |
|
1765 | + foreach ($smileys as $smiley) { |
|
1766 | + if (strlen($smiley) <= 48) |
|
1691 | 1767 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
1768 | + } |
|
1692 | 1769 | |
1693 | 1770 | if (!empty($new_smileys)) |
1694 | 1771 | { |
@@ -1753,8 +1830,9 @@ discard block |
||
1753 | 1830 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
1754 | 1831 | { |
1755 | 1832 | $deleteIcons = array(); |
1756 | - foreach ($_POST['checked_icons'] as $icon) |
|
1757 | - $deleteIcons[] = (int) $icon; |
|
1833 | + foreach ($_POST['checked_icons'] as $icon) { |
|
1834 | + $deleteIcons[] = (int) $icon; |
|
1835 | + } |
|
1758 | 1836 | |
1759 | 1837 | // Do the actual delete! |
1760 | 1838 | $smcFunc['db_query']('', ' |
@@ -1771,35 +1849,41 @@ discard block |
||
1771 | 1849 | $_GET['icon'] = (int) $_GET['icon']; |
1772 | 1850 | |
1773 | 1851 | // Do some preperation with the data... like check the icon exists *somewhere* |
1774 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
1775 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1776 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
1777 | - fatal_lang_error('icon_not_found'); |
|
1852 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
1853 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1854 | + } |
|
1855 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
1856 | + fatal_lang_error('icon_not_found'); |
|
1857 | + } |
|
1778 | 1858 | // There is a 16 character limit on message icons... |
1779 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
1780 | - fatal_lang_error('icon_name_too_long'); |
|
1781 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
1782 | - fatal_lang_error('icon_after_itself'); |
|
1859 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
1860 | + fatal_lang_error('icon_name_too_long'); |
|
1861 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
1862 | + fatal_lang_error('icon_after_itself'); |
|
1863 | + } |
|
1783 | 1864 | |
1784 | 1865 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
1785 | 1866 | if ($_GET['icon'] != 0) |
1786 | 1867 | { |
1787 | 1868 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
1788 | - foreach ($context['icons'] as $id => $data) |
|
1789 | - if ($data['true_order'] > $oldOrder) |
|
1869 | + foreach ($context['icons'] as $id => $data) { |
|
1870 | + if ($data['true_order'] > $oldOrder) |
|
1790 | 1871 | $context['icons'][$id]['true_order']--; |
1872 | + } |
|
1791 | 1873 | } |
1792 | 1874 | |
1793 | 1875 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
1794 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
1795 | - $_GET['icon'] = 1; |
|
1876 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
1877 | + $_GET['icon'] = 1; |
|
1878 | + } |
|
1796 | 1879 | |
1797 | 1880 | // Get the new order. |
1798 | 1881 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
1799 | 1882 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
1800 | - foreach ($context['icons'] as $id => $data) |
|
1801 | - if ($data['true_order'] >= $newOrder) |
|
1883 | + foreach ($context['icons'] as $id => $data) { |
|
1884 | + if ($data['true_order'] >= $newOrder) |
|
1802 | 1885 | $context['icons'][$id]['true_order']++; |
1886 | + } |
|
1803 | 1887 | |
1804 | 1888 | // Finally set the current icon's position! |
1805 | 1889 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1817,8 +1901,7 @@ discard block |
||
1817 | 1901 | if ($id != 0) |
1818 | 1902 | { |
1819 | 1903 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1820 | - } |
|
1821 | - else |
|
1904 | + } else |
|
1822 | 1905 | { |
1823 | 1906 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1824 | 1907 | } |
@@ -1843,8 +1926,9 @@ discard block |
||
1843 | 1926 | } |
1844 | 1927 | |
1845 | 1928 | // Unless we're adding a new thing, we'll escape |
1846 | - if (!isset($_POST['add'])) |
|
1847 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1929 | + if (!isset($_POST['add'])) { |
|
1930 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1931 | + } |
|
1848 | 1932 | } |
1849 | 1933 | |
1850 | 1934 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1954,8 +2038,9 @@ discard block |
||
1954 | 2038 | $context['new_icon'] = !isset($_GET['icon']); |
1955 | 2039 | |
1956 | 2040 | // Get the properties of the current icon from the icon list. |
1957 | - if (!$context['new_icon']) |
|
1958 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2041 | + if (!$context['new_icon']) { |
|
2042 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2043 | + } |
|
1959 | 2044 | |
1960 | 2045 | // Get a list of boards needed for assigning this icon to a specific board. |
1961 | 2046 | $boardListOptions = array( |
@@ -1989,8 +2074,9 @@ discard block |
||
1989 | 2074 | ); |
1990 | 2075 | |
1991 | 2076 | $message_icons = array(); |
1992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1993 | - $message_icons[] = $row; |
|
2077 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2078 | + $message_icons[] = $row; |
|
2079 | + } |
|
1994 | 2080 | $smcFunc['db_free_result']($request); |
1995 | 2081 | |
1996 | 2082 | return $message_icons; |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | 'member_name' => $regOptions['username'], |
587 | 587 | 'email_address' => $regOptions['email'], |
588 | 588 | 'passwd' => hash_password($regOptions['username'], $regOptions['password']), |
589 | - 'password_salt' => substr(md5(mt_rand()), 0, 4) , |
|
589 | + 'password_salt' => substr(md5(mt_rand()), 0, 4), |
|
590 | 590 | 'posts' => 0, |
591 | 591 | 'date_registered' => time(), |
592 | 592 | 'member_ip' => $regOptions['interface'] == 'admin' ? '127.0.0.1' : $user_info['ip'], |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | 'time_offset', |
677 | 677 | ); |
678 | 678 | $knownInets = array( |
679 | - 'member_ip','member_ip2', |
|
679 | + 'member_ip', 'member_ip2', |
|
680 | 680 | ); |
681 | 681 | |
682 | 682 | // Call an optional function to validate the users' input. |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
905 | 905 | |
906 | 906 | //when we got no wildcard we can use equal -> fast |
907 | - $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=' ); |
|
907 | + $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '='); |
|
908 | 908 | |
909 | 909 | // Make sure they don't want someone else's name. |
910 | 910 | $request = $smcFunc['db_query']('', ' |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | $user_info['buddies'][] = $userReceiver; |
1274 | 1274 | |
1275 | 1275 | // And add a nice alert. Don't abuse though! |
1276 | - if ((cache_get_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, 86400)) == null) |
|
1276 | + if ((cache_get_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, 86400)) == null) |
|
1277 | 1277 | { |
1278 | 1278 | $smcFunc['db_insert']('insert', |
1279 | 1279 | '{db_prefix}background_tasks', |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | ); |
1289 | 1289 | |
1290 | 1290 | // Store this in a cache entry to avoid creating multiple alerts. Give it a long life cycle. |
1291 | - cache_put_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, '1', 86400); |
|
1291 | + cache_put_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, '1', 86400); |
|
1292 | 1292 | } |
1293 | 1293 | } |
1294 | 1294 |
@@ -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 | * Delete one or more members. |
@@ -43,30 +44,32 @@ discard block |
||
43 | 44 | setMemoryLimit('128M'); |
44 | 45 | |
45 | 46 | // If it's not an array, make it so! |
46 | - if (!is_array($users)) |
|
47 | - $users = array($users); |
|
48 | - else |
|
49 | - $users = array_unique($users); |
|
47 | + if (!is_array($users)) { |
|
48 | + $users = array($users); |
|
49 | + } else { |
|
50 | + $users = array_unique($users); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Make sure there's no void user in here. |
52 | 54 | $users = array_diff($users, array(0)); |
53 | 55 | |
54 | 56 | // How many are they deleting? |
55 | - if (empty($users)) |
|
56 | - return; |
|
57 | - elseif (count($users) == 1) |
|
57 | + if (empty($users)) { |
|
58 | + return; |
|
59 | + } elseif (count($users) == 1) |
|
58 | 60 | { |
59 | 61 | list ($user) = $users; |
60 | 62 | |
61 | - if ($user == $user_info['id']) |
|
62 | - isAllowedTo('profile_remove_own'); |
|
63 | - else |
|
64 | - isAllowedTo('profile_remove_any'); |
|
65 | - } |
|
66 | - else |
|
63 | + if ($user == $user_info['id']) { |
|
64 | + isAllowedTo('profile_remove_own'); |
|
65 | + } else { |
|
66 | + isAllowedTo('profile_remove_any'); |
|
67 | + } |
|
68 | + } else |
|
67 | 69 | { |
68 | - foreach ($users as $k => $v) |
|
69 | - $users[$k] = (int) $v; |
|
70 | + foreach ($users as $k => $v) { |
|
71 | + $users[$k] = (int) $v; |
|
72 | + } |
|
70 | 73 | |
71 | 74 | // Deleting more than one? You can't have more than one account... |
72 | 75 | isAllowedTo('profile_remove_any'); |
@@ -88,26 +91,30 @@ discard block |
||
88 | 91 | $user_log_details = array(); |
89 | 92 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
90 | 93 | { |
91 | - if ($row['is_admin']) |
|
92 | - $admins[] = $row['id_member']; |
|
94 | + if ($row['is_admin']) { |
|
95 | + $admins[] = $row['id_member']; |
|
96 | + } |
|
93 | 97 | $user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']); |
94 | 98 | } |
95 | 99 | $smcFunc['db_free_result']($request); |
96 | 100 | |
97 | - if (empty($user_log_details)) |
|
98 | - return; |
|
101 | + if (empty($user_log_details)) { |
|
102 | + return; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themself. |
101 | 106 | if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id'])))) |
102 | 107 | { |
103 | 108 | $users = array_diff($users, $admins); |
104 | - foreach ($admins as $id) |
|
105 | - unset($user_log_details[$id]); |
|
109 | + foreach ($admins as $id) { |
|
110 | + unset($user_log_details[$id]); |
|
111 | + } |
|
106 | 112 | } |
107 | 113 | |
108 | 114 | // No one left? |
109 | - if (empty($users)) |
|
110 | - return; |
|
115 | + if (empty($users)) { |
|
116 | + return; |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Log the action - regardless of who is deleting it. |
113 | 120 | $log_changes = array(); |
@@ -124,8 +131,9 @@ discard block |
||
124 | 131 | ); |
125 | 132 | |
126 | 133 | // Remove any cached data if enabled. |
127 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
128 | - cache_put_data('user_settings-' . $user[0], null, 60); |
|
134 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
135 | + cache_put_data('user_settings-' . $user[0], null, 60); |
|
136 | + } |
|
129 | 137 | } |
130 | 138 | |
131 | 139 | // Make these peoples' posts guest posts. |
@@ -388,8 +396,8 @@ discard block |
||
388 | 396 | 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users), |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
392 | - $smcFunc['db_query']('', ' |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
400 | + $smcFunc['db_query']('', ' |
|
393 | 401 | UPDATE {db_prefix}members |
394 | 402 | SET |
395 | 403 | pm_ignore_list = {string:pm_ignore_list}, |
@@ -401,6 +409,7 @@ discard block |
||
401 | 409 | 'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)), |
402 | 410 | ) |
403 | 411 | ); |
412 | + } |
|
404 | 413 | $smcFunc['db_free_result']($request); |
405 | 414 | |
406 | 415 | // Make sure no member's birthday is still sticking in the calendar... |
@@ -455,29 +464,34 @@ discard block |
||
455 | 464 | elseif ($regOptions['interface'] == 'guest') |
456 | 465 | { |
457 | 466 | // You cannot register twice... |
458 | - if (empty($user_info['is_guest'])) |
|
459 | - redirectexit(); |
|
467 | + if (empty($user_info['is_guest'])) { |
|
468 | + redirectexit(); |
|
469 | + } |
|
460 | 470 | |
461 | 471 | // Make sure they didn't just register with this session. |
462 | - if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) |
|
463 | - fatal_lang_error('register_only_once', false); |
|
472 | + if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) { |
|
473 | + fatal_lang_error('register_only_once', false); |
|
474 | + } |
|
464 | 475 | } |
465 | 476 | |
466 | 477 | // Spaces and other odd characters are evil... |
467 | 478 | $regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username'])); |
468 | 479 | |
469 | 480 | // @todo Separate the sprintf? |
470 | - if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) |
|
471 | - $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
481 | + if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) { |
|
482 | + $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
483 | + } |
|
472 | 484 | |
473 | 485 | $username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name'])); |
474 | - if (!empty($username_validation_errors)) |
|
475 | - $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
486 | + if (!empty($username_validation_errors)) { |
|
487 | + $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
488 | + } |
|
476 | 489 | |
477 | 490 | // Generate a validation code if it's supposed to be emailed. |
478 | 491 | $validation_code = ''; |
479 | - if ($regOptions['require'] == 'activation') |
|
480 | - $validation_code = generateValidationCode(); |
|
492 | + if ($regOptions['require'] == 'activation') { |
|
493 | + $validation_code = generateValidationCode(); |
|
494 | + } |
|
481 | 495 | |
482 | 496 | // If you haven't put in a password generate one. |
483 | 497 | if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '') |
@@ -487,8 +501,9 @@ discard block |
||
487 | 501 | $regOptions['password_check'] = $regOptions['password']; |
488 | 502 | } |
489 | 503 | // Does the first password match the second? |
490 | - elseif ($regOptions['password'] != $regOptions['password_check']) |
|
491 | - $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
504 | + elseif ($regOptions['password'] != $regOptions['password_check']) { |
|
505 | + $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
506 | + } |
|
492 | 507 | |
493 | 508 | // That's kind of easy to guess... |
494 | 509 | if ($regOptions['password'] == '') |
@@ -502,13 +517,15 @@ discard block |
||
502 | 517 | $passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email'])); |
503 | 518 | |
504 | 519 | // Password isn't legal? |
505 | - if ($passwordError != null) |
|
506 | - $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
520 | + if ($passwordError != null) { |
|
521 | + $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
522 | + } |
|
507 | 523 | } |
508 | 524 | |
509 | 525 | // You may not be allowed to register this email. |
510 | - if (!empty($regOptions['check_email_ban'])) |
|
511 | - isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
526 | + if (!empty($regOptions['check_email_ban'])) { |
|
527 | + isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
528 | + } |
|
512 | 529 | |
513 | 530 | // Check if the email address is in use. |
514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -523,8 +540,9 @@ discard block |
||
523 | 540 | ) |
524 | 541 | ); |
525 | 542 | // @todo Separate the sprintf? |
526 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
527 | - $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
543 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
544 | + $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
545 | + } |
|
528 | 546 | |
529 | 547 | $smcFunc['db_free_result']($request); |
530 | 548 | |
@@ -539,24 +557,27 @@ discard block |
||
539 | 557 | 1 = The text/index. |
540 | 558 | 2 = Whether to log. |
541 | 559 | 3 = sprintf data if necessary. */ |
542 | - if ($error[0] == 'lang') |
|
543 | - loadLanguage('Errors'); |
|
560 | + if ($error[0] == 'lang') { |
|
561 | + loadLanguage('Errors'); |
|
562 | + } |
|
544 | 563 | $message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1]; |
545 | 564 | |
546 | 565 | // What to do, what to do, what to do. |
547 | 566 | if ($return_errors) |
548 | 567 | { |
549 | - if (!empty($error[2])) |
|
550 | - log_error($message, $error[2]); |
|
568 | + if (!empty($error[2])) { |
|
569 | + log_error($message, $error[2]); |
|
570 | + } |
|
551 | 571 | $reg_errors[$key] = $message; |
572 | + } else { |
|
573 | + fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
552 | 574 | } |
553 | - else |
|
554 | - fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
555 | 575 | } |
556 | 576 | |
557 | 577 | // If there's any errors left return them at once! |
558 | - if (!empty($reg_errors)) |
|
559 | - return $reg_errors; |
|
578 | + if (!empty($reg_errors)) { |
|
579 | + return $reg_errors; |
|
580 | + } |
|
560 | 581 | |
561 | 582 | $reservedVars = array( |
562 | 583 | 'actual_theme_url', |
@@ -578,8 +599,9 @@ discard block |
||
578 | 599 | ); |
579 | 600 | |
580 | 601 | // Can't change reserved vars. |
581 | - if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) |
|
582 | - fatal_lang_error('no_theme'); |
|
602 | + if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) { |
|
603 | + fatal_lang_error('no_theme'); |
|
604 | + } |
|
583 | 605 | |
584 | 606 | // Some of these might be overwritten. (the lower ones that are in the arrays below.) |
585 | 607 | $regOptions['register_vars'] = array( |
@@ -621,14 +643,17 @@ discard block |
||
621 | 643 | $regOptions['register_vars']['validation_code'] = ''; |
622 | 644 | } |
623 | 645 | // Maybe it can be activated right away? |
624 | - elseif ($regOptions['require'] == 'nothing') |
|
625 | - $regOptions['register_vars']['is_activated'] = 1; |
|
646 | + elseif ($regOptions['require'] == 'nothing') { |
|
647 | + $regOptions['register_vars']['is_activated'] = 1; |
|
648 | + } |
|
626 | 649 | // Maybe it must be activated by email? |
627 | - elseif ($regOptions['require'] == 'activation') |
|
628 | - $regOptions['register_vars']['is_activated'] = 0; |
|
650 | + elseif ($regOptions['require'] == 'activation') { |
|
651 | + $regOptions['register_vars']['is_activated'] = 0; |
|
652 | + } |
|
629 | 653 | // Otherwise it must be awaiting approval! |
630 | - else |
|
631 | - $regOptions['register_vars']['is_activated'] = 3; |
|
654 | + else { |
|
655 | + $regOptions['register_vars']['is_activated'] = 3; |
|
656 | + } |
|
632 | 657 | |
633 | 658 | if (isset($regOptions['memberGroup'])) |
634 | 659 | { |
@@ -647,24 +672,28 @@ discard block |
||
647 | 672 | 'is_protected' => 1, |
648 | 673 | ) |
649 | 674 | ); |
650 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
651 | - $unassignableGroups[] = $row['id_group']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $unassignableGroups[] = $row['id_group']; |
|
677 | + } |
|
652 | 678 | $smcFunc['db_free_result']($request); |
653 | 679 | |
654 | - if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) |
|
655 | - $regOptions['register_vars']['id_group'] = 0; |
|
680 | + if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) { |
|
681 | + $regOptions['register_vars']['id_group'] = 0; |
|
682 | + } |
|
656 | 683 | } |
657 | 684 | |
658 | 685 | // Integrate optional member settings to be set. |
659 | - if (!empty($regOptions['extra_register_vars'])) |
|
660 | - foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
686 | + if (!empty($regOptions['extra_register_vars'])) { |
|
687 | + foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
661 | 688 | $regOptions['register_vars'][$var] = $value; |
689 | + } |
|
662 | 690 | |
663 | 691 | // Integrate optional user theme options to be set. |
664 | 692 | $theme_vars = array(); |
665 | - if (!empty($regOptions['theme_vars'])) |
|
666 | - foreach ($regOptions['theme_vars'] as $var => $value) |
|
693 | + if (!empty($regOptions['theme_vars'])) { |
|
694 | + foreach ($regOptions['theme_vars'] as $var => $value) |
|
667 | 695 | $theme_vars[$var] = $value; |
696 | + } |
|
668 | 697 | |
669 | 698 | // Right, now let's prepare for insertion. |
670 | 699 | $knownInts = array( |
@@ -687,14 +716,15 @@ discard block |
||
687 | 716 | foreach ($regOptions['register_vars'] as $var => $val) |
688 | 717 | { |
689 | 718 | $type = 'string'; |
690 | - if (in_array($var, $knownInts)) |
|
691 | - $type = 'int'; |
|
692 | - elseif (in_array($var, $knownFloats)) |
|
693 | - $type = 'float'; |
|
694 | - elseif (in_array($var, $knownInets)) |
|
695 | - $type = 'inet'; |
|
696 | - elseif ($var == 'birthdate') |
|
697 | - $type = 'date'; |
|
719 | + if (in_array($var, $knownInts)) { |
|
720 | + $type = 'int'; |
|
721 | + } elseif (in_array($var, $knownFloats)) { |
|
722 | + $type = 'float'; |
|
723 | + } elseif (in_array($var, $knownInets)) { |
|
724 | + $type = 'inet'; |
|
725 | + } elseif ($var == 'birthdate') { |
|
726 | + $type = 'date'; |
|
727 | + } |
|
698 | 728 | |
699 | 729 | $column_names[$var] = $type; |
700 | 730 | $values[$var] = $val; |
@@ -713,17 +743,19 @@ discard block |
||
713 | 743 | call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID)); |
714 | 744 | |
715 | 745 | // Update the number of members and latest member's info - and pass the name, but remove the 's. |
716 | - if ($regOptions['register_vars']['is_activated'] == 1) |
|
717 | - updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
718 | - else |
|
719 | - updateStats('member'); |
|
746 | + if ($regOptions['register_vars']['is_activated'] == 1) { |
|
747 | + updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
748 | + } else { |
|
749 | + updateStats('member'); |
|
750 | + } |
|
720 | 751 | |
721 | 752 | // Theme variables too? |
722 | 753 | if (!empty($theme_vars)) |
723 | 754 | { |
724 | 755 | $inserts = array(); |
725 | - foreach ($theme_vars as $var => $val) |
|
726 | - $inserts[] = array($memberID, $var, $val); |
|
756 | + foreach ($theme_vars as $var => $val) { |
|
757 | + $inserts[] = array($memberID, $var, $val); |
|
758 | + } |
|
727 | 759 | $smcFunc['db_insert']('insert', |
728 | 760 | '{db_prefix}themes', |
729 | 761 | array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
@@ -738,10 +770,11 @@ discard block |
||
738 | 770 | // Administrative registrations are a bit different... |
739 | 771 | if ($regOptions['interface'] == 'admin') |
740 | 772 | { |
741 | - if ($regOptions['require'] == 'activation') |
|
742 | - $email_message = 'admin_register_activate'; |
|
743 | - elseif (!empty($regOptions['send_welcome_email'])) |
|
744 | - $email_message = 'admin_register_immediate'; |
|
773 | + if ($regOptions['require'] == 'activation') { |
|
774 | + $email_message = 'admin_register_activate'; |
|
775 | + } elseif (!empty($regOptions['send_welcome_email'])) { |
|
776 | + $email_message = 'admin_register_immediate'; |
|
777 | + } |
|
745 | 778 | |
746 | 779 | if (isset($email_message)) |
747 | 780 | { |
@@ -792,16 +825,17 @@ discard block |
||
792 | 825 | 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', |
793 | 826 | ); |
794 | 827 | |
795 | - if ($regOptions['require'] == 'activation') |
|
796 | - $replacements += array( |
|
828 | + if ($regOptions['require'] == 'activation') { |
|
829 | + $replacements += array( |
|
797 | 830 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, |
798 | 831 | 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, |
799 | 832 | 'ACTIVATIONCODE' => $validation_code, |
800 | 833 | ); |
801 | - else |
|
802 | - $replacements += array( |
|
834 | + } else { |
|
835 | + $replacements += array( |
|
803 | 836 | 'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID, |
804 | 837 | ); |
838 | + } |
|
805 | 839 | |
806 | 840 | $emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements); |
807 | 841 | |
@@ -866,39 +900,45 @@ discard block |
||
866 | 900 | // Check each name in the list... |
867 | 901 | foreach ($reservedNames as $reserved) |
868 | 902 | { |
869 | - if ($reserved == '') |
|
870 | - continue; |
|
903 | + if ($reserved == '') { |
|
904 | + continue; |
|
905 | + } |
|
871 | 906 | |
872 | 907 | // The admin might've used entities too, level the playing field. |
873 | 908 | $reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved); |
874 | 909 | |
875 | 910 | // Case sensitive name? |
876 | - if (empty($modSettings['reserveCase'])) |
|
877 | - $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
911 | + if (empty($modSettings['reserveCase'])) { |
|
912 | + $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
913 | + } |
|
878 | 914 | |
879 | 915 | // If it's not just entire word, check for it in there somewhere... |
880 | - if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) |
|
881 | - if ($fatal) |
|
916 | + if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) { |
|
917 | + if ($fatal) |
|
882 | 918 | fatal_lang_error('username_reserved', 'password', array($reserved)); |
883 | - else |
|
884 | - return true; |
|
919 | + } else { |
|
920 | + return true; |
|
921 | + } |
|
885 | 922 | } |
886 | 923 | |
887 | 924 | $censor_name = $name; |
888 | - if (censorText($censor_name) != $name) |
|
889 | - if ($fatal) |
|
925 | + if (censorText($censor_name) != $name) { |
|
926 | + if ($fatal) |
|
890 | 927 | fatal_lang_error('name_censored', 'password', array($name)); |
891 | - else |
|
892 | - return true; |
|
928 | + } else { |
|
929 | + return true; |
|
930 | + } |
|
893 | 931 | } |
894 | 932 | |
895 | 933 | // Characters we just shouldn't allow, regardless. |
896 | - foreach (array('*') as $char) |
|
897 | - if (strpos($checkName, $char) !== false) |
|
934 | + foreach (array('*') as $char) { |
|
935 | + if (strpos($checkName, $char) !== false) |
|
898 | 936 | if ($fatal) |
899 | 937 | fatal_lang_error('username_reserved', 'password', array($char)); |
900 | - else |
|
901 | - return true; |
|
938 | + } |
|
939 | + else { |
|
940 | + return true; |
|
941 | + } |
|
902 | 942 | |
903 | 943 | // Get rid of any SQL parts of the reserved name... |
904 | 944 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
@@ -980,8 +1020,9 @@ discard block |
||
980 | 1020 | 'permission' => $permission, |
981 | 1021 | ) |
982 | 1022 | ); |
983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
984 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1023 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1024 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1025 | + } |
|
985 | 1026 | $smcFunc['db_free_result']($request); |
986 | 1027 | } |
987 | 1028 | |
@@ -989,9 +1030,9 @@ discard block |
||
989 | 1030 | else |
990 | 1031 | { |
991 | 1032 | // First get the profile of the given board. |
992 | - if (isset($board_info['id']) && $board_info['id'] == $board_id) |
|
993 | - $profile_id = $board_info['profile']; |
|
994 | - elseif ($board_id !== 0) |
|
1033 | + if (isset($board_info['id']) && $board_info['id'] == $board_id) { |
|
1034 | + $profile_id = $board_info['profile']; |
|
1035 | + } elseif ($board_id !== 0) |
|
995 | 1036 | { |
996 | 1037 | $request = $smcFunc['db_query']('', ' |
997 | 1038 | SELECT id_profile |
@@ -1002,13 +1043,14 @@ discard block |
||
1002 | 1043 | 'id_board' => $board_id, |
1003 | 1044 | ) |
1004 | 1045 | ); |
1005 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1006 | - fatal_lang_error('no_board'); |
|
1046 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1047 | + fatal_lang_error('no_board'); |
|
1048 | + } |
|
1007 | 1049 | list ($profile_id) = $smcFunc['db_fetch_row']($request); |
1008 | 1050 | $smcFunc['db_free_result']($request); |
1051 | + } else { |
|
1052 | + $profile_id = 1; |
|
1009 | 1053 | } |
1010 | - else |
|
1011 | - $profile_id = 1; |
|
1012 | 1054 | |
1013 | 1055 | $request = $smcFunc['db_query']('', ' |
1014 | 1056 | SELECT bp.id_group, bp.add_deny |
@@ -1020,8 +1062,9 @@ discard block |
||
1020 | 1062 | 'permission' => $permission, |
1021 | 1063 | ) |
1022 | 1064 | ); |
1023 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1024 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1065 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1066 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1067 | + } |
|
1025 | 1068 | $smcFunc['db_free_result']($request); |
1026 | 1069 | |
1027 | 1070 | $moderator_groups = array(); |
@@ -1030,8 +1073,7 @@ discard block |
||
1030 | 1073 | if (isset($board_info['moderator_groups'])) |
1031 | 1074 | { |
1032 | 1075 | $moderator_groups = array_keys($board_info['moderator_groups']); |
1033 | - } |
|
1034 | - elseif ($board_id !== 0) |
|
1076 | + } elseif ($board_id !== 0) |
|
1035 | 1077 | { |
1036 | 1078 | // Get the groups that can moderate this board |
1037 | 1079 | $request = $smcFunc['db_query']('', ' |
@@ -1116,8 +1158,9 @@ discard block |
||
1116 | 1158 | ) |
1117 | 1159 | ); |
1118 | 1160 | $members = array(); |
1119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1120 | - $members[] = $row['id_member']; |
|
1161 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1162 | + $members[] = $row['id_member']; |
|
1163 | + } |
|
1121 | 1164 | $smcFunc['db_free_result']($request); |
1122 | 1165 | |
1123 | 1166 | return $members; |
@@ -1190,10 +1233,12 @@ discard block |
||
1190 | 1233 | } |
1191 | 1234 | |
1192 | 1235 | $query_parts = array(); |
1193 | - if (!empty($email)) |
|
1194 | - $query_parts[] = 'poster_email = {string:email_address}'; |
|
1195 | - if (!empty($membername)) |
|
1196 | - $query_parts[] = 'poster_name = {string:member_name}'; |
|
1236 | + if (!empty($email)) { |
|
1237 | + $query_parts[] = 'poster_email = {string:email_address}'; |
|
1238 | + } |
|
1239 | + if (!empty($membername)) { |
|
1240 | + $query_parts[] = 'poster_name = {string:member_name}'; |
|
1241 | + } |
|
1197 | 1242 | $query = implode(' AND ', $query_parts); |
1198 | 1243 | |
1199 | 1244 | // Finally, update the posts themselves! |
@@ -1260,12 +1305,14 @@ discard block |
||
1260 | 1305 | |
1261 | 1306 | $userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0; |
1262 | 1307 | |
1263 | - if (empty($userReceiver)) |
|
1264 | - fatal_lang_error('no_access', false); |
|
1308 | + if (empty($userReceiver)) { |
|
1309 | + fatal_lang_error('no_access', false); |
|
1310 | + } |
|
1265 | 1311 | |
1266 | 1312 | // Remove if it's already there... |
1267 | - if (in_array($userReceiver, $user_info['buddies'])) |
|
1268 | - $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
1313 | + if (in_array($userReceiver, $user_info['buddies'])) { |
|
1314 | + $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
1315 | + } |
|
1269 | 1316 | |
1270 | 1317 | // ...or add if it's not and if it's not you. |
1271 | 1318 | elseif ($user_info['id'] != $userReceiver) |
@@ -1340,8 +1387,9 @@ discard block |
||
1340 | 1387 | $smcFunc['db_free_result']($request); |
1341 | 1388 | |
1342 | 1389 | // If we want duplicates pass the members array off. |
1343 | - if ($get_duplicates) |
|
1344 | - populateDuplicateMembers($members); |
|
1390 | + if ($get_duplicates) { |
|
1391 | + populateDuplicateMembers($members); |
|
1392 | + } |
|
1345 | 1393 | |
1346 | 1394 | return $members; |
1347 | 1395 | } |
@@ -1358,8 +1406,9 @@ discard block |
||
1358 | 1406 | global $smcFunc, $modSettings; |
1359 | 1407 | |
1360 | 1408 | // We know how many members there are in total. |
1361 | - if (empty($where) || $where == '1=1') |
|
1362 | - $num_members = $modSettings['totalMembers']; |
|
1409 | + if (empty($where) || $where == '1=1') { |
|
1410 | + $num_members = $modSettings['totalMembers']; |
|
1411 | + } |
|
1363 | 1412 | |
1364 | 1413 | // The database knows the amount when there are extra conditions. |
1365 | 1414 | else |
@@ -1395,16 +1444,19 @@ discard block |
||
1395 | 1444 | $members[$key]['duplicate_members'] = array(); |
1396 | 1445 | |
1397 | 1446 | // Store the IPs. |
1398 | - if (!empty($member['member_ip'])) |
|
1399 | - $ips[] = $member['member_ip']; |
|
1400 | - if (!empty($member['member_ip2'])) |
|
1401 | - $ips[] = $member['member_ip2']; |
|
1447 | + if (!empty($member['member_ip'])) { |
|
1448 | + $ips[] = $member['member_ip']; |
|
1449 | + } |
|
1450 | + if (!empty($member['member_ip2'])) { |
|
1451 | + $ips[] = $member['member_ip2']; |
|
1452 | + } |
|
1402 | 1453 | } |
1403 | 1454 | |
1404 | 1455 | $ips = array_unique($ips); |
1405 | 1456 | |
1406 | - if (empty($ips)) |
|
1407 | - return false; |
|
1457 | + if (empty($ips)) { |
|
1458 | + return false; |
|
1459 | + } |
|
1408 | 1460 | |
1409 | 1461 | // Fetch all members with this IP address, we'll filter out the current ones in a sec. |
1410 | 1462 | $request = $smcFunc['db_query']('', ' |
@@ -1434,10 +1486,12 @@ discard block |
||
1434 | 1486 | 'ip2' => $row['member_ip2'], |
1435 | 1487 | ); |
1436 | 1488 | |
1437 | - if (in_array($row['member_ip'], $ips)) |
|
1438 | - $duplicate_members[$row['member_ip']][] = $member_context; |
|
1439 | - if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) |
|
1440 | - $duplicate_members[$row['member_ip2']][] = $member_context; |
|
1489 | + if (in_array($row['member_ip'], $ips)) { |
|
1490 | + $duplicate_members[$row['member_ip']][] = $member_context; |
|
1491 | + } |
|
1492 | + if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) { |
|
1493 | + $duplicate_members[$row['member_ip2']][] = $member_context; |
|
1494 | + } |
|
1441 | 1495 | } |
1442 | 1496 | $smcFunc['db_free_result']($request); |
1443 | 1497 | |
@@ -1462,8 +1516,9 @@ discard block |
||
1462 | 1516 | $row['poster_ip'] = inet_dtop($row['poster_ip']); |
1463 | 1517 | |
1464 | 1518 | // Don't collect lots of the same. |
1465 | - if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) |
|
1466 | - continue; |
|
1519 | + if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) { |
|
1520 | + continue; |
|
1521 | + } |
|
1467 | 1522 | $had_ips[$row['poster_ip']][] = $row['id_member']; |
1468 | 1523 | |
1469 | 1524 | $duplicate_members[$row['poster_ip']][] = array( |
@@ -1478,13 +1533,15 @@ discard block |
||
1478 | 1533 | $smcFunc['db_free_result']($request); |
1479 | 1534 | |
1480 | 1535 | // Now we have all the duplicate members, stick them with their respective member in the list. |
1481 | - if (!empty($duplicate_members)) |
|
1482 | - foreach ($members as $key => $member) |
|
1536 | + if (!empty($duplicate_members)) { |
|
1537 | + foreach ($members as $key => $member) |
|
1483 | 1538 | { |
1484 | 1539 | if (isset($duplicate_members[$member['member_ip']])) |
1485 | 1540 | $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
1486 | - if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) |
|
1487 | - $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
1541 | + } |
|
1542 | + if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) { |
|
1543 | + $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
1544 | + } |
|
1488 | 1545 | |
1489 | 1546 | // Check we don't have lots of the same member. |
1490 | 1547 | $member_track = array($member['id_member']); |