@@ -20,13 +20,12 @@ discard block |
||
| 20 | 20 | // We completed some tasks? |
| 21 | 21 | if (!empty($context['tasks_were_run'])) |
| 22 | 22 | { |
| 23 | - if (empty($context['scheduled_errors'])) |
|
| 24 | - echo ' |
|
| 23 | + if (empty($context['scheduled_errors'])) { |
|
| 24 | + echo ' |
|
| 25 | 25 | <div class="infobox"> |
| 26 | 26 | ', $txt['scheduled_tasks_were_run'], ' |
| 27 | 27 | </div>'; |
| 28 | - |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | echo ' |
| 32 | 31 | <div class="errorbox" id="errors"> |
@@ -35,14 +34,15 @@ discard block |
||
| 35 | 34 | <strong id="error_serious">', $txt['scheduled_tasks_were_run_errors'], '</strong> |
| 36 | 35 | </dt>'; |
| 37 | 36 | |
| 38 | - foreach ($context['scheduled_errors'] as $task => $errors) |
|
| 39 | - echo ' |
|
| 37 | + foreach ($context['scheduled_errors'] as $task => $errors) { |
|
| 38 | + echo ' |
|
| 40 | 39 | <dd class="error"> |
| 41 | 40 | <strong>', isset($txt['scheduled_task_' . $task]) ? $txt['scheduled_task_' . $task] : $task, '</strong> |
| 42 | 41 | <ul> |
| 43 | 42 | <li>', implode('</li><li>', $errors), '</li> |
| 44 | 43 | </ul> |
| 45 | 44 | </dd>'; |
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | echo ' |
| 48 | 48 | </dl> |
@@ -62,16 +62,17 @@ |
||
| 62 | 62 | <div id="error_box" class="errorbox"> |
| 63 | 63 | <ul id="error_list">'; |
| 64 | 64 | |
| 65 | - foreach ($context['post_errors'] as $key => $error) |
|
| 66 | - echo ' |
|
| 65 | + foreach ($context['post_errors'] as $key => $error) { |
|
| 66 | + echo ' |
|
| 67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | echo ' |
| 70 | 71 | </ul>'; |
| 71 | - } |
|
| 72 | - else |
|
| 73 | - echo ' |
|
| 72 | + } else { |
|
| 73 | + echo ' |
|
| 74 | 74 | <div style="display:none" id="error_box" class="errorbox">'; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | echo ' |
| 77 | 78 | </div>'; |
@@ -89,16 +89,18 @@ discard block |
||
| 89 | 89 | foreach ($section['areas'] as $i => $area) |
| 90 | 90 | { |
| 91 | 91 | // Not supposed to be printed? |
| 92 | - if (empty($area['label'])) |
|
| 93 | - continue; |
|
| 92 | + if (empty($area['label'])) { |
|
| 93 | + continue; |
|
| 94 | + } |
|
| 94 | 95 | |
| 95 | 96 | echo ' |
| 96 | 97 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '> |
| 97 | 98 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>'; |
| 98 | 99 | |
| 99 | 100 | // Is this the current area, or just some area? |
| 100 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
| 101 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 101 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
| 102 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 103 | + } |
|
| 102 | 104 | |
| 103 | 105 | // Are there any subsections? |
| 104 | 106 | if (!empty($area['subsections'])) |
@@ -108,8 +110,9 @@ discard block |
||
| 108 | 110 | |
| 109 | 111 | foreach ($area['subsections'] as $sa => $sub) |
| 110 | 112 | { |
| 111 | - if (!empty($sub['disabled'])) |
|
| 112 | - continue; |
|
| 113 | + if (!empty($sub['disabled'])) { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
| 115 | 118 | |
@@ -156,8 +159,9 @@ discard block |
||
| 156 | 159 | <h3 class="catbg">'; |
| 157 | 160 | |
| 158 | 161 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
| 159 | - if (function_exists('template_admin_quick_search')) |
|
| 160 | - template_admin_quick_search(); |
|
| 162 | + if (function_exists('template_admin_quick_search')) { |
|
| 163 | + template_admin_quick_search(); |
|
| 164 | + } |
|
| 161 | 165 | |
| 162 | 166 | // Exactly how many tabs do we have? |
| 163 | 167 | if (!empty($context['tabs'])) |
@@ -172,30 +176,36 @@ discard block |
||
| 172 | 176 | } |
| 173 | 177 | |
| 174 | 178 | // Did this not even exist - or do we not have a label? |
| 175 | - if (!isset($tab_context['tabs'][$id])) |
|
| 176 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 177 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
| 178 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 179 | + if (!isset($tab_context['tabs'][$id])) { |
|
| 180 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 181 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
| 182 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 183 | + } |
|
| 179 | 184 | |
| 180 | 185 | // Has a custom URL defined in the main admin structure? |
| 181 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
| 182 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 186 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
| 187 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 188 | + } |
|
| 183 | 189 | |
| 184 | 190 | // Any additional paramaters for the url? |
| 185 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
| 186 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 191 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
| 192 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 193 | + } |
|
| 187 | 194 | |
| 188 | 195 | // Has it been deemed selected? |
| 189 | - if (!empty($tab['is_selected'])) |
|
| 190 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 196 | + if (!empty($tab['is_selected'])) { |
|
| 197 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 198 | + } |
|
| 191 | 199 | |
| 192 | 200 | // Does it have its own help? |
| 193 | - if (!empty($tab['help'])) |
|
| 194 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 201 | + if (!empty($tab['help'])) { |
|
| 202 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | // Is this the last one? |
| 197 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
| 198 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
| 206 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
| 207 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
| 208 | + } |
|
| 199 | 209 | } |
| 200 | 210 | |
| 201 | 211 | // Find the selected tab |
@@ -212,22 +222,24 @@ discard block |
||
| 212 | 222 | // Show an icon and/or a help item? |
| 213 | 223 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
| 214 | 224 | { |
| 215 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
| 216 | - echo ' |
|
| 225 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
| 226 | + echo ' |
|
| 217 | 227 | <span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
| 218 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
| 219 | - echo ' |
|
| 228 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
| 229 | + echo ' |
|
| 220 | 230 | <img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
| 231 | + } |
|
| 221 | 232 | |
| 222 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
| 223 | - echo ' |
|
| 233 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
| 234 | + echo ' |
|
| 224 | 235 | <a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
| 236 | + } |
|
| 225 | 237 | |
| 226 | 238 | echo $tab_context['title']; |
| 227 | - } |
|
| 228 | - else |
|
| 229 | - echo ' |
|
| 239 | + } else { |
|
| 240 | + echo ' |
|
| 230 | 241 | ', $tab_context['title']; |
| 242 | + } |
|
| 231 | 243 | |
| 232 | 244 | echo ' |
| 233 | 245 | </h3>', (function_exists('template_admin_quick_search') ? ' |
@@ -236,11 +248,12 @@ discard block |
||
| 236 | 248 | } |
| 237 | 249 | |
| 238 | 250 | // Shall we use the tabs? Yes, it's the only known way! |
| 239 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
| 240 | - echo ' |
|
| 251 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
| 252 | + echo ' |
|
| 241 | 253 | <p class="information"> |
| 242 | 254 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
| 243 | 255 | </p>'; |
| 256 | + } |
|
| 244 | 257 | |
| 245 | 258 | // Print out all the items in this tab (if any). |
| 246 | 259 | if (!empty($context['tabs'])) |
@@ -252,19 +265,21 @@ discard block |
||
| 252 | 265 | |
| 253 | 266 | foreach ($tab_context['tabs'] as $sa => $tab) |
| 254 | 267 | { |
| 255 | - if (!empty($tab['disabled'])) |
|
| 256 | - continue; |
|
| 268 | + if (!empty($tab['disabled'])) { |
|
| 269 | + continue; |
|
| 270 | + } |
|
| 257 | 271 | |
| 258 | - if (!empty($tab['is_selected'])) |
|
| 259 | - echo ' |
|
| 272 | + if (!empty($tab['is_selected'])) { |
|
| 273 | + echo ' |
|
| 260 | 274 | <li> |
| 261 | 275 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 262 | 276 | </li>'; |
| 263 | - else |
|
| 264 | - echo ' |
|
| 277 | + } else { |
|
| 278 | + echo ' |
|
| 265 | 279 | <li> |
| 266 | 280 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 267 | 281 | </li>'; |
| 282 | + } |
|
| 268 | 283 | } |
| 269 | 284 | |
| 270 | 285 | // The end of tabs |
@@ -29,9 +29,10 @@ discard block |
||
| 29 | 29 | // Go through each type of report they can run. |
| 30 | 30 | foreach ($context['report_types'] as $type) |
| 31 | 31 | { |
| 32 | - if (isset($type['description'])) |
|
| 33 | - echo ' |
|
| 32 | + if (isset($type['description'])) { |
|
| 33 | + echo ' |
|
| 34 | 34 | <dt>', $type['description'], '</dt>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | echo ' |
| 37 | 38 | <dd> |
@@ -62,8 +63,9 @@ discard block |
||
| 62 | 63 | </div> |
| 63 | 64 | <div id="report_buttons">'; |
| 64 | 65 | |
| 65 | - if (!empty($context['report_buttons'])) |
|
| 66 | - template_button_strip($context['report_buttons'], 'right'); |
|
| 66 | + if (!empty($context['report_buttons'])) { |
|
| 67 | + template_button_strip($context['report_buttons'], 'right'); |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | echo ' |
| 69 | 71 | </div>'; |
@@ -74,25 +76,27 @@ discard block |
||
| 74 | 76 | echo ' |
| 75 | 77 | <table class="table_grid report_results">'; |
| 76 | 78 | |
| 77 | - if (!empty($table['title'])) |
|
| 78 | - echo ' |
|
| 79 | + if (!empty($table['title'])) { |
|
| 80 | + echo ' |
|
| 79 | 81 | <thead> |
| 80 | 82 | <tr class="title_bar"> |
| 81 | 83 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
| 82 | 84 | </tr> |
| 83 | 85 | </thead> |
| 84 | 86 | <tbody>'; |
| 87 | + } |
|
| 85 | 88 | |
| 86 | 89 | // Now do each row! |
| 87 | 90 | $row_number = 0; |
| 88 | 91 | foreach ($table['data'] as $row) |
| 89 | 92 | { |
| 90 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 91 | - echo ' |
|
| 93 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 94 | + echo ' |
|
| 92 | 95 | <tr class="windowbg table_caption">'; |
| 93 | - else |
|
| 94 | - echo ' |
|
| 96 | + } else { |
|
| 97 | + echo ' |
|
| 95 | 98 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
| 99 | + } |
|
| 96 | 100 | |
| 97 | 101 | // Now do each column. |
| 98 | 102 | $column_number = 0; |
@@ -110,16 +114,17 @@ discard block |
||
| 110 | 114 | } |
| 111 | 115 | |
| 112 | 116 | // Shaded? |
| 113 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 114 | - echo ' |
|
| 117 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 118 | + echo ' |
|
| 115 | 119 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 116 | 120 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 117 | 121 | </td>'; |
| 118 | - else |
|
| 119 | - echo ' |
|
| 122 | + } else { |
|
| 123 | + echo ' |
|
| 120 | 124 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 121 | 125 | ', $data['v'], ' |
| 122 | 126 | </td>'; |
| 127 | + } |
|
| 123 | 128 | |
| 124 | 129 | $column_number++; |
| 125 | 130 | } |
@@ -168,24 +173,26 @@ discard block |
||
| 168 | 173 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
| 169 | 174 | <table class="bordercolor">'; |
| 170 | 175 | |
| 171 | - if (!empty($table['title'])) |
|
| 172 | - echo ' |
|
| 176 | + if (!empty($table['title'])) { |
|
| 177 | + echo ' |
|
| 173 | 178 | <tr class="title_bar"> |
| 174 | 179 | <td colspan="', $table['column_count'], '"> |
| 175 | 180 | ', $table['title'], ' |
| 176 | 181 | </td> |
| 177 | 182 | </tr>'; |
| 183 | + } |
|
| 178 | 184 | |
| 179 | 185 | // Now do each row! |
| 180 | 186 | $row_number = 0; |
| 181 | 187 | foreach ($table['data'] as $row) |
| 182 | 188 | { |
| 183 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 184 | - echo ' |
|
| 189 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 190 | + echo ' |
|
| 185 | 191 | <tr class="titlebg">'; |
| 186 | - else |
|
| 187 | - echo ' |
|
| 192 | + } else { |
|
| 193 | + echo ' |
|
| 188 | 194 | <tr class="windowbg">'; |
| 195 | + } |
|
| 189 | 196 | |
| 190 | 197 | // Now do each column!! |
| 191 | 198 | $column_number = 0; |
@@ -202,16 +209,17 @@ discard block |
||
| 202 | 209 | } |
| 203 | 210 | |
| 204 | 211 | // Shaded? |
| 205 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 206 | - echo ' |
|
| 212 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 213 | + echo ' |
|
| 207 | 214 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 208 | 215 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 209 | 216 | </td>'; |
| 210 | - else |
|
| 211 | - echo ' |
|
| 217 | + } else { |
|
| 218 | + echo ' |
|
| 212 | 219 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 213 | 220 | ', $data['v'], ' |
| 214 | 221 | </td>'; |
| 222 | + } |
|
| 215 | 223 | |
| 216 | 224 | $column_number++; |
| 217 | 225 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
| 107 | 108 | // Perhaps the search method wants to add some settings? |
| 108 | 109 | require_once($sourcedir . '/Search.php'); |
| 109 | 110 | $searchAPI = findSearchAPI(); |
| 110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
| 111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
| 112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | - if ($return_config) |
|
| 114 | - return $config_vars; |
|
| 115 | + if ($return_config) { |
|
| 116 | + return $config_vars; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
| 117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | call_integration_hook('integrate_save_search_settings'); |
| 128 | 131 | |
| 129 | - if (empty($_POST['search_results_per_page'])) |
|
| 130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 132 | + if (empty($_POST['search_results_per_page'])) { |
|
| 133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 134 | + } |
|
| 131 | 135 | saveDBSettings($config_vars); |
| 132 | 136 | $_SESSION['adm-save'] = true; |
| 133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
| 177 | 181 | call_integration_hook('integrate_save_search_weights'); |
| 178 | 182 | |
| 179 | 183 | $changes = array(); |
| 180 | - foreach ($factors as $factor) |
|
| 181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
| 184 | + foreach ($factors as $factor) { |
|
| 185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
| 186 | + } |
|
| 182 | 187 | updateSettings($changes); |
| 183 | 188 | } |
| 184 | 189 | |
| 185 | 190 | $context['relative_weights'] = array('total' => 0); |
| 186 | - foreach ($factors as $factor) |
|
| 187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 191 | + foreach ($factors as $factor) { |
|
| 192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 193 | + } |
|
| 188 | 194 | |
| 189 | - foreach ($factors as $factor) |
|
| 190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 195 | + foreach ($factors as $factor) { |
|
| 196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 197 | + } |
|
| 191 | 198 | |
| 192 | 199 | createToken('admin-msw'); |
| 193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
| 216 | 223 | |
| 217 | 224 | // Detect whether a fulltext index is set. |
| 218 | - if ($context['supports_fulltext']) |
|
| 219 | - detectFulltextIndex(); |
|
| 225 | + if ($context['supports_fulltext']) { |
|
| 226 | + detectFulltextIndex(); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
| 222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
| 240 | 248 | 'language' => $language_ftx |
| 241 | 249 | ) |
| 242 | 250 | ); |
| 243 | - } |
|
| 244 | - else |
|
| 251 | + } else |
|
| 245 | 252 | { |
| 246 | 253 | // Make sure it's gone before creating it. |
| 247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
| 259 | 266 | ) |
| 260 | 267 | ); |
| 261 | 268 | } |
| 262 | - } |
|
| 263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 264 | 270 | { |
| 265 | 271 | checkSession('get'); |
| 266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
| 277 | 283 | $context['fulltext_index'] = array(); |
| 278 | 284 | |
| 279 | 285 | // Go back to the default search method. |
| 280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
| 281 | - updateSettings(array( |
|
| 286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
| 287 | + updateSettings(array( |
|
| 282 | 288 | 'search_index' => '', |
| 283 | 289 | )); |
| 284 | - } |
|
| 285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 290 | + } |
|
| 291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 286 | 292 | { |
| 287 | 293 | checkSession('get'); |
| 288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
| 304 | 310 | )); |
| 305 | 311 | |
| 306 | 312 | // Go back to the default search method. |
| 307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 308 | - updateSettings(array( |
|
| 313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 314 | + updateSettings(array( |
|
| 309 | 315 | 'search_index' => '', |
| 310 | 316 | )); |
| 311 | - } |
|
| 312 | - elseif (isset($_POST['save'])) |
|
| 317 | + } |
|
| 318 | + } elseif (isset($_POST['save'])) |
|
| 313 | 319 | { |
| 314 | 320 | checkSession(); |
| 315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
| 331 | 337 | // Get some info about the messages table, to show its size and index size. |
| 332 | 338 | if ($db_type == 'mysql') |
| 333 | 339 | { |
| 334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 335 | - $request = $smcFunc['db_query']('', ' |
|
| 340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 341 | + $request = $smcFunc['db_query']('', ' |
|
| 336 | 342 | SHOW TABLE STATUS |
| 337 | 343 | FROM {string:database_name} |
| 338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
| 341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 342 | 348 | ) |
| 343 | 349 | ); |
| 344 | - else |
|
| 345 | - $request = $smcFunc['db_query']('', ' |
|
| 350 | + } else { |
|
| 351 | + $request = $smcFunc['db_query']('', ' |
|
| 346 | 352 | SHOW TABLE STATUS |
| 347 | 353 | LIKE {string:table_name}', |
| 348 | 354 | array( |
| 349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 350 | 356 | ) |
| 351 | 357 | ); |
| 358 | + } |
|
| 352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 353 | 360 | { |
| 354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
| 360 | 367 | } |
| 361 | 368 | |
| 362 | 369 | // Now check the custom index table, if it exists at all. |
| 363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 364 | - $request = $smcFunc['db_query']('', ' |
|
| 370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 371 | + $request = $smcFunc['db_query']('', ' |
|
| 365 | 372 | SHOW TABLE STATUS |
| 366 | 373 | FROM {string:database_name} |
| 367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
| 370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
| 371 | 378 | ) |
| 372 | 379 | ); |
| 373 | - else |
|
| 374 | - $request = $smcFunc['db_query']('', ' |
|
| 380 | + } else { |
|
| 381 | + $request = $smcFunc['db_query']('', ' |
|
| 375 | 382 | SHOW TABLE STATUS |
| 376 | 383 | LIKE {string:table_name}', |
| 377 | 384 | array( |
| 378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
| 379 | 386 | ) |
| 380 | 387 | ); |
| 388 | + } |
|
| 381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 382 | 390 | { |
| 383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
| 386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
| 387 | 395 | $smcFunc['db_free_result']($request); |
| 388 | 396 | } |
| 389 | - } |
|
| 390 | - elseif ($db_type == 'postgresql') |
|
| 397 | + } elseif ($db_type == 'postgresql') |
|
| 391 | 398 | { |
| 392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
| 393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
| 429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
| 430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
| 432 | - } |
|
| 433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 434 | 440 | { |
| 435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
| 437 | 443 | } |
| 438 | 444 | } |
| 439 | 445 | $smcFunc['db_free_result']($request); |
| 440 | - } |
|
| 441 | - else |
|
| 442 | - // Didn't work for some reason... |
|
| 446 | + } else { |
|
| 447 | + // Didn't work for some reason... |
|
| 443 | 448 | $context['table_info'] = array( |
| 444 | 449 | 'data_length' => $txt['not_applicable'], |
| 445 | 450 | 'index_length' => $txt['not_applicable'], |
| 446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
| 447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
| 448 | 453 | ); |
| 449 | - } |
|
| 450 | - else |
|
| 451 | - $context['table_info'] = array( |
|
| 454 | + } |
|
| 455 | + } else { |
|
| 456 | + $context['table_info'] = array( |
|
| 452 | 457 | 'data_length' => $txt['not_applicable'], |
| 453 | 458 | 'index_length' => $txt['not_applicable'], |
| 454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
| 455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
| 456 | 461 | ); |
| 462 | + } |
|
| 457 | 463 | |
| 458 | 464 | // Format the data and index length in kilobytes. |
| 459 | 465 | foreach ($context['table_info'] as $type => $size) |
| 460 | 466 | { |
| 461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
| 462 | - if (!is_numeric($size)) |
|
| 463 | - break; |
|
| 468 | + if (!is_numeric($size)) { |
|
| 469 | + break; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
| 466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
| 489 | 496 | |
| 490 | 497 | // Scotty, we need more time... |
| 491 | 498 | @set_time_limit(600); |
| 492 | - if (function_exists('apache_reset_timeout')) |
|
| 493 | - @apache_reset_timeout(); |
|
| 499 | + if (function_exists('apache_reset_timeout')) { |
|
| 500 | + @apache_reset_timeout(); |
|
| 501 | + } |
|
| 494 | 502 | |
| 495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
| 496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
| 520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
| 521 | 529 | unset($context['index_settings']['resume_at']); |
| 522 | 530 | $context['step'] = 1; |
| 523 | - } |
|
| 524 | - else |
|
| 531 | + } else |
|
| 525 | 532 | { |
| 526 | 533 | $context['index_settings'] = array( |
| 527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
| 530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
| 531 | 538 | |
| 532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
| 533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
| 534 | - $_SESSION['admin_time'] = time(); |
|
| 540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
| 541 | + $_SESSION['admin_time'] = time(); |
|
| 542 | + } |
|
| 535 | 543 | } |
| 536 | 544 | |
| 537 | - if ($context['step'] !== 0) |
|
| 538 | - checkSession('request'); |
|
| 545 | + if ($context['step'] !== 0) { |
|
| 546 | + checkSession('request'); |
|
| 547 | + } |
|
| 539 | 548 | |
| 540 | 549 | // Step 0: let the user determine how they like their index. |
| 541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
| 564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
| 565 | 574 | |
| 566 | 575 | // Temporarily switch back to not using a search index. |
| 567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 568 | - updateSettings(array('search_index' => '')); |
|
| 576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 577 | + updateSettings(array('search_index' => '')); |
|
| 578 | + } |
|
| 569 | 579 | |
| 570 | 580 | // Don't let simultanious processes be updating the search index. |
| 571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
| 572 | - updateSettings(array('search_custom_index_config' => '')); |
|
| 581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
| 582 | + updateSettings(array('search_custom_index_config' => '')); |
|
| 583 | + } |
|
| 573 | 584 | } |
| 574 | 585 | |
| 575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
| 585 | 596 | 'starting_id' => $context['start'], |
| 586 | 597 | ) |
| 587 | 598 | ); |
| 588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 601 | + } |
|
| 590 | 602 | |
| 591 | 603 | if (empty($num_messages['todo'])) |
| 592 | 604 | { |
| 593 | 605 | $context['step'] = 2; |
| 594 | 606 | $context['percentage'] = 80; |
| 595 | 607 | $context['start'] = 0; |
| 596 | - } |
|
| 597 | - else |
|
| 608 | + } else |
|
| 598 | 609 | { |
| 599 | 610 | // Number of seconds before the next step. |
| 600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
| 635 | 646 | |
| 636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
| 637 | 648 | |
| 638 | - if (!empty($inserts)) |
|
| 639 | - $smcFunc['db_insert']('ignore', |
|
| 649 | + if (!empty($inserts)) { |
|
| 650 | + $smcFunc['db_insert']('ignore', |
|
| 640 | 651 | '{db_prefix}log_search_words', |
| 641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 642 | 653 | $inserts, |
| 643 | 654 | array('id_word', 'id_msg') |
| 644 | 655 | ); |
| 656 | + } |
|
| 645 | 657 | if ($num_messages['todo'] === 0) |
| 646 | 658 | { |
| 647 | 659 | $context['step'] = 2; |
| 648 | 660 | $context['start'] = 0; |
| 649 | 661 | break; |
| 662 | + } else { |
|
| 663 | + updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 650 | 664 | } |
| 651 | - else |
|
| 652 | - updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 653 | 665 | } |
| 654 | 666 | |
| 655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
| 660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
| 661 | 673 | elseif ($context['step'] === 2) |
| 662 | 674 | { |
| 663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
| 664 | - $context['step'] = 3; |
|
| 665 | - else |
|
| 675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
| 676 | + $context['step'] = 3; |
|
| 677 | + } else |
|
| 666 | 678 | { |
| 667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
| 668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
| 683 | 695 | 'minimum_messages' => $max_messages, |
| 684 | 696 | ) |
| 685 | 697 | ); |
| 686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 687 | - $stop_words[] = $row['id_word']; |
|
| 698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 699 | + $stop_words[] = $row['id_word']; |
|
| 700 | + } |
|
| 688 | 701 | $smcFunc['db_free_result']($request); |
| 689 | 702 | |
| 690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
| 691 | 704 | |
| 692 | - if (!empty($stop_words)) |
|
| 693 | - $smcFunc['db_query']('', ' |
|
| 705 | + if (!empty($stop_words)) { |
|
| 706 | + $smcFunc['db_query']('', ' |
|
| 694 | 707 | DELETE FROM {db_prefix}log_search_words |
| 695 | 708 | WHERE id_word in ({array_int:stop_words})', |
| 696 | 709 | array( |
| 697 | 710 | 'stop_words' => $stop_words, |
| 698 | 711 | ) |
| 699 | 712 | ); |
| 713 | + } |
|
| 700 | 714 | |
| 701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
| 702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
| 757 | 771 | $searchAPI = new $search_class_name(); |
| 758 | 772 | |
| 759 | 773 | // No Support? NEXT! |
| 760 | - if (!$searchAPI->is_supported) |
|
| 761 | - continue; |
|
| 774 | + if (!$searchAPI->is_supported) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 762 | 777 | |
| 763 | 778 | $apis[$index_name] = array( |
| 764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
| 805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
| 806 | 821 | ) |
| 807 | 822 | ); |
| 808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 809 | - $context['fulltext_index'][] = $row['indexname']; |
|
| 810 | - } |
|
| 811 | - else |
|
| 823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 824 | + $context['fulltext_index'][] = $row['indexname']; |
|
| 825 | + } |
|
| 826 | + } else |
|
| 812 | 827 | { |
| 813 | 828 | $request = $smcFunc['db_query']('', ' |
| 814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
| 819 | 834 | $context['fulltext_index'] = array(); |
| 820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 821 | 836 | { |
| 822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
| 840 | + } |
|
| 825 | 841 | $smcFunc['db_free_result']($request); |
| 826 | 842 | |
| 827 | - if (is_array($context['fulltext_index'])) |
|
| 828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 843 | + if (is_array($context['fulltext_index'])) { |
|
| 844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 845 | + } |
|
| 829 | 846 | } |
| 830 | 847 | |
| 831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 832 | - $request = $smcFunc['db_query']('', ' |
|
| 848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 849 | + $request = $smcFunc['db_query']('', ' |
|
| 833 | 850 | SHOW TABLE STATUS |
| 834 | 851 | FROM {string:database_name} |
| 835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
| 838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 839 | 856 | ) |
| 840 | 857 | ); |
| 841 | - else |
|
| 842 | - $request = $smcFunc['db_query']('', ' |
|
| 858 | + } else { |
|
| 859 | + $request = $smcFunc['db_query']('', ' |
|
| 843 | 860 | SHOW TABLE STATUS |
| 844 | 861 | LIKE {string:table_name}', |
| 845 | 862 | array( |
| 846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 847 | 864 | ) |
| 848 | 865 | ); |
| 866 | + } |
|
| 849 | 867 | |
| 850 | 868 | if ($request !== false) |
| 851 | 869 | { |
| 852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
| 870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
| 854 | 872 | $context['cannot_create_fulltext'] = true; |
| 873 | + } |
|
| 855 | 874 | $smcFunc['db_free_result']($request); |
| 856 | 875 | } |
| 857 | 876 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | ); |
| 68 | 69 | |
| 69 | 70 | // Force the right area... |
| 70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
| 71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
| 72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
| 74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
| 100 | 102 | |
| 101 | 103 | // Remove the items that were selected. |
| 102 | - foreach ($temp_news as $i => $news) |
|
| 103 | - if (in_array($i, $_POST['remove'])) |
|
| 104 | + foreach ($temp_news as $i => $news) { |
|
| 105 | + if (in_array($i, $_POST['remove'])) |
|
| 104 | 106 | unset($temp_news[$i]); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | // Update the database. |
| 107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
| 117 | 120 | |
| 118 | 121 | foreach ($_POST['news'] as $i => $news) |
| 119 | 122 | { |
| 120 | - if (trim($news) == '') |
|
| 121 | - unset($_POST['news'][$i]); |
|
| 122 | - else |
|
| 123 | + if (trim($news) == '') { |
|
| 124 | + unset($_POST['news'][$i]); |
|
| 125 | + } else |
|
| 123 | 126 | { |
| 124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
| 125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -155,12 +158,13 @@ discard block |
||
| 155 | 158 | 'data' => array( |
| 156 | 159 | 'function' => function($news) |
| 157 | 160 | { |
| 158 | - if (is_numeric($news['id'])) |
|
| 159 | - return ' |
|
| 161 | + if (is_numeric($news['id'])) { |
|
| 162 | + return ' |
|
| 160 | 163 | <textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
| 161 | 164 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
| 162 | - else |
|
| 163 | - return $news['unparsed']; |
|
| 165 | + } else { |
|
| 166 | + return $news['unparsed']; |
|
| 167 | + } |
|
| 164 | 168 | }, |
| 165 | 169 | 'class' => 'half_table', |
| 166 | 170 | ), |
@@ -186,10 +190,11 @@ discard block |
||
| 186 | 190 | 'data' => array( |
| 187 | 191 | 'function' => function($news) |
| 188 | 192 | { |
| 189 | - if (is_numeric($news['id'])) |
|
| 190 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
| 191 | - else |
|
| 192 | - return ''; |
|
| 193 | + if (is_numeric($news['id'])) { |
|
| 194 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
| 195 | + } else { |
|
| 196 | + return ''; |
|
| 197 | + } |
|
| 193 | 198 | }, |
| 194 | 199 | 'class' => 'centercol icon', |
| 195 | 200 | ), |
@@ -283,12 +288,13 @@ discard block |
||
| 283 | 288 | |
| 284 | 289 | $admin_current_news = array(); |
| 285 | 290 | // Ready the current news. |
| 286 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
| 287 | - $admin_current_news[$id] = array( |
|
| 291 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
| 292 | + $admin_current_news[$id] = array( |
|
| 288 | 293 | 'id' => $id, |
| 289 | 294 | 'unparsed' => un_preparsecode($line), |
| 290 | 295 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
| 291 | 296 | ); |
| 297 | + } |
|
| 292 | 298 | |
| 293 | 299 | $admin_current_news['last'] = array( |
| 294 | 300 | 'id' => 'last', |
@@ -355,10 +361,11 @@ discard block |
||
| 355 | 361 | 'member_count' => 0, |
| 356 | 362 | ); |
| 357 | 363 | |
| 358 | - if ($row['min_posts'] == -1) |
|
| 359 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 360 | - else |
|
| 361 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
| 364 | + if ($row['min_posts'] == -1) { |
|
| 365 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 366 | + } else { |
|
| 367 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
| 368 | + } |
|
| 362 | 369 | } |
| 363 | 370 | $smcFunc['db_free_result']($request); |
| 364 | 371 | |
@@ -374,8 +381,9 @@ discard block |
||
| 374 | 381 | 'post_group_list' => $postGroups, |
| 375 | 382 | ) |
| 376 | 383 | ); |
| 377 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 378 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 384 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 385 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 386 | + } |
|
| 379 | 387 | $smcFunc['db_free_result']($query); |
| 380 | 388 | } |
| 381 | 389 | |
@@ -391,8 +399,9 @@ discard block |
||
| 391 | 399 | 'normal_group_list' => $normalGroups, |
| 392 | 400 | ) |
| 393 | 401 | ); |
| 394 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 395 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 402 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 403 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 404 | + } |
|
| 396 | 405 | $smcFunc['db_free_result']($query); |
| 397 | 406 | |
| 398 | 407 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -409,8 +418,9 @@ discard block |
||
| 409 | 418 | 'blank_string' => '', |
| 410 | 419 | ) |
| 411 | 420 | ); |
| 412 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 413 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 421 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 422 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 423 | + } |
|
| 414 | 424 | $smcFunc['db_free_result']($query); |
| 415 | 425 | } |
| 416 | 426 | |
@@ -461,10 +471,11 @@ discard block |
||
| 461 | 471 | { |
| 462 | 472 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
| 463 | 473 | |
| 464 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
| 465 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 466 | - elseif (!empty($_REQUEST['xml'])) |
|
| 467 | - continue; |
|
| 474 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
| 475 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 476 | + } elseif (!empty($_REQUEST['xml'])) { |
|
| 477 | + continue; |
|
| 478 | + } |
|
| 468 | 479 | |
| 469 | 480 | preparsecode($context[$key]); |
| 470 | 481 | if ($html) |
@@ -543,10 +554,12 @@ discard block |
||
| 543 | 554 | |
| 544 | 555 | // Start by finding any members! |
| 545 | 556 | $toClean = array(); |
| 546 | - if (!empty($_POST['members'])) |
|
| 547 | - $toClean[] = 'members'; |
|
| 548 | - if (!empty($_POST['exclude_members'])) |
|
| 549 | - $toClean[] = 'exclude_members'; |
|
| 557 | + if (!empty($_POST['members'])) { |
|
| 558 | + $toClean[] = 'members'; |
|
| 559 | + } |
|
| 560 | + if (!empty($_POST['exclude_members'])) { |
|
| 561 | + $toClean[] = 'exclude_members'; |
|
| 562 | + } |
|
| 550 | 563 | if (!empty($toClean)) |
| 551 | 564 | { |
| 552 | 565 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -558,11 +571,13 @@ discard block |
||
| 558 | 571 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
| 559 | 572 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
| 560 | 573 | |
| 561 | - foreach ($_POST[$type] as $index => $member) |
|
| 562 | - if (strlen(trim($member)) > 0) |
|
| 574 | + foreach ($_POST[$type] as $index => $member) { |
|
| 575 | + if (strlen(trim($member)) > 0) |
|
| 563 | 576 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
| 564 | - else |
|
| 565 | - unset($_POST[$type][$index]); |
|
| 577 | + } |
|
| 578 | + else { |
|
| 579 | + unset($_POST[$type][$index]); |
|
| 580 | + } |
|
| 566 | 581 | |
| 567 | 582 | // Find the members |
| 568 | 583 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -572,16 +587,18 @@ discard block |
||
| 572 | 587 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
| 573 | 588 | { |
| 574 | 589 | $members = array(); |
| 575 | - foreach ($_POST['member_list'] as $member_id) |
|
| 576 | - $members[] = (int) $member_id; |
|
| 590 | + foreach ($_POST['member_list'] as $member_id) { |
|
| 591 | + $members[] = (int) $member_id; |
|
| 592 | + } |
|
| 577 | 593 | $_POST['members'] = implode(',', $members); |
| 578 | 594 | } |
| 579 | 595 | |
| 580 | 596 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
| 581 | 597 | { |
| 582 | 598 | $members = array(); |
| 583 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
| 584 | - $members[] = (int) $member_id; |
|
| 599 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
| 600 | + $members[] = (int) $member_id; |
|
| 601 | + } |
|
| 585 | 602 | $_POST['exclude_members'] = implode(',', $members); |
| 586 | 603 | } |
| 587 | 604 | |
@@ -605,8 +622,9 @@ discard block |
||
| 605 | 622 | 'current_time' => time(), |
| 606 | 623 | ) |
| 607 | 624 | ); |
| 608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 609 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 625 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 626 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 627 | + } |
|
| 610 | 628 | $smcFunc['db_free_result']($request); |
| 611 | 629 | |
| 612 | 630 | $request = $smcFunc['db_query']('', ' |
@@ -641,8 +659,9 @@ discard block |
||
| 641 | 659 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
| 642 | 660 | $condition_array_params |
| 643 | 661 | ); |
| 644 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 645 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 662 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 663 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 664 | + } |
|
| 646 | 665 | $smcFunc['db_free_result']($request); |
| 647 | 666 | } |
| 648 | 667 | |
@@ -660,10 +679,11 @@ discard block |
||
| 660 | 679 | ); |
| 661 | 680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 662 | 681 | { |
| 663 | - if (in_array(3, $context['recipients'])) |
|
| 664 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 665 | - else |
|
| 666 | - $context['recipients']['members'][] = $row['identifier']; |
|
| 682 | + if (in_array(3, $context['recipients'])) { |
|
| 683 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 684 | + } else { |
|
| 685 | + $context['recipients']['members'][] = $row['identifier']; |
|
| 686 | + } |
|
| 667 | 687 | } |
| 668 | 688 | $smcFunc['db_free_result']($request); |
| 669 | 689 | } |
@@ -710,8 +730,9 @@ discard block |
||
| 710 | 730 | $num_at_once = 1000; |
| 711 | 731 | |
| 712 | 732 | // If by PM's I suggest we half the above number. |
| 713 | - if (!empty($_POST['send_pm'])) |
|
| 714 | - $num_at_once /= 2; |
|
| 733 | + if (!empty($_POST['send_pm'])) { |
|
| 734 | + $num_at_once /= 2; |
|
| 735 | + } |
|
| 715 | 736 | |
| 716 | 737 | checkSession(); |
| 717 | 738 | |
@@ -734,8 +755,7 @@ discard block |
||
| 734 | 755 | ); |
| 735 | 756 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
| 736 | 757 | $smcFunc['db_free_result']($request); |
| 737 | - } |
|
| 738 | - else |
|
| 758 | + } else |
|
| 739 | 759 | { |
| 740 | 760 | $context['total_members'] = (int) $_REQUEST['total_members']; |
| 741 | 761 | } |
@@ -753,32 +773,35 @@ discard block |
||
| 753 | 773 | if (!empty($_POST['exclude_members'])) |
| 754 | 774 | { |
| 755 | 775 | $members = explode(',', $_POST['exclude_members']); |
| 756 | - foreach ($members as $member) |
|
| 757 | - if ($member >= $context['start']) |
|
| 776 | + foreach ($members as $member) { |
|
| 777 | + if ($member >= $context['start']) |
|
| 758 | 778 | $context['recipients']['exclude_members'][] = (int) $member; |
| 779 | + } |
|
| 759 | 780 | } |
| 760 | 781 | |
| 761 | 782 | // What about members we *must* do? |
| 762 | 783 | if (!empty($_POST['members'])) |
| 763 | 784 | { |
| 764 | 785 | $members = explode(',', $_POST['members']); |
| 765 | - foreach ($members as $member) |
|
| 766 | - if ($member >= $context['start']) |
|
| 786 | + foreach ($members as $member) { |
|
| 787 | + if ($member >= $context['start']) |
|
| 767 | 788 | $context['recipients']['members'][] = (int) $member; |
| 789 | + } |
|
| 768 | 790 | } |
| 769 | 791 | // Cleaning groups is simple - although deal with both checkbox and commas. |
| 770 | 792 | if (isset($_POST['groups'])) |
| 771 | 793 | { |
| 772 | 794 | if (is_array($_POST['groups'])) |
| 773 | 795 | { |
| 774 | - foreach ($_POST['groups'] as $group => $dummy) |
|
| 775 | - $context['recipients']['groups'][] = (int) $group; |
|
| 776 | - } |
|
| 777 | - else |
|
| 796 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
| 797 | + $context['recipients']['groups'][] = (int) $group; |
|
| 798 | + } |
|
| 799 | + } else |
|
| 778 | 800 | { |
| 779 | 801 | $groups = explode(',', $_POST['groups']); |
| 780 | - foreach ($groups as $group) |
|
| 781 | - $context['recipients']['groups'][] = (int) $group; |
|
| 802 | + foreach ($groups as $group) { |
|
| 803 | + $context['recipients']['groups'][] = (int) $group; |
|
| 804 | + } |
|
| 782 | 805 | } |
| 783 | 806 | } |
| 784 | 807 | // Same for excluded groups |
@@ -786,15 +809,17 @@ discard block |
||
| 786 | 809 | { |
| 787 | 810 | if (is_array($_POST['exclude_groups'])) |
| 788 | 811 | { |
| 789 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
| 790 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 812 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
| 813 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 814 | + } |
|
| 791 | 815 | } |
| 792 | 816 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
| 793 | 817 | elseif ($_POST['exclude_groups'] != '') |
| 794 | 818 | { |
| 795 | 819 | $groups = explode(',', $_POST['exclude_groups']); |
| 796 | - foreach ($groups as $group) |
|
| 797 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 820 | + foreach ($groups as $group) { |
|
| 821 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 822 | + } |
|
| 798 | 823 | } |
| 799 | 824 | } |
| 800 | 825 | // Finally - emails! |
@@ -804,14 +829,16 @@ discard block |
||
| 804 | 829 | foreach ($addressed as $curmem) |
| 805 | 830 | { |
| 806 | 831 | $curmem = trim($curmem); |
| 807 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
| 808 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
| 832 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
| 833 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
| 834 | + } |
|
| 809 | 835 | } |
| 810 | 836 | } |
| 811 | 837 | |
| 812 | 838 | // If we're only cleaning drop out here. |
| 813 | - if ($clean_only) |
|
| 814 | - return; |
|
| 839 | + if ($clean_only) { |
|
| 840 | + return; |
|
| 841 | + } |
|
| 815 | 842 | |
| 816 | 843 | require_once($sourcedir . '/Subs-Post.php'); |
| 817 | 844 | |
@@ -827,16 +854,18 @@ discard block |
||
| 827 | 854 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
| 828 | 855 | { |
| 829 | 856 | // Prepare the message for HTML. |
| 830 | - if (!empty($_POST['parse_html'])) |
|
| 831 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 857 | + if (!empty($_POST['parse_html'])) { |
|
| 858 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 859 | + } |
|
| 832 | 860 | |
| 833 | 861 | // This is here to prevent spam filters from tagging this as spam. |
| 834 | 862 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
| 835 | 863 | { |
| 836 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
| 837 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 838 | - else |
|
| 839 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 864 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
| 865 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 866 | + } else { |
|
| 867 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 868 | + } |
|
| 840 | 869 | } |
| 841 | 870 | } |
| 842 | 871 | |
@@ -890,15 +919,17 @@ discard block |
||
| 890 | 919 | foreach ($context['recipients']['emails'] as $k => $email) |
| 891 | 920 | { |
| 892 | 921 | // Done as many as we can? |
| 893 | - if ($i >= $num_at_once) |
|
| 894 | - break; |
|
| 922 | + if ($i >= $num_at_once) { |
|
| 923 | + break; |
|
| 924 | + } |
|
| 895 | 925 | |
| 896 | 926 | // Don't sent it twice! |
| 897 | 927 | unset($context['recipients']['emails'][$k]); |
| 898 | 928 | |
| 899 | 929 | // Dammit - can't PM emails! |
| 900 | - if ($context['send_pm']) |
|
| 901 | - continue; |
|
| 930 | + if ($context['send_pm']) { |
|
| 931 | + continue; |
|
| 932 | + } |
|
| 902 | 933 | |
| 903 | 934 | $to_member = array( |
| 904 | 935 | $email, |
@@ -932,8 +963,9 @@ discard block |
||
| 932 | 963 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
| 933 | 964 | } |
| 934 | 965 | } |
| 935 | - if (!empty($queryBuild)) |
|
| 936 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
| 966 | + if (!empty($queryBuild)) { |
|
| 967 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
| 968 | + } |
|
| 937 | 969 | } |
| 938 | 970 | if (!empty($context['recipients']['members'])) |
| 939 | 971 | { |
@@ -952,8 +984,9 @@ discard block |
||
| 952 | 984 | } |
| 953 | 985 | |
| 954 | 986 | // Anything to exclude? |
| 955 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
| 956 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 987 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
| 988 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 989 | + } |
|
| 957 | 990 | if (!empty($context['recipients']['exclude_members'])) |
| 958 | 991 | { |
| 959 | 992 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -989,21 +1022,24 @@ discard block |
||
| 989 | 1022 | foreach ($rows as $row) |
| 990 | 1023 | { |
| 991 | 1024 | // Force them to have it? |
| 992 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
| 993 | - continue; |
|
| 1025 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
| 1026 | + continue; |
|
| 1027 | + } |
|
| 994 | 1028 | |
| 995 | 1029 | // What groups are we looking at here? |
| 996 | - if (empty($row['additional_groups'])) |
|
| 997 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 998 | - else |
|
| 999 | - $groups = array_merge( |
|
| 1030 | + if (empty($row['additional_groups'])) { |
|
| 1031 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 1032 | + } else { |
|
| 1033 | + $groups = array_merge( |
|
| 1000 | 1034 | array($row['id_group'], $row['id_post_group']), |
| 1001 | 1035 | explode(',', $row['additional_groups']) |
| 1002 | 1036 | ); |
| 1037 | + } |
|
| 1003 | 1038 | |
| 1004 | 1039 | // Excluded groups? |
| 1005 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
| 1006 | - continue; |
|
| 1040 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
| 1041 | + continue; |
|
| 1042 | + } |
|
| 1007 | 1043 | |
| 1008 | 1044 | // We might need this |
| 1009 | 1045 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1026,10 +1062,11 @@ discard block |
||
| 1026 | 1062 | ), $_POST['subject']); |
| 1027 | 1063 | |
| 1028 | 1064 | // Send the actual email - or a PM! |
| 1029 | - if (!$context['send_pm']) |
|
| 1030 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1031 | - else |
|
| 1032 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1065 | + if (!$context['send_pm']) { |
|
| 1066 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1067 | + } else { |
|
| 1068 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1069 | + } |
|
| 1033 | 1070 | } |
| 1034 | 1071 | } |
| 1035 | 1072 | |
@@ -1079,8 +1116,9 @@ discard block |
||
| 1079 | 1116 | |
| 1080 | 1117 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
| 1081 | 1118 | |
| 1082 | - if ($return_config) |
|
| 1083 | - return $config_vars; |
|
| 1119 | + if ($return_config) { |
|
| 1120 | + return $config_vars; |
|
| 1121 | + } |
|
| 1084 | 1122 | |
| 1085 | 1123 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
| 1086 | 1124 | $context['sub_template'] = 'show_settings'; |
@@ -5495,7 +5495,6 @@ discard block |
||
| 5495 | 5495 | |
| 5496 | 5496 | /** |
| 5497 | 5497 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
| 5498 | - |
|
| 5499 | 5498 | * @param string $file The file/dir full path. |
| 5500 | 5499 | * @param int $value Not needed, added for legacy reasons. |
| 5501 | 5500 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5535,7 +5534,6 @@ discard block |
||
| 5535 | 5534 | |
| 5536 | 5535 | /** |
| 5537 | 5536 | * Wrapper function for json_decode() with error handling. |
| 5538 | - |
|
| 5539 | 5537 | * @param string $json The string to decode. |
| 5540 | 5538 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
| 5541 | 5539 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -6029,7 +6027,7 @@ discard block |
||
| 6029 | 6027 | $params = stream_context_get_params($stream); |
| 6030 | 6028 | $result = isset($params["options"]["ssl"]["peer_certificate"]) ? true : false; |
| 6031 | 6029 | } |
| 6032 | - return $result; |
|
| 6030 | + return $result; |
|
| 6033 | 6031 | } |
| 6034 | 6032 | |
| 6035 | 6033 | /** |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * - caches the formatting data from the setting for optimization. |
| 694 | 694 | * |
| 695 | 695 | * @param float $number A number |
| 696 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
| 696 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
| 697 | 697 | * @return string A formatted number |
| 698 | 698 | */ |
| 699 | 699 | function comma_format($number, $override_decimal_count = false) |
@@ -5869,7 +5869,7 @@ discard block |
||
| 5869 | 5869 | * It assumes the data is already a string. |
| 5870 | 5870 | * @param string $data The data to print |
| 5871 | 5871 | * @param string $type The content type. Defaults to Json. |
| 5872 | - * @return void |
|
| 5872 | + * @return false|null |
|
| 5873 | 5873 | */ |
| 5874 | 5874 | function smf_serverResponse($data = '', $type = 'content-type: application/json') |
| 5875 | 5875 | { |
@@ -6351,7 +6351,7 @@ discard block |
||
| 6351 | 6351 | * |
| 6352 | 6352 | * @param string $iri The IRI to test. |
| 6353 | 6353 | * @param int $flags Optional flags to pass to filter_var() |
| 6354 | - * @return string|bool Either the original IRI, or false if the IRI was invalid. |
|
| 6354 | + * @return string|false Either the original IRI, or false if the IRI was invalid. |
|
| 6355 | 6355 | */ |
| 6356 | 6356 | function validate_iri($iri, $flags = null) |
| 6357 | 6357 | { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
| 122 | 123 | $smcFunc['db_free_result']($result); |
| 123 | 124 | |
| 124 | 125 | // Add this to the number of unapproved members |
| 125 | - if (!empty($changes['unapprovedMembers'])) |
|
| 126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 127 | - else |
|
| 128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 126 | + if (!empty($changes['unapprovedMembers'])) { |
|
| 127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 128 | + } else { |
|
| 129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
| 133 | 135 | break; |
| 134 | 136 | |
| 135 | 137 | case 'message': |
| 136 | - if ($parameter1 === true && $parameter2 !== null) |
|
| 137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 138 | - else |
|
| 138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
| 139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
| 141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,24 +177,25 @@ discard block |
||
| 175 | 177 | $parameter2 = text2words($parameter2); |
| 176 | 178 | |
| 177 | 179 | $inserts = array(); |
| 178 | - foreach ($parameter2 as $word) |
|
| 179 | - $inserts[] = array($word, $parameter1); |
|
| 180 | + foreach ($parameter2 as $word) { |
|
| 181 | + $inserts[] = array($word, $parameter1); |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if (!empty($inserts)) |
|
| 182 | - $smcFunc['db_insert']('ignore', |
|
| 184 | + if (!empty($inserts)) { |
|
| 185 | + $smcFunc['db_insert']('ignore', |
|
| 183 | 186 | '{db_prefix}log_search_subjects', |
| 184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
| 185 | 188 | $inserts, |
| 186 | 189 | array('word', 'id_topic') |
| 187 | 190 | ); |
| 191 | + } |
|
| 188 | 192 | } |
| 189 | 193 | break; |
| 190 | 194 | |
| 191 | 195 | case 'topic': |
| 192 | - if ($parameter1 === true) |
|
| 193 | - updateSettings(array('totalTopics' => true), true); |
|
| 194 | - |
|
| 195 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 196 | 199 | { |
| 197 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 198 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -213,8 +216,9 @@ discard block |
||
| 213 | 216 | |
| 214 | 217 | case 'postgroups': |
| 215 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 216 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 217 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 218 | 222 | |
| 219 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 220 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -229,8 +233,9 @@ discard block |
||
| 229 | 233 | ) |
| 230 | 234 | ); |
| 231 | 235 | $postgroups = array(); |
| 232 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 233 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 234 | 239 | |
| 235 | 240 | $smcFunc['db_free_result']($request); |
| 236 | 241 | |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | } |
| 242 | 247 | |
| 243 | 248 | // Oh great, they've screwed their post groups. |
| 244 | - if (empty($postgroups)) |
|
| 245 | - return; |
|
| 249 | + if (empty($postgroups)) { |
|
| 250 | + return; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | 253 | // Set all membergroups from most posts to least posts. |
| 248 | 254 | $conditions = ''; |
@@ -301,12 +307,9 @@ discard block |
||
| 301 | 307 | { |
| 302 | 308 | $condition = 'id_member IN ({array_int:members})'; |
| 303 | 309 | $parameters['members'] = $members; |
| 304 | - } |
|
| 305 | - |
|
| 306 | - elseif ($members === null) |
|
| 307 | - $condition = '1=1'; |
|
| 308 | - |
|
| 309 | - else |
|
| 310 | + } elseif ($members === null) { |
|
| 311 | + $condition = '1=1'; |
|
| 312 | + } else |
|
| 310 | 313 | { |
| 311 | 314 | $condition = 'id_member = {int:member}'; |
| 312 | 315 | $parameters['member'] = $members; |
@@ -346,9 +349,9 @@ discard block |
||
| 346 | 349 | if (count($vars_to_integrate) != 0) |
| 347 | 350 | { |
| 348 | 351 | // Fetch a list of member_names if necessary |
| 349 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 350 | - $member_names = array($user_info['username']); |
|
| 351 | - else |
|
| 352 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 353 | + $member_names = array($user_info['username']); |
|
| 354 | + } else |
|
| 352 | 355 | { |
| 353 | 356 | $member_names = array(); |
| 354 | 357 | $request = $smcFunc['db_query']('', ' |
@@ -357,14 +360,16 @@ discard block |
||
| 357 | 360 | WHERE ' . $condition, |
| 358 | 361 | $parameters |
| 359 | 362 | ); |
| 360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 361 | - $member_names[] = $row['member_name']; |
|
| 363 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 364 | + $member_names[] = $row['member_name']; |
|
| 365 | + } |
|
| 362 | 366 | $smcFunc['db_free_result']($request); |
| 363 | 367 | } |
| 364 | 368 | |
| 365 | - if (!empty($member_names)) |
|
| 366 | - foreach ($vars_to_integrate as $var) |
|
| 369 | + if (!empty($member_names)) { |
|
| 370 | + foreach ($vars_to_integrate as $var) |
|
| 367 | 371 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 372 | + } |
|
| 368 | 373 | } |
| 369 | 374 | } |
| 370 | 375 | |
@@ -372,16 +377,17 @@ discard block |
||
| 372 | 377 | foreach ($data as $var => $val) |
| 373 | 378 | { |
| 374 | 379 | $type = 'string'; |
| 375 | - if (in_array($var, $knownInts)) |
|
| 376 | - $type = 'int'; |
|
| 377 | - elseif (in_array($var, $knownFloats)) |
|
| 378 | - $type = 'float'; |
|
| 379 | - elseif ($var == 'birthdate') |
|
| 380 | - $type = 'date'; |
|
| 381 | - elseif ($var == 'member_ip') |
|
| 382 | - $type = 'inet'; |
|
| 383 | - elseif ($var == 'member_ip2') |
|
| 384 | - $type = 'inet'; |
|
| 380 | + if (in_array($var, $knownInts)) { |
|
| 381 | + $type = 'int'; |
|
| 382 | + } elseif (in_array($var, $knownFloats)) { |
|
| 383 | + $type = 'float'; |
|
| 384 | + } elseif ($var == 'birthdate') { |
|
| 385 | + $type = 'date'; |
|
| 386 | + } elseif ($var == 'member_ip') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } elseif ($var == 'member_ip2') { |
|
| 389 | + $type = 'inet'; |
|
| 390 | + } |
|
| 385 | 391 | |
| 386 | 392 | // Doing an increment? |
| 387 | 393 | if ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -390,18 +396,17 @@ discard block |
||
| 390 | 396 | if (is_array($members)) |
| 391 | 397 | { |
| 392 | 398 | $val = 'CASE '; |
| 393 | - foreach ($members as $k => $v) |
|
| 394 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 399 | + foreach ($members as $k => $v) { |
|
| 400 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 401 | + } |
|
| 395 | 402 | $val = $val . ' END'; |
| 396 | 403 | $type = 'raw'; |
| 397 | - } |
|
| 398 | - else |
|
| 404 | + } else |
|
| 399 | 405 | { |
| 400 | 406 | $blub = fetch_alerts($members, false, 0, array(), false); |
| 401 | 407 | $val = count($blub); |
| 402 | 408 | } |
| 403 | - } |
|
| 404 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 409 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 405 | 410 | { |
| 406 | 411 | $val = $var . ' ' . $val . ' 1'; |
| 407 | 412 | $type = 'raw'; |
@@ -412,8 +417,9 @@ discard block |
||
| 412 | 417 | { |
| 413 | 418 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 414 | 419 | { |
| 415 | - if ($match[1] != '+ ') |
|
| 416 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 420 | + if ($match[1] != '+ ') { |
|
| 421 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 422 | + } |
|
| 417 | 423 | $type = 'raw'; |
| 418 | 424 | } |
| 419 | 425 | } |
@@ -434,8 +440,9 @@ discard block |
||
| 434 | 440 | // Clear any caching? |
| 435 | 441 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 436 | 442 | { |
| 437 | - if (!is_array($members)) |
|
| 438 | - $members = array($members); |
|
| 443 | + if (!is_array($members)) { |
|
| 444 | + $members = array($members); |
|
| 445 | + } |
|
| 439 | 446 | |
| 440 | 447 | foreach ($members as $member) |
| 441 | 448 | { |
@@ -468,29 +475,32 @@ discard block |
||
| 468 | 475 | { |
| 469 | 476 | global $modSettings, $smcFunc; |
| 470 | 477 | |
| 471 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 472 | - return; |
|
| 478 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 479 | + return; |
|
| 480 | + } |
|
| 473 | 481 | |
| 474 | 482 | $toRemove = array(); |
| 475 | 483 | |
| 476 | 484 | // Go check if there is any setting to be removed. |
| 477 | - foreach ($changeArray as $k => $v) |
|
| 478 | - if ($v === null) |
|
| 485 | + foreach ($changeArray as $k => $v) { |
|
| 486 | + if ($v === null) |
|
| 479 | 487 | { |
| 480 | 488 | // Found some, remove them from the original array and add them to ours. |
| 481 | 489 | unset($changeArray[$k]); |
| 490 | + } |
|
| 482 | 491 | $toRemove[] = $k; |
| 483 | 492 | } |
| 484 | 493 | |
| 485 | 494 | // Proceed with the deletion. |
| 486 | - if (!empty($toRemove)) |
|
| 487 | - $smcFunc['db_query']('', ' |
|
| 495 | + if (!empty($toRemove)) { |
|
| 496 | + $smcFunc['db_query']('', ' |
|
| 488 | 497 | DELETE FROM {db_prefix}settings |
| 489 | 498 | WHERE variable IN ({array_string:remove})', |
| 490 | 499 | array( |
| 491 | 500 | 'remove' => $toRemove, |
| 492 | 501 | ) |
| 493 | 502 | ); |
| 503 | + } |
|
| 494 | 504 | |
| 495 | 505 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 496 | 506 | if ($update) |
@@ -519,19 +529,22 @@ discard block |
||
| 519 | 529 | foreach ($changeArray as $variable => $value) |
| 520 | 530 | { |
| 521 | 531 | // Don't bother if it's already like that ;). |
| 522 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 523 | - continue; |
|
| 532 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 533 | + continue; |
|
| 534 | + } |
|
| 524 | 535 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 525 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 526 | - continue; |
|
| 536 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 537 | + continue; |
|
| 538 | + } |
|
| 527 | 539 | |
| 528 | 540 | $replaceArray[] = array($variable, $value); |
| 529 | 541 | |
| 530 | 542 | $modSettings[$variable] = $value; |
| 531 | 543 | } |
| 532 | 544 | |
| 533 | - if (empty($replaceArray)) |
|
| 534 | - return; |
|
| 545 | + if (empty($replaceArray)) { |
|
| 546 | + return; |
|
| 547 | + } |
|
| 535 | 548 | |
| 536 | 549 | $smcFunc['db_insert']('replace', |
| 537 | 550 | '{db_prefix}settings', |
@@ -577,14 +590,17 @@ discard block |
||
| 577 | 590 | $start_invalid = $start < 0; |
| 578 | 591 | |
| 579 | 592 | // Make sure $start is a proper variable - not less than 0. |
| 580 | - if ($start_invalid) |
|
| 581 | - $start = 0; |
|
| 593 | + if ($start_invalid) { |
|
| 594 | + $start = 0; |
|
| 595 | + } |
|
| 582 | 596 | // Not greater than the upper bound. |
| 583 | - elseif ($start >= $max_value) |
|
| 584 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 597 | + elseif ($start >= $max_value) { |
|
| 598 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 599 | + } |
|
| 585 | 600 | // And it has to be a multiple of $num_per_page! |
| 586 | - else |
|
| 587 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 601 | + else { |
|
| 602 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 603 | + } |
|
| 588 | 604 | |
| 589 | 605 | $context['current_page'] = $start / $num_per_page; |
| 590 | 606 | |
@@ -614,77 +630,87 @@ discard block |
||
| 614 | 630 | |
| 615 | 631 | // Show all the pages. |
| 616 | 632 | $display_page = 1; |
| 617 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 618 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 633 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 634 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 635 | + } |
|
| 619 | 636 | |
| 620 | 637 | // Show the right arrow. |
| 621 | 638 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 622 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 623 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 624 | - } |
|
| 625 | - else |
|
| 639 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 640 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 641 | + } |
|
| 642 | + } else |
|
| 626 | 643 | { |
| 627 | 644 | // If they didn't enter an odd value, pretend they did. |
| 628 | 645 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 629 | 646 | |
| 630 | 647 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 631 | - if (!empty($start) && $show_prevnext) |
|
| 632 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 633 | - else |
|
| 634 | - $pageindex .= ''; |
|
| 648 | + if (!empty($start) && $show_prevnext) { |
|
| 649 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 650 | + } else { |
|
| 651 | + $pageindex .= ''; |
|
| 652 | + } |
|
| 635 | 653 | |
| 636 | 654 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 637 | - if ($start > $num_per_page * $PageContiguous) |
|
| 638 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 655 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 656 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 657 | + } |
|
| 639 | 658 | |
| 640 | 659 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 641 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 642 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 660 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 661 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 643 | 662 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 644 | 663 | '{FIRST_PAGE}' => $num_per_page, |
| 645 | 664 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 646 | 665 | '{PER_PAGE}' => $num_per_page, |
| 647 | 666 | )); |
| 667 | + } |
|
| 648 | 668 | |
| 649 | 669 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 650 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 651 | - if ($start >= $num_per_page * $nCont) |
|
| 670 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 671 | + if ($start >= $num_per_page * $nCont) |
|
| 652 | 672 | { |
| 653 | 673 | $tmpStart = $start - $num_per_page * $nCont; |
| 674 | + } |
|
| 654 | 675 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 655 | 676 | } |
| 656 | 677 | |
| 657 | 678 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 658 | - if (!$start_invalid) |
|
| 659 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 660 | - else |
|
| 661 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 679 | + if (!$start_invalid) { |
|
| 680 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 681 | + } else { |
|
| 682 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 683 | + } |
|
| 662 | 684 | |
| 663 | 685 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 664 | 686 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 665 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 666 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 687 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 688 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 667 | 689 | { |
| 668 | 690 | $tmpStart = $start + $num_per_page * $nCont; |
| 691 | + } |
|
| 669 | 692 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 670 | 693 | } |
| 671 | 694 | |
| 672 | 695 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 673 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 674 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 696 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 697 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 675 | 698 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 676 | 699 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 677 | 700 | '{LAST_PAGE}' => $tmpMaxPages, |
| 678 | 701 | '{PER_PAGE}' => $num_per_page, |
| 679 | 702 | )); |
| 703 | + } |
|
| 680 | 704 | |
| 681 | 705 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 682 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 683 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 706 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 707 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 708 | + } |
|
| 684 | 709 | |
| 685 | 710 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 686 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 687 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 711 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 712 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 713 | + } |
|
| 688 | 714 | } |
| 689 | 715 | $pageindex .= $settings['page_index']['extra_after']; |
| 690 | 716 | |
@@ -710,8 +736,9 @@ discard block |
||
| 710 | 736 | if ($decimal_separator === null) |
| 711 | 737 | { |
| 712 | 738 | // Not set for whatever reason? |
| 713 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 714 | - return $number; |
|
| 739 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 740 | + return $number; |
|
| 741 | + } |
|
| 715 | 742 | |
| 716 | 743 | // Cache these each load... |
| 717 | 744 | $thousands_separator = $matches[1]; |
@@ -752,17 +779,20 @@ discard block |
||
| 752 | 779 | $user_info['time_format'] = !empty($user_info['time_format']) ? $user_info['time_format'] : (!empty($modSettings['time_format']) ? $modSettings['time_format'] : '%F %H:%M'); |
| 753 | 780 | |
| 754 | 781 | // Offset the time. |
| 755 | - if (!$offset_type) |
|
| 756 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 782 | + if (!$offset_type) { |
|
| 783 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 784 | + } |
|
| 757 | 785 | // Just the forum offset? |
| 758 | - elseif ($offset_type == 'forum') |
|
| 759 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 760 | - else |
|
| 761 | - $time = $log_time; |
|
| 786 | + elseif ($offset_type == 'forum') { |
|
| 787 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 788 | + } else { |
|
| 789 | + $time = $log_time; |
|
| 790 | + } |
|
| 762 | 791 | |
| 763 | 792 | // We can't have a negative date (on Windows, at least.) |
| 764 | - if ($log_time < 0) |
|
| 765 | - $log_time = 0; |
|
| 793 | + if ($log_time < 0) { |
|
| 794 | + $log_time = 0; |
|
| 795 | + } |
|
| 766 | 796 | |
| 767 | 797 | // Today and Yesterday? |
| 768 | 798 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -779,24 +809,27 @@ discard block |
||
| 779 | 809 | { |
| 780 | 810 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 781 | 811 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 812 | + } else { |
|
| 813 | + $today_fmt = '%H:%M' . $s; |
|
| 782 | 814 | } |
| 783 | - else |
|
| 784 | - $today_fmt = '%H:%M' . $s; |
|
| 785 | 815 | |
| 786 | 816 | // Same day of the year, same year.... Today! |
| 787 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 788 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 817 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 818 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 819 | + } |
|
| 789 | 820 | |
| 790 | 821 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 791 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
| 792 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 822 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
| 823 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 824 | + } |
|
| 793 | 825 | } |
| 794 | 826 | |
| 795 | 827 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 796 | 828 | |
| 797 | 829 | // Use the cached formats if available |
| 798 | - if (is_null($finalizedFormats)) |
|
| 799 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 830 | + if (is_null($finalizedFormats)) { |
|
| 831 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 832 | + } |
|
| 800 | 833 | |
| 801 | 834 | // Make a supported version for this format if we don't already have one |
| 802 | 835 | if (empty($finalizedFormats[$str])) |
@@ -825,8 +858,9 @@ discard block |
||
| 825 | 858 | ); |
| 826 | 859 | |
| 827 | 860 | // No need to do this part again if we already did it once |
| 828 | - if (is_null($unsupportedFormats)) |
|
| 829 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 861 | + if (is_null($unsupportedFormats)) { |
|
| 862 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 863 | + } |
|
| 830 | 864 | if (empty($unsupportedFormats)) |
| 831 | 865 | { |
| 832 | 866 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -842,20 +876,23 @@ discard block |
||
| 842 | 876 | |
| 843 | 877 | // Windows will return false for unsupported formats |
| 844 | 878 | // Other operating systems return the format string as a literal |
| 845 | - if ($value === false || $value === $format) |
|
| 846 | - $unsupportedFormats[] = $format; |
|
| 879 | + if ($value === false || $value === $format) { |
|
| 880 | + $unsupportedFormats[] = $format; |
|
| 881 | + } |
|
| 847 | 882 | } |
| 848 | 883 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
| 849 | 884 | } |
| 850 | 885 | |
| 851 | 886 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
| 852 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
| 853 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 887 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
| 888 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 889 | + } |
|
| 854 | 890 | |
| 855 | 891 | // Substitute unsupported formats with supported ones |
| 856 | - if (!empty($unsupportedFormats)) |
|
| 857 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 892 | + if (!empty($unsupportedFormats)) { |
|
| 893 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 858 | 894 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
| 895 | + } |
|
| 859 | 896 | |
| 860 | 897 | // Remember this so we don't need to do it again |
| 861 | 898 | $finalizedFormats[$str] = $timeformat; |
@@ -864,33 +901,39 @@ discard block |
||
| 864 | 901 | |
| 865 | 902 | $str = $finalizedFormats[$str]; |
| 866 | 903 | |
| 867 | - if (!isset($locale_cache)) |
|
| 868 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 904 | + if (!isset($locale_cache)) { |
|
| 905 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 906 | + } |
|
| 869 | 907 | |
| 870 | 908 | if ($locale_cache !== false) |
| 871 | 909 | { |
| 872 | 910 | // Check if another process changed the locale |
| 873 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
| 874 | - setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 911 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
| 912 | + setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 913 | + } |
|
| 875 | 914 | |
| 876 | - if (!isset($non_twelve_hour)) |
|
| 877 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 878 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 879 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 915 | + if (!isset($non_twelve_hour)) { |
|
| 916 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 917 | + } |
|
| 918 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 920 | + } |
|
| 880 | 921 | |
| 881 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 882 | - if (strpos($str, $token) !== false) |
|
| 922 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 923 | + if (strpos($str, $token) !== false) |
|
| 883 | 924 | $str = str_replace($token, strftime($token, $time), $str); |
| 884 | - } |
|
| 885 | - else |
|
| 925 | + } |
|
| 926 | + } else |
|
| 886 | 927 | { |
| 887 | 928 | // Do-it-yourself time localization. Fun. |
| 888 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 889 | - if (strpos($str, $token) !== false) |
|
| 929 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 930 | + if (strpos($str, $token) !== false) |
|
| 890 | 931 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 932 | + } |
|
| 891 | 933 | |
| 892 | - if (strpos($str, '%p') !== false) |
|
| 893 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 934 | + if (strpos($str, '%p') !== false) { |
|
| 935 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 936 | + } |
|
| 894 | 937 | } |
| 895 | 938 | |
| 896 | 939 | // Format the time and then restore any literal percent characters |
@@ -913,16 +956,19 @@ discard block |
||
| 913 | 956 | static $translation = array(); |
| 914 | 957 | |
| 915 | 958 | // Determine the character set... Default to UTF-8 |
| 916 | - if (empty($context['character_set'])) |
|
| 917 | - $charset = 'UTF-8'; |
|
| 959 | + if (empty($context['character_set'])) { |
|
| 960 | + $charset = 'UTF-8'; |
|
| 961 | + } |
|
| 918 | 962 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 919 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 920 | - $charset = 'ISO-8859-1'; |
|
| 921 | - else |
|
| 922 | - $charset = $context['character_set']; |
|
| 963 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 964 | + $charset = 'ISO-8859-1'; |
|
| 965 | + } else { |
|
| 966 | + $charset = $context['character_set']; |
|
| 967 | + } |
|
| 923 | 968 | |
| 924 | - if (empty($translation)) |
|
| 925 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 969 | + if (empty($translation)) { |
|
| 970 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 971 | + } |
|
| 926 | 972 | |
| 927 | 973 | return strtr($string, $translation); |
| 928 | 974 | } |
@@ -944,8 +990,9 @@ discard block |
||
| 944 | 990 | global $smcFunc; |
| 945 | 991 | |
| 946 | 992 | // It was already short enough! |
| 947 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 948 | - return $subject; |
|
| 993 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 994 | + return $subject; |
|
| 995 | + } |
|
| 949 | 996 | |
| 950 | 997 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 951 | 998 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -964,10 +1011,11 @@ discard block |
||
| 964 | 1011 | { |
| 965 | 1012 | global $user_info, $modSettings; |
| 966 | 1013 | |
| 967 | - if ($timestamp === null) |
|
| 968 | - $timestamp = time(); |
|
| 969 | - elseif ($timestamp == 0) |
|
| 970 | - return 0; |
|
| 1014 | + if ($timestamp === null) { |
|
| 1015 | + $timestamp = time(); |
|
| 1016 | + } elseif ($timestamp == 0) { |
|
| 1017 | + return 0; |
|
| 1018 | + } |
|
| 971 | 1019 | |
| 972 | 1020 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 973 | 1021 | } |
@@ -996,8 +1044,9 @@ discard block |
||
| 996 | 1044 | $array[$i] = $array[$j]; |
| 997 | 1045 | $array[$j] = $temp; |
| 998 | 1046 | |
| 999 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 1000 | - $p[$i] = 1; |
|
| 1047 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 1048 | + $p[$i] = 1; |
|
| 1049 | + } |
|
| 1001 | 1050 | |
| 1002 | 1051 | $orders[] = $array; |
| 1003 | 1052 | } |
@@ -1029,12 +1078,14 @@ discard block |
||
| 1029 | 1078 | static $disabled; |
| 1030 | 1079 | |
| 1031 | 1080 | // Don't waste cycles |
| 1032 | - if ($message === '') |
|
| 1033 | - return ''; |
|
| 1081 | + if ($message === '') { |
|
| 1082 | + return ''; |
|
| 1083 | + } |
|
| 1034 | 1084 | |
| 1035 | 1085 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 1036 | - if (!isset($context['utf8'])) |
|
| 1037 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1086 | + if (!isset($context['utf8'])) { |
|
| 1087 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1088 | + } |
|
| 1038 | 1089 | |
| 1039 | 1090 | // Clean up any cut/paste issues we may have |
| 1040 | 1091 | $message = sanitizeMSCutPaste($message); |
@@ -1046,13 +1097,15 @@ discard block |
||
| 1046 | 1097 | return $message; |
| 1047 | 1098 | } |
| 1048 | 1099 | |
| 1049 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 1050 | - $smileys = (bool) $smileys; |
|
| 1100 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 1101 | + $smileys = (bool) $smileys; |
|
| 1102 | + } |
|
| 1051 | 1103 | |
| 1052 | 1104 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 1053 | 1105 | { |
| 1054 | - if ($smileys === true) |
|
| 1055 | - parsesmileys($message); |
|
| 1106 | + if ($smileys === true) { |
|
| 1107 | + parsesmileys($message); |
|
| 1108 | + } |
|
| 1056 | 1109 | |
| 1057 | 1110 | return $message; |
| 1058 | 1111 | } |
@@ -1065,8 +1118,9 @@ discard block |
||
| 1065 | 1118 | } |
| 1066 | 1119 | |
| 1067 | 1120 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 1068 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 1069 | - set_tld_regex(); |
|
| 1121 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1122 | + set_tld_regex(); |
|
| 1123 | + } |
|
| 1070 | 1124 | |
| 1071 | 1125 | // Allow mods access before entering the main parse_bbc loop |
| 1072 | 1126 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1080,8 +1134,9 @@ discard block |
||
| 1080 | 1134 | |
| 1081 | 1135 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 1082 | 1136 | |
| 1083 | - foreach ($temp as $tag) |
|
| 1084 | - $disabled[trim($tag)] = true; |
|
| 1137 | + foreach ($temp as $tag) { |
|
| 1138 | + $disabled[trim($tag)] = true; |
|
| 1139 | + } |
|
| 1085 | 1140 | } |
| 1086 | 1141 | |
| 1087 | 1142 | /* The following bbc are formatted as an array, with keys as follows: |
@@ -1211,8 +1266,9 @@ discard block |
||
| 1211 | 1266 | $returnContext = ''; |
| 1212 | 1267 | |
| 1213 | 1268 | // BBC or the entire attachments feature is disabled |
| 1214 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1215 | - return $data; |
|
| 1269 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1270 | + return $data; |
|
| 1271 | + } |
|
| 1216 | 1272 | |
| 1217 | 1273 | // Save the attach ID. |
| 1218 | 1274 | $attachID = $data; |
@@ -1223,8 +1279,9 @@ discard block |
||
| 1223 | 1279 | $currentAttachment = parseAttachBBC($attachID); |
| 1224 | 1280 | |
| 1225 | 1281 | // parseAttachBBC will return a string ($txt key) rather than dying with a fatal_error. Up to you to decide what to do. |
| 1226 | - if (is_string($currentAttachment)) |
|
| 1227 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1282 | + if (is_string($currentAttachment)) { |
|
| 1283 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1284 | + } |
|
| 1228 | 1285 | |
| 1229 | 1286 | if (!empty($currentAttachment['is_image'])) |
| 1230 | 1287 | { |
@@ -1240,15 +1297,17 @@ discard block |
||
| 1240 | 1297 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1241 | 1298 | } |
| 1242 | 1299 | |
| 1243 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1244 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1245 | - else |
|
| 1246 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1300 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1301 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1302 | + } else { |
|
| 1303 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1304 | + } |
|
| 1247 | 1305 | } |
| 1248 | 1306 | |
| 1249 | 1307 | // No image. Show a link. |
| 1250 | - else |
|
| 1251 | - $returnContext .= $currentAttachment['link']; |
|
| 1308 | + else { |
|
| 1309 | + $returnContext .= $currentAttachment['link']; |
|
| 1310 | + } |
|
| 1252 | 1311 | |
| 1253 | 1312 | // Gotta append what we just did. |
| 1254 | 1313 | $data = $returnContext; |
@@ -1302,8 +1361,9 @@ discard block |
||
| 1302 | 1361 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1303 | 1362 | { |
| 1304 | 1363 | // Do PHP code coloring? |
| 1305 | - if ($php_parts[$php_i] != '<?php') |
|
| 1306 | - continue; |
|
| 1364 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1365 | + continue; |
|
| 1366 | + } |
|
| 1307 | 1367 | |
| 1308 | 1368 | $php_string = ''; |
| 1309 | 1369 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1319,8 +1379,9 @@ discard block |
||
| 1319 | 1379 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1320 | 1380 | |
| 1321 | 1381 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1322 | - if ($context['browser']['is_opera']) |
|
| 1323 | - $data .= ' '; |
|
| 1382 | + if ($context['browser']['is_opera']) { |
|
| 1383 | + $data .= ' '; |
|
| 1384 | + } |
|
| 1324 | 1385 | } |
| 1325 | 1386 | }, |
| 1326 | 1387 | 'block_level' => true, |
@@ -1339,8 +1400,9 @@ discard block |
||
| 1339 | 1400 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1340 | 1401 | { |
| 1341 | 1402 | // Do PHP code coloring? |
| 1342 | - if ($php_parts[$php_i] != '<?php') |
|
| 1343 | - continue; |
|
| 1403 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1404 | + continue; |
|
| 1405 | + } |
|
| 1344 | 1406 | |
| 1345 | 1407 | $php_string = ''; |
| 1346 | 1408 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1356,8 +1418,9 @@ discard block |
||
| 1356 | 1418 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1357 | 1419 | |
| 1358 | 1420 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1359 | - if ($context['browser']['is_opera']) |
|
| 1360 | - $data[0] .= ' '; |
|
| 1421 | + if ($context['browser']['is_opera']) { |
|
| 1422 | + $data[0] .= ' '; |
|
| 1423 | + } |
|
| 1361 | 1424 | } |
| 1362 | 1425 | }, |
| 1363 | 1426 | 'block_level' => true, |
@@ -1398,10 +1461,11 @@ discard block |
||
| 1398 | 1461 | { |
| 1399 | 1462 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1400 | 1463 | |
| 1401 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1402 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1403 | - else |
|
| 1404 | - $css = ''; |
|
| 1464 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1465 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1466 | + } else { |
|
| 1467 | + $css = ''; |
|
| 1468 | + } |
|
| 1405 | 1469 | |
| 1406 | 1470 | $data = $class . $css; |
| 1407 | 1471 | }, |
@@ -1416,8 +1480,9 @@ discard block |
||
| 1416 | 1480 | { |
| 1417 | 1481 | $data = strtr($data, array('<br />' => '')); |
| 1418 | 1482 | |
| 1419 | - if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) |
|
| 1420 | - $data = 'ftp://' . $data; |
|
| 1483 | + if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) { |
|
| 1484 | + $data = 'ftp://' . $data; |
|
| 1485 | + } |
|
| 1421 | 1486 | }, |
| 1422 | 1487 | ), |
| 1423 | 1488 | array( |
@@ -1427,8 +1492,9 @@ discard block |
||
| 1427 | 1492 | 'after' => '</a>', |
| 1428 | 1493 | 'validate' => function(&$tag, &$data, $disabled) |
| 1429 | 1494 | { |
| 1430 | - if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) |
|
| 1431 | - $data = 'ftp://' . $data; |
|
| 1495 | + if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) { |
|
| 1496 | + $data = 'ftp://' . $data; |
|
| 1497 | + } |
|
| 1432 | 1498 | }, |
| 1433 | 1499 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1434 | 1500 | 'disabled_after' => ' ($1)', |
@@ -1488,17 +1554,20 @@ discard block |
||
| 1488 | 1554 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1489 | 1555 | if ($image_proxy_enabled) |
| 1490 | 1556 | { |
| 1491 | - if (!empty($user_info['possibly_robot'])) |
|
| 1492 | - return; |
|
| 1557 | + if (!empty($user_info['possibly_robot'])) { |
|
| 1558 | + return; |
|
| 1559 | + } |
|
| 1493 | 1560 | |
| 1494 | - if (empty($scheme)) |
|
| 1495 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1561 | + if (empty($scheme)) { |
|
| 1562 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1563 | + } |
|
| 1496 | 1564 | |
| 1497 | - if ($scheme != 'https') |
|
| 1498 | - $data = get_proxied_url($data); |
|
| 1565 | + if ($scheme != 'https') { |
|
| 1566 | + $data = get_proxied_url($data); |
|
| 1567 | + } |
|
| 1568 | + } elseif (empty($scheme)) { |
|
| 1569 | + $data = '//' . ltrim($data, ':/'); |
|
| 1499 | 1570 | } |
| 1500 | - elseif (empty($scheme)) |
|
| 1501 | - $data = '//' . ltrim($data, ':/'); |
|
| 1502 | 1571 | }, |
| 1503 | 1572 | 'disabled_content' => '($1)', |
| 1504 | 1573 | ), |
@@ -1514,17 +1583,20 @@ discard block |
||
| 1514 | 1583 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1515 | 1584 | if ($image_proxy_enabled) |
| 1516 | 1585 | { |
| 1517 | - if (!empty($user_info['possibly_robot'])) |
|
| 1518 | - return; |
|
| 1586 | + if (!empty($user_info['possibly_robot'])) { |
|
| 1587 | + return; |
|
| 1588 | + } |
|
| 1519 | 1589 | |
| 1520 | - if (empty($scheme)) |
|
| 1521 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1590 | + if (empty($scheme)) { |
|
| 1591 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1592 | + } |
|
| 1522 | 1593 | |
| 1523 | - if ($scheme != 'https') |
|
| 1524 | - $data = get_proxied_url($data); |
|
| 1594 | + if ($scheme != 'https') { |
|
| 1595 | + $data = get_proxied_url($data); |
|
| 1596 | + } |
|
| 1597 | + } elseif (empty($scheme)) { |
|
| 1598 | + $data = '//' . ltrim($data, ':/'); |
|
| 1525 | 1599 | } |
| 1526 | - elseif (empty($scheme)) |
|
| 1527 | - $data = '//' . ltrim($data, ':/'); |
|
| 1528 | 1600 | }, |
| 1529 | 1601 | 'disabled_content' => '($1)', |
| 1530 | 1602 | ), |
@@ -1536,8 +1608,9 @@ discard block |
||
| 1536 | 1608 | { |
| 1537 | 1609 | $data = strtr($data, array('<br>' => '')); |
| 1538 | 1610 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1539 | - if (empty($scheme)) |
|
| 1540 | - $data = '//' . ltrim($data, ':/'); |
|
| 1611 | + if (empty($scheme)) { |
|
| 1612 | + $data = '//' . ltrim($data, ':/'); |
|
| 1613 | + } |
|
| 1541 | 1614 | }, |
| 1542 | 1615 | ), |
| 1543 | 1616 | array( |
@@ -1548,13 +1621,14 @@ discard block |
||
| 1548 | 1621 | 'after' => '</a>', |
| 1549 | 1622 | 'validate' => function (&$tag, &$data, $disabled) |
| 1550 | 1623 | { |
| 1551 | - if (substr($data, 0, 1) == '#') |
|
| 1552 | - $data = '#post_' . substr($data, 1); |
|
| 1553 | - else |
|
| 1624 | + if (substr($data, 0, 1) == '#') { |
|
| 1625 | + $data = '#post_' . substr($data, 1); |
|
| 1626 | + } else |
|
| 1554 | 1627 | { |
| 1555 | 1628 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1556 | - if (empty($scheme)) |
|
| 1557 | - $data = '//' . ltrim($data, ':/'); |
|
| 1629 | + if (empty($scheme)) { |
|
| 1630 | + $data = '//' . ltrim($data, ':/'); |
|
| 1631 | + } |
|
| 1558 | 1632 | } |
| 1559 | 1633 | }, |
| 1560 | 1634 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1645,8 +1719,9 @@ discard block |
||
| 1645 | 1719 | { |
| 1646 | 1720 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1647 | 1721 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1648 | - if ($add_begin) |
|
| 1649 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1722 | + if ($add_begin) { |
|
| 1723 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1724 | + } |
|
| 1650 | 1725 | } |
| 1651 | 1726 | }, |
| 1652 | 1727 | 'block_level' => false, |
@@ -1759,20 +1834,17 @@ discard block |
||
| 1759 | 1834 | : function(&$tag, &$data, $disabled) |
| 1760 | 1835 | { |
| 1761 | 1836 | |
| 1762 | - if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) |
|
| 1763 | - $data[1] = '0 -2px 1px'; |
|
| 1764 | - |
|
| 1765 | - elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) |
|
| 1766 | - $data[1] = '2px 0 1px'; |
|
| 1767 | - |
|
| 1768 | - elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) |
|
| 1769 | - $data[1] = '0 2px 1px'; |
|
| 1770 | - |
|
| 1771 | - elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) |
|
| 1772 | - $data[1] = '-2px 0 1px'; |
|
| 1773 | - |
|
| 1774 | - else |
|
| 1775 | - $data[1] = '1px 1px 1px'; |
|
| 1837 | + if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) { |
|
| 1838 | + $data[1] = '0 -2px 1px'; |
|
| 1839 | + } elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) { |
|
| 1840 | + $data[1] = '2px 0 1px'; |
|
| 1841 | + } elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) { |
|
| 1842 | + $data[1] = '0 2px 1px'; |
|
| 1843 | + } elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) { |
|
| 1844 | + $data[1] = '-2px 0 1px'; |
|
| 1845 | + } else { |
|
| 1846 | + $data[1] = '1px 1px 1px'; |
|
| 1847 | + } |
|
| 1776 | 1848 | }, |
| 1777 | 1849 | ), |
| 1778 | 1850 | array( |
@@ -1828,10 +1900,11 @@ discard block |
||
| 1828 | 1900 | 'content' => '$1', |
| 1829 | 1901 | 'validate' => function (&$tag, &$data, $disabled) |
| 1830 | 1902 | { |
| 1831 | - if (is_numeric($data)) |
|
| 1832 | - $data = timeformat($data); |
|
| 1833 | - else |
|
| 1834 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1903 | + if (is_numeric($data)) { |
|
| 1904 | + $data = timeformat($data); |
|
| 1905 | + } else { |
|
| 1906 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1907 | + } |
|
| 1835 | 1908 | }, |
| 1836 | 1909 | ), |
| 1837 | 1910 | array( |
@@ -1863,8 +1936,9 @@ discard block |
||
| 1863 | 1936 | { |
| 1864 | 1937 | $data = strtr($data, array('<br>' => '')); |
| 1865 | 1938 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1866 | - if (empty($scheme)) |
|
| 1867 | - $data = '//' . ltrim($data, ':/'); |
|
| 1939 | + if (empty($scheme)) { |
|
| 1940 | + $data = '//' . ltrim($data, ':/'); |
|
| 1941 | + } |
|
| 1868 | 1942 | }, |
| 1869 | 1943 | ), |
| 1870 | 1944 | array( |
@@ -1876,8 +1950,9 @@ discard block |
||
| 1876 | 1950 | 'validate' => function (&$tag, &$data, $disabled) |
| 1877 | 1951 | { |
| 1878 | 1952 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1879 | - if (empty($scheme)) |
|
| 1880 | - $data = '//' . ltrim($data, ':/'); |
|
| 1953 | + if (empty($scheme)) { |
|
| 1954 | + $data = '//' . ltrim($data, ':/'); |
|
| 1955 | + } |
|
| 1881 | 1956 | }, |
| 1882 | 1957 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1883 | 1958 | 'disabled_after' => ' ($1)', |
@@ -1904,12 +1979,13 @@ discard block |
||
| 1904 | 1979 | ); |
| 1905 | 1980 | |
| 1906 | 1981 | // Handle legacy bbc codes. |
| 1907 | - foreach ($context['legacy_bbc'] as $bbc) |
|
| 1908 | - $codes[] = array( |
|
| 1982 | + foreach ($context['legacy_bbc'] as $bbc) { |
|
| 1983 | + $codes[] = array( |
|
| 1909 | 1984 | 'tag' => $bbc, |
| 1910 | 1985 | 'before' => '', |
| 1911 | 1986 | 'after' => '', |
| 1912 | 1987 | ); |
| 1988 | + } |
|
| 1913 | 1989 | |
| 1914 | 1990 | // Let mods add new BBC without hassle. |
| 1915 | 1991 | call_integration_hook('integrate_bbc_codes', array(&$codes, &$no_autolink_tags)); |
@@ -1917,8 +1993,9 @@ discard block |
||
| 1917 | 1993 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1918 | 1994 | if ($message === false) |
| 1919 | 1995 | { |
| 1920 | - if (isset($temp_bbc)) |
|
| 1921 | - $bbc_codes = $temp_bbc; |
|
| 1996 | + if (isset($temp_bbc)) { |
|
| 1997 | + $bbc_codes = $temp_bbc; |
|
| 1998 | + } |
|
| 1922 | 1999 | usort($codes, function ($a, $b) { |
| 1923 | 2000 | return strcmp($a['tag'], $b['tag']); |
| 1924 | 2001 | }); |
@@ -1938,8 +2015,9 @@ discard block |
||
| 1938 | 2015 | ); |
| 1939 | 2016 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1940 | 2017 | { |
| 1941 | - foreach ($itemcodes as $c => $dummy) |
|
| 1942 | - $bbc_codes[$c] = array(); |
|
| 2018 | + foreach ($itemcodes as $c => $dummy) { |
|
| 2019 | + $bbc_codes[$c] = array(); |
|
| 2020 | + } |
|
| 1943 | 2021 | } |
| 1944 | 2022 | |
| 1945 | 2023 | // Shhhh! |
@@ -1960,12 +2038,14 @@ discard block |
||
| 1960 | 2038 | foreach ($codes as $code) |
| 1961 | 2039 | { |
| 1962 | 2040 | // Make it easier to process parameters later |
| 1963 | - if (!empty($code['parameters'])) |
|
| 1964 | - ksort($code['parameters'], SORT_STRING); |
|
| 2041 | + if (!empty($code['parameters'])) { |
|
| 2042 | + ksort($code['parameters'], SORT_STRING); |
|
| 2043 | + } |
|
| 1965 | 2044 | |
| 1966 | 2045 | // If we are not doing every tag only do ones we are interested in. |
| 1967 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1968 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 2046 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 2047 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 2048 | + } |
|
| 1969 | 2049 | } |
| 1970 | 2050 | $codes = null; |
| 1971 | 2051 | } |
@@ -1976,8 +2056,9 @@ discard block |
||
| 1976 | 2056 | // It's likely this will change if the message is modified. |
| 1977 | 2057 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1978 | 2058 | |
| 1979 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1980 | - return $temp; |
|
| 2059 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 2060 | + return $temp; |
|
| 2061 | + } |
|
| 1981 | 2062 | |
| 1982 | 2063 | $cache_t = microtime(); |
| 1983 | 2064 | } |
@@ -2009,8 +2090,9 @@ discard block |
||
| 2009 | 2090 | $disabled['flash'] = true; |
| 2010 | 2091 | |
| 2011 | 2092 | // @todo Change maybe? |
| 2012 | - if (!isset($_GET['images'])) |
|
| 2013 | - $disabled['img'] = true; |
|
| 2093 | + if (!isset($_GET['images'])) { |
|
| 2094 | + $disabled['img'] = true; |
|
| 2095 | + } |
|
| 2014 | 2096 | |
| 2015 | 2097 | // @todo Interface/setting to add more? |
| 2016 | 2098 | } |
@@ -2021,8 +2103,9 @@ discard block |
||
| 2021 | 2103 | $alltags = array(); |
| 2022 | 2104 | foreach ($bbc_codes as $section) |
| 2023 | 2105 | { |
| 2024 | - foreach ($section as $code) |
|
| 2025 | - $alltags[] = $code['tag']; |
|
| 2106 | + foreach ($section as $code) { |
|
| 2107 | + $alltags[] = $code['tag']; |
|
| 2108 | + } |
|
| 2026 | 2109 | } |
| 2027 | 2110 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
| 2028 | 2111 | |
@@ -2034,8 +2117,9 @@ discard block |
||
| 2034 | 2117 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 2035 | 2118 | |
| 2036 | 2119 | // Failsafe. |
| 2037 | - if ($pos === false || $last_pos > $pos) |
|
| 2038 | - $pos = strlen($message) + 1; |
|
| 2120 | + if ($pos === false || $last_pos > $pos) { |
|
| 2121 | + $pos = strlen($message) + 1; |
|
| 2122 | + } |
|
| 2039 | 2123 | |
| 2040 | 2124 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 2041 | 2125 | if ($last_pos < $pos - 1) |
@@ -2053,8 +2137,9 @@ discard block |
||
| 2053 | 2137 | |
| 2054 | 2138 | // <br> should be empty. |
| 2055 | 2139 | $empty_tags = array('br', 'hr'); |
| 2056 | - foreach ($empty_tags as $tag) |
|
| 2057 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 2140 | + foreach ($empty_tags as $tag) { |
|
| 2141 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 2142 | + } |
|
| 2058 | 2143 | |
| 2059 | 2144 | // b, u, i, s, pre... basic tags. |
| 2060 | 2145 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -2063,8 +2148,9 @@ discard block |
||
| 2063 | 2148 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 2064 | 2149 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 2065 | 2150 | |
| 2066 | - if ($diff > 0) |
|
| 2067 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 2151 | + if ($diff > 0) { |
|
| 2152 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 2153 | + } |
|
| 2068 | 2154 | } |
| 2069 | 2155 | |
| 2070 | 2156 | // Do <img ...> - with security... action= -> action-. |
@@ -2077,8 +2163,9 @@ discard block |
||
| 2077 | 2163 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 2078 | 2164 | |
| 2079 | 2165 | // Remove action= from the URL - no funny business, now. |
| 2080 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 2081 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2166 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 2167 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2168 | + } |
|
| 2082 | 2169 | |
| 2083 | 2170 | $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
| 2084 | 2171 | } |
@@ -2093,16 +2180,18 @@ discard block |
||
| 2093 | 2180 | $no_autolink_area = false; |
| 2094 | 2181 | if (!empty($open_tags)) |
| 2095 | 2182 | { |
| 2096 | - foreach ($open_tags as $open_tag) |
|
| 2097 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2183 | + foreach ($open_tags as $open_tag) { |
|
| 2184 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2098 | 2185 | $no_autolink_area = true; |
| 2186 | + } |
|
| 2099 | 2187 | } |
| 2100 | 2188 | |
| 2101 | 2189 | // Don't go backwards. |
| 2102 | 2190 | // @todo Don't think is the real solution.... |
| 2103 | 2191 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 2104 | - if ($pos < $lastAutoPos) |
|
| 2105 | - $no_autolink_area = true; |
|
| 2192 | + if ($pos < $lastAutoPos) { |
|
| 2193 | + $no_autolink_area = true; |
|
| 2194 | + } |
|
| 2106 | 2195 | $lastAutoPos = $pos; |
| 2107 | 2196 | |
| 2108 | 2197 | if (!$no_autolink_area) |
@@ -2207,29 +2296,33 @@ discard block |
||
| 2207 | 2296 | $url = array_shift($matches); |
| 2208 | 2297 | |
| 2209 | 2298 | // If this isn't a clean URL, bail out |
| 2210 | - if ($url != sanitize_iri($url)) |
|
| 2211 | - return $url; |
|
| 2299 | + if ($url != sanitize_iri($url)) { |
|
| 2300 | + return $url; |
|
| 2301 | + } |
|
| 2212 | 2302 | |
| 2213 | 2303 | $scheme = parse_url($url, PHP_URL_SCHEME); |
| 2214 | 2304 | |
| 2215 | 2305 | if ($scheme == 'mailto') |
| 2216 | 2306 | { |
| 2217 | 2307 | $email_address = str_replace('mailto:', '', $url); |
| 2218 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 2219 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2220 | - else |
|
| 2221 | - return $url; |
|
| 2308 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2309 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2310 | + } else { |
|
| 2311 | + return $url; |
|
| 2312 | + } |
|
| 2222 | 2313 | } |
| 2223 | 2314 | |
| 2224 | 2315 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 2225 | - if (empty($scheme)) |
|
| 2226 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2227 | - else |
|
| 2228 | - $fullUrl = $url; |
|
| 2316 | + if (empty($scheme)) { |
|
| 2317 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2318 | + } else { |
|
| 2319 | + $fullUrl = $url; |
|
| 2320 | + } |
|
| 2229 | 2321 | |
| 2230 | 2322 | // Make sure that $fullUrl really is valid |
| 2231 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
| 2232 | - return $url; |
|
| 2323 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) { |
|
| 2324 | + return $url; |
|
| 2325 | + } |
|
| 2233 | 2326 | |
| 2234 | 2327 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2235 | 2328 | }, $data); |
@@ -2278,22 +2371,25 @@ discard block |
||
| 2278 | 2371 | } |
| 2279 | 2372 | |
| 2280 | 2373 | // Are we there yet? Are we there yet? |
| 2281 | - if ($pos >= strlen($message) - 1) |
|
| 2282 | - break; |
|
| 2374 | + if ($pos >= strlen($message) - 1) { |
|
| 2375 | + break; |
|
| 2376 | + } |
|
| 2283 | 2377 | |
| 2284 | 2378 | $tags = strtolower($message[$pos + 1]); |
| 2285 | 2379 | |
| 2286 | 2380 | if ($tags == '/' && !empty($open_tags)) |
| 2287 | 2381 | { |
| 2288 | 2382 | $pos2 = strpos($message, ']', $pos + 1); |
| 2289 | - if ($pos2 == $pos + 2) |
|
| 2290 | - continue; |
|
| 2383 | + if ($pos2 == $pos + 2) { |
|
| 2384 | + continue; |
|
| 2385 | + } |
|
| 2291 | 2386 | |
| 2292 | 2387 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2293 | 2388 | |
| 2294 | 2389 | // A closing tag that doesn't match any open tags? Skip it. |
| 2295 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
| 2296 | - continue; |
|
| 2390 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
| 2391 | + continue; |
|
| 2392 | + } |
|
| 2297 | 2393 | |
| 2298 | 2394 | $to_close = array(); |
| 2299 | 2395 | $block_level = null; |
@@ -2301,8 +2397,9 @@ discard block |
||
| 2301 | 2397 | do |
| 2302 | 2398 | { |
| 2303 | 2399 | $tag = array_pop($open_tags); |
| 2304 | - if (!$tag) |
|
| 2305 | - break; |
|
| 2400 | + if (!$tag) { |
|
| 2401 | + break; |
|
| 2402 | + } |
|
| 2306 | 2403 | |
| 2307 | 2404 | if (!empty($tag['block_level'])) |
| 2308 | 2405 | { |
@@ -2316,10 +2413,11 @@ discard block |
||
| 2316 | 2413 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2317 | 2414 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2318 | 2415 | { |
| 2319 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2320 | - if ($temp['tag'] == $look_for) |
|
| 2416 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2417 | + if ($temp['tag'] == $look_for) |
|
| 2321 | 2418 | { |
| 2322 | 2419 | $block_level = !empty($temp['block_level']); |
| 2420 | + } |
|
| 2323 | 2421 | break; |
| 2324 | 2422 | } |
| 2325 | 2423 | } |
@@ -2341,15 +2439,15 @@ discard block |
||
| 2341 | 2439 | { |
| 2342 | 2440 | $open_tags = $to_close; |
| 2343 | 2441 | continue; |
| 2344 | - } |
|
| 2345 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2442 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2346 | 2443 | { |
| 2347 | 2444 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2348 | 2445 | { |
| 2349 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2350 | - if ($temp['tag'] == $look_for) |
|
| 2446 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2447 | + if ($temp['tag'] == $look_for) |
|
| 2351 | 2448 | { |
| 2352 | 2449 | $block_level = !empty($temp['block_level']); |
| 2450 | + } |
|
| 2353 | 2451 | break; |
| 2354 | 2452 | } |
| 2355 | 2453 | } |
@@ -2357,8 +2455,9 @@ discard block |
||
| 2357 | 2455 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2358 | 2456 | if (!$block_level) |
| 2359 | 2457 | { |
| 2360 | - foreach ($to_close as $tag) |
|
| 2361 | - array_push($open_tags, $tag); |
|
| 2458 | + foreach ($to_close as $tag) { |
|
| 2459 | + array_push($open_tags, $tag); |
|
| 2460 | + } |
|
| 2362 | 2461 | continue; |
| 2363 | 2462 | } |
| 2364 | 2463 | } |
@@ -2371,14 +2470,17 @@ discard block |
||
| 2371 | 2470 | |
| 2372 | 2471 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2373 | 2472 | $whitespace_regex = ''; |
| 2374 | - if (!empty($tag['block_level'])) |
|
| 2375 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2473 | + if (!empty($tag['block_level'])) { |
|
| 2474 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2475 | + } |
|
| 2376 | 2476 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2377 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2378 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2477 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2478 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2479 | + } |
|
| 2379 | 2480 | |
| 2380 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2381 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2481 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2482 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2483 | + } |
|
| 2382 | 2484 | } |
| 2383 | 2485 | |
| 2384 | 2486 | if (!empty($to_close)) |
@@ -2391,8 +2493,9 @@ discard block |
||
| 2391 | 2493 | } |
| 2392 | 2494 | |
| 2393 | 2495 | // No tags for this character, so just keep going (fastest possible course.) |
| 2394 | - if (!isset($bbc_codes[$tags])) |
|
| 2395 | - continue; |
|
| 2496 | + if (!isset($bbc_codes[$tags])) { |
|
| 2497 | + continue; |
|
| 2498 | + } |
|
| 2396 | 2499 | |
| 2397 | 2500 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2398 | 2501 | $tag = null; |
@@ -2401,48 +2504,57 @@ discard block |
||
| 2401 | 2504 | $pt_strlen = strlen($possible['tag']); |
| 2402 | 2505 | |
| 2403 | 2506 | // Not a match? |
| 2404 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2405 | - continue; |
|
| 2507 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2508 | + continue; |
|
| 2509 | + } |
|
| 2406 | 2510 | |
| 2407 | 2511 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
| 2408 | 2512 | |
| 2409 | 2513 | // A tag is the last char maybe |
| 2410 | - if ($next_c == '') |
|
| 2411 | - break; |
|
| 2514 | + if ($next_c == '') { |
|
| 2515 | + break; |
|
| 2516 | + } |
|
| 2412 | 2517 | |
| 2413 | 2518 | // A test validation? |
| 2414 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2415 | - continue; |
|
| 2519 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2520 | + continue; |
|
| 2521 | + } |
|
| 2416 | 2522 | // Do we want parameters? |
| 2417 | 2523 | elseif (!empty($possible['parameters'])) |
| 2418 | 2524 | { |
| 2419 | - if ($next_c != ' ') |
|
| 2420 | - continue; |
|
| 2421 | - } |
|
| 2422 | - elseif (isset($possible['type'])) |
|
| 2525 | + if ($next_c != ' ') { |
|
| 2526 | + continue; |
|
| 2527 | + } |
|
| 2528 | + } elseif (isset($possible['type'])) |
|
| 2423 | 2529 | { |
| 2424 | 2530 | // Do we need an equal sign? |
| 2425 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2426 | - continue; |
|
| 2531 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2532 | + continue; |
|
| 2533 | + } |
|
| 2427 | 2534 | // Maybe we just want a /... |
| 2428 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2429 | - continue; |
|
| 2535 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2536 | + continue; |
|
| 2537 | + } |
|
| 2430 | 2538 | // An immediate ]? |
| 2431 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2432 | - continue; |
|
| 2539 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2540 | + continue; |
|
| 2541 | + } |
|
| 2433 | 2542 | } |
| 2434 | 2543 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2435 | - elseif ($next_c != ']') |
|
| 2436 | - continue; |
|
| 2544 | + elseif ($next_c != ']') { |
|
| 2545 | + continue; |
|
| 2546 | + } |
|
| 2437 | 2547 | |
| 2438 | 2548 | // Check allowed tree? |
| 2439 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2440 | - continue; |
|
| 2441 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2442 | - continue; |
|
| 2549 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2550 | + continue; |
|
| 2551 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2552 | + continue; |
|
| 2553 | + } |
|
| 2443 | 2554 | // If this is in the list of disallowed child tags, don't parse it. |
| 2444 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2445 | - continue; |
|
| 2555 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2556 | + continue; |
|
| 2557 | + } |
|
| 2446 | 2558 | |
| 2447 | 2559 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2448 | 2560 | |
@@ -2454,8 +2566,9 @@ discard block |
||
| 2454 | 2566 | foreach ($open_tags as $open_quote) |
| 2455 | 2567 | { |
| 2456 | 2568 | // Every parent quote this quote has flips the styling |
| 2457 | - if ($open_quote['tag'] == 'quote') |
|
| 2458 | - $quote_alt = !$quote_alt; |
|
| 2569 | + if ($open_quote['tag'] == 'quote') { |
|
| 2570 | + $quote_alt = !$quote_alt; |
|
| 2571 | + } |
|
| 2459 | 2572 | } |
| 2460 | 2573 | // Add a class to the quote to style alternating blockquotes |
| 2461 | 2574 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2466,8 +2579,9 @@ discard block |
||
| 2466 | 2579 | { |
| 2467 | 2580 | // Build a regular expression for each parameter for the current tag. |
| 2468 | 2581 | $preg = array(); |
| 2469 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2470 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2582 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2583 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2584 | + } |
|
| 2471 | 2585 | |
| 2472 | 2586 | // Extract the string that potentially holds our parameters. |
| 2473 | 2587 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2486,24 +2600,27 @@ discard block |
||
| 2486 | 2600 | |
| 2487 | 2601 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2488 | 2602 | |
| 2489 | - if ($match) |
|
| 2490 | - $blob_counter = count($blobs) + 1; |
|
| 2603 | + if ($match) { |
|
| 2604 | + $blob_counter = count($blobs) + 1; |
|
| 2605 | + } |
|
| 2491 | 2606 | } |
| 2492 | 2607 | |
| 2493 | 2608 | // Didn't match our parameter list, try the next possible. |
| 2494 | - if (!$match) |
|
| 2495 | - continue; |
|
| 2609 | + if (!$match) { |
|
| 2610 | + continue; |
|
| 2611 | + } |
|
| 2496 | 2612 | |
| 2497 | 2613 | $params = array(); |
| 2498 | 2614 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2499 | 2615 | { |
| 2500 | 2616 | $key = strtok(ltrim($matches[$i]), '='); |
| 2501 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2502 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2503 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2504 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2505 | - else |
|
| 2506 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2617 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2618 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2619 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2620 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2621 | + } else { |
|
| 2622 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2623 | + } |
|
| 2507 | 2624 | |
| 2508 | 2625 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2509 | 2626 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2511,23 +2628,26 @@ discard block |
||
| 2511 | 2628 | |
| 2512 | 2629 | foreach ($possible['parameters'] as $p => $info) |
| 2513 | 2630 | { |
| 2514 | - if (!isset($params['{' . $p . '}'])) |
|
| 2515 | - $params['{' . $p . '}'] = ''; |
|
| 2631 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2632 | + $params['{' . $p . '}'] = ''; |
|
| 2633 | + } |
|
| 2516 | 2634 | } |
| 2517 | 2635 | |
| 2518 | 2636 | $tag = $possible; |
| 2519 | 2637 | |
| 2520 | 2638 | // Put the parameters into the string. |
| 2521 | - if (isset($tag['before'])) |
|
| 2522 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2523 | - if (isset($tag['after'])) |
|
| 2524 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2525 | - if (isset($tag['content'])) |
|
| 2526 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2639 | + if (isset($tag['before'])) { |
|
| 2640 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2641 | + } |
|
| 2642 | + if (isset($tag['after'])) { |
|
| 2643 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2644 | + } |
|
| 2645 | + if (isset($tag['content'])) { |
|
| 2646 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2647 | + } |
|
| 2527 | 2648 | |
| 2528 | 2649 | $pos1 += strlen($given_param_string); |
| 2529 | - } |
|
| 2530 | - else |
|
| 2650 | + } else |
|
| 2531 | 2651 | { |
| 2532 | 2652 | $tag = $possible; |
| 2533 | 2653 | $params = array(); |
@@ -2538,8 +2658,9 @@ discard block |
||
| 2538 | 2658 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2539 | 2659 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2540 | 2660 | { |
| 2541 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2542 | - continue; |
|
| 2661 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2662 | + continue; |
|
| 2663 | + } |
|
| 2543 | 2664 | |
| 2544 | 2665 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2545 | 2666 | |
@@ -2560,9 +2681,9 @@ discard block |
||
| 2560 | 2681 | { |
| 2561 | 2682 | array_pop($open_tags); |
| 2562 | 2683 | $code = '</li>'; |
| 2684 | + } else { |
|
| 2685 | + $code = ''; |
|
| 2563 | 2686 | } |
| 2564 | - else |
|
| 2565 | - $code = ''; |
|
| 2566 | 2687 | |
| 2567 | 2688 | // Now we open a new tag. |
| 2568 | 2689 | $open_tags[] = array( |
@@ -2609,12 +2730,14 @@ discard block |
||
| 2609 | 2730 | } |
| 2610 | 2731 | |
| 2611 | 2732 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2612 | - if ($tag === null) |
|
| 2613 | - continue; |
|
| 2733 | + if ($tag === null) { |
|
| 2734 | + continue; |
|
| 2735 | + } |
|
| 2614 | 2736 | |
| 2615 | 2737 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2616 | - if (isset($inside['disallow_children'])) |
|
| 2617 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2738 | + if (isset($inside['disallow_children'])) { |
|
| 2739 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2740 | + } |
|
| 2618 | 2741 | |
| 2619 | 2742 | // Is this tag disabled? |
| 2620 | 2743 | if (isset($disabled[$tag['tag']])) |
@@ -2624,14 +2747,13 @@ discard block |
||
| 2624 | 2747 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2625 | 2748 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2626 | 2749 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2627 | - } |
|
| 2628 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2750 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2629 | 2751 | { |
| 2630 | 2752 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2631 | 2753 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2754 | + } else { |
|
| 2755 | + $tag['content'] = $tag['disabled_content']; |
|
| 2632 | 2756 | } |
| 2633 | - else |
|
| 2634 | - $tag['content'] = $tag['disabled_content']; |
|
| 2635 | 2757 | } |
| 2636 | 2758 | |
| 2637 | 2759 | // we use this a lot |
@@ -2641,8 +2763,9 @@ discard block |
||
| 2641 | 2763 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2642 | 2764 | { |
| 2643 | 2765 | $n = count($open_tags) - 1; |
| 2644 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2645 | - $n--; |
|
| 2766 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2767 | + $n--; |
|
| 2768 | + } |
|
| 2646 | 2769 | |
| 2647 | 2770 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2648 | 2771 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2654,12 +2777,15 @@ discard block |
||
| 2654 | 2777 | |
| 2655 | 2778 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2656 | 2779 | $whitespace_regex = ''; |
| 2657 | - if (!empty($tag['block_level'])) |
|
| 2658 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2659 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2660 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2661 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2662 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2780 | + if (!empty($tag['block_level'])) { |
|
| 2781 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2782 | + } |
|
| 2783 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2784 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2785 | + } |
|
| 2786 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2787 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2788 | + } |
|
| 2663 | 2789 | |
| 2664 | 2790 | array_pop($open_tags); |
| 2665 | 2791 | } |
@@ -2680,16 +2806,19 @@ discard block |
||
| 2680 | 2806 | elseif ($tag['type'] == 'unparsed_content') |
| 2681 | 2807 | { |
| 2682 | 2808 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2683 | - if ($pos2 === false) |
|
| 2684 | - continue; |
|
| 2809 | + if ($pos2 === false) { |
|
| 2810 | + continue; |
|
| 2811 | + } |
|
| 2685 | 2812 | |
| 2686 | 2813 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2687 | 2814 | |
| 2688 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2689 | - $data = substr($data, 4); |
|
| 2815 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2816 | + $data = substr($data, 4); |
|
| 2817 | + } |
|
| 2690 | 2818 | |
| 2691 | - if (isset($tag['validate'])) |
|
| 2692 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2819 | + if (isset($tag['validate'])) { |
|
| 2820 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2821 | + } |
|
| 2693 | 2822 | |
| 2694 | 2823 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2695 | 2824 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2704,34 +2833,40 @@ discard block |
||
| 2704 | 2833 | if (isset($tag['quoted'])) |
| 2705 | 2834 | { |
| 2706 | 2835 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2707 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2708 | - continue; |
|
| 2836 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2837 | + continue; |
|
| 2838 | + } |
|
| 2709 | 2839 | |
| 2710 | - if ($quoted) |
|
| 2711 | - $pos1 += 6; |
|
| 2840 | + if ($quoted) { |
|
| 2841 | + $pos1 += 6; |
|
| 2842 | + } |
|
| 2843 | + } else { |
|
| 2844 | + $quoted = false; |
|
| 2712 | 2845 | } |
| 2713 | - else |
|
| 2714 | - $quoted = false; |
|
| 2715 | 2846 | |
| 2716 | 2847 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2717 | - if ($pos2 === false) |
|
| 2718 | - continue; |
|
| 2848 | + if ($pos2 === false) { |
|
| 2849 | + continue; |
|
| 2850 | + } |
|
| 2719 | 2851 | |
| 2720 | 2852 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2721 | - if ($pos3 === false) |
|
| 2722 | - continue; |
|
| 2853 | + if ($pos3 === false) { |
|
| 2854 | + continue; |
|
| 2855 | + } |
|
| 2723 | 2856 | |
| 2724 | 2857 | $data = array( |
| 2725 | 2858 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2726 | 2859 | substr($message, $pos1, $pos2 - $pos1) |
| 2727 | 2860 | ); |
| 2728 | 2861 | |
| 2729 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2730 | - $data[0] = substr($data[0], 4); |
|
| 2862 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2863 | + $data[0] = substr($data[0], 4); |
|
| 2864 | + } |
|
| 2731 | 2865 | |
| 2732 | 2866 | // Validation for my parking, please! |
| 2733 | - if (isset($tag['validate'])) |
|
| 2734 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2867 | + if (isset($tag['validate'])) { |
|
| 2868 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2869 | + } |
|
| 2735 | 2870 | |
| 2736 | 2871 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2737 | 2872 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2748,23 +2883,27 @@ discard block |
||
| 2748 | 2883 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2749 | 2884 | { |
| 2750 | 2885 | $pos2 = strpos($message, ']', $pos1); |
| 2751 | - if ($pos2 === false) |
|
| 2752 | - continue; |
|
| 2886 | + if ($pos2 === false) { |
|
| 2887 | + continue; |
|
| 2888 | + } |
|
| 2753 | 2889 | |
| 2754 | 2890 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2755 | - if ($pos3 === false) |
|
| 2756 | - continue; |
|
| 2891 | + if ($pos3 === false) { |
|
| 2892 | + continue; |
|
| 2893 | + } |
|
| 2757 | 2894 | |
| 2758 | 2895 | // We want $1 to be the content, and the rest to be csv. |
| 2759 | 2896 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2760 | 2897 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2761 | 2898 | |
| 2762 | - if (isset($tag['validate'])) |
|
| 2763 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2899 | + if (isset($tag['validate'])) { |
|
| 2900 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2901 | + } |
|
| 2764 | 2902 | |
| 2765 | 2903 | $code = $tag['content']; |
| 2766 | - foreach ($data as $k => $d) |
|
| 2767 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2904 | + foreach ($data as $k => $d) { |
|
| 2905 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2906 | + } |
|
| 2768 | 2907 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2769 | 2908 | $pos += strlen($code) - 1 + 2; |
| 2770 | 2909 | } |
@@ -2772,24 +2911,28 @@ discard block |
||
| 2772 | 2911 | elseif ($tag['type'] == 'unparsed_commas') |
| 2773 | 2912 | { |
| 2774 | 2913 | $pos2 = strpos($message, ']', $pos1); |
| 2775 | - if ($pos2 === false) |
|
| 2776 | - continue; |
|
| 2914 | + if ($pos2 === false) { |
|
| 2915 | + continue; |
|
| 2916 | + } |
|
| 2777 | 2917 | |
| 2778 | 2918 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2779 | 2919 | |
| 2780 | - if (isset($tag['validate'])) |
|
| 2781 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2920 | + if (isset($tag['validate'])) { |
|
| 2921 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2922 | + } |
|
| 2782 | 2923 | |
| 2783 | 2924 | // Fix after, for disabled code mainly. |
| 2784 | - foreach ($data as $k => $d) |
|
| 2785 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2925 | + foreach ($data as $k => $d) { |
|
| 2926 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2927 | + } |
|
| 2786 | 2928 | |
| 2787 | 2929 | $open_tags[] = $tag; |
| 2788 | 2930 | |
| 2789 | 2931 | // Replace them out, $1, $2, $3, $4, etc. |
| 2790 | 2932 | $code = $tag['before']; |
| 2791 | - foreach ($data as $k => $d) |
|
| 2792 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2933 | + foreach ($data as $k => $d) { |
|
| 2934 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2935 | + } |
|
| 2793 | 2936 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2794 | 2937 | $pos += strlen($code) - 1 + 2; |
| 2795 | 2938 | } |
@@ -2800,28 +2943,33 @@ discard block |
||
| 2800 | 2943 | if (isset($tag['quoted'])) |
| 2801 | 2944 | { |
| 2802 | 2945 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2803 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2804 | - continue; |
|
| 2946 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2947 | + continue; |
|
| 2948 | + } |
|
| 2805 | 2949 | |
| 2806 | - if ($quoted) |
|
| 2807 | - $pos1 += 6; |
|
| 2950 | + if ($quoted) { |
|
| 2951 | + $pos1 += 6; |
|
| 2952 | + } |
|
| 2953 | + } else { |
|
| 2954 | + $quoted = false; |
|
| 2808 | 2955 | } |
| 2809 | - else |
|
| 2810 | - $quoted = false; |
|
| 2811 | 2956 | |
| 2812 | 2957 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2813 | - if ($pos2 === false) |
|
| 2814 | - continue; |
|
| 2958 | + if ($pos2 === false) { |
|
| 2959 | + continue; |
|
| 2960 | + } |
|
| 2815 | 2961 | |
| 2816 | 2962 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2817 | 2963 | |
| 2818 | 2964 | // Validation for my parking, please! |
| 2819 | - if (isset($tag['validate'])) |
|
| 2820 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2965 | + if (isset($tag['validate'])) { |
|
| 2966 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2967 | + } |
|
| 2821 | 2968 | |
| 2822 | 2969 | // For parsed content, we must recurse to avoid security problems. |
| 2823 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2824 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2970 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2971 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2972 | + } |
|
| 2825 | 2973 | |
| 2826 | 2974 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2827 | 2975 | |
@@ -2833,34 +2981,40 @@ discard block |
||
| 2833 | 2981 | } |
| 2834 | 2982 | |
| 2835 | 2983 | // If this is block level, eat any breaks after it. |
| 2836 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2837 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2984 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2985 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2986 | + } |
|
| 2838 | 2987 | |
| 2839 | 2988 | // Are we trimming outside this tag? |
| 2840 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2841 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2989 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2990 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2991 | + } |
|
| 2842 | 2992 | } |
| 2843 | 2993 | |
| 2844 | 2994 | // Close any remaining tags. |
| 2845 | - while ($tag = array_pop($open_tags)) |
|
| 2846 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2995 | + while ($tag = array_pop($open_tags)) { |
|
| 2996 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2997 | + } |
|
| 2847 | 2998 | |
| 2848 | 2999 | // Parse the smileys within the parts where it can be done safely. |
| 2849 | 3000 | if ($smileys === true) |
| 2850 | 3001 | { |
| 2851 | 3002 | $message_parts = explode("\n", $message); |
| 2852 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2853 | - parsesmileys($message_parts[$i]); |
|
| 3003 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 3004 | + parsesmileys($message_parts[$i]); |
|
| 3005 | + } |
|
| 2854 | 3006 | |
| 2855 | 3007 | $message = implode('', $message_parts); |
| 2856 | 3008 | } |
| 2857 | 3009 | |
| 2858 | 3010 | // No smileys, just get rid of the markers. |
| 2859 | - else |
|
| 2860 | - $message = strtr($message, array("\n" => '')); |
|
| 3011 | + else { |
|
| 3012 | + $message = strtr($message, array("\n" => '')); |
|
| 3013 | + } |
|
| 2861 | 3014 | |
| 2862 | - if ($message !== '' && $message[0] === ' ') |
|
| 2863 | - $message = ' ' . substr($message, 1); |
|
| 3015 | + if ($message !== '' && $message[0] === ' ') { |
|
| 3016 | + $message = ' ' . substr($message, 1); |
|
| 3017 | + } |
|
| 2864 | 3018 | |
| 2865 | 3019 | // Cleanup whitespace. |
| 2866 | 3020 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2869,15 +3023,16 @@ discard block |
||
| 2869 | 3023 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2870 | 3024 | |
| 2871 | 3025 | // Cache the output if it took some time... |
| 2872 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2873 | - cache_put_data($cache_key, $message, 240); |
|
| 3026 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 3027 | + cache_put_data($cache_key, $message, 240); |
|
| 3028 | + } |
|
| 2874 | 3029 | |
| 2875 | 3030 | // If this was a force parse revert if needed. |
| 2876 | 3031 | if (!empty($parse_tags)) |
| 2877 | 3032 | { |
| 2878 | - if (empty($temp_bbc)) |
|
| 2879 | - $bbc_codes = array(); |
|
| 2880 | - else |
|
| 3033 | + if (empty($temp_bbc)) { |
|
| 3034 | + $bbc_codes = array(); |
|
| 3035 | + } else |
|
| 2881 | 3036 | { |
| 2882 | 3037 | $bbc_codes = $temp_bbc; |
| 2883 | 3038 | unset($temp_bbc); |
@@ -2904,8 +3059,9 @@ discard block |
||
| 2904 | 3059 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2905 | 3060 | |
| 2906 | 3061 | // No smiley set at all?! |
| 2907 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2908 | - return; |
|
| 3062 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 3063 | + return; |
|
| 3064 | + } |
|
| 2909 | 3065 | |
| 2910 | 3066 | // Maybe a mod wants to implement an alternative method (e.g. emojis instead of images) |
| 2911 | 3067 | call_integration_hook('integrate_smileys', array(&$smileyPregSearch, &$smileyPregReplacements)); |
@@ -2919,8 +3075,7 @@ discard block |
||
| 2919 | 3075 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', 'O:-)'); |
| 2920 | 3076 | $smileysto = array('evil.png', 'cheesy.png', 'rolleyes.png', 'angry.png', 'laugh.png', 'smiley.png', 'wink.png', 'grin.png', 'sad.png', 'shocked.png', 'cool.png', 'tongue.png', 'huh.png', 'embarrassed.png', 'lipsrsealed.png', 'kiss.png', 'cry.png', 'undecided.png', 'azn.png', 'afro.png', 'police.png', 'angel.png'); |
| 2921 | 3077 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
| 2922 | - } |
|
| 2923 | - else |
|
| 3078 | + } else |
|
| 2924 | 3079 | { |
| 2925 | 3080 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2926 | 3081 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2944,9 +3099,9 @@ discard block |
||
| 2944 | 3099 | $smcFunc['db_free_result']($result); |
| 2945 | 3100 | |
| 2946 | 3101 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 3102 | + } else { |
|
| 3103 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2947 | 3104 | } |
| 2948 | - else |
|
| 2949 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2950 | 3105 | } |
| 2951 | 3106 | |
| 2952 | 3107 | // The non-breaking-space is a complex thing... |
@@ -2968,16 +3123,18 @@ discard block |
||
| 2968 | 3123 | $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
| 2969 | 3124 | if (!empty($alt_images)) |
| 2970 | 3125 | { |
| 2971 | - foreach ($exts as $ext) |
|
| 2972 | - if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images)) |
|
| 3126 | + foreach ($exts as $ext) { |
|
| 3127 | + if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images)) |
|
| 2973 | 3128 | { |
| 2974 | 3129 | $smileysto[$i] = $fname . '.' . $ext; |
| 3130 | + } |
|
| 2975 | 3131 | break; |
| 2976 | 3132 | } |
| 2977 | 3133 | } |
| 2978 | 3134 | // If we have no image, just leave the text version in place |
| 2979 | - else |
|
| 2980 | - continue; |
|
| 3135 | + else { |
|
| 3136 | + continue; |
|
| 3137 | + } |
|
| 2981 | 3138 | } |
| 2982 | 3139 | |
| 2983 | 3140 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
@@ -3053,12 +3210,14 @@ discard block |
||
| 3053 | 3210 | global $boardurl, $image_proxy_enabled, $image_proxy_secret; |
| 3054 | 3211 | |
| 3055 | 3212 | // Only use the proxy if enabled and necessary |
| 3056 | - if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') |
|
| 3057 | - return $url; |
|
| 3213 | + if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') { |
|
| 3214 | + return $url; |
|
| 3215 | + } |
|
| 3058 | 3216 | |
| 3059 | 3217 | // We don't need to proxy our own resources |
| 3060 | - if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) |
|
| 3061 | - return strtr($url, array('http://' => 'https://')); |
|
| 3218 | + if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) { |
|
| 3219 | + return strtr($url, array('http://' => 'https://')); |
|
| 3220 | + } |
|
| 3062 | 3221 | |
| 3063 | 3222 | // By default, use SMF's own image proxy script |
| 3064 | 3223 | $proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret); |
@@ -3083,35 +3242,41 @@ discard block |
||
| 3083 | 3242 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 3084 | 3243 | |
| 3085 | 3244 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 3086 | - if (!empty($context['flush_mail'])) |
|
| 3087 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3245 | + if (!empty($context['flush_mail'])) { |
|
| 3246 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3088 | 3247 | AddMailQueue(true); |
| 3248 | + } |
|
| 3089 | 3249 | |
| 3090 | 3250 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 3091 | 3251 | |
| 3092 | - if ($add) |
|
| 3093 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3252 | + if ($add) { |
|
| 3253 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3254 | + } |
|
| 3094 | 3255 | |
| 3095 | 3256 | // Put the session ID in. |
| 3096 | - if (defined('SID') && SID != '') |
|
| 3097 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3257 | + if (defined('SID') && SID != '') { |
|
| 3258 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3259 | + } |
|
| 3098 | 3260 | // Keep that debug in their for template debugging! |
| 3099 | - elseif (isset($_GET['debug'])) |
|
| 3100 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3261 | + elseif (isset($_GET['debug'])) { |
|
| 3262 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3263 | + } |
|
| 3101 | 3264 | |
| 3102 | 3265 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
| 3103 | 3266 | { |
| 3104 | - if (defined('SID') && SID != '') |
|
| 3105 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3267 | + if (defined('SID') && SID != '') { |
|
| 3268 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3106 | 3269 | function ($m) use ($scripturl) |
| 3107 | 3270 | { |
| 3108 | 3271 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 3272 | + } |
|
| 3109 | 3273 | }, $setLocation); |
| 3110 | - else |
|
| 3111 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3274 | + else { |
|
| 3275 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3112 | 3276 | function ($m) use ($scripturl) |
| 3113 | 3277 | { |
| 3114 | 3278 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3279 | + } |
|
| 3115 | 3280 | }, $setLocation); |
| 3116 | 3281 | } |
| 3117 | 3282 | |
@@ -3122,8 +3287,9 @@ discard block |
||
| 3122 | 3287 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 3123 | 3288 | |
| 3124 | 3289 | // Debugging. |
| 3125 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3126 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 3290 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3291 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 3292 | + } |
|
| 3127 | 3293 | |
| 3128 | 3294 | obExit(false); |
| 3129 | 3295 | } |
@@ -3142,51 +3308,60 @@ discard block |
||
| 3142 | 3308 | |
| 3143 | 3309 | // Attempt to prevent a recursive loop. |
| 3144 | 3310 | ++$level; |
| 3145 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 3146 | - exit; |
|
| 3147 | - if ($from_fatal_error) |
|
| 3148 | - $has_fatal_error = true; |
|
| 3311 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 3312 | + exit; |
|
| 3313 | + } |
|
| 3314 | + if ($from_fatal_error) { |
|
| 3315 | + $has_fatal_error = true; |
|
| 3316 | + } |
|
| 3149 | 3317 | |
| 3150 | 3318 | // Clear out the stat cache. |
| 3151 | 3319 | trackStats(); |
| 3152 | 3320 | |
| 3153 | 3321 | // If we have mail to send, send it. |
| 3154 | - if (!empty($context['flush_mail'])) |
|
| 3155 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3322 | + if (!empty($context['flush_mail'])) { |
|
| 3323 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3156 | 3324 | AddMailQueue(true); |
| 3325 | + } |
|
| 3157 | 3326 | |
| 3158 | 3327 | $do_header = $header === null ? !$header_done : $header; |
| 3159 | - if ($do_footer === null) |
|
| 3160 | - $do_footer = $do_header; |
|
| 3328 | + if ($do_footer === null) { |
|
| 3329 | + $do_footer = $do_header; |
|
| 3330 | + } |
|
| 3161 | 3331 | |
| 3162 | 3332 | // Has the template/header been done yet? |
| 3163 | 3333 | if ($do_header) |
| 3164 | 3334 | { |
| 3165 | 3335 | // Was the page title set last minute? Also update the HTML safe one. |
| 3166 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 3167 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3336 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3337 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3338 | + } |
|
| 3168 | 3339 | |
| 3169 | 3340 | // Start up the session URL fixer. |
| 3170 | 3341 | ob_start('ob_sessrewrite'); |
| 3171 | 3342 | |
| 3172 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 3173 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 3174 | - elseif (!empty($settings['output_buffers'])) |
|
| 3175 | - $buffers = $settings['output_buffers']; |
|
| 3176 | - else |
|
| 3177 | - $buffers = array(); |
|
| 3343 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3344 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3345 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3346 | + $buffers = $settings['output_buffers']; |
|
| 3347 | + } else { |
|
| 3348 | + $buffers = array(); |
|
| 3349 | + } |
|
| 3178 | 3350 | |
| 3179 | - if (isset($modSettings['integrate_buffer'])) |
|
| 3180 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3351 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3352 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3353 | + } |
|
| 3181 | 3354 | |
| 3182 | - if (!empty($buffers)) |
|
| 3183 | - foreach ($buffers as $function) |
|
| 3355 | + if (!empty($buffers)) { |
|
| 3356 | + foreach ($buffers as $function) |
|
| 3184 | 3357 | { |
| 3185 | 3358 | $call = call_helper($function, true); |
| 3359 | + } |
|
| 3186 | 3360 | |
| 3187 | 3361 | // Is it valid? |
| 3188 | - if (!empty($call)) |
|
| 3189 | - ob_start($call); |
|
| 3362 | + if (!empty($call)) { |
|
| 3363 | + ob_start($call); |
|
| 3364 | + } |
|
| 3190 | 3365 | } |
| 3191 | 3366 | |
| 3192 | 3367 | // Display the screen in the logical order. |
@@ -3198,8 +3373,9 @@ discard block |
||
| 3198 | 3373 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 3199 | 3374 | |
| 3200 | 3375 | // Anything special to put out? |
| 3201 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 3202 | - echo $context['insert_after_template']; |
|
| 3376 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3377 | + echo $context['insert_after_template']; |
|
| 3378 | + } |
|
| 3203 | 3379 | |
| 3204 | 3380 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 3205 | 3381 | if (!$footer_done) |
@@ -3208,14 +3384,16 @@ discard block |
||
| 3208 | 3384 | template_footer(); |
| 3209 | 3385 | |
| 3210 | 3386 | // (since this is just debugging... it's okay that it's after </html>.) |
| 3211 | - if (!isset($_REQUEST['xml'])) |
|
| 3212 | - displayDebug(); |
|
| 3387 | + if (!isset($_REQUEST['xml'])) { |
|
| 3388 | + displayDebug(); |
|
| 3389 | + } |
|
| 3213 | 3390 | } |
| 3214 | 3391 | } |
| 3215 | 3392 | |
| 3216 | 3393 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 3217 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 3218 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3394 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3395 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3396 | + } |
|
| 3219 | 3397 | |
| 3220 | 3398 | // For session check verification.... don't switch browsers... |
| 3221 | 3399 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3224,9 +3402,10 @@ discard block |
||
| 3224 | 3402 | call_integration_hook('integrate_exit', array($do_footer)); |
| 3225 | 3403 | |
| 3226 | 3404 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 3227 | - if (!$from_index) |
|
| 3228 | - exit; |
|
| 3229 | -} |
|
| 3405 | + if (!$from_index) { |
|
| 3406 | + exit; |
|
| 3407 | + } |
|
| 3408 | + } |
|
| 3230 | 3409 | |
| 3231 | 3410 | /** |
| 3232 | 3411 | * Get the size of a specified image with better error handling. |
@@ -3245,8 +3424,9 @@ discard block |
||
| 3245 | 3424 | $url = str_replace(' ', '%20', $url); |
| 3246 | 3425 | |
| 3247 | 3426 | // Can we pull this from the cache... please please? |
| 3248 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 3249 | - return $temp; |
|
| 3427 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3428 | + return $temp; |
|
| 3429 | + } |
|
| 3250 | 3430 | $t = microtime(); |
| 3251 | 3431 | |
| 3252 | 3432 | // Get the host to pester... |
@@ -3256,12 +3436,10 @@ discard block |
||
| 3256 | 3436 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 3257 | 3437 | { |
| 3258 | 3438 | return false; |
| 3259 | - } |
|
| 3260 | - elseif (!isset($match[1])) |
|
| 3439 | + } elseif (!isset($match[1])) |
|
| 3261 | 3440 | { |
| 3262 | 3441 | $size = @getimagesize($url); |
| 3263 | - } |
|
| 3264 | - else |
|
| 3442 | + } else |
|
| 3265 | 3443 | { |
| 3266 | 3444 | // Try to connect to the server... give it half a second. |
| 3267 | 3445 | $temp = 0; |
@@ -3298,12 +3476,14 @@ discard block |
||
| 3298 | 3476 | } |
| 3299 | 3477 | |
| 3300 | 3478 | // If we didn't get it, we failed. |
| 3301 | - if (!isset($size)) |
|
| 3302 | - $size = false; |
|
| 3479 | + if (!isset($size)) { |
|
| 3480 | + $size = false; |
|
| 3481 | + } |
|
| 3303 | 3482 | |
| 3304 | 3483 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3305 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3306 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3484 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3485 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3486 | + } |
|
| 3307 | 3487 | |
| 3308 | 3488 | // Didn't work. |
| 3309 | 3489 | return $size; |
@@ -3321,8 +3501,9 @@ discard block |
||
| 3321 | 3501 | |
| 3322 | 3502 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3323 | 3503 | // So only run the function once unless we are forced to run it again. |
| 3324 | - if ($loaded && !$forceload) |
|
| 3325 | - return; |
|
| 3504 | + if ($loaded && !$forceload) { |
|
| 3505 | + return; |
|
| 3506 | + } |
|
| 3326 | 3507 | |
| 3327 | 3508 | $loaded = true; |
| 3328 | 3509 | |
@@ -3334,14 +3515,16 @@ discard block |
||
| 3334 | 3515 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3335 | 3516 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3336 | 3517 | { |
| 3337 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3338 | - continue; |
|
| 3518 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3519 | + continue; |
|
| 3520 | + } |
|
| 3339 | 3521 | |
| 3340 | 3522 | // Clean it up for presentation ;). |
| 3341 | 3523 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3342 | 3524 | } |
| 3343 | - if (!empty($context['news_lines'])) |
|
| 3344 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3525 | + if (!empty($context['news_lines'])) { |
|
| 3526 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3527 | + } |
|
| 3345 | 3528 | |
| 3346 | 3529 | if (!$user_info['is_guest']) |
| 3347 | 3530 | { |
@@ -3350,40 +3533,48 @@ discard block |
||
| 3350 | 3533 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3351 | 3534 | |
| 3352 | 3535 | // Personal message popup... |
| 3353 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3354 | - $context['user']['popup_messages'] = true; |
|
| 3355 | - else |
|
| 3356 | - $context['user']['popup_messages'] = false; |
|
| 3536 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3537 | + $context['user']['popup_messages'] = true; |
|
| 3538 | + } else { |
|
| 3539 | + $context['user']['popup_messages'] = false; |
|
| 3540 | + } |
|
| 3357 | 3541 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3358 | 3542 | |
| 3359 | - if (allowedTo('moderate_forum')) |
|
| 3360 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3543 | + if (allowedTo('moderate_forum')) { |
|
| 3544 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3545 | + } |
|
| 3361 | 3546 | |
| 3362 | 3547 | $context['user']['avatar'] = array(); |
| 3363 | 3548 | |
| 3364 | 3549 | // Check for gravatar first since we might be forcing them... |
| 3365 | 3550 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3366 | 3551 | { |
| 3367 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3368 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3369 | - else |
|
| 3370 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3552 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3553 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3554 | + } else { |
|
| 3555 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3556 | + } |
|
| 3371 | 3557 | } |
| 3372 | 3558 | // Uploaded? |
| 3373 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3374 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3559 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3560 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3561 | + } |
|
| 3375 | 3562 | // Full URL? |
| 3376 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3377 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3563 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3564 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3565 | + } |
|
| 3378 | 3566 | // Otherwise we assume it's server stored. |
| 3379 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3380 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3567 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3568 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3569 | + } |
|
| 3381 | 3570 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3382 | - else |
|
| 3383 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3571 | + else { |
|
| 3572 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3573 | + } |
|
| 3384 | 3574 | |
| 3385 | - if (!empty($context['user']['avatar'])) |
|
| 3386 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3575 | + if (!empty($context['user']['avatar'])) { |
|
| 3576 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3577 | + } |
|
| 3387 | 3578 | |
| 3388 | 3579 | // Figure out how long they've been logged in. |
| 3389 | 3580 | $context['user']['total_time_logged_in'] = array( |
@@ -3391,8 +3582,7 @@ discard block |
||
| 3391 | 3582 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3392 | 3583 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3393 | 3584 | ); |
| 3394 | - } |
|
| 3395 | - else |
|
| 3585 | + } else |
|
| 3396 | 3586 | { |
| 3397 | 3587 | $context['user']['messages'] = 0; |
| 3398 | 3588 | $context['user']['unread_messages'] = 0; |
@@ -3400,12 +3590,14 @@ discard block |
||
| 3400 | 3590 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3401 | 3591 | $context['user']['popup_messages'] = false; |
| 3402 | 3592 | |
| 3403 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3404 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3593 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3594 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3595 | + } |
|
| 3405 | 3596 | |
| 3406 | 3597 | // If we've upgraded recently, go easy on the passwords. |
| 3407 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3408 | - $context['disable_login_hashing'] = true; |
|
| 3598 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3599 | + $context['disable_login_hashing'] = true; |
|
| 3600 | + } |
|
| 3409 | 3601 | } |
| 3410 | 3602 | |
| 3411 | 3603 | // Setup the main menu items. |
@@ -3418,8 +3610,8 @@ discard block |
||
| 3418 | 3610 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3419 | 3611 | |
| 3420 | 3612 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3421 | - if ($context['show_pm_popup']) |
|
| 3422 | - addInlineJavaScript(' |
|
| 3613 | + if ($context['show_pm_popup']) { |
|
| 3614 | + addInlineJavaScript(' |
|
| 3423 | 3615 | jQuery(document).ready(function($) { |
| 3424 | 3616 | new smc_Popup({ |
| 3425 | 3617 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3427,24 +3619,28 @@ discard block |
||
| 3427 | 3619 | icon_class: \'generic_icons mail_new\' |
| 3428 | 3620 | }); |
| 3429 | 3621 | });'); |
| 3622 | + } |
|
| 3430 | 3623 | |
| 3431 | 3624 | // Add a generic "Are you sure?" confirmation message. |
| 3432 | 3625 | addInlineJavaScript(' |
| 3433 | 3626 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3434 | 3627 | |
| 3435 | 3628 | // Now add the capping code for avatars. |
| 3436 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
| 3437 | - addInlineCss(' |
|
| 3629 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
| 3630 | + addInlineCss(' |
|
| 3438 | 3631 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3632 | + } |
|
| 3439 | 3633 | |
| 3440 | 3634 | // Add max image limits |
| 3441 | - if (!empty($modSettings['max_image_width'])) |
|
| 3442 | - addInlineCss(' |
|
| 3635 | + if (!empty($modSettings['max_image_width'])) { |
|
| 3636 | + addInlineCss(' |
|
| 3443 | 3637 | .postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }'); |
| 3638 | + } |
|
| 3444 | 3639 | |
| 3445 | - if (!empty($modSettings['max_image_height'])) |
|
| 3446 | - addInlineCss(' |
|
| 3640 | + if (!empty($modSettings['max_image_height'])) { |
|
| 3641 | + addInlineCss(' |
|
| 3447 | 3642 | .postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }'); |
| 3643 | + } |
|
| 3448 | 3644 | |
| 3449 | 3645 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3450 | 3646 | $context['common_stats']['latest_member'] = array( |
@@ -3461,11 +3657,13 @@ discard block |
||
| 3461 | 3657 | ); |
| 3462 | 3658 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
| 3463 | 3659 | |
| 3464 | - if (empty($settings['theme_version'])) |
|
| 3465 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3660 | + if (empty($settings['theme_version'])) { |
|
| 3661 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3662 | + } |
|
| 3466 | 3663 | |
| 3467 | - if (!isset($context['page_title'])) |
|
| 3468 | - $context['page_title'] = ''; |
|
| 3664 | + if (!isset($context['page_title'])) { |
|
| 3665 | + $context['page_title'] = ''; |
|
| 3666 | + } |
|
| 3469 | 3667 | |
| 3470 | 3668 | // Set some specific vars. |
| 3471 | 3669 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3475,21 +3673,23 @@ discard block |
||
| 3475 | 3673 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3476 | 3674 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3477 | 3675 | |
| 3478 | - if (!empty($context['meta_keywords'])) |
|
| 3479 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3676 | + if (!empty($context['meta_keywords'])) { |
|
| 3677 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3678 | + } |
|
| 3480 | 3679 | |
| 3481 | - if (!empty($context['canonical_url'])) |
|
| 3482 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3680 | + if (!empty($context['canonical_url'])) { |
|
| 3681 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3682 | + } |
|
| 3483 | 3683 | |
| 3484 | - if (!empty($settings['og_image'])) |
|
| 3485 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3684 | + if (!empty($settings['og_image'])) { |
|
| 3685 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3686 | + } |
|
| 3486 | 3687 | |
| 3487 | 3688 | if (!empty($context['meta_description'])) |
| 3488 | 3689 | { |
| 3489 | 3690 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3490 | 3691 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3491 | - } |
|
| 3492 | - else |
|
| 3692 | + } else |
|
| 3493 | 3693 | { |
| 3494 | 3694 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3495 | 3695 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3514,8 +3714,9 @@ discard block |
||
| 3514 | 3714 | $memory_needed = memoryReturnBytes($needed); |
| 3515 | 3715 | |
| 3516 | 3716 | // should we account for how much is currently being used? |
| 3517 | - if ($in_use) |
|
| 3518 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3717 | + if ($in_use) { |
|
| 3718 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3719 | + } |
|
| 3519 | 3720 | |
| 3520 | 3721 | // if more is needed, request it |
| 3521 | 3722 | if ($memory_current < $memory_needed) |
@@ -3538,8 +3739,9 @@ discard block |
||
| 3538 | 3739 | */ |
| 3539 | 3740 | function memoryReturnBytes($val) |
| 3540 | 3741 | { |
| 3541 | - if (is_integer($val)) |
|
| 3542 | - return $val; |
|
| 3742 | + if (is_integer($val)) { |
|
| 3743 | + return $val; |
|
| 3744 | + } |
|
| 3543 | 3745 | |
| 3544 | 3746 | // Separate the number from the designator |
| 3545 | 3747 | $val = trim($val); |
@@ -3575,10 +3777,11 @@ discard block |
||
| 3575 | 3777 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3576 | 3778 | |
| 3577 | 3779 | // Are we debugging the template/html content? |
| 3578 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3579 | - header('content-type: application/xhtml+xml'); |
|
| 3580 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3581 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3780 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3781 | + header('content-type: application/xhtml+xml'); |
|
| 3782 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3783 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3784 | + } |
|
| 3582 | 3785 | } |
| 3583 | 3786 | |
| 3584 | 3787 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3587,8 +3790,9 @@ discard block |
||
| 3587 | 3790 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3588 | 3791 | { |
| 3589 | 3792 | $position = array_search('body', $context['template_layers']); |
| 3590 | - if ($position === false) |
|
| 3591 | - $position = array_search('main', $context['template_layers']); |
|
| 3793 | + if ($position === false) { |
|
| 3794 | + $position = array_search('main', $context['template_layers']); |
|
| 3795 | + } |
|
| 3592 | 3796 | |
| 3593 | 3797 | if ($position !== false) |
| 3594 | 3798 | { |
@@ -3616,23 +3820,25 @@ discard block |
||
| 3616 | 3820 | |
| 3617 | 3821 | foreach ($securityFiles as $i => $securityFile) |
| 3618 | 3822 | { |
| 3619 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3620 | - unset($securityFiles[$i]); |
|
| 3823 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3824 | + unset($securityFiles[$i]); |
|
| 3825 | + } |
|
| 3621 | 3826 | } |
| 3622 | 3827 | |
| 3623 | 3828 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3624 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3625 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3626 | - |
|
| 3627 | - else |
|
| 3628 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3829 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3830 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3831 | + } else { |
|
| 3832 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3833 | + } |
|
| 3629 | 3834 | |
| 3630 | 3835 | secureDirectory($path, true); |
| 3631 | 3836 | secureDirectory($cachedir); |
| 3632 | 3837 | |
| 3633 | 3838 | // If agreement is enabled, at least the english version shall exists |
| 3634 | - if ($modSettings['requireAgreement']) |
|
| 3635 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3839 | + if ($modSettings['requireAgreement']) { |
|
| 3840 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3841 | + } |
|
| 3636 | 3842 | |
| 3637 | 3843 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3638 | 3844 | { |
@@ -3647,18 +3853,21 @@ discard block |
||
| 3647 | 3853 | echo ' |
| 3648 | 3854 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3649 | 3855 | |
| 3650 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3651 | - echo ' |
|
| 3856 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3857 | + echo ' |
|
| 3652 | 3858 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3859 | + } |
|
| 3653 | 3860 | } |
| 3654 | 3861 | |
| 3655 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3656 | - echo ' |
|
| 3862 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3863 | + echo ' |
|
| 3657 | 3864 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3865 | + } |
|
| 3658 | 3866 | |
| 3659 | - if (!empty($agreement)) |
|
| 3660 | - echo ' |
|
| 3867 | + if (!empty($agreement)) { |
|
| 3868 | + echo ' |
|
| 3661 | 3869 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3870 | + } |
|
| 3662 | 3871 | |
| 3663 | 3872 | echo ' |
| 3664 | 3873 | </p> |
@@ -3673,16 +3882,18 @@ discard block |
||
| 3673 | 3882 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3674 | 3883 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3675 | 3884 | |
| 3676 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3677 | - echo ' |
|
| 3885 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3886 | + echo ' |
|
| 3678 | 3887 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3888 | + } |
|
| 3679 | 3889 | |
| 3680 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3681 | - echo ' |
|
| 3890 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3891 | + echo ' |
|
| 3682 | 3892 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3683 | - else |
|
| 3684 | - echo ' |
|
| 3893 | + } else { |
|
| 3894 | + echo ' |
|
| 3685 | 3895 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3896 | + } |
|
| 3686 | 3897 | |
| 3687 | 3898 | echo ' |
| 3688 | 3899 | </div>'; |
@@ -3698,8 +3909,9 @@ discard block |
||
| 3698 | 3909 | global $forum_copyright, $software_year, $forum_version; |
| 3699 | 3910 | |
| 3700 | 3911 | // Don't display copyright for things like SSI. |
| 3701 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3702 | - return; |
|
| 3912 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3913 | + return; |
|
| 3914 | + } |
|
| 3703 | 3915 | |
| 3704 | 3916 | // Put in the version... |
| 3705 | 3917 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3717,9 +3929,10 @@ discard block |
||
| 3717 | 3929 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
| 3718 | 3930 | $context['load_queries'] = $db_count; |
| 3719 | 3931 | |
| 3720 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3721 | - loadSubTemplate($layer . '_below', true); |
|
| 3722 | -} |
|
| 3932 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3933 | + loadSubTemplate($layer . '_below', true); |
|
| 3934 | + } |
|
| 3935 | + } |
|
| 3723 | 3936 | |
| 3724 | 3937 | /** |
| 3725 | 3938 | * Output the Javascript files |
@@ -3753,8 +3966,7 @@ discard block |
||
| 3753 | 3966 | { |
| 3754 | 3967 | echo ' |
| 3755 | 3968 | var ', $key, ';'; |
| 3756 | - } |
|
| 3757 | - else |
|
| 3969 | + } else |
|
| 3758 | 3970 | { |
| 3759 | 3971 | echo ' |
| 3760 | 3972 | var ', $key, ' = ', $value, ';'; |
@@ -3773,27 +3985,29 @@ discard block |
||
| 3773 | 3985 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3774 | 3986 | { |
| 3775 | 3987 | // Last minute call! allow theme authors to disable single files. |
| 3776 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3777 | - continue; |
|
| 3988 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3989 | + continue; |
|
| 3990 | + } |
|
| 3778 | 3991 | |
| 3779 | 3992 | // By default files don't get minimized unless the file explicitly says so! |
| 3780 | 3993 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3781 | 3994 | { |
| 3782 | - if (!empty($js_file['options']['async'])) |
|
| 3783 | - $toMinify['async'][] = $js_file; |
|
| 3784 | - elseif (!empty($js_file['options']['defer'])) |
|
| 3785 | - $toMinify['defer'][] = $js_file; |
|
| 3786 | - else |
|
| 3787 | - $toMinify['standard'][] = $js_file; |
|
| 3995 | + if (!empty($js_file['options']['async'])) { |
|
| 3996 | + $toMinify['async'][] = $js_file; |
|
| 3997 | + } elseif (!empty($js_file['options']['defer'])) { |
|
| 3998 | + $toMinify['defer'][] = $js_file; |
|
| 3999 | + } else { |
|
| 4000 | + $toMinify['standard'][] = $js_file; |
|
| 4001 | + } |
|
| 3788 | 4002 | |
| 3789 | 4003 | // Grab a random seed. |
| 3790 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
| 3791 | - $minSeed = $js_file['options']['seed']; |
|
| 3792 | - } |
|
| 3793 | - |
|
| 3794 | - else |
|
| 3795 | - echo ' |
|
| 4004 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
| 4005 | + $minSeed = $js_file['options']['seed']; |
|
| 4006 | + } |
|
| 4007 | + } else { |
|
| 4008 | + echo ' |
|
| 3796 | 4009 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>'; |
| 4010 | + } |
|
| 3797 | 4011 | } |
| 3798 | 4012 | |
| 3799 | 4013 | foreach ($toMinify as $js_files) |
@@ -3804,9 +4018,10 @@ discard block |
||
| 3804 | 4018 | |
| 3805 | 4019 | $minSuccessful = array_keys($result) === array('smf_minified'); |
| 3806 | 4020 | |
| 3807 | - foreach ($result as $minFile) |
|
| 3808 | - echo ' |
|
| 4021 | + foreach ($result as $minFile) { |
|
| 4022 | + echo ' |
|
| 3809 | 4023 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>'; |
| 4024 | + } |
|
| 3810 | 4025 | } |
| 3811 | 4026 | } |
| 3812 | 4027 | } |
@@ -3820,8 +4035,9 @@ discard block |
||
| 3820 | 4035 | <script> |
| 3821 | 4036 | window.addEventListener("DOMContentLoaded", function() {'; |
| 3822 | 4037 | |
| 3823 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3824 | - echo $js_code; |
|
| 4038 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 4039 | + echo $js_code; |
|
| 4040 | + } |
|
| 3825 | 4041 | |
| 3826 | 4042 | echo ' |
| 3827 | 4043 | }); |
@@ -3833,8 +4049,9 @@ discard block |
||
| 3833 | 4049 | echo ' |
| 3834 | 4050 | <script>'; |
| 3835 | 4051 | |
| 3836 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3837 | - echo $js_code; |
|
| 4052 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 4053 | + echo $js_code; |
|
| 4054 | + } |
|
| 3838 | 4055 | |
| 3839 | 4056 | echo ' |
| 3840 | 4057 | </script>'; |
@@ -3862,23 +4079,26 @@ discard block |
||
| 3862 | 4079 | foreach ($context['css_files'] as $id => $file) |
| 3863 | 4080 | { |
| 3864 | 4081 | // Last minute call! allow theme authors to disable single files. |
| 3865 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3866 | - continue; |
|
| 4082 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 4083 | + continue; |
|
| 4084 | + } |
|
| 3867 | 4085 | |
| 3868 | 4086 | // Files are minimized unless they explicitly opt out. |
| 3869 | - if (!isset($file['options']['minimize'])) |
|
| 3870 | - $file['options']['minimize'] = true; |
|
| 4087 | + if (!isset($file['options']['minimize'])) { |
|
| 4088 | + $file['options']['minimize'] = true; |
|
| 4089 | + } |
|
| 3871 | 4090 | |
| 3872 | 4091 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3873 | 4092 | { |
| 3874 | 4093 | $toMinify[] = $file; |
| 3875 | 4094 | |
| 3876 | 4095 | // Grab a random seed. |
| 3877 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
| 3878 | - $minSeed = $file['options']['seed']; |
|
| 4096 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
| 4097 | + $minSeed = $file['options']['seed']; |
|
| 4098 | + } |
|
| 4099 | + } else { |
|
| 4100 | + $normal[] = $file['fileUrl']; |
|
| 3879 | 4101 | } |
| 3880 | - else |
|
| 3881 | - $normal[] = $file['fileUrl']; |
|
| 3882 | 4102 | } |
| 3883 | 4103 | |
| 3884 | 4104 | if (!empty($toMinify)) |
@@ -3887,23 +4107,26 @@ discard block |
||
| 3887 | 4107 | |
| 3888 | 4108 | $minSuccessful = array_keys($result) === array('smf_minified'); |
| 3889 | 4109 | |
| 3890 | - foreach ($result as $minFile) |
|
| 3891 | - echo ' |
|
| 4110 | + foreach ($result as $minFile) { |
|
| 4111 | + echo ' |
|
| 3892 | 4112 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
| 4113 | + } |
|
| 3893 | 4114 | } |
| 3894 | 4115 | |
| 3895 | 4116 | // Print the rest after the minified files. |
| 3896 | - if (!empty($normal)) |
|
| 3897 | - foreach ($normal as $nf) |
|
| 4117 | + if (!empty($normal)) { |
|
| 4118 | + foreach ($normal as $nf) |
|
| 3898 | 4119 | echo ' |
| 3899 | 4120 | <link rel="stylesheet" href="', $nf ,'">'; |
| 4121 | + } |
|
| 3900 | 4122 | |
| 3901 | 4123 | if ($db_show_debug === true) |
| 3902 | 4124 | { |
| 3903 | 4125 | // Try to keep only what's useful. |
| 3904 | 4126 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3905 | - foreach ($context['css_files'] as $file) |
|
| 3906 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 4127 | + foreach ($context['css_files'] as $file) { |
|
| 4128 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 4129 | + } |
|
| 3907 | 4130 | } |
| 3908 | 4131 | |
| 3909 | 4132 | if (!empty($context['css_header'])) |
@@ -3911,9 +4134,10 @@ discard block |
||
| 3911 | 4134 | echo ' |
| 3912 | 4135 | <style>'; |
| 3913 | 4136 | |
| 3914 | - foreach ($context['css_header'] as $css) |
|
| 3915 | - echo $css .' |
|
| 4137 | + foreach ($context['css_header'] as $css) { |
|
| 4138 | + echo $css .' |
|
| 3916 | 4139 | '; |
| 4140 | + } |
|
| 3917 | 4141 | |
| 3918 | 4142 | echo' |
| 3919 | 4143 | </style>'; |
@@ -3936,8 +4160,9 @@ discard block |
||
| 3936 | 4160 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3937 | 4161 | $data = is_array($data) ? $data : array(); |
| 3938 | 4162 | |
| 3939 | - if (empty($type) || empty($data)) |
|
| 3940 | - return $data; |
|
| 4163 | + if (empty($type) || empty($data)) { |
|
| 4164 | + return $data; |
|
| 4165 | + } |
|
| 3941 | 4166 | |
| 3942 | 4167 | // Different pages include different files, so we use a hash to label the different combinations |
| 3943 | 4168 | $hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data))); |
@@ -3946,13 +4171,14 @@ discard block |
||
| 3946 | 4171 | list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null); |
| 3947 | 4172 | |
| 3948 | 4173 | // Already done? |
| 3949 | - if (!empty($toCache)) |
|
| 3950 | - return array('smf_minified' => array( |
|
| 4174 | + if (!empty($toCache)) { |
|
| 4175 | + return array('smf_minified' => array( |
|
| 3951 | 4176 | 'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache), |
| 3952 | 4177 | 'filePath' => $toCache, |
| 3953 | 4178 | 'fileName' => basename($toCache), |
| 3954 | 4179 | 'options' => array('async' => !empty($async), 'defer' => !empty($defer)), |
| 3955 | 4180 | )); |
| 4181 | + } |
|
| 3956 | 4182 | |
| 3957 | 4183 | |
| 3958 | 4184 | // No namespaces, sorry! |
@@ -3982,9 +4208,9 @@ discard block |
||
| 3982 | 4208 | |
| 3983 | 4209 | foreach ($data as $id => $file) |
| 3984 | 4210 | { |
| 3985 | - if (empty($file['filePath'])) |
|
| 3986 | - $toAdd = false; |
|
| 3987 | - else |
|
| 4211 | + if (empty($file['filePath'])) { |
|
| 4212 | + $toAdd = false; |
|
| 4213 | + } else |
|
| 3988 | 4214 | { |
| 3989 | 4215 | $seed = isset($file['options']['seed']) ? $file['options']['seed'] : ''; |
| 3990 | 4216 | $tempFile = str_replace($seed, '', $file['filePath']); |
@@ -3992,12 +4218,14 @@ discard block |
||
| 3992 | 4218 | } |
| 3993 | 4219 | |
| 3994 | 4220 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
| 3995 | - if (empty($file['options']['async'])) |
|
| 3996 | - $async = false; |
|
| 4221 | + if (empty($file['options']['async'])) { |
|
| 4222 | + $async = false; |
|
| 4223 | + } |
|
| 3997 | 4224 | |
| 3998 | 4225 | // A minified script should only be deferred if all its components wanted to be. |
| 3999 | - if (empty($file['options']['defer'])) |
|
| 4000 | - $defer = false; |
|
| 4226 | + if (empty($file['options']['defer'])) { |
|
| 4227 | + $defer = false; |
|
| 4228 | + } |
|
| 4001 | 4229 | |
| 4002 | 4230 | // The file couldn't be located so it won't be added. Log this error. |
| 4003 | 4231 | if (empty($toAdd)) |
@@ -4063,12 +4291,14 @@ discard block |
||
| 4063 | 4291 | foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename) |
| 4064 | 4292 | { |
| 4065 | 4293 | // Remove the cache entry |
| 4066 | - if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) |
|
| 4067 | - cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
| 4294 | + if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) { |
|
| 4295 | + cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
| 4296 | + } |
|
| 4068 | 4297 | |
| 4069 | 4298 | // Try to delete the file. Add it to our error list if it fails. |
| 4070 | - if (!@unlink($filename)) |
|
| 4071 | - $not_deleted[] = $filename; |
|
| 4299 | + if (!@unlink($filename)) { |
|
| 4300 | + $not_deleted[] = $filename; |
|
| 4301 | + } |
|
| 4072 | 4302 | } |
| 4073 | 4303 | } |
| 4074 | 4304 | } |
@@ -4100,8 +4330,9 @@ discard block |
||
| 4100 | 4330 | global $modSettings, $smcFunc; |
| 4101 | 4331 | |
| 4102 | 4332 | // Just make up a nice hash... |
| 4103 | - if ($new) |
|
| 4104 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 4333 | + if ($new) { |
|
| 4334 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 4335 | + } |
|
| 4105 | 4336 | |
| 4106 | 4337 | // Just make sure that attachment id is only a int |
| 4107 | 4338 | $attachment_id = (int) $attachment_id; |
@@ -4118,23 +4349,25 @@ discard block |
||
| 4118 | 4349 | 'id_attach' => $attachment_id, |
| 4119 | 4350 | )); |
| 4120 | 4351 | |
| 4121 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 4122 | - return false; |
|
| 4352 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 4353 | + return false; |
|
| 4354 | + } |
|
| 4123 | 4355 | |
| 4124 | 4356 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 4125 | 4357 | $smcFunc['db_free_result']($request); |
| 4126 | 4358 | } |
| 4127 | 4359 | |
| 4128 | 4360 | // Still no hash? mmm... |
| 4129 | - if (empty($file_hash)) |
|
| 4130 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4361 | + if (empty($file_hash)) { |
|
| 4362 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4363 | + } |
|
| 4131 | 4364 | |
| 4132 | 4365 | // Are we using multiple directories? |
| 4133 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 4134 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4135 | - |
|
| 4136 | - else |
|
| 4137 | - $path = $modSettings['attachmentUploadDir']; |
|
| 4366 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 4367 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4368 | + } else { |
|
| 4369 | + $path = $modSettings['attachmentUploadDir']; |
|
| 4370 | + } |
|
| 4138 | 4371 | |
| 4139 | 4372 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 4140 | 4373 | } |
@@ -4149,8 +4382,9 @@ discard block |
||
| 4149 | 4382 | function ip2range($fullip) |
| 4150 | 4383 | { |
| 4151 | 4384 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 4152 | - if ($fullip == 'unknown') |
|
| 4153 | - $fullip = '255.255.255.255'; |
|
| 4385 | + if ($fullip == 'unknown') { |
|
| 4386 | + $fullip = '255.255.255.255'; |
|
| 4387 | + } |
|
| 4154 | 4388 | |
| 4155 | 4389 | $ip_parts = explode('-', $fullip); |
| 4156 | 4390 | $ip_array = array(); |
@@ -4174,10 +4408,11 @@ discard block |
||
| 4174 | 4408 | $ip_array['low'] = $ip_parts[0]; |
| 4175 | 4409 | $ip_array['high'] = $ip_parts[1]; |
| 4176 | 4410 | return $ip_array; |
| 4177 | - } |
|
| 4178 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 4411 | + } elseif (count($ip_parts) == 2) { |
|
| 4412 | + // if ip 22.22.*-22.22.* |
|
| 4179 | 4413 | { |
| 4180 | 4414 | $valid_low = isValidIP($ip_parts[0]); |
| 4415 | + } |
|
| 4181 | 4416 | $valid_high = isValidIP($ip_parts[1]); |
| 4182 | 4417 | $count = 0; |
| 4183 | 4418 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -4192,7 +4427,9 @@ discard block |
||
| 4192 | 4427 | $ip_parts[0] .= $mode . $min; |
| 4193 | 4428 | $valid_low = isValidIP($ip_parts[0]); |
| 4194 | 4429 | $count++; |
| 4195 | - if ($count > 9) break; |
|
| 4430 | + if ($count > 9) { |
|
| 4431 | + break; |
|
| 4432 | + } |
|
| 4196 | 4433 | } |
| 4197 | 4434 | } |
| 4198 | 4435 | |
@@ -4206,7 +4443,9 @@ discard block |
||
| 4206 | 4443 | $ip_parts[1] .= $mode . $max; |
| 4207 | 4444 | $valid_high = isValidIP($ip_parts[1]); |
| 4208 | 4445 | $count++; |
| 4209 | - if ($count > 9) break; |
|
| 4446 | + if ($count > 9) { |
|
| 4447 | + break; |
|
| 4448 | + } |
|
| 4210 | 4449 | } |
| 4211 | 4450 | } |
| 4212 | 4451 | |
@@ -4230,46 +4469,54 @@ discard block |
||
| 4230 | 4469 | { |
| 4231 | 4470 | global $modSettings; |
| 4232 | 4471 | |
| 4233 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 4234 | - return $host; |
|
| 4472 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4473 | + return $host; |
|
| 4474 | + } |
|
| 4235 | 4475 | $t = microtime(); |
| 4236 | 4476 | |
| 4237 | 4477 | // Try the Linux host command, perhaps? |
| 4238 | 4478 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 4239 | 4479 | { |
| 4240 | - if (!isset($modSettings['host_to_dis'])) |
|
| 4241 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4242 | - else |
|
| 4243 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4480 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4481 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4482 | + } else { |
|
| 4483 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4484 | + } |
|
| 4244 | 4485 | |
| 4245 | 4486 | // Did host say it didn't find anything? |
| 4246 | - if (strpos($test, 'not found') !== false) |
|
| 4247 | - $host = ''; |
|
| 4487 | + if (strpos($test, 'not found') !== false) { |
|
| 4488 | + $host = ''; |
|
| 4489 | + } |
|
| 4248 | 4490 | // Invalid server option? |
| 4249 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 4250 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4491 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4492 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4493 | + } |
|
| 4251 | 4494 | // Maybe it found something, after all? |
| 4252 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 4253 | - $host = $match[1]; |
|
| 4495 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4496 | + $host = $match[1]; |
|
| 4497 | + } |
|
| 4254 | 4498 | } |
| 4255 | 4499 | |
| 4256 | 4500 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 4257 | 4501 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 4258 | 4502 | { |
| 4259 | 4503 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 4260 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 4261 | - $host = ''; |
|
| 4262 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 4263 | - $host = $match[1]; |
|
| 4504 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4505 | + $host = ''; |
|
| 4506 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4507 | + $host = $match[1]; |
|
| 4508 | + } |
|
| 4264 | 4509 | } |
| 4265 | 4510 | |
| 4266 | 4511 | // This is the last try :/. |
| 4267 | - if (!isset($host) || $host === false) |
|
| 4268 | - $host = @gethostbyaddr($ip); |
|
| 4512 | + if (!isset($host) || $host === false) { |
|
| 4513 | + $host = @gethostbyaddr($ip); |
|
| 4514 | + } |
|
| 4269 | 4515 | |
| 4270 | 4516 | // It took a long time, so let's cache it! |
| 4271 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 4272 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4517 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4518 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4519 | + } |
|
| 4273 | 4520 | |
| 4274 | 4521 | return $host; |
| 4275 | 4522 | } |
@@ -4305,20 +4552,21 @@ discard block |
||
| 4305 | 4552 | { |
| 4306 | 4553 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 4307 | 4554 | $total = 0; |
| 4308 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 4309 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4555 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4556 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4557 | + } |
|
| 4310 | 4558 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 4311 | 4559 | } |
| 4312 | 4560 | } |
| 4313 | 4561 | return array_unique($returned_ints); |
| 4314 | - } |
|
| 4315 | - else |
|
| 4562 | + } else |
|
| 4316 | 4563 | { |
| 4317 | 4564 | // Trim characters before and after and add slashes for database insertion. |
| 4318 | 4565 | $returned_words = array(); |
| 4319 | - foreach ($words as $word) |
|
| 4320 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4566 | + foreach ($words as $word) { |
|
| 4567 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 4321 | 4568 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4569 | + } |
|
| 4322 | 4570 | |
| 4323 | 4571 | // Filter out all words that occur more than once. |
| 4324 | 4572 | return array_unique($returned_words); |
@@ -4340,16 +4588,18 @@ discard block |
||
| 4340 | 4588 | global $settings, $txt; |
| 4341 | 4589 | |
| 4342 | 4590 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 4343 | - if (function_exists('template_create_button') && !$force_use) |
|
| 4344 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4591 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4592 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4593 | + } |
|
| 4345 | 4594 | |
| 4346 | - if (!$settings['use_image_buttons']) |
|
| 4347 | - return $txt[$alt]; |
|
| 4348 | - elseif (!empty($settings['use_buttons'])) |
|
| 4349 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4350 | - else |
|
| 4351 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4352 | -} |
|
| 4595 | + if (!$settings['use_image_buttons']) { |
|
| 4596 | + return $txt[$alt]; |
|
| 4597 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4598 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4599 | + } else { |
|
| 4600 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4601 | + } |
|
| 4602 | + } |
|
| 4353 | 4603 | |
| 4354 | 4604 | /** |
| 4355 | 4605 | * Sets up all of the top menu buttons |
@@ -4392,9 +4642,10 @@ discard block |
||
| 4392 | 4642 | var user_menus = new smc_PopupMenu(); |
| 4393 | 4643 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4394 | 4644 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 4395 | - if ($context['allow_pm']) |
|
| 4396 | - addInlineJavaScript(' |
|
| 4645 | + if ($context['allow_pm']) { |
|
| 4646 | + addInlineJavaScript(' |
|
| 4397 | 4647 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4648 | + } |
|
| 4398 | 4649 | |
| 4399 | 4650 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4400 | 4651 | { |
@@ -4554,88 +4805,96 @@ discard block |
||
| 4554 | 4805 | |
| 4555 | 4806 | // Now we put the buttons in the context so the theme can use them. |
| 4556 | 4807 | $menu_buttons = array(); |
| 4557 | - foreach ($buttons as $act => $button) |
|
| 4558 | - if (!empty($button['show'])) |
|
| 4808 | + foreach ($buttons as $act => $button) { |
|
| 4809 | + if (!empty($button['show'])) |
|
| 4559 | 4810 | { |
| 4560 | 4811 | $button['active_button'] = false; |
| 4812 | + } |
|
| 4561 | 4813 | |
| 4562 | 4814 | // This button needs some action. |
| 4563 | - if (isset($button['action_hook'])) |
|
| 4564 | - $needs_action_hook = true; |
|
| 4815 | + if (isset($button['action_hook'])) { |
|
| 4816 | + $needs_action_hook = true; |
|
| 4817 | + } |
|
| 4565 | 4818 | |
| 4566 | 4819 | // Make sure the last button truly is the last button. |
| 4567 | 4820 | if (!empty($button['is_last'])) |
| 4568 | 4821 | { |
| 4569 | - if (isset($last_button)) |
|
| 4570 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4822 | + if (isset($last_button)) { |
|
| 4823 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4824 | + } |
|
| 4571 | 4825 | $last_button = $act; |
| 4572 | 4826 | } |
| 4573 | 4827 | |
| 4574 | 4828 | // Go through the sub buttons if there are any. |
| 4575 | - if (!empty($button['sub_buttons'])) |
|
| 4576 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4829 | + if (!empty($button['sub_buttons'])) { |
|
| 4830 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4577 | 4831 | { |
| 4578 | 4832 | if (empty($subbutton['show'])) |
| 4579 | 4833 | unset($button['sub_buttons'][$key]); |
| 4834 | + } |
|
| 4580 | 4835 | |
| 4581 | 4836 | // 2nd level sub buttons next... |
| 4582 | 4837 | if (!empty($subbutton['sub_buttons'])) |
| 4583 | 4838 | { |
| 4584 | 4839 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4585 | 4840 | { |
| 4586 | - if (empty($sub_button2['show'])) |
|
| 4587 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4841 | + if (empty($sub_button2['show'])) { |
|
| 4842 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4843 | + } |
|
| 4588 | 4844 | } |
| 4589 | 4845 | } |
| 4590 | 4846 | } |
| 4591 | 4847 | |
| 4592 | 4848 | // Does this button have its own icon? |
| 4593 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4594 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4595 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4596 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4597 | - elseif (isset($button['icon'])) |
|
| 4598 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4599 | - else |
|
| 4600 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4849 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4850 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4851 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4852 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4853 | + } elseif (isset($button['icon'])) { |
|
| 4854 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4855 | + } else { |
|
| 4856 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4857 | + } |
|
| 4601 | 4858 | |
| 4602 | 4859 | $menu_buttons[$act] = $button; |
| 4603 | 4860 | } |
| 4604 | 4861 | |
| 4605 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4606 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4862 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4863 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4864 | + } |
|
| 4607 | 4865 | } |
| 4608 | 4866 | |
| 4609 | 4867 | $context['menu_buttons'] = $menu_buttons; |
| 4610 | 4868 | |
| 4611 | 4869 | // Logging out requires the session id in the url. |
| 4612 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4613 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4870 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4871 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4872 | + } |
|
| 4614 | 4873 | |
| 4615 | 4874 | // Figure out which action we are doing so we can set the active tab. |
| 4616 | 4875 | // Default to home. |
| 4617 | 4876 | $current_action = 'home'; |
| 4618 | 4877 | |
| 4619 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4620 | - $current_action = $context['current_action']; |
|
| 4621 | - elseif ($context['current_action'] == 'search2') |
|
| 4622 | - $current_action = 'search'; |
|
| 4623 | - elseif ($context['current_action'] == 'theme') |
|
| 4624 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4625 | - elseif ($context['current_action'] == 'register2') |
|
| 4626 | - $current_action = 'register'; |
|
| 4627 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4628 | - $current_action = 'login'; |
|
| 4629 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4630 | - $current_action = 'moderate'; |
|
| 4878 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4879 | + $current_action = $context['current_action']; |
|
| 4880 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4881 | + $current_action = 'search'; |
|
| 4882 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4883 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4884 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4885 | + $current_action = 'register'; |
|
| 4886 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4887 | + $current_action = 'login'; |
|
| 4888 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4889 | + $current_action = 'moderate'; |
|
| 4890 | + } |
|
| 4631 | 4891 | |
| 4632 | 4892 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4633 | 4893 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4634 | 4894 | { |
| 4635 | 4895 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4636 | 4896 | $context[$current_action] = true; |
| 4637 | - } |
|
| 4638 | - elseif ($context['current_action'] == 'pm') |
|
| 4897 | + } elseif ($context['current_action'] == 'pm') |
|
| 4639 | 4898 | { |
| 4640 | 4899 | $current_action = 'self_pm'; |
| 4641 | 4900 | $context['self_pm'] = true; |
@@ -4694,12 +4953,14 @@ discard block |
||
| 4694 | 4953 | } |
| 4695 | 4954 | |
| 4696 | 4955 | // Not all actions are simple. |
| 4697 | - if (!empty($needs_action_hook)) |
|
| 4698 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4956 | + if (!empty($needs_action_hook)) { |
|
| 4957 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4958 | + } |
|
| 4699 | 4959 | |
| 4700 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4701 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4702 | -} |
|
| 4960 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4961 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4962 | + } |
|
| 4963 | + } |
|
| 4703 | 4964 | |
| 4704 | 4965 | /** |
| 4705 | 4966 | * Generate a random seed and ensure it's stored in settings. |
@@ -4723,30 +4984,35 @@ discard block |
||
| 4723 | 4984 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4724 | 4985 | global $context, $txt; |
| 4725 | 4986 | |
| 4726 | - if ($db_show_debug === true) |
|
| 4727 | - $context['debug']['hooks'][] = $hook; |
|
| 4987 | + if ($db_show_debug === true) { |
|
| 4988 | + $context['debug']['hooks'][] = $hook; |
|
| 4989 | + } |
|
| 4728 | 4990 | |
| 4729 | 4991 | // Need to have some control. |
| 4730 | - if (!isset($context['instances'])) |
|
| 4731 | - $context['instances'] = array(); |
|
| 4992 | + if (!isset($context['instances'])) { |
|
| 4993 | + $context['instances'] = array(); |
|
| 4994 | + } |
|
| 4732 | 4995 | |
| 4733 | 4996 | $results = array(); |
| 4734 | - if (empty($modSettings[$hook])) |
|
| 4735 | - return $results; |
|
| 4997 | + if (empty($modSettings[$hook])) { |
|
| 4998 | + return $results; |
|
| 4999 | + } |
|
| 4736 | 5000 | |
| 4737 | 5001 | $functions = explode(',', $modSettings[$hook]); |
| 4738 | 5002 | // Loop through each function. |
| 4739 | 5003 | foreach ($functions as $function) |
| 4740 | 5004 | { |
| 4741 | 5005 | // Hook has been marked as "disabled". Skip it! |
| 4742 | - if (strpos($function, '!') !== false) |
|
| 4743 | - continue; |
|
| 5006 | + if (strpos($function, '!') !== false) { |
|
| 5007 | + continue; |
|
| 5008 | + } |
|
| 4744 | 5009 | |
| 4745 | 5010 | $call = call_helper($function, true); |
| 4746 | 5011 | |
| 4747 | 5012 | // Is it valid? |
| 4748 | - if (!empty($call)) |
|
| 4749 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 5013 | + if (!empty($call)) { |
|
| 5014 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 5015 | + } |
|
| 4750 | 5016 | |
| 4751 | 5017 | // Whatever it was suppose to call, it failed :( |
| 4752 | 5018 | elseif (!empty($function)) |
@@ -4762,8 +5028,9 @@ discard block |
||
| 4762 | 5028 | } |
| 4763 | 5029 | |
| 4764 | 5030 | // "Assume" the file resides on $boarddir somewhere... |
| 4765 | - else |
|
| 4766 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 5031 | + else { |
|
| 5032 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 5033 | + } |
|
| 4767 | 5034 | } |
| 4768 | 5035 | } |
| 4769 | 5036 | |
@@ -4785,12 +5052,14 @@ discard block |
||
| 4785 | 5052 | global $smcFunc, $modSettings; |
| 4786 | 5053 | |
| 4787 | 5054 | // Any objects? |
| 4788 | - if ($object) |
|
| 4789 | - $function = $function . '#'; |
|
| 5055 | + if ($object) { |
|
| 5056 | + $function = $function . '#'; |
|
| 5057 | + } |
|
| 4790 | 5058 | |
| 4791 | 5059 | // Any files to load? |
| 4792 | - if (!empty($file) && is_string($file)) |
|
| 4793 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 5060 | + if (!empty($file) && is_string($file)) { |
|
| 5061 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 5062 | + } |
|
| 4794 | 5063 | |
| 4795 | 5064 | // Get the correct string. |
| 4796 | 5065 | $integration_call = $function; |
@@ -4812,13 +5081,14 @@ discard block |
||
| 4812 | 5081 | if (!empty($current_functions)) |
| 4813 | 5082 | { |
| 4814 | 5083 | $current_functions = explode(',', $current_functions); |
| 4815 | - if (in_array($integration_call, $current_functions)) |
|
| 4816 | - return; |
|
| 5084 | + if (in_array($integration_call, $current_functions)) { |
|
| 5085 | + return; |
|
| 5086 | + } |
|
| 4817 | 5087 | |
| 4818 | 5088 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 5089 | + } else { |
|
| 5090 | + $permanent_functions = array($integration_call); |
|
| 4819 | 5091 | } |
| 4820 | - else |
|
| 4821 | - $permanent_functions = array($integration_call); |
|
| 4822 | 5092 | |
| 4823 | 5093 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4824 | 5094 | } |
@@ -4827,8 +5097,9 @@ discard block |
||
| 4827 | 5097 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4828 | 5098 | |
| 4829 | 5099 | // Do nothing, if it's already there. |
| 4830 | - if (in_array($integration_call, $functions)) |
|
| 4831 | - return; |
|
| 5100 | + if (in_array($integration_call, $functions)) { |
|
| 5101 | + return; |
|
| 5102 | + } |
|
| 4832 | 5103 | |
| 4833 | 5104 | $functions[] = $integration_call; |
| 4834 | 5105 | $modSettings[$hook] = implode(',', $functions); |
@@ -4851,12 +5122,14 @@ discard block |
||
| 4851 | 5122 | global $smcFunc, $modSettings; |
| 4852 | 5123 | |
| 4853 | 5124 | // Any objects? |
| 4854 | - if ($object) |
|
| 4855 | - $function = $function . '#'; |
|
| 5125 | + if ($object) { |
|
| 5126 | + $function = $function . '#'; |
|
| 5127 | + } |
|
| 4856 | 5128 | |
| 4857 | 5129 | // Any files to load? |
| 4858 | - if (!empty($file) && is_string($file)) |
|
| 4859 | - $function = $file . '|' . $function; |
|
| 5130 | + if (!empty($file) && is_string($file)) { |
|
| 5131 | + $function = $file . '|' . $function; |
|
| 5132 | + } |
|
| 4860 | 5133 | |
| 4861 | 5134 | // Get the correct string. |
| 4862 | 5135 | $integration_call = $function; |
@@ -4877,16 +5150,18 @@ discard block |
||
| 4877 | 5150 | { |
| 4878 | 5151 | $current_functions = explode(',', $current_functions); |
| 4879 | 5152 | |
| 4880 | - if (in_array($integration_call, $current_functions)) |
|
| 4881 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 5153 | + if (in_array($integration_call, $current_functions)) { |
|
| 5154 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 5155 | + } |
|
| 4882 | 5156 | } |
| 4883 | 5157 | |
| 4884 | 5158 | // Turn the function list into something usable. |
| 4885 | 5159 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4886 | 5160 | |
| 4887 | 5161 | // You can only remove it if it's available. |
| 4888 | - if (!in_array($integration_call, $functions)) |
|
| 4889 | - return; |
|
| 5162 | + if (!in_array($integration_call, $functions)) { |
|
| 5163 | + return; |
|
| 5164 | + } |
|
| 4890 | 5165 | |
| 4891 | 5166 | $functions = array_diff($functions, array($integration_call)); |
| 4892 | 5167 | $modSettings[$hook] = implode(',', $functions); |
@@ -4907,17 +5182,20 @@ discard block |
||
| 4907 | 5182 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4908 | 5183 | |
| 4909 | 5184 | // Really? |
| 4910 | - if (empty($string)) |
|
| 4911 | - return false; |
|
| 5185 | + if (empty($string)) { |
|
| 5186 | + return false; |
|
| 5187 | + } |
|
| 4912 | 5188 | |
| 4913 | 5189 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4914 | 5190 | // A closure? should be a callable one. |
| 4915 | - if (is_array($string) || $string instanceof Closure) |
|
| 4916 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 5191 | + if (is_array($string) || $string instanceof Closure) { |
|
| 5192 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 5193 | + } |
|
| 4917 | 5194 | |
| 4918 | 5195 | // No full objects, sorry! pass a method or a property instead! |
| 4919 | - if (is_object($string)) |
|
| 4920 | - return false; |
|
| 5196 | + if (is_object($string)) { |
|
| 5197 | + return false; |
|
| 5198 | + } |
|
| 4921 | 5199 | |
| 4922 | 5200 | // Stay vitaminized my friends... |
| 4923 | 5201 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4926,8 +5204,9 @@ discard block |
||
| 4926 | 5204 | $string = load_file($string); |
| 4927 | 5205 | |
| 4928 | 5206 | // Loaded file failed |
| 4929 | - if (empty($string)) |
|
| 4930 | - return false; |
|
| 5207 | + if (empty($string)) { |
|
| 5208 | + return false; |
|
| 5209 | + } |
|
| 4931 | 5210 | |
| 4932 | 5211 | // Found a method. |
| 4933 | 5212 | if (strpos($string, '::') !== false) |
@@ -4948,8 +5227,9 @@ discard block |
||
| 4948 | 5227 | // Add another one to the list. |
| 4949 | 5228 | if ($db_show_debug === true) |
| 4950 | 5229 | { |
| 4951 | - if (!isset($context['debug']['instances'])) |
|
| 4952 | - $context['debug']['instances'] = array(); |
|
| 5230 | + if (!isset($context['debug']['instances'])) { |
|
| 5231 | + $context['debug']['instances'] = array(); |
|
| 5232 | + } |
|
| 4953 | 5233 | |
| 4954 | 5234 | $context['debug']['instances'][$class] = $class; |
| 4955 | 5235 | } |
@@ -4959,13 +5239,15 @@ discard block |
||
| 4959 | 5239 | } |
| 4960 | 5240 | |
| 4961 | 5241 | // Right then. This is a call to a static method. |
| 4962 | - else |
|
| 4963 | - $func = array($class, $method); |
|
| 5242 | + else { |
|
| 5243 | + $func = array($class, $method); |
|
| 5244 | + } |
|
| 4964 | 5245 | } |
| 4965 | 5246 | |
| 4966 | 5247 | // Nope! just a plain regular function. |
| 4967 | - else |
|
| 4968 | - $func = $string; |
|
| 5248 | + else { |
|
| 5249 | + $func = $string; |
|
| 5250 | + } |
|
| 4969 | 5251 | |
| 4970 | 5252 | // Right, we got what we need, time to do some checks. |
| 4971 | 5253 | if (!is_callable($func, false, $callable_name)) |
@@ -4981,17 +5263,18 @@ discard block |
||
| 4981 | 5263 | else |
| 4982 | 5264 | { |
| 4983 | 5265 | // What are we gonna do about it? |
| 4984 | - if ($return) |
|
| 4985 | - return $func; |
|
| 5266 | + if ($return) { |
|
| 5267 | + return $func; |
|
| 5268 | + } |
|
| 4986 | 5269 | |
| 4987 | 5270 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4988 | 5271 | else |
| 4989 | 5272 | { |
| 4990 | - if (is_array($func)) |
|
| 4991 | - call_user_func($func); |
|
| 4992 | - |
|
| 4993 | - else |
|
| 4994 | - $func(); |
|
| 5273 | + if (is_array($func)) { |
|
| 5274 | + call_user_func($func); |
|
| 5275 | + } else { |
|
| 5276 | + $func(); |
|
| 5277 | + } |
|
| 4995 | 5278 | } |
| 4996 | 5279 | } |
| 4997 | 5280 | } |
@@ -5008,31 +5291,34 @@ discard block |
||
| 5008 | 5291 | { |
| 5009 | 5292 | global $sourcedir, $txt, $boarddir, $settings; |
| 5010 | 5293 | |
| 5011 | - if (empty($string)) |
|
| 5012 | - return false; |
|
| 5294 | + if (empty($string)) { |
|
| 5295 | + return false; |
|
| 5296 | + } |
|
| 5013 | 5297 | |
| 5014 | 5298 | if (strpos($string, '|') !== false) |
| 5015 | 5299 | { |
| 5016 | 5300 | list ($file, $string) = explode('|', $string); |
| 5017 | 5301 | |
| 5018 | 5302 | // Match the wildcards to their regular vars. |
| 5019 | - if (empty($settings['theme_dir'])) |
|
| 5020 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 5021 | - |
|
| 5022 | - else |
|
| 5023 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 5303 | + if (empty($settings['theme_dir'])) { |
|
| 5304 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 5305 | + } else { |
|
| 5306 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 5307 | + } |
|
| 5024 | 5308 | |
| 5025 | 5309 | // Load the file if it can be loaded. |
| 5026 | - if (file_exists($absPath)) |
|
| 5027 | - require_once($absPath); |
|
| 5310 | + if (file_exists($absPath)) { |
|
| 5311 | + require_once($absPath); |
|
| 5312 | + } |
|
| 5028 | 5313 | |
| 5029 | 5314 | // No? try a fallback to $sourcedir |
| 5030 | 5315 | else |
| 5031 | 5316 | { |
| 5032 | 5317 | $absPath = $sourcedir .'/'. $file; |
| 5033 | 5318 | |
| 5034 | - if (file_exists($absPath)) |
|
| 5035 | - require_once($absPath); |
|
| 5319 | + if (file_exists($absPath)) { |
|
| 5320 | + require_once($absPath); |
|
| 5321 | + } |
|
| 5036 | 5322 | |
| 5037 | 5323 | // Sorry, can't do much for you at this point. |
| 5038 | 5324 | else |
@@ -5071,8 +5357,9 @@ discard block |
||
| 5071 | 5357 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
| 5072 | 5358 | |
| 5073 | 5359 | // No scheme? No data for you! |
| 5074 | - if (empty($match[1])) |
|
| 5075 | - return false; |
|
| 5360 | + if (empty($match[1])) { |
|
| 5361 | + return false; |
|
| 5362 | + } |
|
| 5076 | 5363 | |
| 5077 | 5364 | // An FTP url. We should try connecting and RETRieving it... |
| 5078 | 5365 | elseif ($match[1] == 'ftp') |
@@ -5082,23 +5369,26 @@ discard block |
||
| 5082 | 5369 | |
| 5083 | 5370 | // Establish a connection and attempt to enable passive mode. |
| 5084 | 5371 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
| 5085 | - if ($ftp->error !== false || !$ftp->passive()) |
|
| 5086 | - return false; |
|
| 5372 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
| 5373 | + return false; |
|
| 5374 | + } |
|
| 5087 | 5375 | |
| 5088 | 5376 | // I want that one *points*! |
| 5089 | 5377 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
| 5090 | 5378 | |
| 5091 | 5379 | // Since passive mode worked (or we would have returned already!) open the connection. |
| 5092 | 5380 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
| 5093 | - if (!$fp) |
|
| 5094 | - return false; |
|
| 5381 | + if (!$fp) { |
|
| 5382 | + return false; |
|
| 5383 | + } |
|
| 5095 | 5384 | |
| 5096 | 5385 | // The server should now say something in acknowledgement. |
| 5097 | 5386 | $ftp->check_response(150); |
| 5098 | 5387 | |
| 5099 | 5388 | $data = ''; |
| 5100 | - while (!feof($fp)) |
|
| 5101 | - $data .= fread($fp, 4096); |
|
| 5389 | + while (!feof($fp)) { |
|
| 5390 | + $data .= fread($fp, 4096); |
|
| 5391 | + } |
|
| 5102 | 5392 | fclose($fp); |
| 5103 | 5393 | |
| 5104 | 5394 | // All done, right? Good. |
@@ -5110,8 +5400,9 @@ discard block |
||
| 5110 | 5400 | elseif (isset($match[1]) && $match[1] == 'http') |
| 5111 | 5401 | { |
| 5112 | 5402 | // First try to use fsockopen, because it is fastest. |
| 5113 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
| 5114 | - $fp = $keep_alive_fp; |
|
| 5403 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
| 5404 | + $fp = $keep_alive_fp; |
|
| 5405 | + } |
|
| 5115 | 5406 | if (empty($fp)) |
| 5116 | 5407 | { |
| 5117 | 5408 | // Open the socket on the port we want... |
@@ -5131,20 +5422,21 @@ discard block |
||
| 5131 | 5422 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
| 5132 | 5423 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 5133 | 5424 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
| 5134 | - if ($keep_alive) |
|
| 5135 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
| 5136 | - else |
|
| 5137 | - fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
| 5138 | - } |
|
| 5139 | - else |
|
| 5425 | + if ($keep_alive) { |
|
| 5426 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
| 5427 | + } else { |
|
| 5428 | + fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
| 5429 | + } |
|
| 5430 | + } else |
|
| 5140 | 5431 | { |
| 5141 | 5432 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
| 5142 | 5433 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 5143 | 5434 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
| 5144 | - if ($keep_alive) |
|
| 5145 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
| 5146 | - else |
|
| 5147 | - fwrite($fp, 'connection: close' . "\r\n"); |
|
| 5435 | + if ($keep_alive) { |
|
| 5436 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
| 5437 | + } else { |
|
| 5438 | + fwrite($fp, 'connection: close' . "\r\n"); |
|
| 5439 | + } |
|
| 5148 | 5440 | fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n"); |
| 5149 | 5441 | fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n"); |
| 5150 | 5442 | fwrite($fp, $post_data); |
@@ -5157,30 +5449,33 @@ discard block |
||
| 5157 | 5449 | { |
| 5158 | 5450 | $header = ''; |
| 5159 | 5451 | $location = ''; |
| 5160 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
| 5161 | - if (strpos($header, 'location:') !== false) |
|
| 5452 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
| 5453 | + if (strpos($header, 'location:') !== false) |
|
| 5162 | 5454 | $location = trim(substr($header, strpos($header, ':') + 1)); |
| 5455 | + } |
|
| 5163 | 5456 | |
| 5164 | - if (empty($location)) |
|
| 5165 | - return false; |
|
| 5166 | - else |
|
| 5457 | + if (empty($location)) { |
|
| 5458 | + return false; |
|
| 5459 | + } else |
|
| 5167 | 5460 | { |
| 5168 | - if (!$keep_alive) |
|
| 5169 | - fclose($fp); |
|
| 5461 | + if (!$keep_alive) { |
|
| 5462 | + fclose($fp); |
|
| 5463 | + } |
|
| 5170 | 5464 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
| 5171 | 5465 | } |
| 5172 | 5466 | } |
| 5173 | 5467 | |
| 5174 | 5468 | // Make sure we get a 200 OK. |
| 5175 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
| 5176 | - return false; |
|
| 5469 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
| 5470 | + return false; |
|
| 5471 | + } |
|
| 5177 | 5472 | |
| 5178 | 5473 | // Skip the headers... |
| 5179 | 5474 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
| 5180 | 5475 | { |
| 5181 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
| 5182 | - $content_length = $match[1]; |
|
| 5183 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
| 5476 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
| 5477 | + $content_length = $match[1]; |
|
| 5478 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
| 5184 | 5479 | { |
| 5185 | 5480 | $keep_alive_dom = null; |
| 5186 | 5481 | $keep_alive = false; |
@@ -5192,17 +5487,19 @@ discard block |
||
| 5192 | 5487 | $data = ''; |
| 5193 | 5488 | if (isset($content_length)) |
| 5194 | 5489 | { |
| 5195 | - while (!feof($fp) && strlen($data) < $content_length) |
|
| 5196 | - $data .= fread($fp, $content_length - strlen($data)); |
|
| 5197 | - } |
|
| 5198 | - else |
|
| 5490 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
| 5491 | + $data .= fread($fp, $content_length - strlen($data)); |
|
| 5492 | + } |
|
| 5493 | + } else |
|
| 5199 | 5494 | { |
| 5200 | - while (!feof($fp)) |
|
| 5201 | - $data .= fread($fp, 4096); |
|
| 5495 | + while (!feof($fp)) { |
|
| 5496 | + $data .= fread($fp, 4096); |
|
| 5497 | + } |
|
| 5202 | 5498 | } |
| 5203 | 5499 | |
| 5204 | - if (!$keep_alive) |
|
| 5205 | - fclose($fp); |
|
| 5500 | + if (!$keep_alive) { |
|
| 5501 | + fclose($fp); |
|
| 5502 | + } |
|
| 5206 | 5503 | } |
| 5207 | 5504 | |
| 5208 | 5505 | // If using fsockopen didn't work, try to use cURL if available. |
@@ -5215,17 +5512,18 @@ discard block |
||
| 5215 | 5512 | $fetch_data->get_url_data($url, $post_data); |
| 5216 | 5513 | |
| 5217 | 5514 | // no errors and a 200 result, then we have a good dataset, well we at least have data. ;) |
| 5218 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
| 5219 | - $data = $fetch_data->result('body'); |
|
| 5220 | - else |
|
| 5221 | - return false; |
|
| 5515 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
| 5516 | + $data = $fetch_data->result('body'); |
|
| 5517 | + } else { |
|
| 5518 | + return false; |
|
| 5519 | + } |
|
| 5222 | 5520 | } |
| 5223 | 5521 | |
| 5224 | 5522 | // Neither fsockopen nor curl are available. Well, phooey. |
| 5225 | - else |
|
| 5226 | - return false; |
|
| 5227 | - } |
|
| 5228 | - else |
|
| 5523 | + else { |
|
| 5524 | + return false; |
|
| 5525 | + } |
|
| 5526 | + } else |
|
| 5229 | 5527 | { |
| 5230 | 5528 | // Umm, this shouldn't happen? |
| 5231 | 5529 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -5245,8 +5543,9 @@ discard block |
||
| 5245 | 5543 | global $user_info, $smcFunc; |
| 5246 | 5544 | |
| 5247 | 5545 | // Make sure we have something to work with. |
| 5248 | - if (empty($topic)) |
|
| 5249 | - return array(); |
|
| 5546 | + if (empty($topic)) { |
|
| 5547 | + return array(); |
|
| 5548 | + } |
|
| 5250 | 5549 | |
| 5251 | 5550 | |
| 5252 | 5551 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -5269,8 +5568,9 @@ discard block |
||
| 5269 | 5568 | 'topic' => $topic, |
| 5270 | 5569 | ) |
| 5271 | 5570 | ); |
| 5272 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 5273 | - $temp[] = (int) $row['content_id']; |
|
| 5571 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5572 | + $temp[] = (int) $row['content_id']; |
|
| 5573 | + } |
|
| 5274 | 5574 | |
| 5275 | 5575 | cache_put_data($cache_key, $temp, $ttl); |
| 5276 | 5576 | } |
@@ -5291,8 +5591,9 @@ discard block |
||
| 5291 | 5591 | { |
| 5292 | 5592 | global $context; |
| 5293 | 5593 | |
| 5294 | - if (empty($string)) |
|
| 5295 | - return $string; |
|
| 5594 | + if (empty($string)) { |
|
| 5595 | + return $string; |
|
| 5596 | + } |
|
| 5296 | 5597 | |
| 5297 | 5598 | // UTF-8 occurences of MS special characters |
| 5298 | 5599 | $findchars_utf8 = array( |
@@ -5333,10 +5634,11 @@ discard block |
||
| 5333 | 5634 | '--', // — |
| 5334 | 5635 | ); |
| 5335 | 5636 | |
| 5336 | - if ($context['utf8']) |
|
| 5337 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5338 | - else |
|
| 5339 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5637 | + if ($context['utf8']) { |
|
| 5638 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5639 | + } else { |
|
| 5640 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5641 | + } |
|
| 5340 | 5642 | |
| 5341 | 5643 | return $string; |
| 5342 | 5644 | } |
@@ -5355,49 +5657,59 @@ discard block |
||
| 5355 | 5657 | { |
| 5356 | 5658 | global $context; |
| 5357 | 5659 | |
| 5358 | - if (!isset($matches[2])) |
|
| 5359 | - return ''; |
|
| 5660 | + if (!isset($matches[2])) { |
|
| 5661 | + return ''; |
|
| 5662 | + } |
|
| 5360 | 5663 | |
| 5361 | 5664 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 5362 | 5665 | |
| 5363 | 5666 | // remove left to right / right to left overrides |
| 5364 | - if ($num === 0x202D || $num === 0x202E) |
|
| 5365 | - return ''; |
|
| 5667 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5668 | + return ''; |
|
| 5669 | + } |
|
| 5366 | 5670 | |
| 5367 | 5671 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 5368 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 5369 | - return '&#' . $num . ';'; |
|
| 5672 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5673 | + return '&#' . $num . ';'; |
|
| 5674 | + } |
|
| 5370 | 5675 | |
| 5371 | 5676 | if (empty($context['utf8'])) |
| 5372 | 5677 | { |
| 5373 | 5678 | // no control characters |
| 5374 | - if ($num < 0x20) |
|
| 5375 | - return ''; |
|
| 5679 | + if ($num < 0x20) { |
|
| 5680 | + return ''; |
|
| 5681 | + } |
|
| 5376 | 5682 | // text is text |
| 5377 | - elseif ($num < 0x80) |
|
| 5378 | - return chr($num); |
|
| 5683 | + elseif ($num < 0x80) { |
|
| 5684 | + return chr($num); |
|
| 5685 | + } |
|
| 5379 | 5686 | // all others get html-ised |
| 5380 | - else |
|
| 5381 | - return '&#' . $matches[2] . ';'; |
|
| 5382 | - } |
|
| 5383 | - else |
|
| 5687 | + else { |
|
| 5688 | + return '&#' . $matches[2] . ';'; |
|
| 5689 | + } |
|
| 5690 | + } else |
|
| 5384 | 5691 | { |
| 5385 | 5692 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 5386 | 5693 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 5387 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 5388 | - return ''; |
|
| 5694 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5695 | + return ''; |
|
| 5696 | + } |
|
| 5389 | 5697 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 5390 | - elseif ($num < 0x80) |
|
| 5391 | - return chr($num); |
|
| 5698 | + elseif ($num < 0x80) { |
|
| 5699 | + return chr($num); |
|
| 5700 | + } |
|
| 5392 | 5701 | // <0x800 (2048) |
| 5393 | - elseif ($num < 0x800) |
|
| 5394 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5702 | + elseif ($num < 0x800) { |
|
| 5703 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5704 | + } |
|
| 5395 | 5705 | // < 0x10000 (65536) |
| 5396 | - elseif ($num < 0x10000) |
|
| 5397 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5706 | + elseif ($num < 0x10000) { |
|
| 5707 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5708 | + } |
|
| 5398 | 5709 | // <= 0x10FFFF (1114111) |
| 5399 | - else |
|
| 5400 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5710 | + else { |
|
| 5711 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5712 | + } |
|
| 5401 | 5713 | } |
| 5402 | 5714 | } |
| 5403 | 5715 | |
@@ -5413,28 +5725,34 @@ discard block |
||
| 5413 | 5725 | */ |
| 5414 | 5726 | function fixchar__callback($matches) |
| 5415 | 5727 | { |
| 5416 | - if (!isset($matches[1])) |
|
| 5417 | - return ''; |
|
| 5728 | + if (!isset($matches[1])) { |
|
| 5729 | + return ''; |
|
| 5730 | + } |
|
| 5418 | 5731 | |
| 5419 | 5732 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 5420 | 5733 | |
| 5421 | 5734 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 5422 | 5735 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 5423 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 5424 | - return ''; |
|
| 5736 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5737 | + return ''; |
|
| 5738 | + } |
|
| 5425 | 5739 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 5426 | - elseif ($num < 0x80) |
|
| 5427 | - return chr($num); |
|
| 5740 | + elseif ($num < 0x80) { |
|
| 5741 | + return chr($num); |
|
| 5742 | + } |
|
| 5428 | 5743 | // <0x800 (2048) |
| 5429 | - elseif ($num < 0x800) |
|
| 5430 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5744 | + elseif ($num < 0x800) { |
|
| 5745 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5746 | + } |
|
| 5431 | 5747 | // < 0x10000 (65536) |
| 5432 | - elseif ($num < 0x10000) |
|
| 5433 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5748 | + elseif ($num < 0x10000) { |
|
| 5749 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5750 | + } |
|
| 5434 | 5751 | // <= 0x10FFFF (1114111) |
| 5435 | - else |
|
| 5436 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5437 | -} |
|
| 5752 | + else { |
|
| 5753 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5754 | + } |
|
| 5755 | + } |
|
| 5438 | 5756 | |
| 5439 | 5757 | /** |
| 5440 | 5758 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -5447,17 +5765,19 @@ discard block |
||
| 5447 | 5765 | */ |
| 5448 | 5766 | function entity_fix__callback($matches) |
| 5449 | 5767 | { |
| 5450 | - if (!isset($matches[2])) |
|
| 5451 | - return ''; |
|
| 5768 | + if (!isset($matches[2])) { |
|
| 5769 | + return ''; |
|
| 5770 | + } |
|
| 5452 | 5771 | |
| 5453 | 5772 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 5454 | 5773 | |
| 5455 | 5774 | // we don't allow control characters, characters out of range, byte markers, etc |
| 5456 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 5457 | - return ''; |
|
| 5458 | - else |
|
| 5459 | - return '&#' . $num . ';'; |
|
| 5460 | -} |
|
| 5775 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5776 | + return ''; |
|
| 5777 | + } else { |
|
| 5778 | + return '&#' . $num . ';'; |
|
| 5779 | + } |
|
| 5780 | + } |
|
| 5461 | 5781 | |
| 5462 | 5782 | /** |
| 5463 | 5783 | * Return a Gravatar URL based on |
@@ -5481,18 +5801,23 @@ discard block |
||
| 5481 | 5801 | $ratings = array('G', 'PG', 'R', 'X'); |
| 5482 | 5802 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 5483 | 5803 | $url_params = array(); |
| 5484 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 5485 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5486 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 5487 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5488 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 5489 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5490 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 5491 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5804 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5805 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5806 | + } |
|
| 5807 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5808 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5809 | + } |
|
| 5810 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5811 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5812 | + } |
|
| 5813 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5814 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5492 | 5815 | $size_string = $modSettings['avatar_max_height_external']; |
| 5816 | + } |
|
| 5493 | 5817 | |
| 5494 | - if (!empty($size_string)) |
|
| 5495 | - $url_params[] = 's=' . $size_string; |
|
| 5818 | + if (!empty($size_string)) { |
|
| 5819 | + $url_params[] = 's=' . $size_string; |
|
| 5820 | + } |
|
| 5496 | 5821 | } |
| 5497 | 5822 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
| 5498 | 5823 | |
@@ -5511,22 +5836,26 @@ discard block |
||
| 5511 | 5836 | static $timezones = null, $lastwhen = null; |
| 5512 | 5837 | |
| 5513 | 5838 | // No point doing this over if we already did it once |
| 5514 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 5515 | - return $timezones; |
|
| 5516 | - else |
|
| 5517 | - $lastwhen = $when; |
|
| 5839 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5840 | + return $timezones; |
|
| 5841 | + } else { |
|
| 5842 | + $lastwhen = $when; |
|
| 5843 | + } |
|
| 5518 | 5844 | |
| 5519 | 5845 | // Parseable datetime string? |
| 5520 | - if (is_int($timestamp = strtotime($when))) |
|
| 5521 | - $when = $timestamp; |
|
| 5846 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5847 | + $when = $timestamp; |
|
| 5848 | + } |
|
| 5522 | 5849 | |
| 5523 | 5850 | // A Unix timestamp? |
| 5524 | - elseif (is_numeric($when)) |
|
| 5525 | - $when = intval($when); |
|
| 5851 | + elseif (is_numeric($when)) { |
|
| 5852 | + $when = intval($when); |
|
| 5853 | + } |
|
| 5526 | 5854 | |
| 5527 | 5855 | // Invalid value? Just get current Unix timestamp. |
| 5528 | - else |
|
| 5529 | - $when = time(); |
|
| 5856 | + else { |
|
| 5857 | + $when = time(); |
|
| 5858 | + } |
|
| 5530 | 5859 | |
| 5531 | 5860 | // We'll need these too |
| 5532 | 5861 | $date_when = date_create('@' . $when); |
@@ -5541,8 +5870,9 @@ discard block |
||
| 5541 | 5870 | foreach ($priority_countries as $country) |
| 5542 | 5871 | { |
| 5543 | 5872 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 5544 | - if (!empty($country_tzids)) |
|
| 5545 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5873 | + if (!empty($country_tzids)) { |
|
| 5874 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5875 | + } |
|
| 5546 | 5876 | } |
| 5547 | 5877 | |
| 5548 | 5878 | // Antarctic research stations should be listed last, unless you're running a penguin forum |
@@ -5556,8 +5886,9 @@ discard block |
||
| 5556 | 5886 | foreach ($tzids as $tzid) |
| 5557 | 5887 | { |
| 5558 | 5888 | // We don't want UTC right now |
| 5559 | - if ($tzid == 'UTC') |
|
| 5560 | - continue; |
|
| 5889 | + if ($tzid == 'UTC') { |
|
| 5890 | + continue; |
|
| 5891 | + } |
|
| 5561 | 5892 | |
| 5562 | 5893 | $tz = timezone_open($tzid); |
| 5563 | 5894 | |
@@ -5578,13 +5909,14 @@ discard block |
||
| 5578 | 5909 | } |
| 5579 | 5910 | |
| 5580 | 5911 | // A time zone from a prioritized country? |
| 5581 | - if (in_array($tzid, $priority_tzids)) |
|
| 5582 | - $priority_zones[$tzkey] = true; |
|
| 5912 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5913 | + $priority_zones[$tzkey] = true; |
|
| 5914 | + } |
|
| 5583 | 5915 | |
| 5584 | 5916 | // Keep track of the location and offset for this tzid |
| 5585 | - if (!empty($txt[$tzid])) |
|
| 5586 | - $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
| 5587 | - else |
|
| 5917 | + if (!empty($txt[$tzid])) { |
|
| 5918 | + $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
| 5919 | + } else |
|
| 5588 | 5920 | { |
| 5589 | 5921 | $tzid_parts = explode('/', $tzid); |
| 5590 | 5922 | $zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop($tzid_parts)); |
@@ -5604,23 +5936,27 @@ discard block |
||
| 5604 | 5936 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5605 | 5937 | |
| 5606 | 5938 | // Use the custom description, if there is one |
| 5607 | - if (!empty($tztxt[$tzvalue['tzid']])) |
|
| 5608 | - $desc = $tztxt[$tzvalue['tzid']]; |
|
| 5939 | + if (!empty($tztxt[$tzvalue['tzid']])) { |
|
| 5940 | + $desc = $tztxt[$tzvalue['tzid']]; |
|
| 5941 | + } |
|
| 5609 | 5942 | // Otherwise, use the list of locations (max 5, so things don't get silly) |
| 5610 | - else |
|
| 5611 | - $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
| 5943 | + else { |
|
| 5944 | + $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
| 5945 | + } |
|
| 5612 | 5946 | |
| 5613 | 5947 | // Show the UTC offset and the abbreviation, if it's something like 'MST' and not '-06' |
| 5614 | 5948 | $desc = '[UTC' . date_format($date_when, 'P') . '] - ' . (!strspn($tzvalue['abbr'], '+-') ? $tzvalue['abbr'] . ' - ' : '') . $desc; |
| 5615 | 5949 | |
| 5616 | - if (isset($priority_zones[$tzkey])) |
|
| 5617 | - $priority_timezones[$tzvalue['tzid']] = $desc; |
|
| 5618 | - else |
|
| 5619 | - $timezones[$tzvalue['tzid']] = $desc; |
|
| 5950 | + if (isset($priority_zones[$tzkey])) { |
|
| 5951 | + $priority_timezones[$tzvalue['tzid']] = $desc; |
|
| 5952 | + } else { |
|
| 5953 | + $timezones[$tzvalue['tzid']] = $desc; |
|
| 5954 | + } |
|
| 5620 | 5955 | } |
| 5621 | 5956 | |
| 5622 | - if (!empty($priority_timezones)) |
|
| 5623 | - $priority_timezones[] = '-----'; |
|
| 5957 | + if (!empty($priority_timezones)) { |
|
| 5958 | + $priority_timezones[] = '-----'; |
|
| 5959 | + } |
|
| 5624 | 5960 | |
| 5625 | 5961 | $timezones = array_merge( |
| 5626 | 5962 | $priority_timezones, |
@@ -5637,8 +5973,9 @@ discard block |
||
| 5637 | 5973 | */ |
| 5638 | 5974 | function inet_ptod($ip_address) |
| 5639 | 5975 | { |
| 5640 | - if (!isValidIP($ip_address)) |
|
| 5641 | - return $ip_address; |
|
| 5976 | + if (!isValidIP($ip_address)) { |
|
| 5977 | + return $ip_address; |
|
| 5978 | + } |
|
| 5642 | 5979 | |
| 5643 | 5980 | $bin = inet_pton($ip_address); |
| 5644 | 5981 | return $bin; |
@@ -5650,13 +5987,15 @@ discard block |
||
| 5650 | 5987 | */ |
| 5651 | 5988 | function inet_dtop($bin) |
| 5652 | 5989 | { |
| 5653 | - if(empty($bin)) |
|
| 5654 | - return ''; |
|
| 5990 | + if(empty($bin)) { |
|
| 5991 | + return ''; |
|
| 5992 | + } |
|
| 5655 | 5993 | |
| 5656 | 5994 | global $db_type; |
| 5657 | 5995 | |
| 5658 | - if ($db_type == 'postgresql') |
|
| 5659 | - return $bin; |
|
| 5996 | + if ($db_type == 'postgresql') { |
|
| 5997 | + return $bin; |
|
| 5998 | + } |
|
| 5660 | 5999 | |
| 5661 | 6000 | $ip_address = inet_ntop($bin); |
| 5662 | 6001 | |
@@ -5681,26 +6020,32 @@ discard block |
||
| 5681 | 6020 | */ |
| 5682 | 6021 | function _safe_serialize($value) |
| 5683 | 6022 | { |
| 5684 | - if(is_null($value)) |
|
| 5685 | - return 'N;'; |
|
| 6023 | + if(is_null($value)) { |
|
| 6024 | + return 'N;'; |
|
| 6025 | + } |
|
| 5686 | 6026 | |
| 5687 | - if(is_bool($value)) |
|
| 5688 | - return 'b:'. (int) $value .';'; |
|
| 6027 | + if(is_bool($value)) { |
|
| 6028 | + return 'b:'. (int) $value .';'; |
|
| 6029 | + } |
|
| 5689 | 6030 | |
| 5690 | - if(is_int($value)) |
|
| 5691 | - return 'i:'. $value .';'; |
|
| 6031 | + if(is_int($value)) { |
|
| 6032 | + return 'i:'. $value .';'; |
|
| 6033 | + } |
|
| 5692 | 6034 | |
| 5693 | - if(is_float($value)) |
|
| 5694 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 6035 | + if(is_float($value)) { |
|
| 6036 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 6037 | + } |
|
| 5695 | 6038 | |
| 5696 | - if(is_string($value)) |
|
| 5697 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 6039 | + if(is_string($value)) { |
|
| 6040 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 6041 | + } |
|
| 5698 | 6042 | |
| 5699 | 6043 | if(is_array($value)) |
| 5700 | 6044 | { |
| 5701 | 6045 | $out = ''; |
| 5702 | - foreach($value as $k => $v) |
|
| 5703 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 6046 | + foreach($value as $k => $v) { |
|
| 6047 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 6048 | + } |
|
| 5704 | 6049 | |
| 5705 | 6050 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5706 | 6051 | } |
@@ -5726,8 +6071,9 @@ discard block |
||
| 5726 | 6071 | |
| 5727 | 6072 | $out = _safe_serialize($value); |
| 5728 | 6073 | |
| 5729 | - if (isset($mbIntEnc)) |
|
| 5730 | - mb_internal_encoding($mbIntEnc); |
|
| 6074 | + if (isset($mbIntEnc)) { |
|
| 6075 | + mb_internal_encoding($mbIntEnc); |
|
| 6076 | + } |
|
| 5731 | 6077 | |
| 5732 | 6078 | return $out; |
| 5733 | 6079 | } |
@@ -5744,8 +6090,9 @@ discard block |
||
| 5744 | 6090 | function _safe_unserialize($str) |
| 5745 | 6091 | { |
| 5746 | 6092 | // Input is not a string. |
| 5747 | - if(empty($str) || !is_string($str)) |
|
| 5748 | - return false; |
|
| 6093 | + if(empty($str) || !is_string($str)) { |
|
| 6094 | + return false; |
|
| 6095 | + } |
|
| 5749 | 6096 | |
| 5750 | 6097 | $stack = array(); |
| 5751 | 6098 | $expected = array(); |
@@ -5761,43 +6108,38 @@ discard block |
||
| 5761 | 6108 | while($state != 1) |
| 5762 | 6109 | { |
| 5763 | 6110 | $type = isset($str[0]) ? $str[0] : ''; |
| 5764 | - if($type == '}') |
|
| 5765 | - $str = substr($str, 1); |
|
| 5766 | - |
|
| 5767 | - else if($type == 'N' && $str[1] == ';') |
|
| 6111 | + if($type == '}') { |
|
| 6112 | + $str = substr($str, 1); |
|
| 6113 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5768 | 6114 | { |
| 5769 | 6115 | $value = null; |
| 5770 | 6116 | $str = substr($str, 2); |
| 5771 | - } |
|
| 5772 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 6117 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5773 | 6118 | { |
| 5774 | 6119 | $value = $matches[1] == '1' ? true : false; |
| 5775 | 6120 | $str = substr($str, 4); |
| 5776 | - } |
|
| 5777 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 6121 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5778 | 6122 | { |
| 5779 | 6123 | $value = (int)$matches[1]; |
| 5780 | 6124 | $str = $matches[2]; |
| 5781 | - } |
|
| 5782 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 6125 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5783 | 6126 | { |
| 5784 | 6127 | $value = (float)$matches[1]; |
| 5785 | 6128 | $str = $matches[3]; |
| 5786 | - } |
|
| 5787 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 6129 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5788 | 6130 | { |
| 5789 | 6131 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5790 | 6132 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5791 | - } |
|
| 5792 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 6133 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5793 | 6134 | { |
| 5794 | 6135 | $expectedLength = (int)$matches[1]; |
| 5795 | 6136 | $str = $matches[2]; |
| 5796 | 6137 | } |
| 5797 | 6138 | |
| 5798 | 6139 | // Object or unknown/malformed type. |
| 5799 | - else |
|
| 5800 | - return false; |
|
| 6140 | + else { |
|
| 6141 | + return false; |
|
| 6142 | + } |
|
| 5801 | 6143 | |
| 5802 | 6144 | switch($state) |
| 5803 | 6145 | { |
@@ -5825,8 +6167,9 @@ discard block |
||
| 5825 | 6167 | if($type == '}') |
| 5826 | 6168 | { |
| 5827 | 6169 | // Array size is less than expected. |
| 5828 | - if(count($list) < end($expected)) |
|
| 5829 | - return false; |
|
| 6170 | + if(count($list) < end($expected)) { |
|
| 6171 | + return false; |
|
| 6172 | + } |
|
| 5830 | 6173 | |
| 5831 | 6174 | unset($list); |
| 5832 | 6175 | $list = &$stack[count($stack)-1]; |
@@ -5835,8 +6178,9 @@ discard block |
||
| 5835 | 6178 | // Go to terminal state if we're at the end of the root array. |
| 5836 | 6179 | array_pop($expected); |
| 5837 | 6180 | |
| 5838 | - if(count($expected) == 0) |
|
| 5839 | - $state = 1; |
|
| 6181 | + if(count($expected) == 0) { |
|
| 6182 | + $state = 1; |
|
| 6183 | + } |
|
| 5840 | 6184 | |
| 5841 | 6185 | break; |
| 5842 | 6186 | } |
@@ -5844,8 +6188,9 @@ discard block |
||
| 5844 | 6188 | if($type == 'i' || $type == 's') |
| 5845 | 6189 | { |
| 5846 | 6190 | // Array size exceeds expected length. |
| 5847 | - if(count($list) >= end($expected)) |
|
| 5848 | - return false; |
|
| 6191 | + if(count($list) >= end($expected)) { |
|
| 6192 | + return false; |
|
| 6193 | + } |
|
| 5849 | 6194 | |
| 5850 | 6195 | $key = $value; |
| 5851 | 6196 | $state = 3; |
@@ -5879,8 +6224,9 @@ discard block |
||
| 5879 | 6224 | } |
| 5880 | 6225 | |
| 5881 | 6226 | // Trailing data in input. |
| 5882 | - if(!empty($str)) |
|
| 5883 | - return false; |
|
| 6227 | + if(!empty($str)) { |
|
| 6228 | + return false; |
|
| 6229 | + } |
|
| 5884 | 6230 | |
| 5885 | 6231 | return $data; |
| 5886 | 6232 | } |
@@ -5903,8 +6249,9 @@ discard block |
||
| 5903 | 6249 | |
| 5904 | 6250 | $out = _safe_unserialize($str); |
| 5905 | 6251 | |
| 5906 | - if (isset($mbIntEnc)) |
|
| 5907 | - mb_internal_encoding($mbIntEnc); |
|
| 6252 | + if (isset($mbIntEnc)) { |
|
| 6253 | + mb_internal_encoding($mbIntEnc); |
|
| 6254 | + } |
|
| 5908 | 6255 | |
| 5909 | 6256 | return $out; |
| 5910 | 6257 | } |
@@ -5919,12 +6266,14 @@ discard block |
||
| 5919 | 6266 | function smf_chmod($file, $value = 0) |
| 5920 | 6267 | { |
| 5921 | 6268 | // No file? no checks! |
| 5922 | - if (empty($file)) |
|
| 5923 | - return false; |
|
| 6269 | + if (empty($file)) { |
|
| 6270 | + return false; |
|
| 6271 | + } |
|
| 5924 | 6272 | |
| 5925 | 6273 | // Already writable? |
| 5926 | - if (is_writable($file)) |
|
| 5927 | - return true; |
|
| 6274 | + if (is_writable($file)) { |
|
| 6275 | + return true; |
|
| 6276 | + } |
|
| 5928 | 6277 | |
| 5929 | 6278 | // Do we have a file or a dir? |
| 5930 | 6279 | $isDir = is_dir($file); |
@@ -5940,10 +6289,9 @@ discard block |
||
| 5940 | 6289 | { |
| 5941 | 6290 | $isWritable = true; |
| 5942 | 6291 | break; |
| 6292 | + } else { |
|
| 6293 | + @chmod($file, $val); |
|
| 5943 | 6294 | } |
| 5944 | - |
|
| 5945 | - else |
|
| 5946 | - @chmod($file, $val); |
|
| 5947 | 6295 | } |
| 5948 | 6296 | |
| 5949 | 6297 | return $isWritable; |
@@ -5962,8 +6310,9 @@ discard block |
||
| 5962 | 6310 | global $txt; |
| 5963 | 6311 | |
| 5964 | 6312 | // Come on... |
| 5965 | - if (empty($json) || !is_string($json)) |
|
| 5966 | - return array(); |
|
| 6313 | + if (empty($json) || !is_string($json)) { |
|
| 6314 | + return array(); |
|
| 6315 | + } |
|
| 5967 | 6316 | |
| 5968 | 6317 | $returnArray = @json_decode($json, $returnAsArray); |
| 5969 | 6318 | |
@@ -6001,11 +6350,11 @@ discard block |
||
| 6001 | 6350 | $jsonDebug = $jsonDebug[0]; |
| 6002 | 6351 | loadLanguage('Errors'); |
| 6003 | 6352 | |
| 6004 | - if (!empty($jsonDebug)) |
|
| 6005 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6006 | - |
|
| 6007 | - else |
|
| 6008 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6353 | + if (!empty($jsonDebug)) { |
|
| 6354 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6355 | + } else { |
|
| 6356 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6357 | + } |
|
| 6009 | 6358 | |
| 6010 | 6359 | // Everyone expects an array. |
| 6011 | 6360 | return array(); |
@@ -6039,8 +6388,9 @@ discard block |
||
| 6039 | 6388 | global $db_show_debug, $modSettings; |
| 6040 | 6389 | |
| 6041 | 6390 | // Defensive programming anyone? |
| 6042 | - if (empty($data)) |
|
| 6043 | - return false; |
|
| 6391 | + if (empty($data)) { |
|
| 6392 | + return false; |
|
| 6393 | + } |
|
| 6044 | 6394 | |
| 6045 | 6395 | // Don't need extra stuff... |
| 6046 | 6396 | $db_show_debug = false; |
@@ -6048,11 +6398,11 @@ discard block |
||
| 6048 | 6398 | // Kill anything else. |
| 6049 | 6399 | ob_end_clean(); |
| 6050 | 6400 | |
| 6051 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 6052 | - @ob_start('ob_gzhandler'); |
|
| 6053 | - |
|
| 6054 | - else |
|
| 6055 | - ob_start(); |
|
| 6401 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 6402 | + @ob_start('ob_gzhandler'); |
|
| 6403 | + } else { |
|
| 6404 | + ob_start(); |
|
| 6405 | + } |
|
| 6056 | 6406 | |
| 6057 | 6407 | // Set the header. |
| 6058 | 6408 | header($type); |
@@ -6084,8 +6434,9 @@ discard block |
||
| 6084 | 6434 | static $done = false; |
| 6085 | 6435 | |
| 6086 | 6436 | // If we don't need to do anything, don't |
| 6087 | - if (!$update && $done) |
|
| 6088 | - return; |
|
| 6437 | + if (!$update && $done) { |
|
| 6438 | + return; |
|
| 6439 | + } |
|
| 6089 | 6440 | |
| 6090 | 6441 | // Should we get a new copy of the official list of TLDs? |
| 6091 | 6442 | if ($update) |
@@ -6097,8 +6448,9 @@ discard block |
||
| 6097 | 6448 | // marauding bandits roaming on the surface. We don't want to waste precious electricity on |
| 6098 | 6449 | // pointlessly repeating background tasks, so we'll wait until the next regularly scheduled |
| 6099 | 6450 | // update to see if civilization has been restored. |
| 6100 | - if ($tlds === false) |
|
| 6101 | - $postapocalypticNightmare = true; |
|
| 6451 | + if ($tlds === false) { |
|
| 6452 | + $postapocalypticNightmare = true; |
|
| 6453 | + } |
|
| 6102 | 6454 | } |
| 6103 | 6455 | // If we aren't updating and the regex is valid, we're done |
| 6104 | 6456 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -6113,10 +6465,11 @@ discard block |
||
| 6113 | 6465 | // Clean $tlds and convert it to an array |
| 6114 | 6466 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 6115 | 6467 | $line = trim($line); |
| 6116 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 6117 | - return false; |
|
| 6118 | - else |
|
| 6119 | - return true; |
|
| 6468 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 6469 | + return false; |
|
| 6470 | + } else { |
|
| 6471 | + return true; |
|
| 6472 | + } |
|
| 6120 | 6473 | }); |
| 6121 | 6474 | |
| 6122 | 6475 | // Convert Punycode to Unicode |
@@ -6208,8 +6561,7 @@ discard block |
||
| 6208 | 6561 | |
| 6209 | 6562 | $strlen = 'mb_strlen'; |
| 6210 | 6563 | $substr = 'mb_substr'; |
| 6211 | - } |
|
| 6212 | - else |
|
| 6564 | + } else |
|
| 6213 | 6565 | { |
| 6214 | 6566 | $strlen = $smcFunc['strlen']; |
| 6215 | 6567 | $substr = $smcFunc['substr']; |
@@ -6223,20 +6575,21 @@ discard block |
||
| 6223 | 6575 | |
| 6224 | 6576 | $first = $substr($string, 0, 1); |
| 6225 | 6577 | |
| 6226 | - if (empty($index[$first])) |
|
| 6227 | - $index[$first] = array(); |
|
| 6578 | + if (empty($index[$first])) { |
|
| 6579 | + $index[$first] = array(); |
|
| 6580 | + } |
|
| 6228 | 6581 | |
| 6229 | 6582 | if ($strlen($string) > 1) |
| 6230 | 6583 | { |
| 6231 | 6584 | // Sanity check on recursion |
| 6232 | - if ($depth > 99) |
|
| 6233 | - $index[$first][$substr($string, 1)] = ''; |
|
| 6234 | - |
|
| 6235 | - else |
|
| 6236 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6585 | + if ($depth > 99) { |
|
| 6586 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6587 | + } else { |
|
| 6588 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6589 | + } |
|
| 6590 | + } else { |
|
| 6591 | + $index[$first][''] = ''; |
|
| 6237 | 6592 | } |
| 6238 | - else |
|
| 6239 | - $index[$first][''] = ''; |
|
| 6240 | 6593 | |
| 6241 | 6594 | $depth--; |
| 6242 | 6595 | return $index; |
@@ -6259,9 +6612,9 @@ discard block |
||
| 6259 | 6612 | $key_regex = preg_quote($key, $delim); |
| 6260 | 6613 | $new_key = $key; |
| 6261 | 6614 | |
| 6262 | - if (empty($value)) |
|
| 6263 | - $sub_regex = ''; |
|
| 6264 | - else |
|
| 6615 | + if (empty($value)) { |
|
| 6616 | + $sub_regex = ''; |
|
| 6617 | + } else |
|
| 6265 | 6618 | { |
| 6266 | 6619 | $sub_regex = $index_to_regex($value, $delim); |
| 6267 | 6620 | |
@@ -6269,22 +6622,22 @@ discard block |
||
| 6269 | 6622 | { |
| 6270 | 6623 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 6271 | 6624 | $new_key .= $new_key_array[0]; |
| 6625 | + } else { |
|
| 6626 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6272 | 6627 | } |
| 6273 | - else |
|
| 6274 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6275 | 6628 | } |
| 6276 | 6629 | |
| 6277 | - if ($depth > 1) |
|
| 6278 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6279 | - else |
|
| 6630 | + if ($depth > 1) { |
|
| 6631 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6632 | + } else |
|
| 6280 | 6633 | { |
| 6281 | 6634 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 6282 | 6635 | { |
| 6283 | 6636 | $regex[$new_key] = $key_regex . $sub_regex; |
| 6284 | 6637 | unset($index[$key]); |
| 6638 | + } else { |
|
| 6639 | + break; |
|
| 6285 | 6640 | } |
| 6286 | - else |
|
| 6287 | - break; |
|
| 6288 | 6641 | } |
| 6289 | 6642 | } |
| 6290 | 6643 | |
@@ -6293,10 +6646,11 @@ discard block |
||
| 6293 | 6646 | $l1 = $strlen($k1); |
| 6294 | 6647 | $l2 = $strlen($k2); |
| 6295 | 6648 | |
| 6296 | - if ($l1 == $l2) |
|
| 6297 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6298 | - else |
|
| 6299 | - return $l1 > $l2 ? -1 : 1; |
|
| 6649 | + if ($l1 == $l2) { |
|
| 6650 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6651 | + } else { |
|
| 6652 | + return $l1 > $l2 ? -1 : 1; |
|
| 6653 | + } |
|
| 6300 | 6654 | }); |
| 6301 | 6655 | |
| 6302 | 6656 | $depth--; |
@@ -6307,21 +6661,24 @@ discard block |
||
| 6307 | 6661 | $index = array(); |
| 6308 | 6662 | $regex = ''; |
| 6309 | 6663 | |
| 6310 | - foreach ($strings as $string) |
|
| 6311 | - $index = $add_string_to_index($string, $index); |
|
| 6664 | + foreach ($strings as $string) { |
|
| 6665 | + $index = $add_string_to_index($string, $index); |
|
| 6666 | + } |
|
| 6312 | 6667 | |
| 6313 | 6668 | if ($returnArray === true) |
| 6314 | 6669 | { |
| 6315 | 6670 | $regex = array(); |
| 6316 | - while (!empty($index)) |
|
| 6317 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6671 | + while (!empty($index)) { |
|
| 6672 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6673 | + } |
|
| 6674 | + } else { |
|
| 6675 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6318 | 6676 | } |
| 6319 | - else |
|
| 6320 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6321 | 6677 | |
| 6322 | 6678 | // Restore PHP's internal character encoding to whatever it was originally |
| 6323 | - if (!empty($current_encoding)) |
|
| 6324 | - mb_internal_encoding($current_encoding); |
|
| 6679 | + if (!empty($current_encoding)) { |
|
| 6680 | + mb_internal_encoding($current_encoding); |
|
| 6681 | + } |
|
| 6325 | 6682 | |
| 6326 | 6683 | return $regex; |
| 6327 | 6684 | } |
@@ -6364,13 +6721,15 @@ discard block |
||
| 6364 | 6721 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
| 6365 | 6722 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
| 6366 | 6723 | $headers = @get_headers($url); |
| 6367 | - if ($headers === false) |
|
| 6368 | - return false; |
|
| 6724 | + if ($headers === false) { |
|
| 6725 | + return false; |
|
| 6726 | + } |
|
| 6369 | 6727 | |
| 6370 | 6728 | // Now to see if it came back https... |
| 6371 | 6729 | // First check for a redirect status code in first row (301, 302, 307) |
| 6372 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
| 6373 | - return false; |
|
| 6730 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
| 6731 | + return false; |
|
| 6732 | + } |
|
| 6374 | 6733 | |
| 6375 | 6734 | // Search for the location entry to confirm https |
| 6376 | 6735 | $result = false; |
@@ -6408,8 +6767,7 @@ discard block |
||
| 6408 | 6767 | $is_admin = $user_info['is_admin']; |
| 6409 | 6768 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
| 6410 | 6769 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
| 6411 | - } |
|
| 6412 | - else |
|
| 6770 | + } else |
|
| 6413 | 6771 | { |
| 6414 | 6772 | $request = $smcFunc['db_query']('', ' |
| 6415 | 6773 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6423,17 +6781,19 @@ discard block |
||
| 6423 | 6781 | |
| 6424 | 6782 | $row = $smcFunc['db_fetch_assoc']($request); |
| 6425 | 6783 | |
| 6426 | - if (empty($row['additional_groups'])) |
|
| 6427 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6428 | - else |
|
| 6429 | - $groups = array_merge( |
|
| 6784 | + if (empty($row['additional_groups'])) { |
|
| 6785 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6786 | + } else { |
|
| 6787 | + $groups = array_merge( |
|
| 6430 | 6788 | array($row['id_group'], $row['id_post_group']), |
| 6431 | 6789 | explode(',', $row['additional_groups']) |
| 6432 | 6790 | ); |
| 6791 | + } |
|
| 6433 | 6792 | |
| 6434 | 6793 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 6435 | - foreach ($groups as $k => $v) |
|
| 6436 | - $groups[$k] = (int) $v; |
|
| 6794 | + foreach ($groups as $k => $v) { |
|
| 6795 | + $groups[$k] = (int) $v; |
|
| 6796 | + } |
|
| 6437 | 6797 | |
| 6438 | 6798 | $is_admin = in_array(1, $groups); |
| 6439 | 6799 | |
@@ -6450,8 +6810,9 @@ discard block |
||
| 6450 | 6810 | 'current_member' => $userid, |
| 6451 | 6811 | ) |
| 6452 | 6812 | ); |
| 6453 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6454 | - $boards_mod[] = $row['id_board']; |
|
| 6813 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6814 | + $boards_mod[] = $row['id_board']; |
|
| 6815 | + } |
|
| 6455 | 6816 | $smcFunc['db_free_result']($request); |
| 6456 | 6817 | |
| 6457 | 6818 | // Can any of the groups they're in moderate any of the boards? |
@@ -6463,8 +6824,9 @@ discard block |
||
| 6463 | 6824 | 'groups' => $groups, |
| 6464 | 6825 | ) |
| 6465 | 6826 | ); |
| 6466 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6467 | - $boards_mod[] = $row['id_board']; |
|
| 6827 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6828 | + $boards_mod[] = $row['id_board']; |
|
| 6829 | + } |
|
| 6468 | 6830 | $smcFunc['db_free_result']($request); |
| 6469 | 6831 | |
| 6470 | 6832 | // Just in case we've got duplicates here... |
@@ -6474,21 +6836,25 @@ discard block |
||
| 6474 | 6836 | } |
| 6475 | 6837 | |
| 6476 | 6838 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 6477 | - if ($is_admin) |
|
| 6478 | - $query_part['query_see_board'] = '1=1'; |
|
| 6839 | + if ($is_admin) { |
|
| 6840 | + $query_part['query_see_board'] = '1=1'; |
|
| 6841 | + } |
|
| 6479 | 6842 | // Otherwise just the groups in $user_info['groups']. |
| 6480 | - else |
|
| 6481 | - $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6843 | + else { |
|
| 6844 | + $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6845 | + } |
|
| 6482 | 6846 | |
| 6483 | 6847 | // Build the list of boards they WANT to see. |
| 6484 | 6848 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 6485 | 6849 | |
| 6486 | 6850 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 6487 | - if (empty($ignoreboards)) |
|
| 6488 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6851 | + if (empty($ignoreboards)) { |
|
| 6852 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6853 | + } |
|
| 6489 | 6854 | // Ok I guess they don't want to see all the boards |
| 6490 | - else |
|
| 6491 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6855 | + else { |
|
| 6856 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6857 | + } |
|
| 6492 | 6858 | |
| 6493 | 6859 | return $query_part; |
| 6494 | 6860 | } |
@@ -6502,10 +6868,11 @@ discard block |
||
| 6502 | 6868 | { |
| 6503 | 6869 | $secure = false; |
| 6504 | 6870 | |
| 6505 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 6506 | - $secure = true; |
|
| 6507 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 6508 | - $secure = true; |
|
| 6871 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 6872 | + $secure = true; |
|
| 6873 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 6874 | + $secure = true; |
|
| 6875 | + } |
|
| 6509 | 6876 | |
| 6510 | 6877 | return $secure; |
| 6511 | 6878 | } |
@@ -6522,11 +6889,12 @@ discard block |
||
| 6522 | 6889 | { |
| 6523 | 6890 | $url = iri_to_url($iri); |
| 6524 | 6891 | |
| 6525 | - if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) |
|
| 6526 | - return $iri; |
|
| 6527 | - else |
|
| 6528 | - return false; |
|
| 6529 | -} |
|
| 6892 | + if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) { |
|
| 6893 | + return $iri; |
|
| 6894 | + } else { |
|
| 6895 | + return false; |
|
| 6896 | + } |
|
| 6897 | + } |
|
| 6530 | 6898 | |
| 6531 | 6899 | /** |
| 6532 | 6900 | * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs |
@@ -6569,8 +6937,9 @@ discard block |
||
| 6569 | 6937 | |
| 6570 | 6938 | $host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST); |
| 6571 | 6939 | |
| 6572 | - if (empty($host)) |
|
| 6573 | - return $iri; |
|
| 6940 | + if (empty($host)) { |
|
| 6941 | + return $iri; |
|
| 6942 | + } |
|
| 6574 | 6943 | |
| 6575 | 6944 | // Convert the domain using the Punycode algorithm |
| 6576 | 6945 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6606,8 +6975,9 @@ discard block |
||
| 6606 | 6975 | |
| 6607 | 6976 | $host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST); |
| 6608 | 6977 | |
| 6609 | - if (empty($host)) |
|
| 6610 | - return $url; |
|
| 6978 | + if (empty($host)) { |
|
| 6979 | + return $url; |
|
| 6980 | + } |
|
| 6611 | 6981 | |
| 6612 | 6982 | // Decode the domain from Punycode |
| 6613 | 6983 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6633,8 +7003,9 @@ discard block |
||
| 6633 | 7003 | { |
| 6634 | 7004 | global $user_info, $modSettings, $smcFunc, $txt; |
| 6635 | 7005 | |
| 6636 | - if (empty($modSettings['cron_last_checked'])) |
|
| 6637 | - $modSettings['cron_last_checked'] = 0; |
|
| 7006 | + if (empty($modSettings['cron_last_checked'])) { |
|
| 7007 | + $modSettings['cron_last_checked'] = 0; |
|
| 7008 | + } |
|
| 6638 | 7009 | |
| 6639 | 7010 | if (!empty($modSettings['cron_is_real_cron']) && time() - $modSettings['cron_last_checked'] > 84600) |
| 6640 | 7011 | { |
@@ -6654,9 +7025,9 @@ discard block |
||
| 6654 | 7025 | loadLanguage('ManageScheduledTasks'); |
| 6655 | 7026 | log_error($txt['cron_not_working']); |
| 6656 | 7027 | updateSettings(array('cron_is_real_cron' => 0)); |
| 7028 | + } else { |
|
| 7029 | + updateSettings(array('cron_last_checked' => time())); |
|
| 6657 | 7030 | } |
| 6658 | - else |
|
| 6659 | - updateSettings(array('cron_last_checked' => time())); |
|
| 6660 | 7031 | } |
| 6661 | 7032 | } |
| 6662 | 7033 | |
@@ -6680,10 +7051,11 @@ discard block |
||
| 6680 | 7051 | |
| 6681 | 7052 | $protocol = preg_match('~^\s*(HTTP/[12]\.\d)\s*$~i', $_SERVER['SERVER_PROTOCOL'], $matches) ? $matches[1] : 'HTTP/1.0'; |
| 6682 | 7053 | |
| 6683 | - if (!isset($statuses[$code]) && empty($status)) |
|
| 6684 | - header($protocol . ' 500 Internal Server Error'); |
|
| 6685 | - else |
|
| 6686 | - header($protocol . ' ' . $code . ' ' . (!empty($status) ? $status : $statuses[$code])); |
|
| 6687 | -} |
|
| 7054 | + if (!isset($statuses[$code]) && empty($status)) { |
|
| 7055 | + header($protocol . ' 500 Internal Server Error'); |
|
| 7056 | + } else { |
|
| 7057 | + header($protocol . ' ' . $code . ' ' . (!empty($status) ? $status : $statuses[$code])); |
|
| 7058 | + } |
|
| 7059 | + } |
|
| 6688 | 7060 | |
| 6689 | 7061 | ?> |
| 6690 | 7062 | \ No newline at end of file |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | { |
| 392 | 392 | $val = 'CASE '; |
| 393 | 393 | foreach ($members as $k => $v) |
| 394 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 394 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 395 | 395 | $val = $val . ' END'; |
| 396 | 396 | $type = 'raw'; |
| 397 | 397 | } |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | static $non_twelve_hour, $locale_cache; |
| 745 | 745 | static $unsupportedFormats, $finalizedFormats; |
| 746 | 746 | |
| 747 | - $unsupportedFormatsWindows = array('z','Z'); |
|
| 747 | + $unsupportedFormatsWindows = array('z', 'Z'); |
|
| 748 | 748 | |
| 749 | 749 | // Ensure required values are set |
| 750 | 750 | $user_info['time_offset'] = !empty($user_info['time_offset']) ? $user_info['time_offset'] : 0; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
| 830 | 830 | if (empty($unsupportedFormats)) |
| 831 | 831 | { |
| 832 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
| 832 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
| 833 | 833 | { |
| 834 | 834 | // Avoid a crashing bug with PHP 7 on certain versions of Windows |
| 835 | 835 | if ($context['server']['is_windows'] && in_array($format, $unsupportedFormatsWindows)) |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
| 1207 | 1207 | ), |
| 1208 | 1208 | 'content' => '$1', |
| 1209 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1209 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1210 | 1210 | { |
| 1211 | 1211 | $returnContext = ''; |
| 1212 | 1212 | |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
| 1244 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1244 | + $returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>'; |
|
| 1245 | 1245 | else |
| 1246 | 1246 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
| 1247 | 1247 | } |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | 'type' => 'unparsed_content', |
| 1294 | 1294 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
| 1295 | 1295 | // @todo Maybe this can be simplified? |
| 1296 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1296 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1297 | 1297 | { |
| 1298 | 1298 | if (!isset($disabled['code'])) |
| 1299 | 1299 | { |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | 'type' => 'unparsed_equals_content', |
| 1331 | 1331 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
| 1332 | 1332 | // @todo Maybe this can be simplified? |
| 1333 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1333 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1334 | 1334 | { |
| 1335 | 1335 | if (!isset($disabled['code'])) |
| 1336 | 1336 | { |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | 'type' => 'unparsed_content', |
| 1375 | 1375 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
| 1376 | 1376 | // @todo Should this respect guest_hideContacts? |
| 1377 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1377 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1378 | 1378 | { |
| 1379 | 1379 | $data = strtr($data, array('<br>' => '')); |
| 1380 | 1380 | }, |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
| 1395 | 1395 | 'before' => '<div $1>', |
| 1396 | 1396 | 'after' => '</div>', |
| 1397 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1397 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1398 | 1398 | { |
| 1399 | 1399 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1400 | 1400 | |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
| 1481 | 1481 | ), |
| 1482 | 1482 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
| 1483 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1483 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1484 | 1484 | { |
| 1485 | 1485 | global $image_proxy_enabled, $user_info; |
| 1486 | 1486 | |
@@ -1506,7 +1506,7 @@ discard block |
||
| 1506 | 1506 | 'tag' => 'img', |
| 1507 | 1507 | 'type' => 'unparsed_content', |
| 1508 | 1508 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
| 1509 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1509 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1510 | 1510 | { |
| 1511 | 1511 | global $image_proxy_enabled, $user_info; |
| 1512 | 1512 | |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | 'tag' => 'iurl', |
| 1533 | 1533 | 'type' => 'unparsed_content', |
| 1534 | 1534 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
| 1535 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1535 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1536 | 1536 | { |
| 1537 | 1537 | $data = strtr($data, array('<br>' => '')); |
| 1538 | 1538 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | 'quoted' => 'optional', |
| 1547 | 1547 | 'before' => '<a href="$1" class="bbc_link">', |
| 1548 | 1548 | 'after' => '</a>', |
| 1549 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1549 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1550 | 1550 | { |
| 1551 | 1551 | if (substr($data, 0, 1) == '#') |
| 1552 | 1552 | $data = '#post_' . substr($data, 1); |
@@ -1639,7 +1639,7 @@ discard block |
||
| 1639 | 1639 | 'tag' => 'php', |
| 1640 | 1640 | 'type' => 'unparsed_content', |
| 1641 | 1641 | 'content' => '<span class="phpcode">$1</span>', |
| 1642 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
| 1642 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
| 1643 | 1643 | { |
| 1644 | 1644 | if (!isset($disabled['php'])) |
| 1645 | 1645 | { |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | 'test' => '[1-7]\]', |
| 1789 | 1789 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
| 1790 | 1790 | 'after' => '</span>', |
| 1791 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1791 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1792 | 1792 | { |
| 1793 | 1793 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
| 1794 | 1794 | $data = $sizes[$data] . 'em'; |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | 'tag' => 'time', |
| 1827 | 1827 | 'type' => 'unparsed_content', |
| 1828 | 1828 | 'content' => '$1', |
| 1829 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1829 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1830 | 1830 | { |
| 1831 | 1831 | if (is_numeric($data)) |
| 1832 | 1832 | $data = timeformat($data); |
@@ -1859,7 +1859,7 @@ discard block |
||
| 1859 | 1859 | 'tag' => 'url', |
| 1860 | 1860 | 'type' => 'unparsed_content', |
| 1861 | 1861 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
| 1862 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1862 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1863 | 1863 | { |
| 1864 | 1864 | $data = strtr($data, array('<br>' => '')); |
| 1865 | 1865 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1873,7 +1873,7 @@ discard block |
||
| 1873 | 1873 | 'quoted' => 'optional', |
| 1874 | 1874 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
| 1875 | 1875 | 'after' => '</a>', |
| 1876 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1876 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1877 | 1877 | { |
| 1878 | 1878 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1879 | 1879 | if (empty($scheme)) |
@@ -1919,7 +1919,7 @@ discard block |
||
| 1919 | 1919 | { |
| 1920 | 1920 | if (isset($temp_bbc)) |
| 1921 | 1921 | $bbc_codes = $temp_bbc; |
| 1922 | - usort($codes, function ($a, $b) { |
|
| 1922 | + usort($codes, function($a, $b) { |
|
| 1923 | 1923 | return strcmp($a['tag'], $b['tag']); |
| 1924 | 1924 | }); |
| 1925 | 1925 | return $codes; |
@@ -2135,7 +2135,7 @@ discard block |
||
| 2135 | 2135 | # a run of Unicode domain name characters and a dot |
| 2136 | 2136 | [\p{L}\p{M}\p{N}\-.:@]+\. |
| 2137 | 2137 | # and then a TLD valid in the DNS or the reserved "local" TLD |
| 2138 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
| 2138 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
| 2139 | 2139 | ) |
| 2140 | 2140 | # followed by a non-domain character or end of line |
| 2141 | 2141 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2203,7 +2203,7 @@ discard block |
||
| 2203 | 2203 | )? |
| 2204 | 2204 | '; |
| 2205 | 2205 | |
| 2206 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
| 2206 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
| 2207 | 2207 | $url = array_shift($matches); |
| 2208 | 2208 | |
| 2209 | 2209 | // If this isn't a clean URL, bail out |
@@ -2228,7 +2228,7 @@ discard block |
||
| 2228 | 2228 | $fullUrl = $url; |
| 2229 | 2229 | |
| 2230 | 2230 | // Make sure that $fullUrl really is valid |
| 2231 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
| 2231 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '') . $fullUrl) === false) |
|
| 2232 | 2232 | return $url; |
| 2233 | 2233 | |
| 2234 | 2234 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
@@ -2292,7 +2292,7 @@ discard block |
||
| 2292 | 2292 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2293 | 2293 | |
| 2294 | 2294 | // A closing tag that doesn't match any open tags? Skip it. |
| 2295 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
| 2295 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
| 2296 | 2296 | continue; |
| 2297 | 2297 | |
| 2298 | 2298 | $to_close = array(); |
@@ -2965,7 +2965,7 @@ discard block |
||
| 2965 | 2965 | { |
| 2966 | 2966 | $exts = array('svg', 'png', 'gif', 'jpg'); |
| 2967 | 2967 | $fname = pathinfo($smileysto[$i], PATHINFO_FILENAME); |
| 2968 | - $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
|
| 2968 | + $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
|
| 2969 | 2969 | if (!empty($alt_images)) |
| 2970 | 2970 | { |
| 2971 | 2971 | foreach ($exts as $ext) |
@@ -2981,7 +2981,7 @@ discard block |
||
| 2981 | 2981 | } |
| 2982 | 2982 | |
| 2983 | 2983 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
| 2984 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2984 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2985 | 2985 | |
| 2986 | 2986 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
| 2987 | 2987 | |
@@ -3006,7 +3006,7 @@ discard block |
||
| 3006 | 3006 | |
| 3007 | 3007 | // Replace away! |
| 3008 | 3008 | $message = preg_replace_callback($smileyPregSearch, |
| 3009 | - function ($matches) use ($smileyPregReplacements) |
|
| 3009 | + function($matches) use ($smileyPregReplacements) |
|
| 3010 | 3010 | { |
| 3011 | 3011 | return $smileyPregReplacements[$matches[1]]; |
| 3012 | 3012 | }, $message); |
@@ -3103,13 +3103,13 @@ discard block |
||
| 3103 | 3103 | { |
| 3104 | 3104 | if (defined('SID') && SID != '') |
| 3105 | 3105 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
| 3106 | - function ($m) use ($scripturl) |
|
| 3106 | + function($m) use ($scripturl) |
|
| 3107 | 3107 | { |
| 3108 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
| 3108 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
| 3109 | 3109 | }, $setLocation); |
| 3110 | 3110 | else |
| 3111 | 3111 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
| 3112 | - function ($m) use ($scripturl) |
|
| 3112 | + function($m) use ($scripturl) |
|
| 3113 | 3113 | { |
| 3114 | 3114 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3115 | 3115 | }, $setLocation); |
@@ -3430,7 +3430,7 @@ discard block |
||
| 3430 | 3430 | |
| 3431 | 3431 | // Add a generic "Are you sure?" confirmation message. |
| 3432 | 3432 | addInlineJavaScript(' |
| 3433 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
| 3433 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
| 3434 | 3434 | |
| 3435 | 3435 | // Now add the capping code for avatars. |
| 3436 | 3436 | if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
@@ -3896,7 +3896,7 @@ discard block |
||
| 3896 | 3896 | if (!empty($normal)) |
| 3897 | 3897 | foreach ($normal as $nf) |
| 3898 | 3898 | echo ' |
| 3899 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
| 3899 | + <link rel="stylesheet" href="', $nf, '">'; |
|
| 3900 | 3900 | |
| 3901 | 3901 | if ($db_show_debug === true) |
| 3902 | 3902 | { |
@@ -3912,7 +3912,7 @@ discard block |
||
| 3912 | 3912 | <style>'; |
| 3913 | 3913 | |
| 3914 | 3914 | foreach ($context['css_header'] as $css) |
| 3915 | - echo $css .' |
|
| 3915 | + echo $css . ' |
|
| 3916 | 3916 | '; |
| 3917 | 3917 | |
| 3918 | 3918 | echo' |
@@ -3956,7 +3956,7 @@ discard block |
||
| 3956 | 3956 | |
| 3957 | 3957 | |
| 3958 | 3958 | // No namespaces, sorry! |
| 3959 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
| 3959 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
| 3960 | 3960 | |
| 3961 | 3961 | // Temp path. |
| 3962 | 3962 | $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
@@ -4136,7 +4136,7 @@ discard block |
||
| 4136 | 4136 | else |
| 4137 | 4137 | $path = $modSettings['attachmentUploadDir']; |
| 4138 | 4138 | |
| 4139 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
| 4139 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
| 4140 | 4140 | } |
| 4141 | 4141 | |
| 4142 | 4142 | /** |
@@ -4180,10 +4180,10 @@ discard block |
||
| 4180 | 4180 | $valid_low = isValidIP($ip_parts[0]); |
| 4181 | 4181 | $valid_high = isValidIP($ip_parts[1]); |
| 4182 | 4182 | $count = 0; |
| 4183 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
| 4183 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
| 4184 | 4184 | $max = ($mode == ':' ? 'ffff' : '255'); |
| 4185 | 4185 | $min = 0; |
| 4186 | - if(!$valid_low) |
|
| 4186 | + if (!$valid_low) |
|
| 4187 | 4187 | { |
| 4188 | 4188 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
| 4189 | 4189 | $valid_low = isValidIP($ip_parts[0]); |
@@ -4197,7 +4197,7 @@ discard block |
||
| 4197 | 4197 | } |
| 4198 | 4198 | |
| 4199 | 4199 | $count = 0; |
| 4200 | - if(!$valid_high) |
|
| 4200 | + if (!$valid_high) |
|
| 4201 | 4201 | { |
| 4202 | 4202 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
| 4203 | 4203 | $valid_high = isValidIP($ip_parts[1]); |
@@ -4210,7 +4210,7 @@ discard block |
||
| 4210 | 4210 | } |
| 4211 | 4211 | } |
| 4212 | 4212 | |
| 4213 | - if($valid_high && $valid_low) |
|
| 4213 | + if ($valid_high && $valid_low) |
|
| 4214 | 4214 | { |
| 4215 | 4215 | $ip_array['low'] = $ip_parts[0]; |
| 4216 | 4216 | $ip_array['high'] = $ip_parts[1]; |
@@ -4391,7 +4391,7 @@ discard block |
||
| 4391 | 4391 | addInlineJavaScript(' |
| 4392 | 4392 | var user_menus = new smc_PopupMenu(); |
| 4393 | 4393 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4394 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
| 4394 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
| 4395 | 4395 | if ($context['allow_pm']) |
| 4396 | 4396 | addInlineJavaScript(' |
| 4397 | 4397 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4686,7 +4686,7 @@ discard block |
||
| 4686 | 4686 | $total_admin_reports += $context['unapproved_members']; |
| 4687 | 4687 | } |
| 4688 | 4688 | |
| 4689 | - if($total_admin_reports > 0 && !empty($context['menu_buttons']['admin'])) |
|
| 4689 | + if ($total_admin_reports > 0 && !empty($context['menu_buttons']['admin'])) |
|
| 4690 | 4690 | { |
| 4691 | 4691 | $context['menu_buttons']['admin']['title'] .= ' <span class="amt">' . $total_admin_reports . '</span>'; |
| 4692 | 4692 | } |
@@ -5033,7 +5033,7 @@ discard block |
||
| 5033 | 5033 | // No? try a fallback to $sourcedir |
| 5034 | 5034 | else |
| 5035 | 5035 | { |
| 5036 | - $absPath = $sourcedir .'/'. $file; |
|
| 5036 | + $absPath = $sourcedir . '/' . $file; |
|
| 5037 | 5037 | |
| 5038 | 5038 | if (file_exists($absPath)) |
| 5039 | 5039 | require_once($absPath); |
@@ -5300,15 +5300,15 @@ discard block |
||
| 5300 | 5300 | |
| 5301 | 5301 | // UTF-8 occurences of MS special characters |
| 5302 | 5302 | $findchars_utf8 = array( |
| 5303 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 5304 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 5305 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
| 5306 | - "\xe2\x80\x98", // left single curly quote |
|
| 5307 | - "\xe2\x80\x99", // right single curly quote |
|
| 5308 | - "\xe2\x80\x9c", // left double curly quote |
|
| 5309 | - "\xe2\x80\x9d", // right double curly quote |
|
| 5310 | - "\xe2\x80\x93", // en dash |
|
| 5311 | - "\xe2\x80\x94", // em dash |
|
| 5303 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 5304 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 5305 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
| 5306 | + "\xe2\x80\x98", // left single curly quote |
|
| 5307 | + "\xe2\x80\x99", // right single curly quote |
|
| 5308 | + "\xe2\x80\x9c", // left double curly quote |
|
| 5309 | + "\xe2\x80\x9d", // right double curly quote |
|
| 5310 | + "\xe2\x80\x93", // en dash |
|
| 5311 | + "\xe2\x80\x94", // em dash |
|
| 5312 | 5312 | ); |
| 5313 | 5313 | |
| 5314 | 5314 | // windows 1252 / iso equivalents |
@@ -5326,15 +5326,15 @@ discard block |
||
| 5326 | 5326 | |
| 5327 | 5327 | // safe replacements |
| 5328 | 5328 | $replacechars = array( |
| 5329 | - ',', // ‚ |
|
| 5330 | - ',,', // „ |
|
| 5331 | - '...', // … |
|
| 5332 | - "'", // ‘ |
|
| 5333 | - "'", // ’ |
|
| 5334 | - '"', // “ |
|
| 5335 | - '"', // ” |
|
| 5336 | - '-', // – |
|
| 5337 | - '--', // — |
|
| 5329 | + ',', // ‚ |
|
| 5330 | + ',,', // „ |
|
| 5331 | + '...', // … |
|
| 5332 | + "'", // ‘ |
|
| 5333 | + "'", // ’ |
|
| 5334 | + '"', // “ |
|
| 5335 | + '"', // ” |
|
| 5336 | + '-', // – |
|
| 5337 | + '--', // — |
|
| 5338 | 5338 | ); |
| 5339 | 5339 | |
| 5340 | 5340 | if ($context['utf8']) |
@@ -5654,7 +5654,7 @@ discard block |
||
| 5654 | 5654 | */ |
| 5655 | 5655 | function inet_dtop($bin) |
| 5656 | 5656 | { |
| 5657 | - if(empty($bin)) |
|
| 5657 | + if (empty($bin)) |
|
| 5658 | 5658 | return ''; |
| 5659 | 5659 | |
| 5660 | 5660 | global $db_type; |
@@ -5685,28 +5685,28 @@ discard block |
||
| 5685 | 5685 | */ |
| 5686 | 5686 | function _safe_serialize($value) |
| 5687 | 5687 | { |
| 5688 | - if(is_null($value)) |
|
| 5688 | + if (is_null($value)) |
|
| 5689 | 5689 | return 'N;'; |
| 5690 | 5690 | |
| 5691 | - if(is_bool($value)) |
|
| 5692 | - return 'b:'. (int) $value .';'; |
|
| 5691 | + if (is_bool($value)) |
|
| 5692 | + return 'b:' . (int) $value . ';'; |
|
| 5693 | 5693 | |
| 5694 | - if(is_int($value)) |
|
| 5695 | - return 'i:'. $value .';'; |
|
| 5694 | + if (is_int($value)) |
|
| 5695 | + return 'i:' . $value . ';'; |
|
| 5696 | 5696 | |
| 5697 | - if(is_float($value)) |
|
| 5698 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5697 | + if (is_float($value)) |
|
| 5698 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
| 5699 | 5699 | |
| 5700 | - if(is_string($value)) |
|
| 5701 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5700 | + if (is_string($value)) |
|
| 5701 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 5702 | 5702 | |
| 5703 | - if(is_array($value)) |
|
| 5703 | + if (is_array($value)) |
|
| 5704 | 5704 | { |
| 5705 | 5705 | $out = ''; |
| 5706 | - foreach($value as $k => $v) |
|
| 5706 | + foreach ($value as $k => $v) |
|
| 5707 | 5707 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 5708 | 5708 | |
| 5709 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
| 5709 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 5710 | 5710 | } |
| 5711 | 5711 | |
| 5712 | 5712 | // safe_serialize cannot serialize resources or objects. |
@@ -5748,7 +5748,7 @@ discard block |
||
| 5748 | 5748 | function _safe_unserialize($str) |
| 5749 | 5749 | { |
| 5750 | 5750 | // Input is not a string. |
| 5751 | - if(empty($str) || !is_string($str)) |
|
| 5751 | + if (empty($str) || !is_string($str)) |
|
| 5752 | 5752 | return false; |
| 5753 | 5753 | |
| 5754 | 5754 | $stack = array(); |
@@ -5762,40 +5762,40 @@ discard block |
||
| 5762 | 5762 | * 3 - in array, expecting value or another array |
| 5763 | 5763 | */ |
| 5764 | 5764 | $state = 0; |
| 5765 | - while($state != 1) |
|
| 5765 | + while ($state != 1) |
|
| 5766 | 5766 | { |
| 5767 | 5767 | $type = isset($str[0]) ? $str[0] : ''; |
| 5768 | - if($type == '}') |
|
| 5768 | + if ($type == '}') |
|
| 5769 | 5769 | $str = substr($str, 1); |
| 5770 | 5770 | |
| 5771 | - else if($type == 'N' && $str[1] == ';') |
|
| 5771 | + else if ($type == 'N' && $str[1] == ';') |
|
| 5772 | 5772 | { |
| 5773 | 5773 | $value = null; |
| 5774 | 5774 | $str = substr($str, 2); |
| 5775 | 5775 | } |
| 5776 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5776 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5777 | 5777 | { |
| 5778 | 5778 | $value = $matches[1] == '1' ? true : false; |
| 5779 | 5779 | $str = substr($str, 4); |
| 5780 | 5780 | } |
| 5781 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5781 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5782 | 5782 | { |
| 5783 | - $value = (int)$matches[1]; |
|
| 5783 | + $value = (int) $matches[1]; |
|
| 5784 | 5784 | $str = $matches[2]; |
| 5785 | 5785 | } |
| 5786 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5786 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5787 | 5787 | { |
| 5788 | - $value = (float)$matches[1]; |
|
| 5788 | + $value = (float) $matches[1]; |
|
| 5789 | 5789 | $str = $matches[3]; |
| 5790 | 5790 | } |
| 5791 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5791 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 5792 | 5792 | { |
| 5793 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 5794 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 5793 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 5794 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 5795 | 5795 | } |
| 5796 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5796 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5797 | 5797 | { |
| 5798 | - $expectedLength = (int)$matches[1]; |
|
| 5798 | + $expectedLength = (int) $matches[1]; |
|
| 5799 | 5799 | $str = $matches[2]; |
| 5800 | 5800 | } |
| 5801 | 5801 | |
@@ -5803,10 +5803,10 @@ discard block |
||
| 5803 | 5803 | else |
| 5804 | 5804 | return false; |
| 5805 | 5805 | |
| 5806 | - switch($state) |
|
| 5806 | + switch ($state) |
|
| 5807 | 5807 | { |
| 5808 | 5808 | case 3: // In array, expecting value or another array. |
| 5809 | - if($type == 'a') |
|
| 5809 | + if ($type == 'a') |
|
| 5810 | 5810 | { |
| 5811 | 5811 | $stack[] = &$list; |
| 5812 | 5812 | $list[$key] = array(); |
@@ -5815,7 +5815,7 @@ discard block |
||
| 5815 | 5815 | $state = 2; |
| 5816 | 5816 | break; |
| 5817 | 5817 | } |
| 5818 | - if($type != '}') |
|
| 5818 | + if ($type != '}') |
|
| 5819 | 5819 | { |
| 5820 | 5820 | $list[$key] = $value; |
| 5821 | 5821 | $state = 2; |
@@ -5826,29 +5826,29 @@ discard block |
||
| 5826 | 5826 | return false; |
| 5827 | 5827 | |
| 5828 | 5828 | case 2: // in array, expecting end of array or a key |
| 5829 | - if($type == '}') |
|
| 5829 | + if ($type == '}') |
|
| 5830 | 5830 | { |
| 5831 | 5831 | // Array size is less than expected. |
| 5832 | - if(count($list) < end($expected)) |
|
| 5832 | + if (count($list) < end($expected)) |
|
| 5833 | 5833 | return false; |
| 5834 | 5834 | |
| 5835 | 5835 | unset($list); |
| 5836 | - $list = &$stack[count($stack)-1]; |
|
| 5836 | + $list = &$stack[count($stack) - 1]; |
|
| 5837 | 5837 | array_pop($stack); |
| 5838 | 5838 | |
| 5839 | 5839 | // Go to terminal state if we're at the end of the root array. |
| 5840 | 5840 | array_pop($expected); |
| 5841 | 5841 | |
| 5842 | - if(count($expected) == 0) |
|
| 5842 | + if (count($expected) == 0) |
|
| 5843 | 5843 | $state = 1; |
| 5844 | 5844 | |
| 5845 | 5845 | break; |
| 5846 | 5846 | } |
| 5847 | 5847 | |
| 5848 | - if($type == 'i' || $type == 's') |
|
| 5848 | + if ($type == 'i' || $type == 's') |
|
| 5849 | 5849 | { |
| 5850 | 5850 | // Array size exceeds expected length. |
| 5851 | - if(count($list) >= end($expected)) |
|
| 5851 | + if (count($list) >= end($expected)) |
|
| 5852 | 5852 | return false; |
| 5853 | 5853 | |
| 5854 | 5854 | $key = $value; |
@@ -5861,7 +5861,7 @@ discard block |
||
| 5861 | 5861 | |
| 5862 | 5862 | // Expecting array or value. |
| 5863 | 5863 | case 0: |
| 5864 | - if($type == 'a') |
|
| 5864 | + if ($type == 'a') |
|
| 5865 | 5865 | { |
| 5866 | 5866 | $data = array(); |
| 5867 | 5867 | $list = &$data; |
@@ -5870,7 +5870,7 @@ discard block |
||
| 5870 | 5870 | break; |
| 5871 | 5871 | } |
| 5872 | 5872 | |
| 5873 | - if($type != '}') |
|
| 5873 | + if ($type != '}') |
|
| 5874 | 5874 | { |
| 5875 | 5875 | $data = $value; |
| 5876 | 5876 | $state = 1; |
@@ -5883,7 +5883,7 @@ discard block |
||
| 5883 | 5883 | } |
| 5884 | 5884 | |
| 5885 | 5885 | // Trailing data in input. |
| 5886 | - if(!empty($str)) |
|
| 5886 | + if (!empty($str)) |
|
| 5887 | 5887 | return false; |
| 5888 | 5888 | |
| 5889 | 5889 | return $data; |
@@ -5937,7 +5937,7 @@ discard block |
||
| 5937 | 5937 | // Set different modes. |
| 5938 | 5938 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
| 5939 | 5939 | |
| 5940 | - foreach($chmodValues as $val) |
|
| 5940 | + foreach ($chmodValues as $val) |
|
| 5941 | 5941 | { |
| 5942 | 5942 | // If it's writable, break out of the loop. |
| 5943 | 5943 | if (is_writable($file)) |
@@ -5972,13 +5972,13 @@ discard block |
||
| 5972 | 5972 | $returnArray = @json_decode($json, $returnAsArray); |
| 5973 | 5973 | |
| 5974 | 5974 | // PHP 5.3 so no json_last_error_msg() |
| 5975 | - switch(json_last_error()) |
|
| 5975 | + switch (json_last_error()) |
|
| 5976 | 5976 | { |
| 5977 | 5977 | case JSON_ERROR_NONE: |
| 5978 | 5978 | $jsonError = false; |
| 5979 | 5979 | break; |
| 5980 | 5980 | case JSON_ERROR_DEPTH: |
| 5981 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5981 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5982 | 5982 | break; |
| 5983 | 5983 | case JSON_ERROR_STATE_MISMATCH: |
| 5984 | 5984 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -6006,10 +6006,10 @@ discard block |
||
| 6006 | 6006 | loadLanguage('Errors'); |
| 6007 | 6007 | |
| 6008 | 6008 | if (!empty($jsonDebug)) |
| 6009 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6009 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6010 | 6010 | |
| 6011 | 6011 | else |
| 6012 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6012 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
| 6013 | 6013 | |
| 6014 | 6014 | // Everyone expects an array. |
| 6015 | 6015 | return array(); |
@@ -6126,7 +6126,7 @@ discard block |
||
| 6126 | 6126 | // Convert Punycode to Unicode |
| 6127 | 6127 | require_once($sourcedir . '/Class-Punycode.php'); |
| 6128 | 6128 | $Punycode = new Punycode(); |
| 6129 | - $tlds = array_map(function ($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
| 6129 | + $tlds = array_map(function($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
| 6130 | 6130 | } |
| 6131 | 6131 | // Otherwise, use the 2012 list of gTLDs and ccTLDs for now and schedule a background update |
| 6132 | 6132 | else |
@@ -6220,7 +6220,7 @@ discard block |
||
| 6220 | 6220 | } |
| 6221 | 6221 | |
| 6222 | 6222 | // This recursive function creates the index array from the strings |
| 6223 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 6223 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 6224 | 6224 | { |
| 6225 | 6225 | static $depth = 0; |
| 6226 | 6226 | $depth++; |
@@ -6247,7 +6247,7 @@ discard block |
||
| 6247 | 6247 | }; |
| 6248 | 6248 | |
| 6249 | 6249 | // This recursive function turns the index array into a regular expression |
| 6250 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 6250 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 6251 | 6251 | { |
| 6252 | 6252 | static $depth = 0; |
| 6253 | 6253 | $depth++; |
@@ -6271,11 +6271,11 @@ discard block |
||
| 6271 | 6271 | |
| 6272 | 6272 | if (count(array_keys($value)) == 1) |
| 6273 | 6273 | { |
| 6274 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
| 6274 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
| 6275 | 6275 | $new_key .= $new_key_array[0]; |
| 6276 | 6276 | } |
| 6277 | 6277 | else |
| 6278 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6278 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
| 6279 | 6279 | } |
| 6280 | 6280 | |
| 6281 | 6281 | if ($depth > 1) |
@@ -6318,10 +6318,10 @@ discard block |
||
| 6318 | 6318 | { |
| 6319 | 6319 | $regex = array(); |
| 6320 | 6320 | while (!empty($index)) |
| 6321 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6321 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6322 | 6322 | } |
| 6323 | 6323 | else |
| 6324 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6324 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6325 | 6325 | |
| 6326 | 6326 | // Restore PHP's internal character encoding to whatever it was originally |
| 6327 | 6327 | if (!empty($current_encoding)) |
@@ -6545,7 +6545,7 @@ discard block |
||
| 6545 | 6545 | function sanitize_iri($iri) |
| 6546 | 6546 | { |
| 6547 | 6547 | // Encode any non-ASCII characters (but not space or control characters of any sort) |
| 6548 | - $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function ($matches) { |
|
| 6548 | + $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function($matches) { |
|
| 6549 | 6549 | return rawurlencode($matches[0]); |
| 6550 | 6550 | }, $iri); |
| 6551 | 6551 | |
@@ -6587,7 +6587,7 @@ discard block |
||
| 6587 | 6587 | $unescaped = array( |
| 6588 | 6588 | '%21'=>'!', '%23'=>'#', '%24'=>'$', '%26'=>'&', |
| 6589 | 6589 | '%27'=>"'", '%28'=>'(', '%29'=>')', '%2A'=>'*', |
| 6590 | - '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
| 6590 | + '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
| 6591 | 6591 | '%3B'=>';', '%3D'=>'=', '%3F'=>'?', '%40'=>'@', |
| 6592 | 6592 | ); |
| 6593 | 6593 | $iri = strtr(rawurlencode($iri), $unescaped); |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
| 51 | 52 | |
| 52 | - if (pg_affected_rows($result) === 0) |
|
| 53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 53 | + if (pg_affected_rows($result) === 0) { |
|
| 54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
| 60 | 62 | { |
| 61 | 63 | global $smcFunc, $db_connection; |
| 62 | 64 | |
| 63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
| 64 | - return false; |
|
| 65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 65 | 68 | |
| 66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
| 67 | 70 | $res = pg_fetch_assoc($result); |
| 68 | 71 | |
| 69 | - if ($res['server_version_num'] < 90500) |
|
| 70 | - return false; |
|
| 72 | + if ($res['server_version_num'] < 90500) { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | return $test ? true : parent::isSupported(); |
| 73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
| 81 | 85 | |
| 82 | 86 | $ttl = time() - $ttl; |
| 83 | 87 | |
| 84 | - if (empty($this->pg_get_data_prep)) |
|
| 85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 88 | + if (empty($this->pg_get_data_prep)) { |
|
| 89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
| 88 | 93 | |
| 89 | - if (pg_affected_rows($result) === 0) |
|
| 90 | - return null; |
|
| 94 | + if (pg_affected_rows($result) === 0) { |
|
| 95 | + return null; |
|
| 96 | + } |
|
| 91 | 97 | |
| 92 | 98 | $res = pg_fetch_assoc($result); |
| 93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
| 101 | 107 | { |
| 102 | 108 | global $db_prefix, $db_connection; |
| 103 | 109 | |
| 104 | - if (!isset($value)) |
|
| 105 | - $value = ''; |
|
| 110 | + if (!isset($value)) { |
|
| 111 | + $value = ''; |
|
| 112 | + } |
|
| 106 | 113 | |
| 107 | 114 | $ttl = time() + $ttl; |
| 108 | 115 | |
| 109 | - if (empty($this->pg_put_data_prep)) |
|
| 110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 116 | + if (empty($this->pg_put_data_prep)) { |
|
| 117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
| 112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
| 113 | 120 | ); |
| 121 | + } |
|
| 114 | 122 | |
| 115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
| 116 | 124 | |
| 117 | - if (pg_affected_rows($result) > 0) |
|
| 118 | - return true; |
|
| 119 | - else |
|
| 120 | - return false; |
|
| 125 | + if (pg_affected_rows($result) > 0) { |
|
| 126 | + return true; |
|
| 127 | + } else { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | /** |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | global $db_connection, $db_prefix; |
| 167 | 167 | |
| 168 | - pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time() ); |
|
| 168 | + pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | { |
| 190 | 190 | global $db_connection, $db_prefix; |
| 191 | 191 | |
| 192 | - pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM '. $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING'); |
|
| 192 | + pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM ' . $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING'); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
| 48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
| 49 | 50 | |
| 50 | 51 | // If we are doing approval, update the stats for the member just in case. |
| 51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
| 52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
| 52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
| 53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
| 54 | + } |
|
| 53 | 55 | |
| 54 | 56 | // Make sure we update the stats too. |
| 55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
| 76 | 78 | $issueErrors = array(); |
| 77 | 79 | |
| 78 | 80 | // Doesn't hurt to be overly cautious. |
| 79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
| 80 | - fatal_lang_error('no_access', false); |
|
| 81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
| 82 | + fatal_lang_error('no_access', false); |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Get the base (errors related) stuff done. |
| 83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
| 135 | 138 | |
| 136 | 139 | // This cannot be empty! |
| 137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
| 138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
| 139 | - $issueErrors[] = 'warning_no_reason'; |
|
| 141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
| 142 | + $issueErrors[] = 'warning_no_reason'; |
|
| 143 | + } |
|
| 140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
| 141 | 145 | |
| 142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
| 143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
| 144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
| 145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
| 146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
| 147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
| 148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
| 149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
| 150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
| 151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
| 152 | + } |
|
| 148 | 153 | |
| 149 | 154 | // Do we actually have to issue them with a PM? |
| 150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
| 152 | 157 | { |
| 153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
| 154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
| 155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
| 156 | - $issueErrors[] = 'warning_notify_blank'; |
|
| 160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
| 161 | + $issueErrors[] = 'warning_notify_blank'; |
|
| 162 | + } |
|
| 157 | 163 | // Send the PM? |
| 158 | 164 | else |
| 159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
| 190 | 196 | if (empty($issueErrors)) |
| 191 | 197 | { |
| 192 | 198 | // Log what we've done! |
| 193 | - if (!$context['user']['is_owner']) |
|
| 194 | - $smcFunc['db_insert']('', |
|
| 199 | + if (!$context['user']['is_owner']) { |
|
| 200 | + $smcFunc['db_insert']('', |
|
| 195 | 201 | '{db_prefix}log_comments', |
| 196 | 202 | array( |
| 197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
| 203 | 209 | ), |
| 204 | 210 | array('id_comment') |
| 205 | 211 | ); |
| 212 | + } |
|
| 206 | 213 | |
| 207 | 214 | // Make the change. |
| 208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
| 209 | 216 | |
| 210 | 217 | // Leave a lovely message. |
| 211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
| 212 | - } |
|
| 213 | - else |
|
| 219 | + } else |
|
| 214 | 220 | { |
| 215 | 221 | // Try to remember some bits. |
| 216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
| 229 | 235 | { |
| 230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
| 231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
| 232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
| 233 | - $issueErrors[] = 'warning_notify_blank'; |
|
| 238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
| 239 | + $issueErrors[] = 'warning_notify_blank'; |
|
| 240 | + } |
|
| 234 | 241 | |
| 235 | 242 | if (!empty($_POST['warn_body'])) |
| 236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
| 254 | 261 | { |
| 255 | 262 | // Fill in the suite of errors. |
| 256 | 263 | $context['post_errors'] = array(); |
| 257 | - foreach ($issueErrors as $error) |
|
| 258 | - $context['post_errors'][] = $txt[$error]; |
|
| 264 | + foreach ($issueErrors as $error) { |
|
| 265 | + $context['post_errors'][] = $txt[$error]; |
|
| 266 | + } |
|
| 259 | 267 | } |
| 260 | 268 | |
| 261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
| 272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
| 273 | 281 | ); |
| 274 | 282 | $context['current_level'] = 0; |
| 275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 276 | - if ($context['member']['warning'] >= $limit) |
|
| 283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 284 | + if ($context['member']['warning'] >= $limit) |
|
| 277 | 285 | $context['current_level'] = $limit; |
| 286 | + } |
|
| 278 | 287 | |
| 279 | 288 | $listOptions = array( |
| 280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
| 337 | 346 | ' . $warning['reason'] . ' |
| 338 | 347 | </div>'; |
| 339 | 348 | |
| 340 | - if (!empty($warning['id_notice'])) |
|
| 341 | - $ret .= ' |
|
| 349 | + if (!empty($warning['id_notice'])) { |
|
| 350 | + $ret .= ' |
|
| 342 | 351 | <div class="floatright"> |
| 343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
| 344 | 353 | </div>'; |
| 354 | + } |
|
| 345 | 355 | |
| 346 | 356 | return $ret; |
| 347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
| 413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 414 | 424 | { |
| 415 | 425 | // If we're not warning for a message skip any that are. |
| 416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
| 417 | - continue; |
|
| 426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
| 427 | + continue; |
|
| 428 | + } |
|
| 418 | 429 | |
| 419 | 430 | $context['notification_templates'][] = array( |
| 420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
| 424 | 435 | $smcFunc['db_free_result']($request); |
| 425 | 436 | |
| 426 | 437 | // Setup the "default" templates. |
| 427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
| 428 | - $context['notification_templates'][] = array( |
|
| 438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
| 439 | + $context['notification_templates'][] = array( |
|
| 429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
| 430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
| 431 | 442 | ); |
| 443 | + } |
|
| 432 | 444 | |
| 433 | 445 | // Replace all the common variables in the templates. |
| 434 | - foreach ($context['notification_templates'] as $k => $name) |
|
| 435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
| 436 | -} |
|
| 446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
| 447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
| 448 | + } |
|
| 449 | + } |
|
| 437 | 450 | |
| 438 | 451 | /** |
| 439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
| 517 | 530 | { |
| 518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
| 519 | 532 | |
| 520 | - if (!$context['user']['is_owner']) |
|
| 521 | - isAllowedTo('profile_remove_any'); |
|
| 522 | - elseif (!allowedTo('profile_remove_any')) |
|
| 523 | - isAllowedTo('profile_remove_own'); |
|
| 533 | + if (!$context['user']['is_owner']) { |
|
| 534 | + isAllowedTo('profile_remove_any'); |
|
| 535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
| 536 | + isAllowedTo('profile_remove_own'); |
|
| 537 | + } |
|
| 524 | 538 | |
| 525 | 539 | // Permissions for removing stuff... |
| 526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
| 547 | 561 | |
| 548 | 562 | // @todo Add a way to delete pms as well? |
| 549 | 563 | |
| 550 | - if (!$context['user']['is_owner']) |
|
| 551 | - isAllowedTo('profile_remove_any'); |
|
| 552 | - elseif (!allowedTo('profile_remove_any')) |
|
| 553 | - isAllowedTo('profile_remove_own'); |
|
| 564 | + if (!$context['user']['is_owner']) { |
|
| 565 | + isAllowedTo('profile_remove_any'); |
|
| 566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
| 567 | + isAllowedTo('profile_remove_own'); |
|
| 568 | + } |
|
| 554 | 569 | |
| 555 | 570 | checkSession(); |
| 556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
| 576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 577 | 592 | $smcFunc['db_free_result']($request); |
| 578 | 593 | |
| 579 | - if (empty($another)) |
|
| 580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 594 | + if (empty($another)) { |
|
| 595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 596 | + } |
|
| 581 | 597 | } |
| 582 | 598 | |
| 583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
| 656 | 672 | ) |
| 657 | 673 | ); |
| 658 | 674 | $topicIDs = array(); |
| 659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 660 | - $topicIDs[] = $row['id_topic']; |
|
| 675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 676 | + $topicIDs[] = $row['id_topic']; |
|
| 677 | + } |
|
| 661 | 678 | $smcFunc['db_free_result']($request); |
| 662 | 679 | |
| 663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
| 680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
| 681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 682 | 699 | { |
| 683 | - if (function_exists('apache_reset_timeout')) |
|
| 684 | - @apache_reset_timeout(); |
|
| 700 | + if (function_exists('apache_reset_timeout')) { |
|
| 701 | + @apache_reset_timeout(); |
|
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | removeMessage($row['id_msg']); |
| 687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
| 689 | 707 | } |
| 690 | 708 | |
| 691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
| 692 | - if (isset($_POST['deleteAccount'])) |
|
| 693 | - deleteMembers($memID); |
|
| 710 | + if (isset($_POST['deleteAccount'])) { |
|
| 711 | + deleteMembers($memID); |
|
| 712 | + } |
|
| 694 | 713 | } |
| 695 | 714 | // Do they need approval to delete? |
| 696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
| 741 | 760 | { |
| 742 | 761 | foreach ($costs as $duration => $cost) |
| 743 | 762 | { |
| 744 | - if ($cost != 0) |
|
| 745 | - $cost_array[$duration] = $cost; |
|
| 763 | + if ($cost != 0) { |
|
| 764 | + $cost_array[$duration] = $cost; |
|
| 765 | + } |
|
| 746 | 766 | } |
| 747 | - } |
|
| 748 | - else |
|
| 767 | + } else |
|
| 749 | 768 | { |
| 750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
| 751 | 770 | } |
| 752 | 771 | |
| 753 | - if (empty($cost_array)) |
|
| 754 | - unset($context['subscriptions'][$id]); |
|
| 755 | - else |
|
| 772 | + if (empty($cost_array)) { |
|
| 773 | + unset($context['subscriptions'][$id]); |
|
| 774 | + } else |
|
| 756 | 775 | { |
| 757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
| 758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
| 765 | 784 | foreach ($gateways as $id => $gateway) |
| 766 | 785 | { |
| 767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
| 768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
| 769 | - unset($gateways[$id]); |
|
| 787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
| 788 | + unset($gateways[$id]); |
|
| 789 | + } |
|
| 770 | 790 | } |
| 771 | 791 | |
| 772 | 792 | // No gateways yet? |
| 773 | - if (empty($gateways)) |
|
| 774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 793 | + if (empty($gateways)) { |
|
| 794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 795 | + } |
|
| 775 | 796 | |
| 776 | 797 | // Get the current subscriptions. |
| 777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
| 786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 787 | 808 | { |
| 788 | 809 | // The subscription must exist! |
| 789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 790 | - continue; |
|
| 810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 811 | + continue; |
|
| 812 | + } |
|
| 791 | 813 | |
| 792 | 814 | $context['current'][$row['id_subscribe']] = array( |
| 793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
| 801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
| 802 | 824 | ); |
| 803 | 825 | |
| 804 | - if ($row['status'] == 1) |
|
| 805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
| 826 | + if ($row['status'] == 1) { |
|
| 827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
| 828 | + } |
|
| 806 | 829 | } |
| 807 | 830 | $smcFunc['db_free_result']($request); |
| 808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
| 853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
| 854 | 877 | { |
| 855 | 878 | // Hopefully just one. |
| 856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
| 857 | - $ID_SUB = (int) $k; |
|
| 879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
| 880 | + $ID_SUB = (int) $k; |
|
| 881 | + } |
|
| 858 | 882 | |
| 859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
| 860 | - fatal_lang_error('paid_sub_not_active'); |
|
| 883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
| 884 | + fatal_lang_error('paid_sub_not_active'); |
|
| 885 | + } |
|
| 861 | 886 | |
| 862 | 887 | // Simplify... |
| 863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
| 864 | 889 | $period = 'xx'; |
| 865 | - if ($context['sub']['flexible']) |
|
| 866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
| 890 | + if ($context['sub']['flexible']) { |
|
| 891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
| 892 | + } |
|
| 867 | 893 | |
| 868 | 894 | // Check we have a valid cost. |
| 869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
| 870 | - fatal_lang_error('paid_sub_not_active'); |
|
| 895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
| 896 | + fatal_lang_error('paid_sub_not_active'); |
|
| 897 | + } |
|
| 871 | 898 | |
| 872 | 899 | // Sort out the cost/currency. |
| 873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
| 880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
| 881 | 908 | // The period value for paypal. |
| 882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
| 883 | - } |
|
| 884 | - else |
|
| 910 | + } else |
|
| 885 | 911 | { |
| 886 | 912 | // Real cost... |
| 887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
| 898 | 924 | foreach ($gateways as $id => $gateway) |
| 899 | 925 | { |
| 900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
| 901 | - if (!empty($fields['form'])) |
|
| 902 | - $context['gateways'][] = $fields; |
|
| 927 | + if (!empty($fields['form'])) { |
|
| 928 | + $context['gateways'][] = $fields; |
|
| 929 | + } |
|
| 903 | 930 | } |
| 904 | 931 | |
| 905 | 932 | // Bugger?! |
| 906 | - if (empty($context['gateways'])) |
|
| 907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 933 | + if (empty($context['gateways'])) { |
|
| 934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 935 | + } |
|
| 908 | 936 | |
| 909 | 937 | // Now we are going to assume they want to take this out ;) |
| 910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
| 912 | 940 | { |
| 913 | 941 | // What are the details like? |
| 914 | 942 | $current_pending = array(); |
| 915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
| 916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
| 943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
| 944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
| 945 | + } |
|
| 917 | 946 | // Don't get silly. |
| 918 | - if (count($current_pending) > 9) |
|
| 919 | - $current_pending = array(); |
|
| 947 | + if (count($current_pending) > 9) { |
|
| 948 | + $current_pending = array(); |
|
| 949 | + } |
|
| 920 | 950 | $pending_count = 0; |
| 921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
| 922 | - foreach ($current_pending as $pending) |
|
| 923 | - if ($pending[3] == 'payback') |
|
| 952 | + foreach ($current_pending as $pending) { |
|
| 953 | + if ($pending[3] == 'payback') |
|
| 924 | 954 | $pending_count++; |
| 955 | + } |
|
| 925 | 956 | |
| 926 | 957 | if (!in_array($new_data, $current_pending)) |
| 927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
| 966 | 997 | |
| 967 | 998 | // Quit. |
| 968 | 999 | return; |
| 1000 | + } else { |
|
| 1001 | + $context['sub_template'] = 'user_subscription'; |
|
| 1002 | + } |
|
| 969 | 1003 | } |
| 970 | - else |
|
| 971 | - $context['sub_template'] = 'user_subscription'; |
|
| 972 | -} |
|
| 973 | 1004 | |
| 974 | 1005 | ?> |
| 975 | 1006 | \ No newline at end of file |