@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This is the main function for the languages area. |
@@ -153,11 +154,11 @@ discard block |
||
153 | 154 | $language_list = new xmlArray(fetch_web_data($url), true); |
154 | 155 | |
155 | 156 | // Check that the site responded and that the language exists. |
156 | - if (!$language_list->exists('languages')) |
|
157 | - $context['smf_error'] = 'no_response'; |
|
158 | - elseif (!$language_list->exists('languages/language')) |
|
159 | - $context['smf_error'] = 'no_files'; |
|
160 | - else |
|
157 | + if (!$language_list->exists('languages')) { |
|
158 | + $context['smf_error'] = 'no_response'; |
|
159 | + } elseif (!$language_list->exists('languages/language')) { |
|
160 | + $context['smf_error'] = 'no_files'; |
|
161 | + } else |
|
161 | 162 | { |
162 | 163 | $language_list = $language_list->path('languages[0]'); |
163 | 164 | $lang_files = $language_list->set('language'); |
@@ -165,8 +166,9 @@ discard block |
||
165 | 166 | foreach ($lang_files as $file) |
166 | 167 | { |
167 | 168 | // Were we searching? |
168 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
169 | - continue; |
|
169 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
170 | + continue; |
|
171 | + } |
|
170 | 172 | |
171 | 173 | $smf_languages[] = array( |
172 | 174 | 'id' => $file->fetch('id'), |
@@ -177,10 +179,11 @@ discard block |
||
177 | 179 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
178 | 180 | ); |
179 | 181 | } |
180 | - if (empty($smf_languages)) |
|
181 | - $context['smf_error'] = 'no_files'; |
|
182 | - else |
|
183 | - return $smf_languages; |
|
182 | + if (empty($smf_languages)) { |
|
183 | + $context['smf_error'] = 'no_files'; |
|
184 | + } else { |
|
185 | + return $smf_languages; |
|
186 | + } |
|
184 | 187 | } |
185 | 188 | } |
186 | 189 | |
@@ -202,8 +205,9 @@ discard block |
||
202 | 205 | require_once($sourcedir . '/Subs-Package.php'); |
203 | 206 | |
204 | 207 | // Clearly we need to know what to request. |
205 | - if (!isset($_GET['did'])) |
|
206 | - fatal_lang_error('no_access', false); |
|
208 | + if (!isset($_GET['did'])) { |
|
209 | + fatal_lang_error('no_access', false); |
|
210 | + } |
|
207 | 211 | |
208 | 212 | // Some lovely context. |
209 | 213 | $context['download_id'] = $_GET['did']; |
@@ -223,8 +227,9 @@ discard block |
||
223 | 227 | foreach ($_POST['copy_file'] as $file) |
224 | 228 | { |
225 | 229 | // Check it's not very bad. |
226 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
227 | - fatal_error($txt['languages_download_illegal_paths']); |
|
230 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
231 | + fatal_error($txt['languages_download_illegal_paths']); |
|
232 | + } |
|
228 | 233 | |
229 | 234 | $chmod_files[] = $boarddir . '/' . $file; |
230 | 235 | $install_files[] = $file; |
@@ -235,8 +240,9 @@ discard block |
||
235 | 240 | $files_left = $file_status['files']['notwritable']; |
236 | 241 | |
237 | 242 | // Something not writable? |
238 | - if (!empty($files_left)) |
|
239 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
243 | + if (!empty($files_left)) { |
|
244 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
245 | + } |
|
240 | 246 | // Otherwise, go go go! |
241 | 247 | elseif (!empty($install_files)) |
242 | 248 | { |
@@ -251,11 +257,13 @@ discard block |
||
251 | 257 | } |
252 | 258 | |
253 | 259 | // Open up the old china. |
254 | - if (!isset($archive_content)) |
|
255 | - $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
260 | + if (!isset($archive_content)) { |
|
261 | + $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
262 | + } |
|
256 | 263 | |
257 | - if (empty($archive_content)) |
|
258 | - fatal_error($txt['add_language_error_no_response']); |
|
264 | + if (empty($archive_content)) { |
|
265 | + fatal_error($txt['add_language_error_no_response']); |
|
266 | + } |
|
259 | 267 | |
260 | 268 | // Now for each of the files, let's do some *stuff* |
261 | 269 | $context['files'] = array( |
@@ -270,8 +278,9 @@ discard block |
||
270 | 278 | $extension = substr($filename, strrpos($filename, '.') + 1); |
271 | 279 | |
272 | 280 | // Don't do anything with files we don't understand. |
273 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
274 | - continue; |
|
281 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
282 | + continue; |
|
283 | + } |
|
275 | 284 | |
276 | 285 | // Basic data. |
277 | 286 | $context_data = array( |
@@ -290,8 +299,9 @@ discard block |
||
290 | 299 | // Does the file exist, is it different and can we overwrite? |
291 | 300 | if (file_exists($boarddir . '/' . $file['filename'])) |
292 | 301 | { |
293 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
294 | - $context_data['writable'] = true; |
|
302 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
303 | + $context_data['writable'] = true; |
|
304 | + } |
|
295 | 305 | |
296 | 306 | // Finally, do we actually think the content has changed? |
297 | 307 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -304,16 +314,17 @@ discard block |
||
304 | 314 | { |
305 | 315 | $context_data['exists'] = 'same'; |
306 | 316 | $context_data['default_copy'] = false; |
317 | + } else { |
|
318 | + $context_data['exists'] = 'different'; |
|
307 | 319 | } |
308 | - else |
|
309 | - $context_data['exists'] = 'different'; |
|
310 | 320 | } |
311 | 321 | // No overwrite? |
312 | 322 | else |
313 | 323 | { |
314 | 324 | // Can we at least stick it in the directory... |
315 | - if (is_writable($boarddir . '/' . $dirname)) |
|
316 | - $context_data['writable'] = true; |
|
325 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
326 | + $context_data['writable'] = true; |
|
327 | + } |
|
317 | 328 | } |
318 | 329 | |
319 | 330 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -328,8 +339,9 @@ discard block |
||
328 | 339 | list ($name, $language) = explode('.', $filename); |
329 | 340 | |
330 | 341 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
331 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
332 | - $context_data['version'] = $match[1]; |
|
342 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
343 | + $context_data['version'] = $match[1]; |
|
344 | + } |
|
333 | 345 | |
334 | 346 | // Now does the old file exist - if so what is it's version? |
335 | 347 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -345,34 +357,35 @@ discard block |
||
345 | 357 | $context_data['cur_version'] = $match[1]; |
346 | 358 | |
347 | 359 | // How does this compare? |
348 | - if ($context_data['cur_version'] == $context_data['version']) |
|
349 | - $context_data['version_compare'] = 'same'; |
|
350 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
351 | - $context_data['version_compare'] = 'older'; |
|
360 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
361 | + $context_data['version_compare'] = 'same'; |
|
362 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
363 | + $context_data['version_compare'] = 'older'; |
|
364 | + } |
|
352 | 365 | |
353 | 366 | // Don't recommend copying if the version is the same. |
354 | - if ($context_data['version_compare'] != 'newer') |
|
355 | - $context_data['default_copy'] = false; |
|
367 | + if ($context_data['version_compare'] != 'newer') { |
|
368 | + $context_data['default_copy'] = false; |
|
369 | + } |
|
356 | 370 | } |
357 | 371 | } |
358 | 372 | |
359 | 373 | // Add the context data to the main set. |
360 | 374 | $context['files']['lang'][] = $context_data; |
361 | - } |
|
362 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
375 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
363 | 376 | { |
364 | 377 | // Registration agreement is a primary file |
365 | 378 | $context['files']['lang'][] = $context_data; |
366 | - } |
|
367 | - else |
|
379 | + } else |
|
368 | 380 | { |
369 | 381 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
370 | 382 | $context['files']['other'][] = $context_data; |
371 | 383 | } |
372 | 384 | |
373 | 385 | // Collect together all non-writable areas. |
374 | - if (!$context_data['writable']) |
|
375 | - $context['make_writable'][] = $context_data['destination']; |
|
386 | + if (!$context_data['writable']) { |
|
387 | + $context['make_writable'][] = $context_data['destination']; |
|
388 | + } |
|
376 | 389 | } |
377 | 390 | |
378 | 391 | // Before we go to far can we make anything writable, eh, eh? |
@@ -387,22 +400,24 @@ discard block |
||
387 | 400 | { |
388 | 401 | if ($type == 'lang') |
389 | 402 | { |
390 | - foreach ($data as $k => $file) |
|
391 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
403 | + foreach ($data as $k => $file) { |
|
404 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
392 | 405 | $context['files'][$type][$k]['writable'] = true; |
393 | - } |
|
394 | - else |
|
406 | + } |
|
407 | + } else |
|
395 | 408 | { |
396 | - foreach ($data as $theme => $files) |
|
397 | - foreach ($files as $k => $file) |
|
409 | + foreach ($data as $theme => $files) { |
|
410 | + foreach ($files as $k => $file) |
|
398 | 411 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
399 | 412 | $context['files'][$type][$theme][$k]['writable'] = true; |
413 | + } |
|
400 | 414 | } |
401 | 415 | } |
402 | 416 | |
403 | 417 | // Are we going to need more language stuff? |
404 | - if (!empty($context['still_not_writable'])) |
|
405 | - loadLanguage('Packages'); |
|
418 | + if (!empty($context['still_not_writable'])) { |
|
419 | + loadLanguage('Packages'); |
|
420 | + } |
|
406 | 421 | } |
407 | 422 | |
408 | 423 | // This is the list for the main files. |
@@ -615,12 +630,13 @@ discard block |
||
615 | 630 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
616 | 631 | |
617 | 632 | // Display a warning if we cannot edit the default setting. |
618 | - if (!is_writable($boarddir . '/Settings.php')) |
|
619 | - $listOptions['additional_rows'][] = array( |
|
633 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
634 | + $listOptions['additional_rows'][] = array( |
|
620 | 635 | 'position' => 'after_title', |
621 | 636 | 'value' => $txt['language_settings_writable'], |
622 | 637 | 'class' => 'smalltext alert', |
623 | 638 | ); |
639 | + } |
|
624 | 640 | |
625 | 641 | require_once($sourcedir . '/Subs-List.php'); |
626 | 642 | createList($listOptions); |
@@ -662,10 +678,11 @@ discard block |
||
662 | 678 | |
663 | 679 | // Put them back. |
664 | 680 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
665 | - if (!empty($backup_base_theme_dir)) |
|
666 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
667 | - else |
|
668 | - unset($settings['base_theme_dir']); |
|
681 | + if (!empty($backup_base_theme_dir)) { |
|
682 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
683 | + } else { |
|
684 | + unset($settings['base_theme_dir']); |
|
685 | + } |
|
669 | 686 | |
670 | 687 | // Get the language files and data... |
671 | 688 | foreach ($context['languages'] as $lang) |
@@ -694,13 +711,15 @@ discard block |
||
694 | 711 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
695 | 712 | { |
696 | 713 | // Default? |
697 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
698 | - $row['lngfile'] = $language; |
|
714 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
715 | + $row['lngfile'] = $language; |
|
716 | + } |
|
699 | 717 | |
700 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
701 | - $languages['english']['count'] += $row['num_users']; |
|
702 | - elseif (isset($languages[$row['lngfile']])) |
|
703 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
718 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
719 | + $languages['english']['count'] += $row['num_users']; |
|
720 | + } elseif (isset($languages[$row['lngfile']])) { |
|
721 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
722 | + } |
|
704 | 723 | } |
705 | 724 | $smcFunc['db_free_result']($request); |
706 | 725 | |
@@ -740,13 +759,15 @@ discard block |
||
740 | 759 | |
741 | 760 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
742 | 761 | |
743 | - if ($return_config) |
|
744 | - return $config_vars; |
|
762 | + if ($return_config) { |
|
763 | + return $config_vars; |
|
764 | + } |
|
745 | 765 | |
746 | 766 | // Get our languages. No cache |
747 | 767 | getLanguages(false); |
748 | - foreach ($context['languages'] as $lang) |
|
749 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
768 | + foreach ($context['languages'] as $lang) { |
|
769 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
770 | + } |
|
750 | 771 | |
751 | 772 | // Saving settings? |
752 | 773 | if (isset($_REQUEST['save'])) |
@@ -756,8 +777,9 @@ discard block |
||
756 | 777 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
757 | 778 | |
758 | 779 | saveSettings($config_vars); |
759 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
760 | - $_SESSION['adm-save'] = true; |
|
780 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
781 | + $_SESSION['adm-save'] = true; |
|
782 | + } |
|
761 | 783 | redirectexit('action=admin;area=languages;sa=settings'); |
762 | 784 | } |
763 | 785 | |
@@ -766,10 +788,11 @@ discard block |
||
766 | 788 | $context['settings_title'] = $txt['language_settings']; |
767 | 789 | $context['save_disabled'] = $settings_not_writable; |
768 | 790 | |
769 | - if ($settings_not_writable) |
|
770 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
771 | - elseif ($settings_backup_fail) |
|
772 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
791 | + if ($settings_not_writable) { |
|
792 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
793 | + } elseif ($settings_backup_fail) { |
|
794 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
795 | + } |
|
773 | 796 | |
774 | 797 | // Fill the config array. |
775 | 798 | prepareServerSettingsContext($config_vars); |
@@ -816,8 +839,9 @@ discard block |
||
816 | 839 | 'theme_dir' => $settings['default_theme_dir'], |
817 | 840 | ), |
818 | 841 | ); |
819 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
820 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
842 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
843 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
844 | + } |
|
821 | 845 | $smcFunc['db_free_result']($request); |
822 | 846 | |
823 | 847 | // This will be where we look |
@@ -829,14 +853,16 @@ discard block |
||
829 | 853 | // Check we have themes with a path and a name - just in case - and add the path. |
830 | 854 | foreach ($themes as $id => $data) |
831 | 855 | { |
832 | - if (count($data) != 2) |
|
833 | - unset($themes[$id]); |
|
834 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
835 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
856 | + if (count($data) != 2) { |
|
857 | + unset($themes[$id]); |
|
858 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
859 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
860 | + } |
|
836 | 861 | |
837 | 862 | // How about image directories? |
838 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
839 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
863 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
864 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
865 | + } |
|
840 | 866 | } |
841 | 867 | |
842 | 868 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -850,15 +876,17 @@ discard block |
||
850 | 876 | while ($entry = $dir->read()) |
851 | 877 | { |
852 | 878 | // We're only after the files for this language. |
853 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
854 | - continue; |
|
879 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
880 | + continue; |
|
881 | + } |
|
855 | 882 | |
856 | - if (!isset($context['possible_files'][$theme])) |
|
857 | - $context['possible_files'][$theme] = array( |
|
883 | + if (!isset($context['possible_files'][$theme])) { |
|
884 | + $context['possible_files'][$theme] = array( |
|
858 | 885 | 'id' => $theme, |
859 | 886 | 'name' => $themes[$theme]['name'], |
860 | 887 | 'files' => array(), |
861 | 888 | ); |
889 | + } |
|
862 | 890 | |
863 | 891 | $context['possible_files'][$theme]['files'][] = array( |
864 | 892 | 'id' => $matches[1], |
@@ -887,31 +915,36 @@ discard block |
||
887 | 915 | { |
888 | 916 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
889 | 917 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
890 | - if (!$result) |
|
891 | - fatal_lang_error('could_not_language_backup', false); |
|
918 | + if (!$result) { |
|
919 | + fatal_lang_error('could_not_language_backup', false); |
|
920 | + } |
|
892 | 921 | } |
893 | 922 | |
894 | 923 | // Second, loop through the array to remove the files. |
895 | 924 | foreach ($lang_dirs as $curPath) |
896 | 925 | { |
897 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
898 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
926 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
927 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
899 | 928 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
929 | + } |
|
900 | 930 | |
901 | 931 | // Check for the email template. |
902 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
903 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
932 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
933 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
934 | + } |
|
904 | 935 | } |
905 | 936 | |
906 | 937 | // Third, the agreement file. |
907 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
908 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
938 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
939 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
940 | + } |
|
909 | 941 | |
910 | 942 | // Fourth, a related images folder, if it exists... |
911 | - if (!empty($images_dirs)) |
|
912 | - foreach ($images_dirs as $curPath) |
|
943 | + if (!empty($images_dirs)) { |
|
944 | + foreach ($images_dirs as $curPath) |
|
913 | 945 | if (is_dir($curPath)) |
914 | 946 | deltree($curPath); |
947 | + } |
|
915 | 948 | |
916 | 949 | // Members can no longer use this language. |
917 | 950 | $smcFunc['db_query']('', ' |
@@ -995,8 +1028,9 @@ discard block |
||
995 | 1028 | foreach ($_POST['entry'] as $k => $v) |
996 | 1029 | { |
997 | 1030 | // Only try to save if it's changed! |
998 | - if ($_POST['entry'][$k] != $_POST['comp'][$k]) |
|
999 | - $save_strings[$k] = cleanLangString($v, false); |
|
1031 | + if ($_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
1032 | + $save_strings[$k] = cleanLangString($v, false); |
|
1033 | + } |
|
1000 | 1034 | } |
1001 | 1035 | } |
1002 | 1036 | |
@@ -1030,12 +1064,13 @@ discard block |
||
1030 | 1064 | if ($multiline_cache) |
1031 | 1065 | { |
1032 | 1066 | preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches); |
1033 | - if (!empty($matches[3])) |
|
1034 | - $entries[$matches[2]] = array( |
|
1067 | + if (!empty($matches[3])) { |
|
1068 | + $entries[$matches[2]] = array( |
|
1035 | 1069 | 'type' => $matches[1], |
1036 | 1070 | 'full' => $matches[0], |
1037 | 1071 | 'entry' => $matches[3], |
1038 | 1072 | ); |
1073 | + } |
|
1039 | 1074 | } |
1040 | 1075 | |
1041 | 1076 | // These are the entries we can definitely save. |
@@ -1046,8 +1081,9 @@ discard block |
||
1046 | 1081 | { |
1047 | 1082 | // Ignore some things we set separately. |
1048 | 1083 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
1049 | - if (in_array($entryKey, $ignore_files)) |
|
1050 | - continue; |
|
1084 | + if (in_array($entryKey, $ignore_files)) { |
|
1085 | + continue; |
|
1086 | + } |
|
1051 | 1087 | |
1052 | 1088 | // These are arrays that need breaking out. |
1053 | 1089 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author'); |
@@ -1080,9 +1116,9 @@ discard block |
||
1080 | 1116 | { |
1081 | 1117 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
1082 | 1118 | $save_cache['enabled'] = true; |
1119 | + } else { |
|
1120 | + $save_cache['entries'][$cur_index] = $subValue; |
|
1083 | 1121 | } |
1084 | - else |
|
1085 | - $save_cache['entries'][$cur_index] = $subValue; |
|
1086 | 1122 | |
1087 | 1123 | $context['file_entries'][] = array( |
1088 | 1124 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1105,9 +1141,9 @@ discard block |
||
1105 | 1141 | { |
1106 | 1142 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
1107 | 1143 | $cur_index = $k2; |
1144 | + } else { |
|
1145 | + $items[] = '\'' . $v2 . '\''; |
|
1108 | 1146 | } |
1109 | - else |
|
1110 | - $items[] = '\'' . $v2 . '\''; |
|
1111 | 1147 | |
1112 | 1148 | $cur_index++; |
1113 | 1149 | } |
@@ -1117,15 +1153,15 @@ discard block |
||
1117 | 1153 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
1118 | 1154 | ); |
1119 | 1155 | } |
1120 | - } |
|
1121 | - else |
|
1156 | + } else |
|
1122 | 1157 | { |
1123 | 1158 | // Saving? |
1124 | 1159 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
1125 | 1160 | { |
1126 | 1161 | // @todo Fix this properly. |
1127 | - if ($save_strings[$entryKey] == '') |
|
1128 | - $save_strings[$entryKey] = '\'\''; |
|
1162 | + if ($save_strings[$entryKey] == '') { |
|
1163 | + $save_strings[$entryKey] = '\'\''; |
|
1164 | + } |
|
1129 | 1165 | |
1130 | 1166 | // Set the new value. |
1131 | 1167 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1151,8 +1187,9 @@ discard block |
||
1151 | 1187 | checkSession(); |
1152 | 1188 | |
1153 | 1189 | $file_contents = implode('', file($current_file)); |
1154 | - foreach ($final_saves as $save) |
|
1155 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1190 | + foreach ($final_saves as $save) { |
|
1191 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1192 | + } |
|
1156 | 1193 | |
1157 | 1194 | // Save the actual changes. |
1158 | 1195 | $fp = fopen($current_file, 'w+'); |
@@ -1167,8 +1204,9 @@ discard block |
||
1167 | 1204 | } |
1168 | 1205 | |
1169 | 1206 | // If we saved, redirect. |
1170 | - if ($madeSave) |
|
1171 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1207 | + if ($madeSave) { |
|
1208 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1209 | + } |
|
1172 | 1210 | |
1173 | 1211 | createToken('admin-mlang'); |
1174 | 1212 | } |
@@ -1200,8 +1238,9 @@ discard block |
||
1200 | 1238 | // Toggle the escape. |
1201 | 1239 | $is_escape = !$is_escape; |
1202 | 1240 | // If we're now escaped don't add this string. |
1203 | - if ($is_escape) |
|
1204 | - continue; |
|
1241 | + if ($is_escape) { |
|
1242 | + continue; |
|
1243 | + } |
|
1205 | 1244 | } |
1206 | 1245 | // Special case - parsed string with line break etc? |
1207 | 1246 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1218,11 +1257,13 @@ discard block |
||
1218 | 1257 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
1219 | 1258 | { |
1220 | 1259 | // Is it the end of a single quote string? |
1221 | - if ($in_string == 1) |
|
1222 | - $in_string = 0; |
|
1260 | + if ($in_string == 1) { |
|
1261 | + $in_string = 0; |
|
1262 | + } |
|
1223 | 1263 | // Otherwise it's the start! |
1224 | - else |
|
1225 | - $in_string = 1; |
|
1264 | + else { |
|
1265 | + $in_string = 1; |
|
1266 | + } |
|
1226 | 1267 | |
1227 | 1268 | // Don't actually include this character! |
1228 | 1269 | continue; |
@@ -1235,19 +1276,22 @@ discard block |
||
1235 | 1276 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
1236 | 1277 | { |
1237 | 1278 | // Is it the end of a double quote string? |
1238 | - if ($in_string == 2) |
|
1239 | - $in_string = 0; |
|
1279 | + if ($in_string == 2) { |
|
1280 | + $in_string = 0; |
|
1281 | + } |
|
1240 | 1282 | // Otherwise it's the start! |
1241 | - else |
|
1242 | - $in_string = 2; |
|
1283 | + else { |
|
1284 | + $in_string = 2; |
|
1285 | + } |
|
1243 | 1286 | |
1244 | 1287 | // Don't actually include this character! |
1245 | 1288 | continue; |
1246 | 1289 | } |
1247 | 1290 | } |
1248 | 1291 | // A join/space outside of a string is simply removed. |
1249 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
1250 | - continue; |
|
1292 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
1293 | + continue; |
|
1294 | + } |
|
1251 | 1295 | // Start of a variable? |
1252 | 1296 | elseif ($in_string == 0 && $string{$i} == '$') |
1253 | 1297 | { |
@@ -1281,8 +1325,7 @@ discard block |
||
1281 | 1325 | |
1282 | 1326 | // Unhtml then rehtml the whole thing! |
1283 | 1327 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
1284 | - } |
|
1285 | - else |
|
1328 | + } else |
|
1286 | 1329 | { |
1287 | 1330 | // Keep track of what we're doing... |
1288 | 1331 | $in_string = 0; |
@@ -1311,10 +1354,11 @@ discard block |
||
1311 | 1354 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
1312 | 1355 | if (!empty($matches[1])) |
1313 | 1356 | { |
1314 | - if ($in_string == 1) |
|
1315 | - $new_string .= '\' . '; |
|
1316 | - elseif ($new_string) |
|
1317 | - $new_string .= ' . '; |
|
1357 | + if ($in_string == 1) { |
|
1358 | + $new_string .= '\' . '; |
|
1359 | + } elseif ($new_string) { |
|
1360 | + $new_string .= ' . '; |
|
1361 | + } |
|
1318 | 1362 | |
1319 | 1363 | $new_string .= $matches[1]; |
1320 | 1364 | $i += strlen($matches[1]) + 3; |
@@ -1327,8 +1371,9 @@ discard block |
||
1327 | 1371 | elseif ($string{$i} == '<') |
1328 | 1372 | { |
1329 | 1373 | // Probably HTML? |
1330 | - if ($string{$i + 1} != ' ') |
|
1331 | - $in_html = true; |
|
1374 | + if ($string{$i + 1} != ' ') { |
|
1375 | + $in_html = true; |
|
1376 | + } |
|
1332 | 1377 | // Assume we need an entity... |
1333 | 1378 | else |
1334 | 1379 | { |
@@ -1340,8 +1385,9 @@ discard block |
||
1340 | 1385 | elseif ($string{$i} == '>') |
1341 | 1386 | { |
1342 | 1387 | // Will it be HTML? |
1343 | - if ($in_html) |
|
1344 | - $in_html = false; |
|
1388 | + if ($in_html) { |
|
1389 | + $in_html = false; |
|
1390 | + } |
|
1345 | 1391 | // Otherwise we need an entity... |
1346 | 1392 | else |
1347 | 1393 | { |
@@ -1350,8 +1396,9 @@ discard block |
||
1350 | 1396 | } |
1351 | 1397 | } |
1352 | 1398 | // Is it a slash? If so escape it... |
1353 | - if ($string{$i} == '\\') |
|
1354 | - $new_string .= '\\'; |
|
1399 | + if ($string{$i} == '\\') { |
|
1400 | + $new_string .= '\\'; |
|
1401 | + } |
|
1355 | 1402 | // The infamous double quote? |
1356 | 1403 | elseif ($string{$i} == '"') |
1357 | 1404 | { |
@@ -1374,10 +1421,11 @@ discard block |
||
1374 | 1421 | } |
1375 | 1422 | |
1376 | 1423 | // If we ended as a string then close it off. |
1377 | - if ($in_string == 1) |
|
1378 | - $new_string .= '\''; |
|
1379 | - elseif ($in_string == 2) |
|
1380 | - $new_string .= '"'; |
|
1424 | + if ($in_string == 1) { |
|
1425 | + $new_string .= '\''; |
|
1426 | + } elseif ($in_string == 2) { |
|
1427 | + $new_string .= '"'; |
|
1428 | + } |
|
1381 | 1429 | } |
1382 | 1430 | |
1383 | 1431 | return $new_string; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main admin handling function.<br> |
@@ -444,8 +445,9 @@ discard block |
||
444 | 445 | foreach ($admin_includes as $include) |
445 | 446 | { |
446 | 447 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
447 | - if (file_exists($include)) |
|
448 | - require_once($include); |
|
448 | + if (file_exists($include)) { |
|
449 | + require_once($include); |
|
450 | + } |
|
449 | 451 | } |
450 | 452 | } |
451 | 453 | |
@@ -457,24 +459,27 @@ discard block |
||
457 | 459 | unset($admin_areas); |
458 | 460 | |
459 | 461 | // Nothing valid? |
460 | - if ($admin_include_data == false) |
|
461 | - fatal_lang_error('no_access', false); |
|
462 | + if ($admin_include_data == false) { |
|
463 | + fatal_lang_error('no_access', false); |
|
464 | + } |
|
462 | 465 | |
463 | 466 | // Build the link tree. |
464 | 467 | $context['linktree'][] = array( |
465 | 468 | 'url' => $scripturl . '?action=admin', |
466 | 469 | 'name' => $txt['admin_center'], |
467 | 470 | ); |
468 | - if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
|
469 | - $context['linktree'][] = array( |
|
471 | + if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') { |
|
472 | + $context['linktree'][] = array( |
|
470 | 473 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
471 | 474 | 'name' => $admin_include_data['label'], |
472 | 475 | ); |
473 | - if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
|
474 | - $context['linktree'][] = array( |
|
476 | + } |
|
477 | + if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) { |
|
478 | + $context['linktree'][] = array( |
|
475 | 479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
476 | 480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
477 | 481 | ); |
482 | + } |
|
478 | 483 | |
479 | 484 | // Make a note of the Unique ID for this menu. |
480 | 485 | $context['admin_menu_id'] = $context['max_menu_id']; |
@@ -484,16 +489,18 @@ discard block |
||
484 | 489 | $context['admin_area'] = $admin_include_data['current_area']; |
485 | 490 | |
486 | 491 | // Now - finally - call the right place! |
487 | - if (isset($admin_include_data['file'])) |
|
488 | - require_once($sourcedir . '/' . $admin_include_data['file']); |
|
492 | + if (isset($admin_include_data['file'])) { |
|
493 | + require_once($sourcedir . '/' . $admin_include_data['file']); |
|
494 | + } |
|
489 | 495 | |
490 | 496 | // Get the right callable. |
491 | 497 | $call = call_helper($admin_include_data['function'], true); |
492 | 498 | |
493 | 499 | // Is it valid? |
494 | - if (!empty($call)) |
|
495 | - call_user_func($call); |
|
496 | -} |
|
500 | + if (!empty($call)) { |
|
501 | + call_user_func($call); |
|
502 | + } |
|
503 | + } |
|
497 | 504 | |
498 | 505 | /** |
499 | 506 | * The main administration section. |
@@ -547,13 +554,14 @@ discard block |
||
547 | 554 | |
548 | 555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
549 | 556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
550 | - if ($context['admin_area'] != 'credits') |
|
551 | - $context[$context['admin_menu_name']]['tab_data'] = array( |
|
557 | + if ($context['admin_area'] != 'credits') { |
|
558 | + $context[$context['admin_menu_name']]['tab_data'] = array( |
|
552 | 559 | 'title' => $txt['admin_center'], |
553 | 560 | 'help' => '', |
554 | 561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
555 | 562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
556 | 563 | ); |
564 | + } |
|
557 | 565 | |
558 | 566 | // Lastly, fill in the blanks in the support resources paragraphs. |
559 | 567 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
@@ -571,9 +579,10 @@ discard block |
||
571 | 579 | 'https://www.simplemachines.org/redirect/customize_support' |
572 | 580 | ); |
573 | 581 | |
574 | - if ($context['admin_area'] == 'admin') |
|
575 | - loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
576 | -} |
|
582 | + if ($context['admin_area'] == 'admin') { |
|
583 | + loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
584 | + } |
|
585 | + } |
|
577 | 586 | |
578 | 587 | /** |
579 | 588 | * Get one of the admin information files from Simple Machines. |
@@ -584,8 +593,9 @@ discard block |
||
584 | 593 | |
585 | 594 | setMemoryLimit('32M'); |
586 | 595 | |
587 | - if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
|
588 | - fatal_lang_error('no_access', false); |
|
596 | + if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) { |
|
597 | + fatal_lang_error('no_access', false); |
|
598 | + } |
|
589 | 599 | |
590 | 600 | // Strip off the forum cache part or we won't find it... |
591 | 601 | $_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']); |
@@ -600,27 +610,30 @@ discard block |
||
600 | 610 | ) |
601 | 611 | ); |
602 | 612 | |
603 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
604 | - fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
614 | + fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
615 | + } |
|
605 | 616 | |
606 | 617 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
607 | 618 | $smcFunc['db_free_result']($request); |
608 | 619 | |
609 | 620 | // @todo Temp |
610 | 621 | // Figure out if sesc is still being used. |
611 | - if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
|
612 | - $file_data = ' |
|
622 | + if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') { |
|
623 | + $file_data = ' |
|
613 | 624 | if (!(\'smfForum_sessionvar\' in window)) |
614 | 625 | window.smfForum_sessionvar = \'sesc\'; |
615 | 626 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
627 | + } |
|
616 | 628 | |
617 | 629 | $context['template_layers'] = array(); |
618 | 630 | // Lets make sure we aren't going to output anything nasty. |
619 | 631 | @ob_end_clean(); |
620 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
621 | - @ob_start('ob_gzhandler'); |
|
622 | - else |
|
623 | - @ob_start(); |
|
632 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
633 | + @ob_start('ob_gzhandler'); |
|
634 | + } else { |
|
635 | + @ob_start(); |
|
636 | + } |
|
624 | 637 | |
625 | 638 | // Make sure they know what type of file we are. |
626 | 639 | header('Content-Type: ' . $filetype); |
@@ -660,11 +673,12 @@ discard block |
||
660 | 673 | updateAdminPreferences(); |
661 | 674 | } |
662 | 675 | |
663 | - if (trim($context['search_term']) == '') |
|
664 | - $context['search_results'] = array(); |
|
665 | - else |
|
666 | - call_helper($subActions[$context['search_type']]); |
|
667 | -} |
|
676 | + if (trim($context['search_term']) == '') { |
|
677 | + $context['search_results'] = array(); |
|
678 | + } else { |
|
679 | + call_helper($subActions[$context['search_type']]); |
|
680 | + } |
|
681 | + } |
|
668 | 682 | |
669 | 683 | /** |
670 | 684 | * A complicated but relatively quick internal search. |
@@ -728,8 +742,9 @@ discard block |
||
728 | 742 | |
729 | 743 | loadLanguage(implode('+', $language_files)); |
730 | 744 | |
731 | - foreach ($include_files as $file) |
|
732 | - require_once($sourcedir . '/' . $file . '.php'); |
|
745 | + foreach ($include_files as $file) { |
|
746 | + require_once($sourcedir . '/' . $file . '.php'); |
|
747 | + } |
|
733 | 748 | |
734 | 749 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
735 | 750 | 0 = Language index (Can be array of indexes) to search through for this setting. |
@@ -753,11 +768,12 @@ discard block |
||
753 | 768 | foreach ($section['areas'] as $menu_key => $menu_item) |
754 | 769 | { |
755 | 770 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
756 | - if (!empty($menu_item['subsections'])) |
|
757 | - foreach ($menu_item['subsections'] as $key => $sublabel) |
|
771 | + if (!empty($menu_item['subsections'])) { |
|
772 | + foreach ($menu_item['subsections'] as $key => $sublabel) |
|
758 | 773 | { |
759 | 774 | if (isset($sublabel['label'])) |
760 | 775 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
776 | + } |
|
761 | 777 | } |
762 | 778 | } |
763 | 779 | } |
@@ -767,9 +783,10 @@ discard block |
||
767 | 783 | // Get a list of their variables. |
768 | 784 | $config_vars = $setting_area[0](true); |
769 | 785 | |
770 | - foreach ($config_vars as $var) |
|
771 | - if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
786 | + foreach ($config_vars as $var) { |
|
787 | + if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
772 | 788 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1]); |
789 | + } |
|
773 | 790 | } |
774 | 791 | |
775 | 792 | $context['page_title'] = $txt['admin_search_results']; |
@@ -782,8 +799,9 @@ discard block |
||
782 | 799 | foreach ($data as $item) |
783 | 800 | { |
784 | 801 | $found = false; |
785 | - if (!is_array($item[0])) |
|
786 | - $item[0] = array($item[0]); |
|
802 | + if (!is_array($item[0])) { |
|
803 | + $item[0] = array($item[0]); |
|
804 | + } |
|
787 | 805 | foreach ($item[0] as $term) |
788 | 806 | { |
789 | 807 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
@@ -841,8 +859,9 @@ discard block |
||
841 | 859 | $postVars = explode(' ', $context['search_term']); |
842 | 860 | |
843 | 861 | // Encode the search data. |
844 | - foreach ($postVars as $k => $v) |
|
845 | - $postVars[$k] = urlencode($v); |
|
862 | + foreach ($postVars as $k => $v) { |
|
863 | + $postVars[$k] = urlencode($v); |
|
864 | + } |
|
846 | 865 | |
847 | 866 | // This is what we will send. |
848 | 867 | $postVars = implode('+', $postVars); |
@@ -854,8 +873,9 @@ discard block |
||
854 | 873 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
855 | 874 | |
856 | 875 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
857 | - if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) |
|
858 | - fatal_lang_error('cannot_connect_doc_site'); |
|
876 | + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) { |
|
877 | + fatal_lang_error('cannot_connect_doc_site'); |
|
878 | + } |
|
859 | 879 | |
860 | 880 | $search_results = $matches[1]; |
861 | 881 | |
@@ -867,8 +887,9 @@ discard block |
||
867 | 887 | $results = new xmlArray($search_results, false); |
868 | 888 | |
869 | 889 | // Move through the api layer. |
870 | - if (!$results->exists('api')) |
|
871 | - fatal_lang_error('cannot_connect_doc_site'); |
|
890 | + if (!$results->exists('api')) { |
|
891 | + fatal_lang_error('cannot_connect_doc_site'); |
|
892 | + } |
|
872 | 893 | |
873 | 894 | // Are there actually some results? |
874 | 895 | if ($results->exists('api/query/search/p')) |
@@ -904,8 +925,9 @@ discard block |
||
904 | 925 | ); |
905 | 926 | |
906 | 927 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
907 | - if (!isset($_REQUEST['sa'])) |
|
908 | - $_REQUEST['desc'] = true; |
|
928 | + if (!isset($_REQUEST['sa'])) { |
|
929 | + $_REQUEST['desc'] = true; |
|
930 | + } |
|
909 | 931 | |
910 | 932 | // Setup some tab stuff. |
911 | 933 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -955,9 +977,10 @@ discard block |
||
955 | 977 | unset($_SESSION['admin_time']); |
956 | 978 | |
957 | 979 | // Clean any admin tokens as well. |
958 | - foreach ($_SESSION['token'] as $key => $token) |
|
959 | - if (strpos($key, '-admin') !== false) |
|
980 | + foreach ($_SESSION['token'] as $key => $token) { |
|
981 | + if (strpos($key, '-admin') !== false) |
|
960 | 982 | unset($_SESSION['token'][$key]); |
983 | + } |
|
961 | 984 | |
962 | 985 | redirectexit(); |
963 | 986 | } |
@@ -32,43 +32,43 @@ |
||
32 | 32 | class Curl |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @see https://php.net/curl_init |
|
37 | - * @param string $url |
|
38 | - * @return resource cURL handle |
|
39 | - */ |
|
40 | - public function init($url = null) |
|
41 | - { |
|
42 | - return curl_init($url); |
|
43 | - } |
|
35 | + /** |
|
36 | + * @see https://php.net/curl_init |
|
37 | + * @param string $url |
|
38 | + * @return resource cURL handle |
|
39 | + */ |
|
40 | + public function init($url = null) |
|
41 | + { |
|
42 | + return curl_init($url); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @see https://php.net/curl_setopt_array |
|
47 | - * @param resource $ch |
|
48 | - * @param array $options |
|
49 | - * @return bool |
|
50 | - */ |
|
51 | - public function setoptArray($ch, array $options) |
|
52 | - { |
|
53 | - return curl_setopt_array($ch, $options); |
|
54 | - } |
|
45 | + /** |
|
46 | + * @see https://php.net/curl_setopt_array |
|
47 | + * @param resource $ch |
|
48 | + * @param array $options |
|
49 | + * @return bool |
|
50 | + */ |
|
51 | + public function setoptArray($ch, array $options) |
|
52 | + { |
|
53 | + return curl_setopt_array($ch, $options); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @see https://php.net/curl_exec |
|
58 | - * @param resource $ch |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public function exec($ch) |
|
62 | - { |
|
63 | - return curl_exec($ch); |
|
64 | - } |
|
56 | + /** |
|
57 | + * @see https://php.net/curl_exec |
|
58 | + * @param resource $ch |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public function exec($ch) |
|
62 | + { |
|
63 | + return curl_exec($ch); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @see https://php.net/curl_close |
|
68 | - * @param resource $ch |
|
69 | - */ |
|
70 | - public function close($ch) |
|
71 | - { |
|
72 | - curl_close($ch); |
|
73 | - } |
|
66 | + /** |
|
67 | + * @see https://php.net/curl_close |
|
68 | + * @param resource $ch |
|
69 | + */ |
|
70 | + public function close($ch) |
|
71 | + { |
|
72 | + curl_close($ch); |
|
73 | + } |
|
74 | 74 | } |
@@ -32,74 +32,74 @@ |
||
32 | 32 | */ |
33 | 33 | class Socket |
34 | 34 | { |
35 | - private $handle = null; |
|
35 | + private $handle = null; |
|
36 | 36 | |
37 | - /** |
|
38 | - * fsockopen |
|
39 | - * |
|
40 | - * @see https://php.net/fsockopen |
|
41 | - * @param string $hostname |
|
42 | - * @param int $port |
|
43 | - * @param int $errno |
|
44 | - * @param string $errstr |
|
45 | - * @param float $timeout |
|
46 | - * @return resource |
|
47 | - */ |
|
48 | - public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) |
|
49 | - { |
|
50 | - $this->handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout)); |
|
37 | + /** |
|
38 | + * fsockopen |
|
39 | + * |
|
40 | + * @see https://php.net/fsockopen |
|
41 | + * @param string $hostname |
|
42 | + * @param int $port |
|
43 | + * @param int $errno |
|
44 | + * @param string $errstr |
|
45 | + * @param float $timeout |
|
46 | + * @return resource |
|
47 | + */ |
|
48 | + public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) |
|
49 | + { |
|
50 | + $this->handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout)); |
|
51 | 51 | |
52 | - if ($this->handle != false && $errno === 0 && $errstr === '') { |
|
53 | - return $this->handle; |
|
54 | - } else { |
|
55 | - return false; |
|
56 | - } |
|
57 | - } |
|
52 | + if ($this->handle != false && $errno === 0 && $errstr === '') { |
|
53 | + return $this->handle; |
|
54 | + } else { |
|
55 | + return false; |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * fwrite |
|
61 | - * |
|
62 | - * @see https://php.net/fwrite |
|
63 | - * @param string $string |
|
64 | - * @param int $length |
|
65 | - * @return int | bool |
|
66 | - */ |
|
67 | - public function fwrite($string, $length = null) |
|
68 | - { |
|
69 | - return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length)); |
|
70 | - } |
|
59 | + /** |
|
60 | + * fwrite |
|
61 | + * |
|
62 | + * @see https://php.net/fwrite |
|
63 | + * @param string $string |
|
64 | + * @param int $length |
|
65 | + * @return int | bool |
|
66 | + */ |
|
67 | + public function fwrite($string, $length = null) |
|
68 | + { |
|
69 | + return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length)); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * fgets |
|
74 | - * |
|
75 | - * @see https://php.net/fgets |
|
76 | - * @param int $length |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function fgets($length = null) |
|
80 | - { |
|
81 | - return fgets($this->handle, $length); |
|
82 | - } |
|
72 | + /** |
|
73 | + * fgets |
|
74 | + * |
|
75 | + * @see https://php.net/fgets |
|
76 | + * @param int $length |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function fgets($length = null) |
|
80 | + { |
|
81 | + return fgets($this->handle, $length); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * feof |
|
86 | - * |
|
87 | - * @see https://php.net/feof |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function feof() |
|
91 | - { |
|
92 | - return feof($this->handle); |
|
93 | - } |
|
84 | + /** |
|
85 | + * feof |
|
86 | + * |
|
87 | + * @see https://php.net/feof |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function feof() |
|
91 | + { |
|
92 | + return feof($this->handle); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * fclose |
|
97 | - * |
|
98 | - * @see https://php.net/fclose |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - public function fclose() |
|
102 | - { |
|
103 | - return fclose($this->handle); |
|
104 | - } |
|
95 | + /** |
|
96 | + * fclose |
|
97 | + * |
|
98 | + * @see https://php.net/fclose |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + public function fclose() |
|
102 | + { |
|
103 | + return fclose($this->handle); |
|
104 | + } |
|
105 | 105 | } |
@@ -22,22 +22,24 @@ discard block |
||
22 | 22 | <script>'; |
23 | 23 | |
24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
25 | - if (isBrowser('is_firefox')) |
|
26 | - echo ' |
|
25 | + if (isBrowser('is_firefox')) { |
|
26 | + echo ' |
|
27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
28 | + } |
|
28 | 29 | |
29 | 30 | // Start with message icons - and any missing from this theme. |
30 | 31 | echo ' |
31 | 32 | var icon_urls = {'; |
32 | - foreach ($context['icons'] as $icon) |
|
33 | - echo ' |
|
33 | + foreach ($context['icons'] as $icon) { |
|
34 | + echo ' |
|
34 | 35 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
36 | + } |
|
35 | 37 | echo ' |
36 | 38 | };'; |
37 | 39 | |
38 | 40 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
39 | - if ($context['make_poll']) |
|
40 | - echo ' |
|
41 | + if ($context['make_poll']) { |
|
42 | + echo ' |
|
41 | 43 | var pollOptionNum = 0, pollTabIndex; |
42 | 44 | var pollOptionId = ', $context['last_choice_id'], '; |
43 | 45 | function addPollOption() |
@@ -56,11 +58,13 @@ discard block |
||
56 | 58 | |
57 | 59 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text"></dd><p id="pollMoreOptions"></p>'), '); |
58 | 60 | }'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
61 | - if ($context['make_event']) |
|
62 | - echo ' |
|
64 | + if ($context['make_event']) { |
|
65 | + echo ' |
|
63 | 66 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
67 | + } |
|
64 | 68 | |
65 | 69 | // End of the javascript, start the form and display the link tree. |
66 | 70 | echo ' |
@@ -80,9 +84,10 @@ discard block |
||
80 | 84 | </div> |
81 | 85 | </div><br>'; |
82 | 86 | |
83 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
84 | - echo ' |
|
87 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
88 | + echo ' |
|
85 | 89 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
90 | + } |
|
86 | 91 | |
87 | 92 | // Start the main table. |
88 | 93 | echo ' |
@@ -117,18 +122,20 @@ discard block |
||
117 | 122 | } |
118 | 123 | |
119 | 124 | // If it's locked, show a message to warn the replier. |
120 | - if (!empty($context['locked'])) |
|
121 | - echo ' |
|
125 | + if (!empty($context['locked'])) { |
|
126 | + echo ' |
|
122 | 127 | <p class="errorbox"> |
123 | 128 | ', $txt['topic_locked_no_reply'], ' |
124 | 129 | </p>'; |
130 | + } |
|
125 | 131 | |
126 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
127 | - echo ' |
|
132 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
133 | + echo ' |
|
128 | 134 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
129 | 135 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
130 | 136 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
131 | 137 | </div>'; |
138 | + } |
|
132 | 139 | |
133 | 140 | // The post header... important stuff |
134 | 141 | echo ' |
@@ -180,9 +187,10 @@ discard block |
||
180 | 187 | { |
181 | 188 | echo ' |
182 | 189 | <optgroup label="', $category['name'], '">'; |
183 | - foreach ($category['boards'] as $board) |
|
184 | - echo ' |
|
190 | + foreach ($category['boards'] as $board) { |
|
191 | + echo ' |
|
185 | 192 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
193 | + } |
|
186 | 194 | echo ' |
187 | 195 | </optgroup>'; |
188 | 196 | } |
@@ -218,9 +226,10 @@ discard block |
||
218 | 226 | <span class="label">', $txt['calendar_timezone'], '</span> |
219 | 227 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
220 | 228 | |
221 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
222 | - echo ' |
|
229 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
230 | + echo ' |
|
223 | 231 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | echo ' |
226 | 235 | </select> |
@@ -286,14 +295,15 @@ discard block |
||
286 | 295 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', ' class="input_check"> |
287 | 296 | </dd>'; |
288 | 297 | |
289 | - if ($context['poll_options']['guest_vote_enabled']) |
|
290 | - echo ' |
|
298 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
299 | + echo ' |
|
291 | 300 | <dt> |
292 | 301 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
293 | 302 | </dt> |
294 | 303 | <dd> |
295 | 304 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', ' class="input_check"> |
296 | 305 | </dd>'; |
306 | + } |
|
297 | 307 | |
298 | 308 | echo ' |
299 | 309 | <dt> |
@@ -314,8 +324,8 @@ discard block |
||
314 | 324 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
315 | 325 | |
316 | 326 | // If we're editing and displaying edit details, show a box where they can say why |
317 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
318 | - echo ' |
|
327 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
328 | + echo ' |
|
319 | 329 | <dl> |
320 | 330 | <dt class="clear"> |
321 | 331 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -324,20 +334,23 @@ discard block |
||
324 | 334 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text"> |
325 | 335 | </dd> |
326 | 336 | </dl>'; |
337 | + } |
|
327 | 338 | |
328 | 339 | // If this message has been edited in the past - display when it was. |
329 | - if (isset($context['last_modified'])) |
|
330 | - echo ' |
|
340 | + if (isset($context['last_modified'])) { |
|
341 | + echo ' |
|
331 | 342 | <div class="padding smalltext"> |
332 | 343 | ', $context['last_modified_text'], ' |
333 | 344 | </div>'; |
345 | + } |
|
334 | 346 | |
335 | 347 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
336 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
337 | - echo ' |
|
348 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
349 | + echo ' |
|
338 | 350 | <div id="postAdditionalOptionsHeader"> |
339 | 351 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
340 | 352 | </div>'; |
353 | + } |
|
341 | 354 | |
342 | 355 | echo ' |
343 | 356 | <div id="postAdditionalOptions">'; |
@@ -369,19 +382,21 @@ discard block |
||
369 | 382 | <input type="hidden" name="attach_del[]" value="0"> |
370 | 383 | ', $txt['uncheck_unwatchd_attach'], ': |
371 | 384 | </dd>'; |
372 | - foreach ($context['current_attachments'] as $attachment) |
|
373 | - echo ' |
|
385 | + foreach ($context['current_attachments'] as $attachment) { |
|
386 | + echo ' |
|
374 | 387 | <dd class="smalltext"> |
375 | 388 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', ' class="input_check"> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
376 | 389 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label> |
377 | 390 | </dd>'; |
391 | + } |
|
378 | 392 | |
379 | 393 | echo ' |
380 | 394 | </dl>'; |
381 | 395 | |
382 | - if (!empty($context['files_in_session_warning'])) |
|
383 | - echo ' |
|
396 | + if (!empty($context['files_in_session_warning'])) { |
|
397 | + echo ' |
|
384 | 398 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
399 | + } |
|
385 | 400 | } |
386 | 401 | |
387 | 402 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -434,8 +449,8 @@ discard block |
||
434 | 449 | ', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '">'); |
435 | 450 | |
436 | 451 | // Show more boxes if they aren't approaching that limit. |
437 | - if ($context['num_allowed_attachments'] > 1) |
|
438 | - echo ' |
|
452 | + if ($context['num_allowed_attachments'] > 1) { |
|
453 | + echo ' |
|
439 | 454 | <script> |
440 | 455 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
441 | 456 | var current_attachment = 1; |
@@ -456,9 +471,10 @@ discard block |
||
456 | 471 | </div> |
457 | 472 | </div> |
458 | 473 | </dd>'; |
459 | - else |
|
460 | - echo ' |
|
474 | + } else { |
|
475 | + echo ' |
|
461 | 476 | </dd>'; |
477 | + } |
|
462 | 478 | |
463 | 479 | // Add any template changes for an alternative upload system here. |
464 | 480 | call_integration_hook('integrate_upload_template'); |
@@ -467,21 +483,25 @@ discard block |
||
467 | 483 | <dd class="smalltext">'; |
468 | 484 | |
469 | 485 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
470 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
471 | - echo ' |
|
486 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
487 | + echo ' |
|
472 | 488 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
489 | + } |
|
473 | 490 | |
474 | - if (!empty($context['attachment_restrictions'])) |
|
475 | - echo ' |
|
491 | + if (!empty($context['attachment_restrictions'])) { |
|
492 | + echo ' |
|
476 | 493 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
494 | + } |
|
477 | 495 | |
478 | - if ($context['num_allowed_attachments'] == 0) |
|
479 | - echo ' |
|
496 | + if ($context['num_allowed_attachments'] == 0) { |
|
497 | + echo ' |
|
480 | 498 | ', $txt['attach_limit_nag'], '<br>'; |
499 | + } |
|
481 | 500 | |
482 | - if (!$context['can_post_attachment_unapproved']) |
|
483 | - echo ' |
|
501 | + if (!$context['can_post_attachment_unapproved']) { |
|
502 | + echo ' |
|
484 | 503 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
504 | + } |
|
485 | 505 | |
486 | 506 | echo ' |
487 | 507 | </dd> |
@@ -504,10 +524,11 @@ discard block |
||
504 | 524 | <dt><strong>', $txt['subject'], '</strong></dt> |
505 | 525 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
506 | 526 | |
507 | - foreach ($context['drafts'] as $draft) |
|
508 | - echo ' |
|
527 | + foreach ($context['drafts'] as $draft) { |
|
528 | + echo ' |
|
509 | 529 | <dt>', $draft['link'], '</dt> |
510 | 530 | <dd>', $draft['poster_time'], '</dd>'; |
531 | + } |
|
511 | 532 | echo ' |
512 | 533 | </dl> |
513 | 534 | </div>'; |
@@ -532,9 +553,10 @@ discard block |
||
532 | 553 | ', template_control_richedit_buttons($context['post_box_name']); |
533 | 554 | |
534 | 555 | // Option to delete an event if user is editing one. |
535 | - if ($context['make_event'] && !$context['event']['new']) |
|
536 | - echo ' |
|
556 | + if ($context['make_event'] && !$context['event']['new']) { |
|
557 | + echo ' |
|
537 | 558 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">'; |
559 | + } |
|
538 | 560 | |
539 | 561 | echo ' |
540 | 562 | </span> |
@@ -543,9 +565,10 @@ discard block |
||
543 | 565 | <br class="clear">'; |
544 | 566 | |
545 | 567 | // Assuming this isn't a new topic pass across the last message id. |
546 | - if (isset($context['topic_last_message'])) |
|
547 | - echo ' |
|
568 | + if (isset($context['topic_last_message'])) { |
|
569 | + echo ' |
|
548 | 570 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
571 | + } |
|
549 | 572 | |
550 | 573 | echo ' |
551 | 574 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -687,9 +710,10 @@ discard block |
||
687 | 710 | |
688 | 711 | newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">« <strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \' »</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';'; |
689 | 712 | |
690 | - if ($context['can_quote']) |
|
691 | - echo ' |
|
713 | + if ($context['can_quote']) { |
|
714 | + echo ' |
|
692 | 715 | newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';'; |
716 | + } |
|
693 | 717 | |
694 | 718 | echo ' |
695 | 719 | newPostsHTML += \'<br class="clear">\'; |
@@ -732,8 +756,8 @@ discard block |
||
732 | 756 | }'; |
733 | 757 | |
734 | 758 | // Code for showing and hiding additional options. |
735 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
736 | - echo ' |
|
759 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
760 | + echo ' |
|
737 | 761 | var oSwapAdditionalOptions = new smc_Toggle({ |
738 | 762 | bToggleEnabled: true, |
739 | 763 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -761,10 +785,11 @@ discard block |
||
761 | 785 | } |
762 | 786 | ] |
763 | 787 | });'; |
788 | + } |
|
764 | 789 | |
765 | 790 | // Code for showing and hiding drafts |
766 | - if (!empty($context['drafts'])) |
|
767 | - echo ' |
|
791 | + if (!empty($context['drafts'])) { |
|
792 | + echo ' |
|
768 | 793 | var oSwapDraftOptions = new smc_Toggle({ |
769 | 794 | bToggleEnabled: true, |
770 | 795 | bCurrentlyCollapsed: true, |
@@ -786,6 +811,7 @@ discard block |
||
786 | 811 | } |
787 | 812 | ] |
788 | 813 | });'; |
814 | + } |
|
789 | 815 | |
790 | 816 | echo ' |
791 | 817 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -806,8 +832,9 @@ discard block |
||
806 | 832 | foreach ($context['previous_posts'] as $post) |
807 | 833 | { |
808 | 834 | $ignoring = false; |
809 | - if (!empty($post['is_ignored'])) |
|
810 | - $ignored_posts[] = $ignoring = $post['id']; |
|
835 | + if (!empty($post['is_ignored'])) { |
|
836 | + $ignored_posts[] = $ignoring = $post['id']; |
|
837 | + } |
|
811 | 838 | |
812 | 839 | echo ' |
813 | 840 | <div class="windowbg"> |
@@ -990,10 +1017,10 @@ discard block |
||
990 | 1017 | <div id="temporary_posting_area" style="display: none;"></div> |
991 | 1018 | <script>'; |
992 | 1019 | |
993 | - if ($context['close_window']) |
|
994 | - echo ' |
|
1020 | + if ($context['close_window']) { |
|
1021 | + echo ' |
|
995 | 1022 | window.close();'; |
996 | - else |
|
1023 | + } else |
|
997 | 1024 | { |
998 | 1025 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;). |
999 | 1026 | echo ' |
@@ -1047,11 +1074,12 @@ discard block |
||
1047 | 1074 | </p> |
1048 | 1075 | <ul>'; |
1049 | 1076 | |
1050 | - foreach ($context['groups'] as $group) |
|
1051 | - echo ' |
|
1077 | + foreach ($context['groups'] as $group) { |
|
1078 | + echo ' |
|
1052 | 1079 | <li> |
1053 | 1080 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
1054 | 1081 | </li>'; |
1082 | + } |
|
1055 | 1083 | |
1056 | 1084 | echo ' |
1057 | 1085 | <li> |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | </div> |
417 | 417 | <div class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div> |
418 | 418 | <div class="attach-ui"> |
419 | - <a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'] ,'</a> |
|
420 | - <a class="button_submit upload">', $txt['upload'] ,'</a> |
|
419 | + <a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'], '</a> |
|
420 | + <a class="button_submit upload">', $txt['upload'], '</a> |
|
421 | 421 | </div> |
422 | 422 | </div> |
423 | 423 | </div> |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | </dt> |
436 | 436 | <dd class="smalltext fallback"> |
437 | 437 | <div id="attachUpload" class="descbox"> |
438 | - <h5>', $txt['attach_drop_zone'] ,'</h5> |
|
439 | - <a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a> |
|
440 | - <a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a> |
|
441 | - <a class="button_submit fileinput-button">', $txt['attach_add'] ,'</a> |
|
438 | + <h5>', $txt['attach_drop_zone'], '</h5> |
|
439 | + <a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a> |
|
440 | + <a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a> |
|
441 | + <a class="button_submit fileinput-button">', $txt['attach_add'], '</a> |
|
442 | 442 | <div id="total-progress" class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div> |
443 | 443 | <div class="fallback"> |
444 | 444 | <input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="input_file fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>) |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | // Option to delete an event if user is editing one. |
546 | 546 | if ($context['make_event'] && !$context['event']['new']) |
547 | 547 | echo ' |
548 | - <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">'; |
|
548 | + <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button_submit you_sure">'; |
|
549 | 549 | |
550 | 550 | echo ' |
551 | 551 | </span> |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | });'; |
800 | 800 | |
801 | 801 | echo ' |
802 | - var oEditorID = "', $context['post_box_name'] ,'"; |
|
802 | + var oEditorID = "', $context['post_box_name'], '"; |
|
803 | 803 | var oEditorObject = oEditorHandle_', $context['post_box_name'], '; |
804 | 804 | </script>'; |
805 | 805 | |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | { |
832 | 832 | echo ' |
833 | 833 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
834 | - <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
|
834 | + <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li> |
|
835 | 835 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
836 | 836 | </ul>'; |
837 | 837 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | <head> |
919 | 919 | <meta charset="', $context['character_set'], '"> |
920 | 920 | <title>', $txt['spell_check'], '</title> |
921 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
921 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
922 | 922 | <style> |
923 | 923 | body, td |
924 | 924 | { |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | var spell_formname = window.opener.spell_formname; |
952 | 952 | var spell_fieldname = window.opener.spell_fieldname; |
953 | 953 | </script> |
954 | - <script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script> |
|
955 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
954 | + <script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script> |
|
955 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
956 | 956 | <script> |
957 | 957 | ', $context['spell_js'], ' |
958 | 958 | </script> |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | <head> |
995 | 995 | <meta charset="', $context['character_set'], '"> |
996 | 996 | <title>', $txt['retrieving_quote'], '</title> |
997 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
997 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
998 | 998 | </head> |
999 | 999 | <body> |
1000 | 1000 | ', $txt['retrieving_quote'], ' |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | { |
31 | 32 | global $modSettings; |
32 | 33 | |
33 | - if (!$compat_mode) |
|
34 | - return $text; |
|
34 | + if (!$compat_mode) { |
|
35 | + return $text; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Turn line breaks back into br's. |
37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
49 | 51 | { |
50 | 52 | // Value of 2 means we're inside the tag. |
51 | - if ($i % 4 == 2) |
|
52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
53 | + if ($i % 4 == 2) { |
|
54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | // Put our humpty dumpty message back together again. |
55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
108 | 111 | |
109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
110 | - if (isBrowser('webkit')) |
|
111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
113 | + if (isBrowser('webkit')) { |
|
114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
124 | 128 | { |
125 | 129 | // Value of 2 means we're inside the tag. |
126 | - if ($i % 4 == 2) |
|
127 | - $parts[$i] = strip_tags($parts[$i]); |
|
130 | + if ($i % 4 == 2) { |
|
131 | + $parts[$i] = strip_tags($parts[$i]); |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
150 | 155 | { |
151 | 156 | $found = array_search($file, $smileysto); |
152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
153 | - if ($found) |
|
154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
155 | - else |
|
156 | - $matches[1][$k] = ''; |
|
158 | + if ($found) { |
|
159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
160 | + } else { |
|
161 | + $matches[1][$k] = ''; |
|
162 | + } |
|
157 | 163 | } |
158 | - } |
|
159 | - else |
|
164 | + } else |
|
160 | 165 | { |
161 | 166 | // Load all the smileys. |
162 | 167 | $names = array(); |
163 | - foreach ($matches[1] as $file) |
|
164 | - $names[] = $file; |
|
168 | + foreach ($matches[1] as $file) { |
|
169 | + $names[] = $file; |
|
170 | + } |
|
165 | 171 | $names = array_unique($names); |
166 | 172 | |
167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
175 | 181 | ) |
176 | 182 | ); |
177 | 183 | $mappings = array(); |
178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + } |
|
180 | 187 | $smcFunc['db_free_result']($request); |
181 | 188 | |
182 | - foreach ($matches[1] as $k => $file) |
|
183 | - if (isset($mappings[$file])) |
|
189 | + foreach ($matches[1] as $k => $file) { |
|
190 | + if (isset($mappings[$file])) |
|
184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
192 | + } |
|
185 | 193 | } |
186 | 194 | } |
187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
193 | 201 | } |
194 | 202 | |
195 | 203 | // Only try to buy more time if the client didn't quit. |
196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
197 | - @apache_reset_timeout(); |
|
204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
205 | + @apache_reset_timeout(); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
206 | 215 | { |
207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
208 | - if ($matches[5] === '/') |
|
209 | - continue; |
|
210 | - else |
|
217 | + if ($matches[5] === '/') { |
|
218 | + continue; |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
224 | 233 | |
225 | 234 | // Something like 'font-weight: bold' is expected here. |
226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
227 | - continue; |
|
235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
246 | 256 | { |
247 | 257 | $curCloseTags .= '[/u]'; |
248 | 258 | $replacement .= '[u]'; |
249 | - } |
|
250 | - elseif ($style_value == 'line-through') |
|
259 | + } elseif ($style_value == 'line-through') |
|
251 | 260 | { |
252 | 261 | $curCloseTags .= '[/s]'; |
253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
259 | 268 | { |
260 | 269 | $curCloseTags .= '[/left]'; |
261 | 270 | $replacement .= '[left]'; |
262 | - } |
|
263 | - elseif ($style_value == 'center') |
|
271 | + } elseif ($style_value == 'center') |
|
264 | 272 | { |
265 | 273 | $curCloseTags .= '[/center]'; |
266 | 274 | $replacement .= '[center]'; |
267 | - } |
|
268 | - elseif ($style_value == 'right') |
|
275 | + } elseif ($style_value == 'right') |
|
269 | 276 | { |
270 | 277 | $curCloseTags .= '[/right]'; |
271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | |
288 | 295 | case 'font-size': |
289 | 296 | // Sometimes people put decimals where decimals should not be. |
290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + } |
|
292 | 300 | |
293 | 301 | $curCloseTags .= '[/size]'; |
294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
296 | 304 | |
297 | 305 | case 'font-family': |
298 | 306 | // Only get the first freaking font if there's a list! |
299 | - if (strpos($style_value, ',') !== false) |
|
300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
307 | + if (strpos($style_value, ',') !== false) { |
|
308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $curCloseTags .= '[/font]'; |
303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
306 | 315 | // This is a hack for images with dimensions embedded. |
307 | 316 | case 'width': |
308 | 317 | case 'height': |
309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + } |
|
311 | 321 | break; |
312 | 322 | |
313 | 323 | case 'list-style-type': |
314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + } |
|
316 | 327 | break; |
317 | 328 | } |
318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
325 | 336 | } |
326 | 337 | |
327 | 338 | // If there's something that still needs closing, push it to the stack. |
328 | - if (!empty($curCloseTags)) |
|
329 | - array_push($stack, array( |
|
339 | + if (!empty($curCloseTags)) { |
|
340 | + array_push($stack, array( |
|
330 | 341 | 'element' => strtolower($curElement), |
331 | 342 | 'closeTags' => $curCloseTags |
332 | 343 | ) |
333 | 344 | ); |
334 | - elseif (!empty($extra_attr)) |
|
335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
345 | + } elseif (!empty($extra_attr)) { |
|
346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } |
|
336 | 348 | } |
337 | - } |
|
338 | - |
|
339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
340 | 350 | { |
341 | 351 | // Is this the element that we've been waiting for to be closed? |
342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
346 | 356 | } |
347 | 357 | |
348 | 358 | // Must've been something else. |
349 | - else |
|
350 | - $replacement .= $part; |
|
359 | + else { |
|
360 | + $replacement .= $part; |
|
361 | + } |
|
351 | 362 | } |
352 | 363 | // In all other cases, just add the part to the replacement. |
353 | - else |
|
354 | - $replacement .= $part; |
|
364 | + else { |
|
365 | + $replacement .= $part; |
|
366 | + } |
|
355 | 367 | } |
356 | 368 | |
357 | 369 | // Now put back the replacement in the text. |
358 | 370 | $text = $replacement; |
359 | 371 | |
360 | 372 | // We are not finished yet, request more time. |
361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
362 | - @apache_reset_timeout(); |
|
373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
374 | + @apache_reset_timeout(); |
|
375 | + } |
|
363 | 376 | |
364 | 377 | // Let's pull out any legacy alignments. |
365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
366 | 379 | { |
367 | 380 | // Find the position in the text of this tag over again. |
368 | 381 | $start_pos = strpos($text, $matches[0]); |
369 | - if ($start_pos === false) |
|
370 | - break; |
|
382 | + if ($start_pos === false) { |
|
383 | + break; |
|
384 | + } |
|
371 | 385 | |
372 | 386 | // End tag? |
373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -382,8 +396,7 @@ discard block |
||
382 | 396 | |
383 | 397 | // Put the tags back into the body. |
384 | 398 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
385 | - } |
|
386 | - else |
|
399 | + } else |
|
387 | 400 | { |
388 | 401 | // Just get rid of this evil tag. |
389 | 402 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -396,8 +409,9 @@ discard block |
||
396 | 409 | // Find the position of this again. |
397 | 410 | $start_pos = strpos($text, $matches[0]); |
398 | 411 | $end_pos = false; |
399 | - if ($start_pos === false) |
|
400 | - break; |
|
412 | + if ($start_pos === false) { |
|
413 | + break; |
|
414 | + } |
|
401 | 415 | |
402 | 416 | // This must have an end tag - and we must find the right one. |
403 | 417 | $lower_text = strtolower($text); |
@@ -430,8 +444,9 @@ discard block |
||
430 | 444 | break; |
431 | 445 | } |
432 | 446 | } |
433 | - if ($end_pos === false) |
|
434 | - break; |
|
447 | + if ($end_pos === false) { |
|
448 | + break; |
|
449 | + } |
|
435 | 450 | |
436 | 451 | // Now work out what the attributes are. |
437 | 452 | $attribs = fetchTagAttributes($matches[1]); |
@@ -445,11 +460,11 @@ discard block |
||
445 | 460 | $v = (int) trim($v); |
446 | 461 | $v = empty($v) ? 1 : $v; |
447 | 462 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
463 | + } elseif ($s == 'face') { |
|
464 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
465 | + } elseif ($s == 'color') { |
|
466 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
448 | 467 | } |
449 | - elseif ($s == 'face') |
|
450 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
451 | - elseif ($s == 'color') |
|
452 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
453 | 468 | } |
454 | 469 | |
455 | 470 | // As before add in our tags. |
@@ -457,8 +472,9 @@ discard block |
||
457 | 472 | foreach ($tags as $tag) |
458 | 473 | { |
459 | 474 | $before .= $tag[0]; |
460 | - if (isset($tag[1])) |
|
461 | - $after = $tag[1] . $after; |
|
475 | + if (isset($tag[1])) { |
|
476 | + $after = $tag[1] . $after; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Remove the tag so it's never checked again. |
@@ -469,8 +485,9 @@ discard block |
||
469 | 485 | } |
470 | 486 | |
471 | 487 | // Almost there, just a little more time. |
472 | - if (connection_aborted() && $context['server']['is_apache']) |
|
473 | - @apache_reset_timeout(); |
|
488 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
489 | + @apache_reset_timeout(); |
|
490 | + } |
|
474 | 491 | |
475 | 492 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
476 | 493 | { |
@@ -526,12 +543,13 @@ discard block |
||
526 | 543 | { |
527 | 544 | $inList = true; |
528 | 545 | |
529 | - if ($tag === 'ol') |
|
530 | - $listType = 'decimal'; |
|
531 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
532 | - $listType = $listTypeMapping[$match[1]]; |
|
533 | - else |
|
534 | - $listType = null; |
|
546 | + if ($tag === 'ol') { |
|
547 | + $listType = 'decimal'; |
|
548 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
549 | + $listType = $listTypeMapping[$match[1]]; |
|
550 | + } else { |
|
551 | + $listType = null; |
|
552 | + } |
|
535 | 553 | |
536 | 554 | $listDepth++; |
537 | 555 | |
@@ -595,9 +613,7 @@ discard block |
||
595 | 613 | $parts[$i + 1] = ''; |
596 | 614 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
597 | 615 | $parts[$i + 3] = ''; |
598 | - } |
|
599 | - |
|
600 | - else |
|
616 | + } else |
|
601 | 617 | { |
602 | 618 | // We're in a list item. |
603 | 619 | if ($listDepth > 0) |
@@ -634,9 +650,7 @@ discard block |
||
634 | 650 | $parts[$i + 1] = ''; |
635 | 651 | $parts[$i + 2] = ''; |
636 | 652 | $parts[$i + 3] = ''; |
637 | - } |
|
638 | - |
|
639 | - else |
|
653 | + } else |
|
640 | 654 | { |
641 | 655 | // Remove the trailing breaks from the list item. |
642 | 656 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -674,8 +688,9 @@ discard block |
||
674 | 688 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
675 | 689 | } |
676 | 690 | |
677 | - for ($i = $listDepth; $i > 0; $i--) |
|
678 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
691 | + for ($i = $listDepth; $i > 0; $i--) { |
|
692 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
693 | + } |
|
679 | 694 | |
680 | 695 | } |
681 | 696 | |
@@ -684,8 +699,9 @@ discard block |
||
684 | 699 | { |
685 | 700 | // Find the position of the image. |
686 | 701 | $start_pos = strpos($text, $matches[0]); |
687 | - if ($start_pos === false) |
|
688 | - break; |
|
702 | + if ($start_pos === false) { |
|
703 | + break; |
|
704 | + } |
|
689 | 705 | $end_pos = $start_pos + strlen($matches[0]); |
690 | 706 | |
691 | 707 | $params = ''; |
@@ -694,12 +710,13 @@ discard block |
||
694 | 710 | $attrs = fetchTagAttributes($matches[1]); |
695 | 711 | foreach ($attrs as $attrib => $value) |
696 | 712 | { |
697 | - if (in_array($attrib, array('width', 'height'))) |
|
698 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
699 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
700 | - $params .= ' alt=' . trim($value); |
|
701 | - elseif ($attrib == 'src') |
|
702 | - $src = trim($value); |
|
713 | + if (in_array($attrib, array('width', 'height'))) { |
|
714 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
715 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
716 | + $params .= ' alt=' . trim($value); |
|
717 | + } elseif ($attrib == 'src') { |
|
718 | + $src = trim($value); |
|
719 | + } |
|
703 | 720 | } |
704 | 721 | |
705 | 722 | $tag = ''; |
@@ -710,10 +727,11 @@ discard block |
||
710 | 727 | { |
711 | 728 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
712 | 729 | |
713 | - if (substr($src, 0, 1) === '/') |
|
714 | - $src = $baseURL . $src; |
|
715 | - else |
|
716 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
730 | + if (substr($src, 0, 1) === '/') { |
|
731 | + $src = $baseURL . $src; |
|
732 | + } else { |
|
733 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
734 | + } |
|
717 | 735 | } |
718 | 736 | |
719 | 737 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -891,20 +909,23 @@ discard block |
||
891 | 909 | }, |
892 | 910 | ); |
893 | 911 | |
894 | - foreach ($tags as $tag => $replace) |
|
895 | - $text = preg_replace_callback($tag, $replace, $text); |
|
912 | + foreach ($tags as $tag => $replace) { |
|
913 | + $text = preg_replace_callback($tag, $replace, $text); |
|
914 | + } |
|
896 | 915 | |
897 | 916 | // Please give us just a little more time. |
898 | - if (connection_aborted() && $context['server']['is_apache']) |
|
899 | - @apache_reset_timeout(); |
|
917 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
918 | + @apache_reset_timeout(); |
|
919 | + } |
|
900 | 920 | |
901 | 921 | // What about URL's - the pain in the ass of the tag world. |
902 | 922 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
903 | 923 | { |
904 | 924 | // Find the position of the URL. |
905 | 925 | $start_pos = strpos($text, $matches[0]); |
906 | - if ($start_pos === false) |
|
907 | - break; |
|
926 | + if ($start_pos === false) { |
|
927 | + break; |
|
928 | + } |
|
908 | 929 | $end_pos = $start_pos + strlen($matches[0]); |
909 | 930 | |
910 | 931 | $tag_type = 'url'; |
@@ -918,8 +939,9 @@ discard block |
||
918 | 939 | $href = trim($value); |
919 | 940 | |
920 | 941 | // Are we dealing with an FTP link? |
921 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
922 | - $tag_type = 'ftp'; |
|
942 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
943 | + $tag_type = 'ftp'; |
|
944 | + } |
|
923 | 945 | |
924 | 946 | // Or is this a link to an email address? |
925 | 947 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -933,28 +955,31 @@ discard block |
||
933 | 955 | { |
934 | 956 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
935 | 957 | |
936 | - if (substr($href, 0, 1) === '/') |
|
937 | - $href = $baseURL . $href; |
|
938 | - else |
|
939 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
958 | + if (substr($href, 0, 1) === '/') { |
|
959 | + $href = $baseURL . $href; |
|
960 | + } else { |
|
961 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
962 | + } |
|
940 | 963 | } |
941 | 964 | } |
942 | 965 | |
943 | 966 | // External URL? |
944 | 967 | if ($attrib == 'target' && $tag_type == 'url') |
945 | 968 | { |
946 | - if (trim($value) == '_blank') |
|
947 | - $tag_type == 'iurl'; |
|
969 | + if (trim($value) == '_blank') { |
|
970 | + $tag_type == 'iurl'; |
|
971 | + } |
|
948 | 972 | } |
949 | 973 | } |
950 | 974 | |
951 | 975 | $tag = ''; |
952 | 976 | if ($href != '') |
953 | 977 | { |
954 | - if ($matches[2] == $href) |
|
955 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
956 | - else |
|
957 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
978 | + if ($matches[2] == $href) { |
|
979 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
980 | + } else { |
|
981 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
982 | + } |
|
958 | 983 | } |
959 | 984 | |
960 | 985 | // Replace the tag |
@@ -993,17 +1018,18 @@ discard block |
||
993 | 1018 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
994 | 1019 | if ($text[$i] == '=') |
995 | 1020 | { |
996 | - if ($tag_state == 0) |
|
997 | - $tag_state = 1; |
|
998 | - elseif ($tag_state == 2) |
|
999 | - $value .= '='; |
|
1021 | + if ($tag_state == 0) { |
|
1022 | + $tag_state = 1; |
|
1023 | + } elseif ($tag_state == 2) { |
|
1024 | + $value .= '='; |
|
1025 | + } |
|
1000 | 1026 | } |
1001 | 1027 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1002 | 1028 | elseif ($text[$i] == ' ') |
1003 | 1029 | { |
1004 | - if ($tag_state == 2) |
|
1005 | - $value .= ' '; |
|
1006 | - elseif ($tag_state == 1) |
|
1030 | + if ($tag_state == 2) { |
|
1031 | + $value .= ' '; |
|
1032 | + } elseif ($tag_state == 1) |
|
1007 | 1033 | { |
1008 | 1034 | $attribs[$key] = $value; |
1009 | 1035 | $key = $value = ''; |
@@ -1014,24 +1040,27 @@ discard block |
||
1014 | 1040 | elseif ($text[$i] == '"') |
1015 | 1041 | { |
1016 | 1042 | // Must be either going into or out of a string. |
1017 | - if ($tag_state == 1) |
|
1018 | - $tag_state = 2; |
|
1019 | - else |
|
1020 | - $tag_state = 1; |
|
1043 | + if ($tag_state == 1) { |
|
1044 | + $tag_state = 2; |
|
1045 | + } else { |
|
1046 | + $tag_state = 1; |
|
1047 | + } |
|
1021 | 1048 | } |
1022 | 1049 | // Otherwise it's fine. |
1023 | 1050 | else |
1024 | 1051 | { |
1025 | - if ($tag_state == 0) |
|
1026 | - $key .= $text[$i]; |
|
1027 | - else |
|
1028 | - $value .= $text[$i]; |
|
1052 | + if ($tag_state == 0) { |
|
1053 | + $key .= $text[$i]; |
|
1054 | + } else { |
|
1055 | + $value .= $text[$i]; |
|
1056 | + } |
|
1029 | 1057 | } |
1030 | 1058 | } |
1031 | 1059 | |
1032 | 1060 | // Anything left? |
1033 | - if ($key != '' && $value != '') |
|
1034 | - $attribs[$key] = $value; |
|
1061 | + if ($key != '' && $value != '') { |
|
1062 | + $attribs[$key] = $value; |
|
1063 | + } |
|
1035 | 1064 | |
1036 | 1065 | return $attribs; |
1037 | 1066 | } |
@@ -1047,15 +1076,17 @@ discard block |
||
1047 | 1076 | global $modSettings; |
1048 | 1077 | |
1049 | 1078 | // Don't care about the texts that are too short. |
1050 | - if (strlen($text) < 3) |
|
1051 | - return $text; |
|
1079 | + if (strlen($text) < 3) { |
|
1080 | + return $text; |
|
1081 | + } |
|
1052 | 1082 | |
1053 | 1083 | // A list of tags that's disabled by the admin. |
1054 | 1084 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1055 | 1085 | |
1056 | 1086 | // Add flash if it's disabled as embedded tag. |
1057 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1058 | - $disabled['flash'] = true; |
|
1087 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1088 | + $disabled['flash'] = true; |
|
1089 | + } |
|
1059 | 1090 | |
1060 | 1091 | // Get a list of all the tags that are not disabled. |
1061 | 1092 | $all_tags = parse_bbc(false); |
@@ -1063,10 +1094,12 @@ discard block |
||
1063 | 1094 | $self_closing_tags = array(); |
1064 | 1095 | foreach ($all_tags as $tag) |
1065 | 1096 | { |
1066 | - if (!isset($disabled[$tag['tag']])) |
|
1067 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1068 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1069 | - $self_closing_tags[] = $tag['tag']; |
|
1097 | + if (!isset($disabled[$tag['tag']])) { |
|
1098 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1099 | + } |
|
1100 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1101 | + $self_closing_tags[] = $tag['tag']; |
|
1102 | + } |
|
1070 | 1103 | } |
1071 | 1104 | |
1072 | 1105 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1093,16 +1126,19 @@ discard block |
||
1093 | 1126 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1094 | 1127 | |
1095 | 1128 | // We're closing the exact same tag that we opened. |
1096 | - if ($isClosingTag && $insideTag === $tagName) |
|
1097 | - $insideTag = null; |
|
1129 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1130 | + $insideTag = null; |
|
1131 | + } |
|
1098 | 1132 | |
1099 | 1133 | // We're opening a tag and we're not yet inside one either |
1100 | - elseif (!$isClosingTag && $insideTag === null) |
|
1101 | - $insideTag = $tagName; |
|
1134 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1135 | + $insideTag = $tagName; |
|
1136 | + } |
|
1102 | 1137 | |
1103 | 1138 | // In all other cases, this tag must be invalid |
1104 | - else |
|
1105 | - unset($matches[$i]); |
|
1139 | + else { |
|
1140 | + unset($matches[$i]); |
|
1141 | + } |
|
1106 | 1142 | } |
1107 | 1143 | |
1108 | 1144 | // The next one is gonna be the other one. |
@@ -1110,8 +1146,9 @@ discard block |
||
1110 | 1146 | } |
1111 | 1147 | |
1112 | 1148 | // We're still inside a tag and had no chance for closure? |
1113 | - if ($insideTag !== null) |
|
1114 | - $matches[] = '[/' . $insideTag . ']'; |
|
1149 | + if ($insideTag !== null) { |
|
1150 | + $matches[] = '[/' . $insideTag . ']'; |
|
1151 | + } |
|
1115 | 1152 | |
1116 | 1153 | // And a complete text string again. |
1117 | 1154 | $text = implode('', $matches); |
@@ -1120,8 +1157,9 @@ discard block |
||
1120 | 1157 | // Quickly remove any tags which are back to back. |
1121 | 1158 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1122 | 1159 | $lastlen = 0; |
1123 | - while (strlen($text) !== $lastlen) |
|
1124 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1160 | + while (strlen($text) !== $lastlen) { |
|
1161 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1162 | + } |
|
1125 | 1163 | |
1126 | 1164 | // Need to sort the tags my name length. |
1127 | 1165 | uksort($valid_tags, 'sort_array_length'); |
@@ -1158,8 +1196,9 @@ discard block |
||
1158 | 1196 | $isCompetingTag = in_array($tag, $competing_tags); |
1159 | 1197 | |
1160 | 1198 | // Check if this might be one of those cleaned out tags. |
1161 | - if ($tag === '') |
|
1162 | - continue; |
|
1199 | + if ($tag === '') { |
|
1200 | + continue; |
|
1201 | + } |
|
1163 | 1202 | |
1164 | 1203 | // Special case: inside [code] blocks any code is left untouched. |
1165 | 1204 | elseif ($tag === 'code') |
@@ -1170,8 +1209,9 @@ discard block |
||
1170 | 1209 | $inCode = false; |
1171 | 1210 | |
1172 | 1211 | // Reopen tags that were closed before the code block. |
1173 | - if (!empty($inlineElements)) |
|
1174 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1212 | + if (!empty($inlineElements)) { |
|
1213 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1214 | + } |
|
1175 | 1215 | } |
1176 | 1216 | |
1177 | 1217 | // We're outside a coding and nobbc block and opening it. |
@@ -1200,8 +1240,9 @@ discard block |
||
1200 | 1240 | $inNoBbc = false; |
1201 | 1241 | |
1202 | 1242 | // Some inline elements might've been closed that need reopening. |
1203 | - if (!empty($inlineElements)) |
|
1204 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1243 | + if (!empty($inlineElements)) { |
|
1244 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1245 | + } |
|
1205 | 1246 | } |
1206 | 1247 | |
1207 | 1248 | // We're outside a nobbc and coding block and opening it. |
@@ -1221,8 +1262,9 @@ discard block |
||
1221 | 1262 | } |
1222 | 1263 | |
1223 | 1264 | // So, we're inside one of the special blocks: ignore any tag. |
1224 | - elseif ($inCode || $inNoBbc) |
|
1225 | - continue; |
|
1265 | + elseif ($inCode || $inNoBbc) { |
|
1266 | + continue; |
|
1267 | + } |
|
1226 | 1268 | |
1227 | 1269 | // We're dealing with an opening tag. |
1228 | 1270 | if ($isOpeningTag) |
@@ -1263,8 +1305,9 @@ discard block |
||
1263 | 1305 | if ($parts[$j + 3] === $tag) |
1264 | 1306 | { |
1265 | 1307 | // If it's an opening tag, increase the level. |
1266 | - if ($parts[$j + 2] === '') |
|
1267 | - $curLevel++; |
|
1308 | + if ($parts[$j + 2] === '') { |
|
1309 | + $curLevel++; |
|
1310 | + } |
|
1268 | 1311 | |
1269 | 1312 | // A closing tag, decrease the level. |
1270 | 1313 | else |
@@ -1287,13 +1330,15 @@ discard block |
||
1287 | 1330 | { |
1288 | 1331 | if ($isCompetingTag) |
1289 | 1332 | { |
1290 | - if (!isset($competingElements[$tag])) |
|
1291 | - $competingElements[$tag] = array(); |
|
1333 | + if (!isset($competingElements[$tag])) { |
|
1334 | + $competingElements[$tag] = array(); |
|
1335 | + } |
|
1292 | 1336 | |
1293 | 1337 | $competingElements[$tag][] = $parts[$i + 4]; |
1294 | 1338 | |
1295 | - if (count($competingElements[$tag]) > 1) |
|
1296 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1339 | + if (count($competingElements[$tag]) > 1) { |
|
1340 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1341 | + } |
|
1297 | 1342 | } |
1298 | 1343 | |
1299 | 1344 | $inlineElements[$elementContent] = $tag; |
@@ -1314,15 +1359,17 @@ discard block |
||
1314 | 1359 | $addClosingTags = array(); |
1315 | 1360 | while ($element = array_pop($blockElements)) |
1316 | 1361 | { |
1317 | - if ($element === $tag) |
|
1318 | - break; |
|
1362 | + if ($element === $tag) { |
|
1363 | + break; |
|
1364 | + } |
|
1319 | 1365 | |
1320 | 1366 | // Still a block tag was open not equal to this tag. |
1321 | 1367 | $addClosingTags[] = $element['type']; |
1322 | 1368 | } |
1323 | 1369 | |
1324 | - if (!empty($addClosingTags)) |
|
1325 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1370 | + if (!empty($addClosingTags)) { |
|
1371 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1372 | + } |
|
1326 | 1373 | |
1327 | 1374 | // Apparently the closing tag was not found on the stack. |
1328 | 1375 | if (!is_string($element) || $element !== $tag) |
@@ -1332,8 +1379,7 @@ discard block |
||
1332 | 1379 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1333 | 1380 | continue; |
1334 | 1381 | } |
1335 | - } |
|
1336 | - else |
|
1382 | + } else |
|
1337 | 1383 | { |
1338 | 1384 | // Get rid of this closing tag! |
1339 | 1385 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1362,53 +1408,62 @@ discard block |
||
1362 | 1408 | unset($inlineElements[$tagContentToBeClosed]); |
1363 | 1409 | |
1364 | 1410 | // Was this the tag we were looking for? |
1365 | - if ($tagToBeClosed === $tag) |
|
1366 | - break; |
|
1411 | + if ($tagToBeClosed === $tag) { |
|
1412 | + break; |
|
1413 | + } |
|
1367 | 1414 | |
1368 | 1415 | // Nope, close it and look further! |
1369 | - else |
|
1370 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1416 | + else { |
|
1417 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1418 | + } |
|
1371 | 1419 | } |
1372 | 1420 | |
1373 | 1421 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1374 | 1422 | { |
1375 | 1423 | array_pop($competingElements[$tag]); |
1376 | 1424 | |
1377 | - if (count($competingElements[$tag]) > 0) |
|
1378 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1425 | + if (count($competingElements[$tag]) > 0) { |
|
1426 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1427 | + } |
|
1379 | 1428 | } |
1380 | 1429 | } |
1381 | 1430 | |
1382 | 1431 | // Unexpected closing tag, ex-ter-mi-nate. |
1383 | - else |
|
1384 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1432 | + else { |
|
1433 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1434 | + } |
|
1385 | 1435 | } |
1386 | 1436 | } |
1387 | 1437 | } |
1388 | 1438 | |
1389 | 1439 | // Close the code tags. |
1390 | - if ($inCode) |
|
1391 | - $parts[$i] .= '[/code]'; |
|
1440 | + if ($inCode) { |
|
1441 | + $parts[$i] .= '[/code]'; |
|
1442 | + } |
|
1392 | 1443 | |
1393 | 1444 | // The same for nobbc tags. |
1394 | - elseif ($inNoBbc) |
|
1395 | - $parts[$i] .= '[/nobbc]'; |
|
1445 | + elseif ($inNoBbc) { |
|
1446 | + $parts[$i] .= '[/nobbc]'; |
|
1447 | + } |
|
1396 | 1448 | |
1397 | 1449 | // Still inline tags left unclosed? Close them now, better late than never. |
1398 | - elseif (!empty($inlineElements)) |
|
1399 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1450 | + elseif (!empty($inlineElements)) { |
|
1451 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1452 | + } |
|
1400 | 1453 | |
1401 | 1454 | // Now close the block elements. |
1402 | - if (!empty($blockElements)) |
|
1403 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1455 | + if (!empty($blockElements)) { |
|
1456 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1457 | + } |
|
1404 | 1458 | |
1405 | 1459 | $text = implode('', $parts); |
1406 | 1460 | } |
1407 | 1461 | |
1408 | 1462 | // Final clean up of back to back tags. |
1409 | 1463 | $lastlen = 0; |
1410 | - while (strlen($text) !== $lastlen) |
|
1411 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1464 | + while (strlen($text) !== $lastlen) { |
|
1465 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1466 | + } |
|
1412 | 1467 | |
1413 | 1468 | return $text; |
1414 | 1469 | } |
@@ -1437,22 +1492,25 @@ discard block |
||
1437 | 1492 | $context['template_layers'] = array(); |
1438 | 1493 | // Lets make sure we aren't going to output anything nasty. |
1439 | 1494 | @ob_end_clean(); |
1440 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1441 | - @ob_start('ob_gzhandler'); |
|
1442 | - else |
|
1443 | - @ob_start(); |
|
1495 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1496 | + @ob_start('ob_gzhandler'); |
|
1497 | + } else { |
|
1498 | + @ob_start(); |
|
1499 | + } |
|
1444 | 1500 | |
1445 | 1501 | // If we don't have any locale better avoid broken js |
1446 | - if (empty($txt['lang_locale'])) |
|
1447 | - die(); |
|
1502 | + if (empty($txt['lang_locale'])) { |
|
1503 | + die(); |
|
1504 | + } |
|
1448 | 1505 | |
1449 | 1506 | $file_data = '(function ($) { |
1450 | 1507 | \'use strict\'; |
1451 | 1508 | |
1452 | 1509 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
1453 | - foreach ($editortxt as $key => $val) |
|
1454 | - $file_data .= ' |
|
1510 | + foreach ($editortxt as $key => $val) { |
|
1511 | + $file_data .= ' |
|
1455 | 1512 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
1513 | + } |
|
1456 | 1514 | |
1457 | 1515 | $file_data .= ' |
1458 | 1516 | dateFormat: "day.month.year" |
@@ -1520,8 +1578,9 @@ discard block |
||
1520 | 1578 | ) |
1521 | 1579 | ); |
1522 | 1580 | $icon_data = array(); |
1523 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1524 | - $icon_data[] = $row; |
|
1581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1582 | + $icon_data[] = $row; |
|
1583 | + } |
|
1525 | 1584 | $smcFunc['db_free_result']($request); |
1526 | 1585 | |
1527 | 1586 | $icons = array(); |
@@ -1536,9 +1595,9 @@ discard block |
||
1536 | 1595 | } |
1537 | 1596 | |
1538 | 1597 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1598 | + } else { |
|
1599 | + $icons = $temp; |
|
1539 | 1600 | } |
1540 | - else |
|
1541 | - $icons = $temp; |
|
1542 | 1601 | } |
1543 | 1602 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1544 | 1603 | |
@@ -1579,8 +1638,9 @@ discard block |
||
1579 | 1638 | { |
1580 | 1639 | // Some general stuff. |
1581 | 1640 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1582 | - if (!empty($context['drafts_autosave'])) |
|
1583 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1641 | + if (!empty($context['drafts_autosave'])) { |
|
1642 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1643 | + } |
|
1584 | 1644 | |
1585 | 1645 | // This really has some WYSIWYG stuff. |
1586 | 1646 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1596,8 +1656,9 @@ discard block |
||
1596 | 1656 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1597 | 1657 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1598 | 1658 | // editor language file |
1599 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1600 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1659 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1660 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1661 | + } |
|
1601 | 1662 | |
1602 | 1663 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1603 | 1664 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1606,11 +1667,12 @@ discard block |
||
1606 | 1667 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
1607 | 1668 | |
1608 | 1669 | // Some hidden information is needed in order to make the spell checking work. |
1609 | - if (!isset($_REQUEST['xml'])) |
|
1610 | - $context['insert_after_template'] .= ' |
|
1670 | + if (!isset($_REQUEST['xml'])) { |
|
1671 | + $context['insert_after_template'] .= ' |
|
1611 | 1672 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1612 | 1673 | <input type="hidden" name="spellstring" value=""> |
1613 | 1674 | </form>'; |
1675 | + } |
|
1614 | 1676 | } |
1615 | 1677 | } |
1616 | 1678 | |
@@ -1776,10 +1838,12 @@ discard block |
||
1776 | 1838 | |
1777 | 1839 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1778 | 1840 | $disabled_tags = array(); |
1779 | - if (!empty($modSettings['disabledBBC'])) |
|
1780 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1781 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1782 | - $disabled_tags[] = 'flash'; |
|
1841 | + if (!empty($modSettings['disabledBBC'])) { |
|
1842 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1843 | + } |
|
1844 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1845 | + $disabled_tags[] = 'flash'; |
|
1846 | + } |
|
1783 | 1847 | |
1784 | 1848 | foreach ($disabled_tags as $tag) |
1785 | 1849 | { |
@@ -1789,9 +1853,10 @@ discard block |
||
1789 | 1853 | $context['disabled_tags']['orderedlist'] = true; |
1790 | 1854 | } |
1791 | 1855 | |
1792 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1793 | - if ($tag === $thisTag) |
|
1856 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1857 | + if ($tag === $thisTag) |
|
1794 | 1858 | $context['disabled_tags'][$tagNameBBC] = true; |
1859 | + } |
|
1795 | 1860 | |
1796 | 1861 | $context['disabled_tags'][trim($tag)] = true; |
1797 | 1862 | } |
@@ -1801,19 +1866,21 @@ discard block |
||
1801 | 1866 | $context['bbc_toolbar'] = array(); |
1802 | 1867 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1803 | 1868 | { |
1804 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1805 | - $context['bbc_toolbar'][$row] = array(); |
|
1869 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1870 | + $context['bbc_toolbar'][$row] = array(); |
|
1871 | + } |
|
1806 | 1872 | $tagsRow = array(); |
1807 | 1873 | foreach ($tagRow as $tag) |
1808 | 1874 | { |
1809 | 1875 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
1810 | 1876 | { |
1811 | 1877 | $tagsRow[] = $tag['code']; |
1812 | - if (isset($tag['image'])) |
|
1813 | - $bbcodes_styles .= ' |
|
1878 | + if (isset($tag['image'])) { |
|
1879 | + $bbcodes_styles .= ' |
|
1814 | 1880 | .sceditor-button-' . $tag['code'] . ' div { |
1815 | 1881 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
1816 | 1882 | }'; |
1883 | + } |
|
1817 | 1884 | if (isset($tag['before'])) |
1818 | 1885 | { |
1819 | 1886 | $context['bbcodes_handlers'] .= ' |
@@ -1827,8 +1894,7 @@ discard block |
||
1827 | 1894 | });'; |
1828 | 1895 | } |
1829 | 1896 | |
1830 | - } |
|
1831 | - else |
|
1897 | + } else |
|
1832 | 1898 | { |
1833 | 1899 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1834 | 1900 | $tagsRow = array(); |
@@ -1839,14 +1905,16 @@ discard block |
||
1839 | 1905 | { |
1840 | 1906 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1841 | 1907 | $tagsRow = array(); |
1842 | - if (!isset($context['disabled_tags']['font'])) |
|
1843 | - $tagsRow[] = 'font'; |
|
1844 | - if (!isset($context['disabled_tags']['size'])) |
|
1845 | - $tagsRow[] = 'size'; |
|
1846 | - if (!isset($context['disabled_tags']['color'])) |
|
1847 | - $tagsRow[] = 'color'; |
|
1848 | - } |
|
1849 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1908 | + if (!isset($context['disabled_tags']['font'])) { |
|
1909 | + $tagsRow[] = 'font'; |
|
1910 | + } |
|
1911 | + if (!isset($context['disabled_tags']['size'])) { |
|
1912 | + $tagsRow[] = 'size'; |
|
1913 | + } |
|
1914 | + if (!isset($context['disabled_tags']['color'])) { |
|
1915 | + $tagsRow[] = 'color'; |
|
1916 | + } |
|
1917 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1850 | 1918 | { |
1851 | 1919 | $tmp = array(); |
1852 | 1920 | $tagsRow[] = 'removeformat'; |
@@ -1857,13 +1925,15 @@ discard block |
||
1857 | 1925 | } |
1858 | 1926 | } |
1859 | 1927 | |
1860 | - if (!empty($tagsRow)) |
|
1861 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1928 | + if (!empty($tagsRow)) { |
|
1929 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1930 | + } |
|
1862 | 1931 | } |
1863 | - if (!empty($bbcodes_styles)) |
|
1864 | - $context['html_headers'] .= ' |
|
1932 | + if (!empty($bbcodes_styles)) { |
|
1933 | + $context['html_headers'] .= ' |
|
1865 | 1934 | <style>' . $bbcodes_styles . ' |
1866 | 1935 | </style>'; |
1936 | + } |
|
1867 | 1937 | } |
1868 | 1938 | |
1869 | 1939 | // Initialize smiley array... if not loaded before. |
@@ -1875,8 +1945,8 @@ discard block |
||
1875 | 1945 | ); |
1876 | 1946 | |
1877 | 1947 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1878 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1879 | - $context['smileys']['postform'][] = array( |
|
1948 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1949 | + $context['smileys']['postform'][] = array( |
|
1880 | 1950 | 'smileys' => array( |
1881 | 1951 | array( |
1882 | 1952 | 'code' => ':)', |
@@ -1962,7 +2032,7 @@ discard block |
||
1962 | 2032 | ), |
1963 | 2033 | 'isLast' => true, |
1964 | 2034 | ); |
1965 | - elseif ($user_info['smiley_set'] != 'none') |
|
2035 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1966 | 2036 | { |
1967 | 2037 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1968 | 2038 | { |
@@ -1985,17 +2055,19 @@ discard block |
||
1985 | 2055 | |
1986 | 2056 | foreach ($context['smileys'] as $section => $smileyRows) |
1987 | 2057 | { |
1988 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
1989 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2058 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2059 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2060 | + } |
|
1990 | 2061 | |
1991 | - if (!empty($smileyRows)) |
|
1992 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2062 | + if (!empty($smileyRows)) { |
|
2063 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2064 | + } |
|
1993 | 2065 | } |
1994 | 2066 | |
1995 | 2067 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2068 | + } else { |
|
2069 | + $context['smileys'] = $temp; |
|
1996 | 2070 | } |
1997 | - else |
|
1998 | - $context['smileys'] = $temp; |
|
1999 | 2071 | } |
2000 | 2072 | } |
2001 | 2073 | |
@@ -2021,8 +2093,9 @@ discard block |
||
2021 | 2093 | loadTemplate('GenericControls'); |
2022 | 2094 | |
2023 | 2095 | // Some javascript ma'am? |
2024 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2025 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2096 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2097 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2098 | + } |
|
2026 | 2099 | |
2027 | 2100 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2028 | 2101 | |
@@ -2035,8 +2108,8 @@ discard block |
||
2035 | 2108 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2036 | 2109 | |
2037 | 2110 | // Log this into our collection. |
2038 | - if ($isNew) |
|
2039 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2111 | + if ($isNew) { |
|
2112 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2040 | 2113 | 'id' => $verificationOptions['id'], |
2041 | 2114 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2042 | 2115 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2047,13 +2120,15 @@ discard block |
||
2047 | 2120 | 'questions' => array(), |
2048 | 2121 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2049 | 2122 | ); |
2123 | + } |
|
2050 | 2124 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2051 | 2125 | |
2052 | 2126 | // Is there actually going to be anything? |
2053 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2054 | - return false; |
|
2055 | - elseif (!$isNew && !$do_test) |
|
2056 | - return true; |
|
2127 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2128 | + return false; |
|
2129 | + } elseif (!$isNew && !$do_test) { |
|
2130 | + return true; |
|
2131 | + } |
|
2057 | 2132 | |
2058 | 2133 | // Sanitize reCAPTCHA fields? |
2059 | 2134 | if ($thisVerification['can_recaptcha']) |
@@ -2066,11 +2141,12 @@ discard block |
||
2066 | 2141 | } |
2067 | 2142 | |
2068 | 2143 | // Add javascript for the object. |
2069 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2070 | - $context['insert_after_template'] .= ' |
|
2144 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2145 | + $context['insert_after_template'] .= ' |
|
2071 | 2146 | <script> |
2072 | 2147 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2073 | 2148 | </script>'; |
2149 | + } |
|
2074 | 2150 | |
2075 | 2151 | // If we want questions do we have a cache of all the IDs? |
2076 | 2152 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2093,8 +2169,9 @@ discard block |
||
2093 | 2169 | unset ($row['id_question']); |
2094 | 2170 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2095 | 2171 | $row['answers'] = smf_json_decode($row['answers'], true); |
2096 | - foreach ($row['answers'] as $k => $v) |
|
2097 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2172 | + foreach ($row['answers'] as $k => $v) { |
|
2173 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2174 | + } |
|
2098 | 2175 | |
2099 | 2176 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2100 | 2177 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2105,35 +2182,42 @@ discard block |
||
2105 | 2182 | } |
2106 | 2183 | } |
2107 | 2184 | |
2108 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2109 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2185 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2186 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2187 | + } |
|
2110 | 2188 | |
2111 | 2189 | // Do we need to refresh the verification? |
2112 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2113 | - $force_refresh = true; |
|
2114 | - else |
|
2115 | - $force_refresh = false; |
|
2190 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2191 | + $force_refresh = true; |
|
2192 | + } else { |
|
2193 | + $force_refresh = false; |
|
2194 | + } |
|
2116 | 2195 | |
2117 | 2196 | // This can also force a fresh, although unlikely. |
2118 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2119 | - $force_refresh = true; |
|
2197 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2198 | + $force_refresh = true; |
|
2199 | + } |
|
2120 | 2200 | |
2121 | 2201 | $verification_errors = array(); |
2122 | 2202 | // Start with any testing. |
2123 | 2203 | if ($do_test) |
2124 | 2204 | { |
2125 | 2205 | // This cannot happen! |
2126 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2127 | - fatal_lang_error('no_access', false); |
|
2206 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2207 | + fatal_lang_error('no_access', false); |
|
2208 | + } |
|
2128 | 2209 | // ... nor this! |
2129 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2130 | - fatal_lang_error('no_access', false); |
|
2210 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2211 | + fatal_lang_error('no_access', false); |
|
2212 | + } |
|
2131 | 2213 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2132 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2133 | - fatal_lang_error('no_access', false); |
|
2214 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2215 | + fatal_lang_error('no_access', false); |
|
2216 | + } |
|
2134 | 2217 | // While we're here, did the user do something bad? |
2135 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2136 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2218 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2219 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2220 | + } |
|
2137 | 2221 | |
2138 | 2222 | if ($thisVerification['can_recaptcha']) |
2139 | 2223 | { |
@@ -2144,22 +2228,25 @@ discard block |
||
2144 | 2228 | { |
2145 | 2229 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2146 | 2230 | |
2147 | - if (!$resp->isSuccess()) |
|
2148 | - $verification_errors[] = 'wrong_verification_code'; |
|
2231 | + if (!$resp->isSuccess()) { |
|
2232 | + $verification_errors[] = 'wrong_verification_code'; |
|
2233 | + } |
|
2234 | + } else { |
|
2235 | + $verification_errors[] = 'wrong_verification_code'; |
|
2149 | 2236 | } |
2150 | - else |
|
2151 | - $verification_errors[] = 'wrong_verification_code'; |
|
2152 | 2237 | } |
2153 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2154 | - $verification_errors[] = 'wrong_verification_code'; |
|
2238 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2239 | + $verification_errors[] = 'wrong_verification_code'; |
|
2240 | + } |
|
2155 | 2241 | if ($thisVerification['number_questions']) |
2156 | 2242 | { |
2157 | 2243 | $incorrectQuestions = array(); |
2158 | 2244 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2159 | 2245 | { |
2160 | 2246 | // We don't have this question any more, thus no answers. |
2161 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2162 | - continue; |
|
2247 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2248 | + continue; |
|
2249 | + } |
|
2163 | 2250 | // This is quite complex. We have our question but it might have multiple answers. |
2164 | 2251 | // First, did they actually answer this question? |
2165 | 2252 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2171,24 +2258,28 @@ discard block |
||
2171 | 2258 | else |
2172 | 2259 | { |
2173 | 2260 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2174 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2175 | - $incorrectQuestions[] = $q; |
|
2261 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2262 | + $incorrectQuestions[] = $q; |
|
2263 | + } |
|
2176 | 2264 | } |
2177 | 2265 | } |
2178 | 2266 | |
2179 | - if (!empty($incorrectQuestions)) |
|
2180 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2267 | + if (!empty($incorrectQuestions)) { |
|
2268 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2269 | + } |
|
2181 | 2270 | } |
2182 | 2271 | } |
2183 | 2272 | |
2184 | 2273 | // Any errors means we refresh potentially. |
2185 | 2274 | if (!empty($verification_errors)) |
2186 | 2275 | { |
2187 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2188 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2276 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2277 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2278 | + } |
|
2189 | 2279 | // Too many errors? |
2190 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2191 | - $force_refresh = true; |
|
2280 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2281 | + $force_refresh = true; |
|
2282 | + } |
|
2192 | 2283 | |
2193 | 2284 | // Keep a track of these. |
2194 | 2285 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2221,8 +2312,9 @@ discard block |
||
2221 | 2312 | // Are we overriding the range? |
2222 | 2313 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2223 | 2314 | |
2224 | - for ($i = 0; $i < 6; $i++) |
|
2225 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2315 | + for ($i = 0; $i < 6; $i++) { |
|
2316 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2317 | + } |
|
2226 | 2318 | } |
2227 | 2319 | |
2228 | 2320 | // Getting some new questions? |
@@ -2230,8 +2322,9 @@ discard block |
||
2230 | 2322 | { |
2231 | 2323 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2232 | 2324 | $possible_langs = array(); |
2233 | - if (isset($_SESSION['language'])) |
|
2234 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2325 | + if (isset($_SESSION['language'])) { |
|
2326 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2327 | + } |
|
2235 | 2328 | if (!empty($user_info['language'])); |
2236 | 2329 | $possible_langs[] = $user_info['language']; |
2237 | 2330 | $possible_langs[] = $language; |
@@ -2250,8 +2343,7 @@ discard block |
||
2250 | 2343 | } |
2251 | 2344 | } |
2252 | 2345 | } |
2253 | - } |
|
2254 | - else |
|
2346 | + } else |
|
2255 | 2347 | { |
2256 | 2348 | // Same questions as before. |
2257 | 2349 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2261,8 +2353,9 @@ discard block |
||
2261 | 2353 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2262 | 2354 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2263 | 2355 | { |
2264 | - if (!isset($context['html_headers'])) |
|
2265 | - $context['html_headers'] = ''; |
|
2356 | + if (!isset($context['html_headers'])) { |
|
2357 | + $context['html_headers'] = ''; |
|
2358 | + } |
|
2266 | 2359 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2267 | 2360 | } |
2268 | 2361 | |
@@ -2288,11 +2381,13 @@ discard block |
||
2288 | 2381 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2289 | 2382 | |
2290 | 2383 | // Return errors if we have them. |
2291 | - if (!empty($verification_errors)) |
|
2292 | - return $verification_errors; |
|
2384 | + if (!empty($verification_errors)) { |
|
2385 | + return $verification_errors; |
|
2386 | + } |
|
2293 | 2387 | // If we had a test that one, make a note. |
2294 | - elseif ($do_test) |
|
2295 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2388 | + elseif ($do_test) { |
|
2389 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2390 | + } |
|
2296 | 2391 | |
2297 | 2392 | // Say that everything went well chaps. |
2298 | 2393 | return true; |
@@ -2317,8 +2412,9 @@ discard block |
||
2317 | 2412 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2318 | 2413 | |
2319 | 2414 | // If we're just checking the callback function is registered return true or false. |
2320 | - if ($checkRegistered != null) |
|
2321 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2415 | + if ($checkRegistered != null) { |
|
2416 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2417 | + } |
|
2322 | 2418 | |
2323 | 2419 | checkSession('get'); |
2324 | 2420 | loadTemplate('Xml'); |
@@ -2469,24 +2565,27 @@ discard block |
||
2469 | 2565 | foreach ($possible_versions as $ver) |
2470 | 2566 | { |
2471 | 2567 | $ver = trim($ver); |
2472 | - if (strpos($ver, 'SMF') === 0) |
|
2473 | - $versions[] = $ver; |
|
2568 | + if (strpos($ver, 'SMF') === 0) { |
|
2569 | + $versions[] = $ver; |
|
2570 | + } |
|
2474 | 2571 | } |
2475 | 2572 | } |
2476 | 2573 | $smcFunc['db_free_result']($request); |
2477 | 2574 | |
2478 | 2575 | // Just in case we don't have ANYthing. |
2479 | - if (empty($versions)) |
|
2480 | - $versions = array('SMF 2.0'); |
|
2576 | + if (empty($versions)) { |
|
2577 | + $versions = array('SMF 2.0'); |
|
2578 | + } |
|
2481 | 2579 | |
2482 | - foreach ($versions as $id => $version) |
|
2483 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2580 | + foreach ($versions as $id => $version) { |
|
2581 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2484 | 2582 | $xml_data['items']['children'][] = array( |
2485 | 2583 | 'attributes' => array( |
2486 | 2584 | 'id' => $id, |
2487 | 2585 | ), |
2488 | 2586 | 'value' => $version, |
2489 | 2587 | ); |
2588 | + } |
|
2490 | 2589 | |
2491 | 2590 | return $xml_data; |
2492 | 2591 | } |