@@ -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 | } |
@@ -19,26 +19,28 @@ discard block |
||
| 19 | 19 | global $context, $settings, $scripturl, $txt, $modSettings; |
| 20 | 20 | |
| 21 | 21 | // Not allowed to edit? |
| 22 | - if (!$context['can_modify']) |
|
| 23 | - echo ' |
|
| 22 | + if (!$context['can_modify']) { |
|
| 23 | + echo ' |
|
| 24 | 24 | <div class="errorbox"> |
| 25 | 25 | ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), ' |
| 26 | 26 | </div>'; |
| 27 | + } |
|
| 27 | 28 | |
| 28 | 29 | echo ' |
| 29 | 30 | <div id="admin_form_wrapper"> |
| 30 | 31 | <form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">'; |
| 31 | 32 | |
| 32 | - if (!empty($context['profile'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="cat_bar"> |
| 35 | 36 | <h3 class="catbg">', $txt['permissions_for_profile'], ': "', $context['profile']['name'], '"</h3> |
| 36 | 37 | </div>'; |
| 37 | - else |
|
| 38 | - echo ' |
|
| 38 | + } else { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="cat_bar"> |
| 40 | 41 | <h3 class="catbg">', $txt['permissions_title'], '</h3> |
| 41 | 42 | </div>'; |
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | echo ' |
| 44 | 46 | <table class="table_grid"> |
@@ -47,13 +49,14 @@ discard block |
||
| 47 | 49 | <th>', $txt['membergroups_name'], '</th> |
| 48 | 50 | <th class="small_table">', $txt['membergroups_members_top'], '</th>'; |
| 49 | 51 | |
| 50 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 51 | - echo ' |
|
| 52 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 53 | + echo ' |
|
| 52 | 54 | <th class="small_table">', $txt['membergroups_permissions'], '</th>'; |
| 53 | - else |
|
| 54 | - echo ' |
|
| 55 | + } else { |
|
| 56 | + echo ' |
|
| 55 | 57 | <th class="small_table">', $txt['permissions_allowed'], '</th> |
| 56 | 58 | <th class="small_table">', $txt['permissions_denied'], '</th>'; |
| 59 | + } |
|
| 57 | 60 | |
| 58 | 61 | echo ' |
| 59 | 62 | <th class="small_table">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th> |
@@ -71,26 +74,28 @@ discard block |
||
| 71 | 74 | <td> |
| 72 | 75 | ', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a> ' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', '<span>', $group['name'], '</span>'; |
| 73 | 76 | |
| 74 | - if (!empty($group['children'])) |
|
| 75 | - echo ' |
|
| 77 | + if (!empty($group['children'])) { |
|
| 78 | + echo ' |
|
| 76 | 79 | <br> |
| 77 | 80 | <span class="smalltext">', $txt['permissions_includes_inherited'], ': "', implode('", "', $group['children']), '"</span>'; |
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | echo ' |
| 80 | 84 | </td> |
| 81 | 85 | <td>', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>'; |
| 82 | 86 | |
| 83 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 84 | - echo ' |
|
| 87 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 88 | + echo ' |
|
| 85 | 89 | <td>', $group['num_permissions']['allowed'], '</td>'; |
| 86 | - else |
|
| 87 | - echo ' |
|
| 90 | + } else { |
|
| 91 | + echo ' |
|
| 88 | 92 | <td ', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '> |
| 89 | 93 | ', $group['num_permissions']['allowed'], ' |
| 90 | 94 | </td> |
| 91 | 95 | <td ', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' class="red"' : ''), '> |
| 92 | 96 | ', $group['num_permissions']['denied'], ' |
| 93 | 97 | </td>'; |
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | echo ' |
| 96 | 101 | <td> |
@@ -141,10 +146,11 @@ discard block |
||
| 141 | 146 | <select name="copy_from"> |
| 142 | 147 | <option value="empty">(', $txt['permissions_select_membergroup'], ')</option>'; |
| 143 | 148 | |
| 144 | - foreach ($context['groups'] as $group) |
|
| 145 | - if ($group['id'] != 1) |
|
| 149 | + foreach ($context['groups'] as $group) { |
|
| 150 | + if ($group['id'] != 1) |
|
| 146 | 151 | echo ' |
| 147 | 152 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
| 153 | + } |
|
| 148 | 154 | |
| 149 | 155 | echo ' |
| 150 | 156 | </select> |
@@ -154,9 +160,10 @@ discard block |
||
| 154 | 160 | <option value="add">', $txt['permissions_add'], '...</option> |
| 155 | 161 | <option value="clear">', $txt['permissions_remove'], '...</option>'; |
| 156 | 162 | |
| 157 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 158 | - echo ' |
|
| 163 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 164 | + echo ' |
|
| 159 | 165 | <option value="deny">', $txt['permissions_deny'], '...</option>'; |
| 166 | + } |
|
| 160 | 167 | |
| 161 | 168 | echo ' |
| 162 | 169 | </select> |
@@ -167,31 +174,35 @@ discard block |
||
| 167 | 174 | |
| 168 | 175 | foreach ($context['permissions'] as $permissionType) |
| 169 | 176 | { |
| 170 | - if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) |
|
| 171 | - continue; |
|
| 177 | + if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) { |
|
| 178 | + continue; |
|
| 179 | + } |
|
| 172 | 180 | |
| 173 | 181 | foreach ($permissionType['columns'] as $column) |
| 174 | 182 | { |
| 175 | 183 | foreach ($column as $permissionGroup) |
| 176 | 184 | { |
| 177 | - if ($permissionGroup['hidden']) |
|
| 178 | - continue; |
|
| 185 | + if ($permissionGroup['hidden']) { |
|
| 186 | + continue; |
|
| 187 | + } |
|
| 179 | 188 | |
| 180 | 189 | echo ' |
| 181 | 190 | <option value="" disabled>[', $permissionGroup['name'], ']</option>'; |
| 182 | 191 | |
| 183 | 192 | foreach ($permissionGroup['permissions'] as $perm) |
| 184 | 193 | { |
| 185 | - if ($perm['hidden']) |
|
| 186 | - continue; |
|
| 194 | + if ($perm['hidden']) { |
|
| 195 | + continue; |
|
| 196 | + } |
|
| 187 | 197 | |
| 188 | - if ($perm['has_own_any']) |
|
| 189 | - echo ' |
|
| 198 | + if ($perm['has_own_any']) { |
|
| 199 | + echo ' |
|
| 190 | 200 | <option value="', $permissionType['id'], '/', $perm['own']['id'], '"> ', $perm['name'], ' (', $perm['own']['name'], ')</option> |
| 191 | 201 | <option value="', $permissionType['id'], '/', $perm['any']['id'], '"> ', $perm['name'], ' (', $perm['any']['name'], ')</option>'; |
| 192 | - else |
|
| 193 | - echo ' |
|
| 202 | + } else { |
|
| 203 | + echo ' |
|
| 194 | 204 | <option value="', $permissionType['id'], '/', $perm['id'], '"> ', $perm['name'], '</option>'; |
| 205 | + } |
|
| 195 | 206 | } |
| 196 | 207 | } |
| 197 | 208 | } |
@@ -256,9 +267,10 @@ discard block |
||
| 256 | 267 | } |
| 257 | 268 | </script>'; |
| 258 | 269 | |
| 259 | - if (!empty($context['profile'])) |
|
| 260 | - echo ' |
|
| 270 | + if (!empty($context['profile'])) { |
|
| 271 | + echo ' |
|
| 261 | 272 | <input type="hidden" name="pid" value="', $context['profile']['id'], '">'; |
| 273 | + } |
|
| 262 | 274 | |
| 263 | 275 | echo ' |
| 264 | 276 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -303,9 +315,10 @@ discard block |
||
| 303 | 315 | <h3 class="subbg">', $category['name'], '</h3> |
| 304 | 316 | </div>'; |
| 305 | 317 | |
| 306 | - if (!empty($category['boards'])) |
|
| 307 | - echo ' |
|
| 318 | + if (!empty($category['boards'])) { |
|
| 319 | + echo ' |
|
| 308 | 320 | <ul class="perm_boards flow_hidden">'; |
| 321 | + } |
|
| 309 | 322 | |
| 310 | 323 | foreach ($category['boards'] as $board) |
| 311 | 324 | { |
@@ -321,33 +334,36 @@ discard block |
||
| 321 | 334 | echo ' |
| 322 | 335 | <select name="boardprofile[', $board['id'], ']">'; |
| 323 | 336 | |
| 324 | - foreach ($context['profiles'] as $id => $profile) |
|
| 325 | - echo ' |
|
| 337 | + foreach ($context['profiles'] as $id => $profile) { |
|
| 338 | + echo ' |
|
| 326 | 339 | <option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
| 340 | + } |
|
| 327 | 341 | |
| 328 | 342 | echo ' |
| 329 | 343 | </select>'; |
| 330 | - } |
|
| 331 | - else |
|
| 332 | - echo ' |
|
| 344 | + } else { |
|
| 345 | + echo ' |
|
| 333 | 346 | <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '">', $board['profile_name'], '</a>'; |
| 347 | + } |
|
| 334 | 348 | |
| 335 | 349 | echo ' |
| 336 | 350 | </span> |
| 337 | 351 | </li>'; |
| 338 | 352 | } |
| 339 | 353 | |
| 340 | - if (!empty($category['boards'])) |
|
| 341 | - echo ' |
|
| 354 | + if (!empty($category['boards'])) { |
|
| 355 | + echo ' |
|
| 342 | 356 | </ul>'; |
| 357 | + } |
|
| 343 | 358 | } |
| 344 | 359 | |
| 345 | - if ($context['edit_all']) |
|
| 346 | - echo ' |
|
| 360 | + if ($context['edit_all']) { |
|
| 361 | + echo ' |
|
| 347 | 362 | <input type="submit" name="save_changes" value="', $txt['save'], '" class="button">'; |
| 348 | - else |
|
| 349 | - echo ' |
|
| 363 | + } else { |
|
| 364 | + echo ' |
|
| 350 | 365 | <a class="button" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>'; |
| 366 | + } |
|
| 351 | 367 | |
| 352 | 368 | echo ' |
| 353 | 369 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -387,12 +403,13 @@ discard block |
||
| 387 | 403 | <tr class="windowbg"> |
| 388 | 404 | <td>'; |
| 389 | 405 | |
| 390 | - if (!empty($context['show_rename_boxes']) && $profile['can_edit']) |
|
| 391 | - echo ' |
|
| 406 | + if (!empty($context['show_rename_boxes']) && $profile['can_edit']) { |
|
| 407 | + echo ' |
|
| 392 | 408 | <input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '">'; |
| 393 | - else |
|
| 394 | - echo ' |
|
| 409 | + } else { |
|
| 410 | + echo ' |
|
| 395 | 411 | <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>'; |
| 412 | + } |
|
| 396 | 413 | |
| 397 | 414 | echo ' |
| 398 | 415 | </td> |
@@ -412,9 +429,10 @@ discard block |
||
| 412 | 429 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 413 | 430 | <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">'; |
| 414 | 431 | |
| 415 | - if ($context['can_edit_something']) |
|
| 416 | - echo ' |
|
| 432 | + if ($context['can_edit_something']) { |
|
| 433 | + echo ' |
|
| 417 | 434 | <input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button">'; |
| 435 | + } |
|
| 418 | 436 | |
| 419 | 437 | echo ' |
| 420 | 438 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '> |
@@ -439,9 +457,10 @@ discard block |
||
| 439 | 457 | <dd> |
| 440 | 458 | <select name="copy_from">'; |
| 441 | 459 | |
| 442 | - foreach ($context['profiles'] as $id => $profile) |
|
| 443 | - echo ' |
|
| 460 | + foreach ($context['profiles'] as $id => $profile) { |
|
| 461 | + echo ' |
|
| 444 | 462 | <option value="', $id, '">', $profile['name'], '</option>'; |
| 463 | + } |
|
| 445 | 464 | |
| 446 | 465 | echo ' |
| 447 | 466 | </select> |
@@ -463,13 +482,13 @@ discard block |
||
| 463 | 482 | global $context, $scripturl, $txt, $modSettings; |
| 464 | 483 | |
| 465 | 484 | // Cannot be edited? |
| 466 | - if (!$context['profile']['can_modify']) |
|
| 467 | - echo ' |
|
| 485 | + if (!$context['profile']['can_modify']) { |
|
| 486 | + echo ' |
|
| 468 | 487 | <div class="errorbox"> |
| 469 | 488 | ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), ' |
| 470 | 489 | </div>'; |
| 471 | - else |
|
| 472 | - echo ' |
|
| 490 | + } else { |
|
| 491 | + echo ' |
|
| 473 | 492 | <script> |
| 474 | 493 | window.smf_usedDeny = false; |
| 475 | 494 | |
@@ -481,27 +500,30 @@ discard block |
||
| 481 | 500 | return true; |
| 482 | 501 | } |
| 483 | 502 | </script>'; |
| 503 | + } |
|
| 484 | 504 | |
| 485 | 505 | echo ' |
| 486 | 506 | <div id="admincenter"> |
| 487 | 507 | <form id="permissions" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">'; |
| 488 | 508 | |
| 489 | - if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) |
|
| 490 | - echo ' |
|
| 509 | + if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) { |
|
| 510 | + echo ' |
|
| 491 | 511 | <div class="information"> |
| 492 | 512 | ', $txt['permissions_option_desc'], ' |
| 493 | 513 | </div>'; |
| 514 | + } |
|
| 494 | 515 | |
| 495 | 516 | echo ' |
| 496 | 517 | <div class="cat_bar"> |
| 497 | 518 | <h3 class="catbg">'; |
| 498 | 519 | |
| 499 | - if ($context['permission_type'] == 'board') |
|
| 500 | - echo ' |
|
| 520 | + if ($context['permission_type'] == 'board') { |
|
| 521 | + echo ' |
|
| 501 | 522 | ', $txt['permissions_local_for'], ' "', $context['group']['name'], '" ', $txt['permissions_on'], ' "', $context['profile']['name'], '"'; |
| 502 | - else |
|
| 503 | - echo ' |
|
| 523 | + } else { |
|
| 524 | + echo ' |
|
| 504 | 525 | ', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - "', $context['group']['name'], '"'; |
| 526 | + } |
|
| 505 | 527 | echo ' |
| 506 | 528 | </h3> |
| 507 | 529 | </div>'; |
@@ -524,15 +546,17 @@ discard block |
||
| 524 | 546 | template_modify_group_display('board'); |
| 525 | 547 | } |
| 526 | 548 | |
| 527 | - if ($context['profile']['can_modify']) |
|
| 528 | - echo ' |
|
| 549 | + if ($context['profile']['can_modify']) { |
|
| 550 | + echo ' |
|
| 529 | 551 | <div class="padding"> |
| 530 | 552 | <input type="submit" value="', $txt['permissions_commit'], '" class="button"> |
| 531 | 553 | </div>'; |
| 554 | + } |
|
| 532 | 555 | |
| 533 | - foreach ($context['hidden_perms'] as $hidden_perm) |
|
| 534 | - echo ' |
|
| 556 | + foreach ($context['hidden_perms'] as $hidden_perm) { |
|
| 557 | + echo ' |
|
| 535 | 558 | <input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">'; |
| 559 | + } |
|
| 536 | 560 | |
| 537 | 561 | echo ' |
| 538 | 562 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -560,17 +584,19 @@ discard block |
||
| 560 | 584 | |
| 561 | 585 | foreach ($column as $permissionGroup) |
| 562 | 586 | { |
| 563 | - if (empty($permissionGroup['permissions'])) |
|
| 564 | - continue; |
|
| 587 | + if (empty($permissionGroup['permissions'])) { |
|
| 588 | + continue; |
|
| 589 | + } |
|
| 565 | 590 | |
| 566 | 591 | // Are we likely to have something in this group to display or is it all hidden? |
| 567 | 592 | $has_display_content = false; |
| 568 | 593 | if (!$permissionGroup['hidden']) |
| 569 | 594 | { |
| 570 | 595 | // Before we go any further check we are going to have some data to print otherwise we just have a silly heading. |
| 571 | - foreach ($permissionGroup['permissions'] as $permission) |
|
| 572 | - if (!$permission['hidden']) |
|
| 596 | + foreach ($permissionGroup['permissions'] as $permission) { |
|
| 597 | + if (!$permission['hidden']) |
|
| 573 | 598 | $has_display_content = true; |
| 599 | + } |
|
| 574 | 600 | |
| 575 | 601 | if ($has_display_content) |
| 576 | 602 | { |
@@ -579,10 +605,11 @@ discard block |
||
| 579 | 605 | <th></th> |
| 580 | 606 | <th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>'; |
| 581 | 607 | |
| 582 | - if ($context['group']['id'] != -1) |
|
| 583 | - echo ' |
|
| 608 | + if ($context['group']['id'] != -1) { |
|
| 609 | + echo ' |
|
| 584 | 610 | <th>', $txt['permissions_option_own'], '</th> |
| 585 | 611 | <th>', $txt['permissions_option_any'], '</th>'; |
| 612 | + } |
|
| 586 | 613 | |
| 587 | 614 | echo ' |
| 588 | 615 | </tr>'; |
@@ -605,17 +632,18 @@ discard block |
||
| 605 | 632 | // Guests can't do their own thing. |
| 606 | 633 | if ($context['group']['id'] != -1) |
| 607 | 634 | { |
| 608 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 609 | - echo ' |
|
| 635 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 636 | + echo ' |
|
| 610 | 637 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" ', $disable_field, '>'; |
| 611 | - else |
|
| 638 | + } else |
|
| 612 | 639 | { |
| 613 | 640 | echo ' |
| 614 | 641 | <select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>'; |
| 615 | 642 | |
| 616 | - foreach (array('on', 'off', 'deny') as $c) |
|
| 617 | - echo ' |
|
| 643 | + foreach (array('on', 'off', 'deny') as $c) { |
|
| 644 | + echo ' |
|
| 618 | 645 | <option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
| 646 | + } |
|
| 619 | 647 | echo ' |
| 620 | 648 | </select>'; |
| 621 | 649 | } |
@@ -625,39 +653,41 @@ discard block |
||
| 625 | 653 | <td>'; |
| 626 | 654 | } |
| 627 | 655 | |
| 628 | - if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) |
|
| 629 | - echo ' |
|
| 656 | + if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) { |
|
| 657 | + echo ' |
|
| 630 | 658 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>'; |
| 631 | - else |
|
| 659 | + } else |
|
| 632 | 660 | { |
| 633 | 661 | echo ' |
| 634 | 662 | <select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>'; |
| 635 | 663 | |
| 636 | - foreach (array('on', 'off', 'deny') as $c) |
|
| 637 | - echo ' |
|
| 664 | + foreach (array('on', 'off', 'deny') as $c) { |
|
| 665 | + echo ' |
|
| 638 | 666 | <option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
| 667 | + } |
|
| 639 | 668 | echo ' |
| 640 | 669 | </select>'; |
| 641 | 670 | } |
| 642 | - } |
|
| 643 | - else |
|
| 671 | + } else |
|
| 644 | 672 | { |
| 645 | - if ($context['group']['id'] != -1) |
|
| 646 | - echo ' |
|
| 673 | + if ($context['group']['id'] != -1) { |
|
| 674 | + echo ' |
|
| 647 | 675 | </td> |
| 648 | 676 | <td>'; |
| 677 | + } |
|
| 649 | 678 | |
| 650 | - if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) |
|
| 651 | - echo ' |
|
| 679 | + if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) { |
|
| 680 | + echo ' |
|
| 652 | 681 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>'; |
| 653 | - else |
|
| 682 | + } else |
|
| 654 | 683 | { |
| 655 | 684 | echo ' |
| 656 | 685 | <select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>'; |
| 657 | 686 | |
| 658 | - foreach (array('on', 'off', 'deny') as $c) |
|
| 659 | - echo ' |
|
| 687 | + foreach (array('on', 'off', 'deny') as $c) { |
|
| 688 | + echo ' |
|
| 660 | 689 | <option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
| 690 | + } |
|
| 661 | 691 | echo ' |
| 662 | 692 | </select>'; |
| 663 | 693 | } |
@@ -689,11 +719,11 @@ discard block |
||
| 689 | 719 | <fieldset id="', $context['current_permission'], '"> |
| 690 | 720 | <legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;" class="toggle_up"> ', $txt['avatar_select_permission'], '</a></legend>'; |
| 691 | 721 | |
| 692 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 693 | - echo ' |
|
| 722 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 723 | + echo ' |
|
| 694 | 724 | <ul>'; |
| 695 | - else |
|
| 696 | - echo ' |
|
| 725 | + } else { |
|
| 726 | + echo ' |
|
| 697 | 727 | <div class="information">', $txt['permissions_option_desc'], '</div> |
| 698 | 728 | <dl class="settings"> |
| 699 | 729 | <dt> |
@@ -703,47 +733,52 @@ discard block |
||
| 703 | 733 | </dt> |
| 704 | 734 | <dd> |
| 705 | 735 | </dd>'; |
| 736 | + } |
|
| 706 | 737 | |
| 707 | 738 | foreach ($context['member_groups'] as $group) |
| 708 | 739 | { |
| 709 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 710 | - echo ' |
|
| 740 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 741 | + echo ' |
|
| 711 | 742 | <dt>'; |
| 712 | - else |
|
| 713 | - echo ' |
|
| 743 | + } else { |
|
| 744 | + echo ' |
|
| 714 | 745 | <li>'; |
| 746 | + } |
|
| 715 | 747 | |
| 716 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 717 | - echo ' |
|
| 748 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 749 | + echo ' |
|
| 718 | 750 | <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '>'; |
| 719 | - else |
|
| 720 | - echo ' |
|
| 751 | + } else { |
|
| 752 | + echo ' |
|
| 721 | 753 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '></span> |
| 722 | 754 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', '></span> |
| 723 | 755 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', '></span>'; |
| 756 | + } |
|
| 724 | 757 | |
| 725 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 726 | - echo ' |
|
| 758 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 759 | + echo ' |
|
| 727 | 760 | </dt> |
| 728 | 761 | <dd> |
| 729 | 762 | <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span> |
| 730 | 763 | </dd>'; |
| 731 | - else |
|
| 732 | - echo ' |
|
| 764 | + } else { |
|
| 765 | + echo ' |
|
| 733 | 766 | <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span> |
| 734 | 767 | </li>'; |
| 768 | + } |
|
| 735 | 769 | } |
| 736 | 770 | |
| 737 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 738 | - echo ' |
|
| 771 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 772 | + echo ' |
|
| 739 | 773 | <li> |
| 740 | 774 | <input type="checkbox" onclick="invertAll(this, this.form, \''. $context['current_permission'] . '[\');"> |
| 741 | 775 | <span>', $txt['check_all'], '</span> |
| 742 | 776 | </li> |
| 743 | 777 | </ul>'; |
| 744 | - else |
|
| 745 | - echo ' |
|
| 778 | + } else { |
|
| 779 | + echo ' |
|
| 746 | 780 | </dl>'; |
| 781 | + } |
|
| 747 | 782 | |
| 748 | 783 | echo ' |
| 749 | 784 | </fieldset> |
@@ -783,9 +818,10 @@ discard block |
||
| 783 | 818 | if (!empty($modSettings['postmod_active'])) |
| 784 | 819 | { |
| 785 | 820 | // Got advanced permissions - if so warn! |
| 786 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 787 | - echo ' |
|
| 821 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 822 | + echo ' |
|
| 788 | 823 | <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>'; |
| 824 | + } |
|
| 789 | 825 | |
| 790 | 826 | echo ' |
| 791 | 827 | <div class="padding"> |
@@ -800,10 +836,11 @@ discard block |
||
| 800 | 836 | ', $txt['permissions_post_moderation_select'], ': |
| 801 | 837 | <select name="pid" onchange="document.forms.postmodForm.submit();">'; |
| 802 | 838 | |
| 803 | - foreach ($context['profiles'] as $profile) |
|
| 804 | - if ($profile['can_modify']) |
|
| 839 | + foreach ($context['profiles'] as $profile) { |
|
| 840 | + if ($profile['can_modify']) |
|
| 805 | 841 | echo ' |
| 806 | 842 | <option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
| 843 | + } |
|
| 807 | 844 | |
| 808 | 845 | echo ' |
| 809 | 846 | </select> |
@@ -824,11 +861,12 @@ discard block |
||
| 824 | 861 | ', $txt['permissions_post_moderation_replies_any'], ' |
| 825 | 862 | </th>'; |
| 826 | 863 | |
| 827 | - if ($modSettings['attachmentEnable'] == 1) |
|
| 828 | - echo ' |
|
| 864 | + if ($modSettings['attachmentEnable'] == 1) { |
|
| 865 | + echo ' |
|
| 829 | 866 | <th class="centercol" colspan="3"> |
| 830 | 867 | ', $txt['permissions_post_moderation_attachments'], ' |
| 831 | 868 | </th>'; |
| 869 | + } |
|
| 832 | 870 | |
| 833 | 871 | echo ' |
| 834 | 872 | </tr> |
@@ -846,11 +884,12 @@ discard block |
||
| 846 | 884 | <th><span class="generic_icons post_moderation_moderate"></span></th> |
| 847 | 885 | <th><span class="generic_icons post_moderation_deny"></span></th>'; |
| 848 | 886 | |
| 849 | - if ($modSettings['attachmentEnable'] == 1) |
|
| 850 | - echo ' |
|
| 887 | + if ($modSettings['attachmentEnable'] == 1) { |
|
| 888 | + echo ' |
|
| 851 | 889 | <th><span class="generic_icons post_moderation_allow"></span></th> |
| 852 | 890 | <th><span class="generic_icons post_moderation_moderate"></span></th> |
| 853 | 891 | <th><span class="generic_icons post_moderation_deny"></span></th>'; |
| 892 | + } |
|
| 854 | 893 | |
| 855 | 894 | echo ' |
| 856 | 895 | </tr> |
@@ -864,10 +903,11 @@ discard block |
||
| 864 | 903 | <td class="half_table"> |
| 865 | 904 | <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>'; |
| 866 | 905 | |
| 867 | - if (!empty($group['children'])) |
|
| 868 | - echo ' |
|
| 906 | + if (!empty($group['children'])) { |
|
| 907 | + echo ' |
|
| 869 | 908 | <br> |
| 870 | 909 | <span class="smalltext">', $txt['permissions_includes_inherited'], ': "', implode('", "', $group['children']), '"</span>'; |
| 910 | + } |
|
| 871 | 911 | |
| 872 | 912 | echo ' |
| 873 | 913 | </td> |
@@ -882,11 +922,11 @@ discard block |
||
| 882 | 922 | </td>'; |
| 883 | 923 | |
| 884 | 924 | // Guests can't have "own" permissions |
| 885 | - if ($group['id'] == '-1') |
|
| 886 | - echo ' |
|
| 925 | + if ($group['id'] == '-1') { |
|
| 926 | + echo ' |
|
| 887 | 927 | <td colspan="3"></td>'; |
| 888 | - else |
|
| 889 | - echo ' |
|
| 928 | + } else { |
|
| 929 | + echo ' |
|
| 890 | 930 | <td class="centercol"> |
| 891 | 931 | <input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', '> |
| 892 | 932 | </td> |
@@ -896,6 +936,7 @@ discard block |
||
| 896 | 936 | <td class="centercol"> |
| 897 | 937 | <input type="radio" name="replies_own[', $group['id'], ']" value="disallow"', $group['replies_own'] == 'disallow' ? ' checked' : '', '> |
| 898 | 938 | </td>'; |
| 939 | + } |
|
| 899 | 940 | |
| 900 | 941 | echo ' |
| 901 | 942 | <td class="centercol"> |
@@ -908,8 +949,8 @@ discard block |
||
| 908 | 949 | <input type="radio" name="replies_any[', $group['id'], ']" value="disallow"', $group['replies_any'] == 'disallow' ? ' checked' : '', '> |
| 909 | 950 | </td>'; |
| 910 | 951 | |
| 911 | - if ($modSettings['attachmentEnable'] == 1) |
|
| 912 | - echo ' |
|
| 952 | + if ($modSettings['attachmentEnable'] == 1) { |
|
| 953 | + echo ' |
|
| 913 | 954 | <td class="centercol"> |
| 914 | 955 | <input type="radio" name="attachment[', $group['id'], ']" value="allow"', $group['attachment'] == 'allow' ? ' checked' : '', '> |
| 915 | 956 | </td> |
@@ -919,6 +960,7 @@ discard block |
||
| 919 | 960 | <td class="centercol"> |
| 920 | 961 | <input type="radio" name="attachment[', $group['id'], ']" value="disallow"', $group['attachment'] == 'disallow' ? ' checked' : '', '> |
| 921 | 962 | </td>'; |
| 963 | + } |
|
| 922 | 964 | |
| 923 | 965 | echo ' |
| 924 | 966 | </tr>'; |
@@ -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 | { |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | { |
| 387 | 387 | $val = 'CASE '; |
| 388 | 388 | foreach ($members as $k => $v) |
| 389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 389 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 390 | 390 | $val = $val . ' END'; |
| 391 | 391 | $type = 'raw'; |
| 392 | 392 | } |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | static $non_twelve_hour, $locale_cache; |
| 740 | 740 | static $unsupportedFormats, $finalizedFormats; |
| 741 | 741 | |
| 742 | - $unsupportedFormatsWindows = array('z','Z'); |
|
| 742 | + $unsupportedFormatsWindows = array('z', 'Z'); |
|
| 743 | 743 | |
| 744 | 744 | // Ensure required values are set |
| 745 | 745 | $user_info['time_offset'] = !empty($user_info['time_offset']) ? $user_info['time_offset'] : 0; |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
| 825 | 825 | if (empty($unsupportedFormats)) |
| 826 | 826 | { |
| 827 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
| 827 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
| 828 | 828 | { |
| 829 | 829 | // Avoid a crashing bug with PHP 7 on certain versions of Windows |
| 830 | 830 | if ($context['server']['is_windows'] && in_array($format, $unsupportedFormatsWindows)) |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
| 1197 | 1197 | ), |
| 1198 | 1198 | 'content' => '$1', |
| 1199 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1199 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1200 | 1200 | { |
| 1201 | 1201 | $returnContext = ''; |
| 1202 | 1202 | |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
| 1234 | - $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>'; |
|
| 1234 | + $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>'; |
|
| 1235 | 1235 | else |
| 1236 | 1236 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
| 1237 | 1237 | } |
@@ -1260,7 +1260,7 @@ discard block |
||
| 1260 | 1260 | 'type' => 'unparsed_content', |
| 1261 | 1261 | '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>', |
| 1262 | 1262 | // @todo Maybe this can be simplified? |
| 1263 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1263 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1264 | 1264 | { |
| 1265 | 1265 | if (!isset($disabled['code'])) |
| 1266 | 1266 | { |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | 'type' => 'unparsed_equals_content', |
| 1298 | 1298 | '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>', |
| 1299 | 1299 | // @todo Maybe this can be simplified? |
| 1300 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1300 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1301 | 1301 | { |
| 1302 | 1302 | if (!isset($disabled['code'])) |
| 1303 | 1303 | { |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | 'type' => 'unparsed_content', |
| 1342 | 1342 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
| 1343 | 1343 | // @todo Should this respect guest_hideContacts? |
| 1344 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1344 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1345 | 1345 | { |
| 1346 | 1346 | $data = strtr($data, array('<br>' => '')); |
| 1347 | 1347 | }, |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | 'type' => 'unparsed_commas_content', |
| 1361 | 1361 | 'test' => '\d+,\d+\]', |
| 1362 | 1362 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1363 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1363 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1364 | 1364 | { |
| 1365 | 1365 | if (isset($disabled['url'])) |
| 1366 | 1366 | $tag['content'] = '$1'; |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
| 1377 | 1377 | 'before' => '<div $1>', |
| 1378 | 1378 | 'after' => '</div>', |
| 1379 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1379 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1380 | 1380 | { |
| 1381 | 1381 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1382 | 1382 | |
@@ -1425,7 +1425,7 @@ discard block |
||
| 1425 | 1425 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
| 1426 | 1426 | ), |
| 1427 | 1427 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
| 1428 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1428 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1429 | 1429 | { |
| 1430 | 1430 | global $image_proxy_enabled, $user_info; |
| 1431 | 1431 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | 'tag' => 'img', |
| 1452 | 1452 | 'type' => 'unparsed_content', |
| 1453 | 1453 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
| 1454 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1454 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1455 | 1455 | { |
| 1456 | 1456 | global $image_proxy_enabled, $user_info; |
| 1457 | 1457 | |
@@ -1477,7 +1477,7 @@ discard block |
||
| 1477 | 1477 | 'tag' => 'iurl', |
| 1478 | 1478 | 'type' => 'unparsed_content', |
| 1479 | 1479 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
| 1480 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1480 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1481 | 1481 | { |
| 1482 | 1482 | $data = strtr($data, array('<br>' => '')); |
| 1483 | 1483 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | 'quoted' => 'optional', |
| 1492 | 1492 | 'before' => '<a href="$1" class="bbc_link">', |
| 1493 | 1493 | 'after' => '</a>', |
| 1494 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1494 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1495 | 1495 | { |
| 1496 | 1496 | if (substr($data, 0, 1) == '#') |
| 1497 | 1497 | $data = '#post_' . substr($data, 1); |
@@ -1577,7 +1577,7 @@ discard block |
||
| 1577 | 1577 | 'tag' => 'php', |
| 1578 | 1578 | 'type' => 'unparsed_content', |
| 1579 | 1579 | 'content' => '<span class="phpcode">$1</span>', |
| 1580 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
| 1580 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
| 1581 | 1581 | { |
| 1582 | 1582 | if (!isset($disabled['php'])) |
| 1583 | 1583 | { |
@@ -1675,7 +1675,7 @@ discard block |
||
| 1675 | 1675 | 'test' => '[1-7]\]', |
| 1676 | 1676 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
| 1677 | 1677 | 'after' => '</span>', |
| 1678 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1678 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1679 | 1679 | { |
| 1680 | 1680 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
| 1681 | 1681 | $data = $sizes[$data] . 'em'; |
@@ -1713,7 +1713,7 @@ discard block |
||
| 1713 | 1713 | 'tag' => 'time', |
| 1714 | 1714 | 'type' => 'unparsed_content', |
| 1715 | 1715 | 'content' => '$1', |
| 1716 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1716 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1717 | 1717 | { |
| 1718 | 1718 | if (is_numeric($data)) |
| 1719 | 1719 | $data = timeformat($data); |
@@ -1741,7 +1741,7 @@ discard block |
||
| 1741 | 1741 | 'tag' => 'url', |
| 1742 | 1742 | 'type' => 'unparsed_content', |
| 1743 | 1743 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
| 1744 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1744 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1745 | 1745 | { |
| 1746 | 1746 | $data = strtr($data, array('<br>' => '')); |
| 1747 | 1747 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1755,7 +1755,7 @@ discard block |
||
| 1755 | 1755 | 'quoted' => 'optional', |
| 1756 | 1756 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
| 1757 | 1757 | 'after' => '</a>', |
| 1758 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1758 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1759 | 1759 | { |
| 1760 | 1760 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1761 | 1761 | if (empty($scheme)) |
@@ -1787,7 +1787,7 @@ discard block |
||
| 1787 | 1787 | { |
| 1788 | 1788 | if (isset($temp_bbc)) |
| 1789 | 1789 | $bbc_codes = $temp_bbc; |
| 1790 | - usort($codes, function ($a, $b) { |
|
| 1790 | + usort($codes, function($a, $b) { |
|
| 1791 | 1791 | return strcmp($a['tag'], $b['tag']); |
| 1792 | 1792 | }); |
| 1793 | 1793 | return $codes; |
@@ -2003,7 +2003,7 @@ discard block |
||
| 2003 | 2003 | # a run of Unicode domain name characters and a dot |
| 2004 | 2004 | [\p{L}\p{M}\p{N}\-.:@]+\. |
| 2005 | 2005 | # and then a TLD valid in the DNS or the reserved "local" TLD |
| 2006 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
| 2006 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
| 2007 | 2007 | ) |
| 2008 | 2008 | # followed by a non-domain character or end of line |
| 2009 | 2009 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2071,7 +2071,7 @@ discard block |
||
| 2071 | 2071 | )? |
| 2072 | 2072 | '; |
| 2073 | 2073 | |
| 2074 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
| 2074 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
| 2075 | 2075 | $url = array_shift($matches); |
| 2076 | 2076 | |
| 2077 | 2077 | // If this isn't a clean URL, bail out |
@@ -2096,7 +2096,7 @@ discard block |
||
| 2096 | 2096 | $fullUrl = $url; |
| 2097 | 2097 | |
| 2098 | 2098 | // Make sure that $fullUrl really is valid |
| 2099 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
| 2099 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '') . $fullUrl) === false) |
|
| 2100 | 2100 | return $url; |
| 2101 | 2101 | |
| 2102 | 2102 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
@@ -2160,7 +2160,7 @@ discard block |
||
| 2160 | 2160 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2161 | 2161 | |
| 2162 | 2162 | // A closing tag that doesn't match any open tags? Skip it. |
| 2163 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
| 2163 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
| 2164 | 2164 | continue; |
| 2165 | 2165 | |
| 2166 | 2166 | $to_close = array(); |
@@ -2830,7 +2830,7 @@ discard block |
||
| 2830 | 2830 | { |
| 2831 | 2831 | $exts = array('svg', 'png', 'gif', 'jpg'); |
| 2832 | 2832 | $fname = pathinfo($smileysto[$i], PATHINFO_FILENAME); |
| 2833 | - $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
|
| 2833 | + $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
|
| 2834 | 2834 | if (!empty($alt_images)) |
| 2835 | 2835 | { |
| 2836 | 2836 | foreach ($exts as $ext) |
@@ -2846,7 +2846,7 @@ discard block |
||
| 2846 | 2846 | } |
| 2847 | 2847 | |
| 2848 | 2848 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
| 2849 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2849 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2850 | 2850 | |
| 2851 | 2851 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
| 2852 | 2852 | |
@@ -2863,7 +2863,7 @@ discard block |
||
| 2863 | 2863 | |
| 2864 | 2864 | // Replace away! |
| 2865 | 2865 | $message = preg_replace_callback($smileyPregSearch, |
| 2866 | - function ($matches) use ($smileyPregReplacements) |
|
| 2866 | + function($matches) use ($smileyPregReplacements) |
|
| 2867 | 2867 | { |
| 2868 | 2868 | return $smileyPregReplacements[$matches[1]]; |
| 2869 | 2869 | }, $message); |
@@ -2960,13 +2960,13 @@ discard block |
||
| 2960 | 2960 | { |
| 2961 | 2961 | if (defined('SID') && SID != '') |
| 2962 | 2962 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
| 2963 | - function ($m) use ($scripturl) |
|
| 2963 | + function($m) use ($scripturl) |
|
| 2964 | 2964 | { |
| 2965 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
| 2965 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
| 2966 | 2966 | }, $setLocation); |
| 2967 | 2967 | else |
| 2968 | 2968 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
| 2969 | - function ($m) use ($scripturl) |
|
| 2969 | + function($m) use ($scripturl) |
|
| 2970 | 2970 | { |
| 2971 | 2971 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2972 | 2972 | }, $setLocation); |
@@ -3287,7 +3287,7 @@ discard block |
||
| 3287 | 3287 | |
| 3288 | 3288 | // Add a generic "Are you sure?" confirmation message. |
| 3289 | 3289 | addInlineJavaScript(' |
| 3290 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
| 3290 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
| 3291 | 3291 | |
| 3292 | 3292 | // Now add the capping code for avatars. |
| 3293 | 3293 | 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') |
@@ -3753,7 +3753,7 @@ discard block |
||
| 3753 | 3753 | if (!empty($normal)) |
| 3754 | 3754 | foreach ($normal as $nf) |
| 3755 | 3755 | echo ' |
| 3756 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
| 3756 | + <link rel="stylesheet" href="', $nf, '">'; |
|
| 3757 | 3757 | |
| 3758 | 3758 | if ($db_show_debug === true) |
| 3759 | 3759 | { |
@@ -3769,7 +3769,7 @@ discard block |
||
| 3769 | 3769 | <style>'; |
| 3770 | 3770 | |
| 3771 | 3771 | foreach ($context['css_header'] as $css) |
| 3772 | - echo $css .' |
|
| 3772 | + echo $css . ' |
|
| 3773 | 3773 | '; |
| 3774 | 3774 | |
| 3775 | 3775 | echo' |
@@ -3813,7 +3813,7 @@ discard block |
||
| 3813 | 3813 | |
| 3814 | 3814 | |
| 3815 | 3815 | // No namespaces, sorry! |
| 3816 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
| 3816 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
| 3817 | 3817 | |
| 3818 | 3818 | // Temp path. |
| 3819 | 3819 | $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
@@ -3993,7 +3993,7 @@ discard block |
||
| 3993 | 3993 | else |
| 3994 | 3994 | $path = $modSettings['attachmentUploadDir']; |
| 3995 | 3995 | |
| 3996 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
| 3996 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
| 3997 | 3997 | } |
| 3998 | 3998 | |
| 3999 | 3999 | /** |
@@ -4037,10 +4037,10 @@ discard block |
||
| 4037 | 4037 | $valid_low = isValidIP($ip_parts[0]); |
| 4038 | 4038 | $valid_high = isValidIP($ip_parts[1]); |
| 4039 | 4039 | $count = 0; |
| 4040 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
| 4040 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
| 4041 | 4041 | $max = ($mode == ':' ? 'ffff' : '255'); |
| 4042 | 4042 | $min = 0; |
| 4043 | - if(!$valid_low) |
|
| 4043 | + if (!$valid_low) |
|
| 4044 | 4044 | { |
| 4045 | 4045 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
| 4046 | 4046 | $valid_low = isValidIP($ip_parts[0]); |
@@ -4054,7 +4054,7 @@ discard block |
||
| 4054 | 4054 | } |
| 4055 | 4055 | |
| 4056 | 4056 | $count = 0; |
| 4057 | - if(!$valid_high) |
|
| 4057 | + if (!$valid_high) |
|
| 4058 | 4058 | { |
| 4059 | 4059 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
| 4060 | 4060 | $valid_high = isValidIP($ip_parts[1]); |
@@ -4067,7 +4067,7 @@ discard block |
||
| 4067 | 4067 | } |
| 4068 | 4068 | } |
| 4069 | 4069 | |
| 4070 | - if($valid_high && $valid_low) |
|
| 4070 | + if ($valid_high && $valid_low) |
|
| 4071 | 4071 | { |
| 4072 | 4072 | $ip_array['low'] = $ip_parts[0]; |
| 4073 | 4073 | $ip_array['high'] = $ip_parts[1]; |
@@ -4248,7 +4248,7 @@ discard block |
||
| 4248 | 4248 | addInlineJavaScript(' |
| 4249 | 4249 | var user_menus = new smc_PopupMenu(); |
| 4250 | 4250 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4251 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
| 4251 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
| 4252 | 4252 | if ($context['allow_pm']) |
| 4253 | 4253 | addInlineJavaScript(' |
| 4254 | 4254 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4884,7 +4884,7 @@ discard block |
||
| 4884 | 4884 | // No? try a fallback to $sourcedir |
| 4885 | 4885 | else |
| 4886 | 4886 | { |
| 4887 | - $absPath = $sourcedir .'/'. $file; |
|
| 4887 | + $absPath = $sourcedir . '/' . $file; |
|
| 4888 | 4888 | |
| 4889 | 4889 | if (file_exists($absPath)) |
| 4890 | 4890 | require_once($absPath); |
@@ -5151,15 +5151,15 @@ discard block |
||
| 5151 | 5151 | |
| 5152 | 5152 | // UTF-8 occurences of MS special characters |
| 5153 | 5153 | $findchars_utf8 = array( |
| 5154 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 5155 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 5156 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
| 5157 | - "\xe2\x80\x98", // left single curly quote |
|
| 5158 | - "\xe2\x80\x99", // right single curly quote |
|
| 5159 | - "\xe2\x80\x9c", // left double curly quote |
|
| 5160 | - "\xe2\x80\x9d", // right double curly quote |
|
| 5161 | - "\xe2\x80\x93", // en dash |
|
| 5162 | - "\xe2\x80\x94", // em dash |
|
| 5154 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 5155 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 5156 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
| 5157 | + "\xe2\x80\x98", // left single curly quote |
|
| 5158 | + "\xe2\x80\x99", // right single curly quote |
|
| 5159 | + "\xe2\x80\x9c", // left double curly quote |
|
| 5160 | + "\xe2\x80\x9d", // right double curly quote |
|
| 5161 | + "\xe2\x80\x93", // en dash |
|
| 5162 | + "\xe2\x80\x94", // em dash |
|
| 5163 | 5163 | ); |
| 5164 | 5164 | |
| 5165 | 5165 | // windows 1252 / iso equivalents |
@@ -5177,15 +5177,15 @@ discard block |
||
| 5177 | 5177 | |
| 5178 | 5178 | // safe replacements |
| 5179 | 5179 | $replacechars = array( |
| 5180 | - ',', // ‚ |
|
| 5181 | - ',,', // „ |
|
| 5182 | - '...', // … |
|
| 5183 | - "'", // ‘ |
|
| 5184 | - "'", // ’ |
|
| 5185 | - '"', // “ |
|
| 5186 | - '"', // ” |
|
| 5187 | - '-', // – |
|
| 5188 | - '--', // — |
|
| 5180 | + ',', // ‚ |
|
| 5181 | + ',,', // „ |
|
| 5182 | + '...', // … |
|
| 5183 | + "'", // ‘ |
|
| 5184 | + "'", // ’ |
|
| 5185 | + '"', // “ |
|
| 5186 | + '"', // ” |
|
| 5187 | + '-', // – |
|
| 5188 | + '--', // — |
|
| 5189 | 5189 | ); |
| 5190 | 5190 | |
| 5191 | 5191 | if ($context['utf8']) |
@@ -5505,7 +5505,7 @@ discard block |
||
| 5505 | 5505 | */ |
| 5506 | 5506 | function inet_dtop($bin) |
| 5507 | 5507 | { |
| 5508 | - if(empty($bin)) |
|
| 5508 | + if (empty($bin)) |
|
| 5509 | 5509 | return ''; |
| 5510 | 5510 | |
| 5511 | 5511 | global $db_type; |
@@ -5536,28 +5536,28 @@ discard block |
||
| 5536 | 5536 | */ |
| 5537 | 5537 | function _safe_serialize($value) |
| 5538 | 5538 | { |
| 5539 | - if(is_null($value)) |
|
| 5539 | + if (is_null($value)) |
|
| 5540 | 5540 | return 'N;'; |
| 5541 | 5541 | |
| 5542 | - if(is_bool($value)) |
|
| 5543 | - return 'b:'. (int) $value .';'; |
|
| 5542 | + if (is_bool($value)) |
|
| 5543 | + return 'b:' . (int) $value . ';'; |
|
| 5544 | 5544 | |
| 5545 | - if(is_int($value)) |
|
| 5546 | - return 'i:'. $value .';'; |
|
| 5545 | + if (is_int($value)) |
|
| 5546 | + return 'i:' . $value . ';'; |
|
| 5547 | 5547 | |
| 5548 | - if(is_float($value)) |
|
| 5549 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5548 | + if (is_float($value)) |
|
| 5549 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
| 5550 | 5550 | |
| 5551 | - if(is_string($value)) |
|
| 5552 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5551 | + if (is_string($value)) |
|
| 5552 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 5553 | 5553 | |
| 5554 | - if(is_array($value)) |
|
| 5554 | + if (is_array($value)) |
|
| 5555 | 5555 | { |
| 5556 | 5556 | $out = ''; |
| 5557 | - foreach($value as $k => $v) |
|
| 5557 | + foreach ($value as $k => $v) |
|
| 5558 | 5558 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 5559 | 5559 | |
| 5560 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
| 5560 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 5561 | 5561 | } |
| 5562 | 5562 | |
| 5563 | 5563 | // safe_serialize cannot serialize resources or objects. |
@@ -5599,7 +5599,7 @@ discard block |
||
| 5599 | 5599 | function _safe_unserialize($str) |
| 5600 | 5600 | { |
| 5601 | 5601 | // Input is not a string. |
| 5602 | - if(empty($str) || !is_string($str)) |
|
| 5602 | + if (empty($str) || !is_string($str)) |
|
| 5603 | 5603 | return false; |
| 5604 | 5604 | |
| 5605 | 5605 | $stack = array(); |
@@ -5613,40 +5613,40 @@ discard block |
||
| 5613 | 5613 | * 3 - in array, expecting value or another array |
| 5614 | 5614 | */ |
| 5615 | 5615 | $state = 0; |
| 5616 | - while($state != 1) |
|
| 5616 | + while ($state != 1) |
|
| 5617 | 5617 | { |
| 5618 | 5618 | $type = isset($str[0]) ? $str[0] : ''; |
| 5619 | - if($type == '}') |
|
| 5619 | + if ($type == '}') |
|
| 5620 | 5620 | $str = substr($str, 1); |
| 5621 | 5621 | |
| 5622 | - else if($type == 'N' && $str[1] == ';') |
|
| 5622 | + else if ($type == 'N' && $str[1] == ';') |
|
| 5623 | 5623 | { |
| 5624 | 5624 | $value = null; |
| 5625 | 5625 | $str = substr($str, 2); |
| 5626 | 5626 | } |
| 5627 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5627 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5628 | 5628 | { |
| 5629 | 5629 | $value = $matches[1] == '1' ? true : false; |
| 5630 | 5630 | $str = substr($str, 4); |
| 5631 | 5631 | } |
| 5632 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5632 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5633 | 5633 | { |
| 5634 | - $value = (int)$matches[1]; |
|
| 5634 | + $value = (int) $matches[1]; |
|
| 5635 | 5635 | $str = $matches[2]; |
| 5636 | 5636 | } |
| 5637 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5637 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5638 | 5638 | { |
| 5639 | - $value = (float)$matches[1]; |
|
| 5639 | + $value = (float) $matches[1]; |
|
| 5640 | 5640 | $str = $matches[3]; |
| 5641 | 5641 | } |
| 5642 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5642 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 5643 | 5643 | { |
| 5644 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 5645 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 5644 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 5645 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 5646 | 5646 | } |
| 5647 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5647 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5648 | 5648 | { |
| 5649 | - $expectedLength = (int)$matches[1]; |
|
| 5649 | + $expectedLength = (int) $matches[1]; |
|
| 5650 | 5650 | $str = $matches[2]; |
| 5651 | 5651 | } |
| 5652 | 5652 | |
@@ -5654,10 +5654,10 @@ discard block |
||
| 5654 | 5654 | else |
| 5655 | 5655 | return false; |
| 5656 | 5656 | |
| 5657 | - switch($state) |
|
| 5657 | + switch ($state) |
|
| 5658 | 5658 | { |
| 5659 | 5659 | case 3: // In array, expecting value or another array. |
| 5660 | - if($type == 'a') |
|
| 5660 | + if ($type == 'a') |
|
| 5661 | 5661 | { |
| 5662 | 5662 | $stack[] = &$list; |
| 5663 | 5663 | $list[$key] = array(); |
@@ -5666,7 +5666,7 @@ discard block |
||
| 5666 | 5666 | $state = 2; |
| 5667 | 5667 | break; |
| 5668 | 5668 | } |
| 5669 | - if($type != '}') |
|
| 5669 | + if ($type != '}') |
|
| 5670 | 5670 | { |
| 5671 | 5671 | $list[$key] = $value; |
| 5672 | 5672 | $state = 2; |
@@ -5677,29 +5677,29 @@ discard block |
||
| 5677 | 5677 | return false; |
| 5678 | 5678 | |
| 5679 | 5679 | case 2: // in array, expecting end of array or a key |
| 5680 | - if($type == '}') |
|
| 5680 | + if ($type == '}') |
|
| 5681 | 5681 | { |
| 5682 | 5682 | // Array size is less than expected. |
| 5683 | - if(count($list) < end($expected)) |
|
| 5683 | + if (count($list) < end($expected)) |
|
| 5684 | 5684 | return false; |
| 5685 | 5685 | |
| 5686 | 5686 | unset($list); |
| 5687 | - $list = &$stack[count($stack)-1]; |
|
| 5687 | + $list = &$stack[count($stack) - 1]; |
|
| 5688 | 5688 | array_pop($stack); |
| 5689 | 5689 | |
| 5690 | 5690 | // Go to terminal state if we're at the end of the root array. |
| 5691 | 5691 | array_pop($expected); |
| 5692 | 5692 | |
| 5693 | - if(count($expected) == 0) |
|
| 5693 | + if (count($expected) == 0) |
|
| 5694 | 5694 | $state = 1; |
| 5695 | 5695 | |
| 5696 | 5696 | break; |
| 5697 | 5697 | } |
| 5698 | 5698 | |
| 5699 | - if($type == 'i' || $type == 's') |
|
| 5699 | + if ($type == 'i' || $type == 's') |
|
| 5700 | 5700 | { |
| 5701 | 5701 | // Array size exceeds expected length. |
| 5702 | - if(count($list) >= end($expected)) |
|
| 5702 | + if (count($list) >= end($expected)) |
|
| 5703 | 5703 | return false; |
| 5704 | 5704 | |
| 5705 | 5705 | $key = $value; |
@@ -5712,7 +5712,7 @@ discard block |
||
| 5712 | 5712 | |
| 5713 | 5713 | // Expecting array or value. |
| 5714 | 5714 | case 0: |
| 5715 | - if($type == 'a') |
|
| 5715 | + if ($type == 'a') |
|
| 5716 | 5716 | { |
| 5717 | 5717 | $data = array(); |
| 5718 | 5718 | $list = &$data; |
@@ -5721,7 +5721,7 @@ discard block |
||
| 5721 | 5721 | break; |
| 5722 | 5722 | } |
| 5723 | 5723 | |
| 5724 | - if($type != '}') |
|
| 5724 | + if ($type != '}') |
|
| 5725 | 5725 | { |
| 5726 | 5726 | $data = $value; |
| 5727 | 5727 | $state = 1; |
@@ -5734,7 +5734,7 @@ discard block |
||
| 5734 | 5734 | } |
| 5735 | 5735 | |
| 5736 | 5736 | // Trailing data in input. |
| 5737 | - if(!empty($str)) |
|
| 5737 | + if (!empty($str)) |
|
| 5738 | 5738 | return false; |
| 5739 | 5739 | |
| 5740 | 5740 | return $data; |
@@ -5788,7 +5788,7 @@ discard block |
||
| 5788 | 5788 | // Set different modes. |
| 5789 | 5789 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
| 5790 | 5790 | |
| 5791 | - foreach($chmodValues as $val) |
|
| 5791 | + foreach ($chmodValues as $val) |
|
| 5792 | 5792 | { |
| 5793 | 5793 | // If it's writable, break out of the loop. |
| 5794 | 5794 | if (is_writable($file)) |
@@ -5823,13 +5823,13 @@ discard block |
||
| 5823 | 5823 | $returnArray = @json_decode($json, $returnAsArray); |
| 5824 | 5824 | |
| 5825 | 5825 | // PHP 5.3 so no json_last_error_msg() |
| 5826 | - switch(json_last_error()) |
|
| 5826 | + switch (json_last_error()) |
|
| 5827 | 5827 | { |
| 5828 | 5828 | case JSON_ERROR_NONE: |
| 5829 | 5829 | $jsonError = false; |
| 5830 | 5830 | break; |
| 5831 | 5831 | case JSON_ERROR_DEPTH: |
| 5832 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5832 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5833 | 5833 | break; |
| 5834 | 5834 | case JSON_ERROR_STATE_MISMATCH: |
| 5835 | 5835 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5857,10 +5857,10 @@ discard block |
||
| 5857 | 5857 | loadLanguage('Errors'); |
| 5858 | 5858 | |
| 5859 | 5859 | if (!empty($jsonDebug)) |
| 5860 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5860 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5861 | 5861 | |
| 5862 | 5862 | else |
| 5863 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5863 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
| 5864 | 5864 | |
| 5865 | 5865 | // Everyone expects an array. |
| 5866 | 5866 | return array(); |
@@ -5977,7 +5977,7 @@ discard block |
||
| 5977 | 5977 | // Convert Punycode to Unicode |
| 5978 | 5978 | require_once($sourcedir . '/Class-Punycode.php'); |
| 5979 | 5979 | $Punycode = new Punycode(); |
| 5980 | - $tlds = array_map(function ($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
| 5980 | + $tlds = array_map(function($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
| 5981 | 5981 | } |
| 5982 | 5982 | // Otherwise, use the 2012 list of gTLDs and ccTLDs for now and schedule a background update |
| 5983 | 5983 | else |
@@ -6071,7 +6071,7 @@ discard block |
||
| 6071 | 6071 | } |
| 6072 | 6072 | |
| 6073 | 6073 | // This recursive function creates the index array from the strings |
| 6074 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 6074 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 6075 | 6075 | { |
| 6076 | 6076 | static $depth = 0; |
| 6077 | 6077 | $depth++; |
@@ -6098,7 +6098,7 @@ discard block |
||
| 6098 | 6098 | }; |
| 6099 | 6099 | |
| 6100 | 6100 | // This recursive function turns the index array into a regular expression |
| 6101 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 6101 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 6102 | 6102 | { |
| 6103 | 6103 | static $depth = 0; |
| 6104 | 6104 | $depth++; |
@@ -6122,11 +6122,11 @@ discard block |
||
| 6122 | 6122 | |
| 6123 | 6123 | if (count(array_keys($value)) == 1) |
| 6124 | 6124 | { |
| 6125 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
| 6125 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
| 6126 | 6126 | $new_key .= $new_key_array[0]; |
| 6127 | 6127 | } |
| 6128 | 6128 | else |
| 6129 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6129 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
| 6130 | 6130 | } |
| 6131 | 6131 | |
| 6132 | 6132 | if ($depth > 1) |
@@ -6169,10 +6169,10 @@ discard block |
||
| 6169 | 6169 | { |
| 6170 | 6170 | $regex = array(); |
| 6171 | 6171 | while (!empty($index)) |
| 6172 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6172 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6173 | 6173 | } |
| 6174 | 6174 | else |
| 6175 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6175 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6176 | 6176 | |
| 6177 | 6177 | // Restore PHP's internal character encoding to whatever it was originally |
| 6178 | 6178 | if (!empty($current_encoding)) |
@@ -6396,7 +6396,7 @@ discard block |
||
| 6396 | 6396 | function sanitize_iri($iri) |
| 6397 | 6397 | { |
| 6398 | 6398 | // Encode any non-ASCII characters (but not space or control characters of any sort) |
| 6399 | - $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function ($matches) { |
|
| 6399 | + $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function($matches) { |
|
| 6400 | 6400 | return rawurlencode($matches[0]); |
| 6401 | 6401 | }, $iri); |
| 6402 | 6402 | |
@@ -6438,7 +6438,7 @@ discard block |
||
| 6438 | 6438 | $unescaped = array( |
| 6439 | 6439 | '%21'=>'!', '%23'=>'#', '%24'=>'$', '%26'=>'&', |
| 6440 | 6440 | '%27'=>"'", '%28'=>'(', '%29'=>')', '%2A'=>'*', |
| 6441 | - '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
| 6441 | + '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
| 6442 | 6442 | '%3B'=>';', '%3D'=>'=', '%3F'=>'?', '%40'=>'@', |
| 6443 | 6443 | ); |
| 6444 | 6444 | $iri = strtr(rawurlencode($iri), $unescaped); |
@@ -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,12 +1134,14 @@ 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 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1088 | - $disabled['flash'] = true; |
|
| 1142 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1143 | + $disabled['flash'] = true; |
|
| 1144 | + } |
|
| 1089 | 1145 | |
| 1090 | 1146 | /* The following bbc are formatted as an array, with keys as follows: |
| 1091 | 1147 | |
@@ -1214,8 +1270,9 @@ discard block |
||
| 1214 | 1270 | $returnContext = ''; |
| 1215 | 1271 | |
| 1216 | 1272 | // BBC or the entire attachments feature is disabled |
| 1217 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1218 | - return $data; |
|
| 1273 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1274 | + return $data; |
|
| 1275 | + } |
|
| 1219 | 1276 | |
| 1220 | 1277 | // Save the attach ID. |
| 1221 | 1278 | $attachID = $data; |
@@ -1226,8 +1283,9 @@ discard block |
||
| 1226 | 1283 | $currentAttachment = parseAttachBBC($attachID); |
| 1227 | 1284 | |
| 1228 | 1285 | // parseAttachBBC will return a string ($txt key) rather than dying with a fatal_error. Up to you to decide what to do. |
| 1229 | - if (is_string($currentAttachment)) |
|
| 1230 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1286 | + if (is_string($currentAttachment)) { |
|
| 1287 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1288 | + } |
|
| 1231 | 1289 | |
| 1232 | 1290 | if (!empty($currentAttachment['is_image'])) |
| 1233 | 1291 | { |
@@ -1243,15 +1301,17 @@ discard block |
||
| 1243 | 1301 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1244 | 1302 | } |
| 1245 | 1303 | |
| 1246 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1247 | - $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>'; |
|
| 1248 | - else |
|
| 1249 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1304 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1305 | + $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>'; |
|
| 1306 | + } else { |
|
| 1307 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1308 | + } |
|
| 1250 | 1309 | } |
| 1251 | 1310 | |
| 1252 | 1311 | // No image. Show a link. |
| 1253 | - else |
|
| 1254 | - $returnContext .= $currentAttachment['link']; |
|
| 1312 | + else { |
|
| 1313 | + $returnContext .= $currentAttachment['link']; |
|
| 1314 | + } |
|
| 1255 | 1315 | |
| 1256 | 1316 | // Gotta append what we just did. |
| 1257 | 1317 | $data = $returnContext; |
@@ -1305,8 +1365,9 @@ discard block |
||
| 1305 | 1365 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1306 | 1366 | { |
| 1307 | 1367 | // Do PHP code coloring? |
| 1308 | - if ($php_parts[$php_i] != '<?php') |
|
| 1309 | - continue; |
|
| 1368 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1369 | + continue; |
|
| 1370 | + } |
|
| 1310 | 1371 | |
| 1311 | 1372 | $php_string = ''; |
| 1312 | 1373 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1322,8 +1383,9 @@ discard block |
||
| 1322 | 1383 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1323 | 1384 | |
| 1324 | 1385 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1325 | - if ($context['browser']['is_opera']) |
|
| 1326 | - $data .= ' '; |
|
| 1386 | + if ($context['browser']['is_opera']) { |
|
| 1387 | + $data .= ' '; |
|
| 1388 | + } |
|
| 1327 | 1389 | } |
| 1328 | 1390 | }, |
| 1329 | 1391 | 'block_level' => true, |
@@ -1342,8 +1404,9 @@ discard block |
||
| 1342 | 1404 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1343 | 1405 | { |
| 1344 | 1406 | // Do PHP code coloring? |
| 1345 | - if ($php_parts[$php_i] != '<?php') |
|
| 1346 | - continue; |
|
| 1407 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1408 | + continue; |
|
| 1409 | + } |
|
| 1347 | 1410 | |
| 1348 | 1411 | $php_string = ''; |
| 1349 | 1412 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1359,8 +1422,9 @@ discard block |
||
| 1359 | 1422 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1360 | 1423 | |
| 1361 | 1424 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1362 | - if ($context['browser']['is_opera']) |
|
| 1363 | - $data[0] .= ' '; |
|
| 1425 | + if ($context['browser']['is_opera']) { |
|
| 1426 | + $data[0] .= ' '; |
|
| 1427 | + } |
|
| 1364 | 1428 | } |
| 1365 | 1429 | }, |
| 1366 | 1430 | 'block_level' => true, |
@@ -1398,11 +1462,13 @@ discard block |
||
| 1398 | 1462 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1399 | 1463 | 'validate' => function (&$tag, &$data, $disabled) |
| 1400 | 1464 | { |
| 1401 | - if (isset($disabled['url'])) |
|
| 1402 | - $tag['content'] = '$1'; |
|
| 1465 | + if (isset($disabled['url'])) { |
|
| 1466 | + $tag['content'] = '$1'; |
|
| 1467 | + } |
|
| 1403 | 1468 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1404 | - if (empty($scheme)) |
|
| 1405 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1469 | + if (empty($scheme)) { |
|
| 1470 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1471 | + } |
|
| 1406 | 1472 | }, |
| 1407 | 1473 | 'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', |
| 1408 | 1474 | ), |
@@ -1416,10 +1482,11 @@ discard block |
||
| 1416 | 1482 | { |
| 1417 | 1483 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1418 | 1484 | |
| 1419 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1420 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1421 | - else |
|
| 1422 | - $css = ''; |
|
| 1485 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1486 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1487 | + } else { |
|
| 1488 | + $css = ''; |
|
| 1489 | + } |
|
| 1423 | 1490 | |
| 1424 | 1491 | $data = $class . $css; |
| 1425 | 1492 | }, |
@@ -1434,8 +1501,9 @@ discard block |
||
| 1434 | 1501 | { |
| 1435 | 1502 | $data = strtr($data, array('<br />' => '')); |
| 1436 | 1503 | |
| 1437 | - if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) |
|
| 1438 | - $data = 'ftp://' . $data; |
|
| 1504 | + if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) { |
|
| 1505 | + $data = 'ftp://' . $data; |
|
| 1506 | + } |
|
| 1439 | 1507 | }, |
| 1440 | 1508 | ), |
| 1441 | 1509 | array( |
@@ -1445,8 +1513,9 @@ discard block |
||
| 1445 | 1513 | 'after' => '</a>', |
| 1446 | 1514 | 'validate' => function(&$tag, &$data, $disabled) |
| 1447 | 1515 | { |
| 1448 | - if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) |
|
| 1449 | - $data = 'ftp://' . $data; |
|
| 1516 | + if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) { |
|
| 1517 | + $data = 'ftp://' . $data; |
|
| 1518 | + } |
|
| 1450 | 1519 | }, |
| 1451 | 1520 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1452 | 1521 | 'disabled_after' => ' ($1)', |
@@ -1506,17 +1575,20 @@ discard block |
||
| 1506 | 1575 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1507 | 1576 | if ($image_proxy_enabled) |
| 1508 | 1577 | { |
| 1509 | - if (!empty($user_info['possibly_robot'])) |
|
| 1510 | - return; |
|
| 1578 | + if (!empty($user_info['possibly_robot'])) { |
|
| 1579 | + return; |
|
| 1580 | + } |
|
| 1511 | 1581 | |
| 1512 | - if (empty($scheme)) |
|
| 1513 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1582 | + if (empty($scheme)) { |
|
| 1583 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1584 | + } |
|
| 1514 | 1585 | |
| 1515 | - if ($scheme != 'https') |
|
| 1516 | - $data = get_proxied_url($data); |
|
| 1586 | + if ($scheme != 'https') { |
|
| 1587 | + $data = get_proxied_url($data); |
|
| 1588 | + } |
|
| 1589 | + } elseif (empty($scheme)) { |
|
| 1590 | + $data = '//' . ltrim($data, ':/'); |
|
| 1517 | 1591 | } |
| 1518 | - elseif (empty($scheme)) |
|
| 1519 | - $data = '//' . ltrim($data, ':/'); |
|
| 1520 | 1592 | }, |
| 1521 | 1593 | 'disabled_content' => '($1)', |
| 1522 | 1594 | ), |
@@ -1532,17 +1604,20 @@ discard block |
||
| 1532 | 1604 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1533 | 1605 | if ($image_proxy_enabled) |
| 1534 | 1606 | { |
| 1535 | - if (!empty($user_info['possibly_robot'])) |
|
| 1536 | - return; |
|
| 1607 | + if (!empty($user_info['possibly_robot'])) { |
|
| 1608 | + return; |
|
| 1609 | + } |
|
| 1537 | 1610 | |
| 1538 | - if (empty($scheme)) |
|
| 1539 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1611 | + if (empty($scheme)) { |
|
| 1612 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1613 | + } |
|
| 1540 | 1614 | |
| 1541 | - if ($scheme != 'https') |
|
| 1542 | - $data = get_proxied_url($data); |
|
| 1615 | + if ($scheme != 'https') { |
|
| 1616 | + $data = get_proxied_url($data); |
|
| 1617 | + } |
|
| 1618 | + } elseif (empty($scheme)) { |
|
| 1619 | + $data = '//' . ltrim($data, ':/'); |
|
| 1543 | 1620 | } |
| 1544 | - elseif (empty($scheme)) |
|
| 1545 | - $data = '//' . ltrim($data, ':/'); |
|
| 1546 | 1621 | }, |
| 1547 | 1622 | 'disabled_content' => '($1)', |
| 1548 | 1623 | ), |
@@ -1554,8 +1629,9 @@ discard block |
||
| 1554 | 1629 | { |
| 1555 | 1630 | $data = strtr($data, array('<br>' => '')); |
| 1556 | 1631 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1557 | - if (empty($scheme)) |
|
| 1558 | - $data = '//' . ltrim($data, ':/'); |
|
| 1632 | + if (empty($scheme)) { |
|
| 1633 | + $data = '//' . ltrim($data, ':/'); |
|
| 1634 | + } |
|
| 1559 | 1635 | }, |
| 1560 | 1636 | ), |
| 1561 | 1637 | array( |
@@ -1566,13 +1642,14 @@ discard block |
||
| 1566 | 1642 | 'after' => '</a>', |
| 1567 | 1643 | 'validate' => function (&$tag, &$data, $disabled) |
| 1568 | 1644 | { |
| 1569 | - if (substr($data, 0, 1) == '#') |
|
| 1570 | - $data = '#post_' . substr($data, 1); |
|
| 1571 | - else |
|
| 1645 | + if (substr($data, 0, 1) == '#') { |
|
| 1646 | + $data = '#post_' . substr($data, 1); |
|
| 1647 | + } else |
|
| 1572 | 1648 | { |
| 1573 | 1649 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1574 | - if (empty($scheme)) |
|
| 1575 | - $data = '//' . ltrim($data, ':/'); |
|
| 1650 | + if (empty($scheme)) { |
|
| 1651 | + $data = '//' . ltrim($data, ':/'); |
|
| 1652 | + } |
|
| 1576 | 1653 | } |
| 1577 | 1654 | }, |
| 1578 | 1655 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1663,8 +1740,9 @@ discard block |
||
| 1663 | 1740 | { |
| 1664 | 1741 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1665 | 1742 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1666 | - if ($add_begin) |
|
| 1667 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1743 | + if ($add_begin) { |
|
| 1744 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1745 | + } |
|
| 1668 | 1746 | } |
| 1669 | 1747 | }, |
| 1670 | 1748 | 'block_level' => false, |
@@ -1777,20 +1855,17 @@ discard block |
||
| 1777 | 1855 | : function(&$tag, &$data, $disabled) |
| 1778 | 1856 | { |
| 1779 | 1857 | |
| 1780 | - if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) |
|
| 1781 | - $data[1] = '0 -2px 1px'; |
|
| 1782 | - |
|
| 1783 | - elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) |
|
| 1784 | - $data[1] = '2px 0 1px'; |
|
| 1785 | - |
|
| 1786 | - elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) |
|
| 1787 | - $data[1] = '0 2px 1px'; |
|
| 1788 | - |
|
| 1789 | - elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) |
|
| 1790 | - $data[1] = '-2px 0 1px'; |
|
| 1791 | - |
|
| 1792 | - else |
|
| 1793 | - $data[1] = '1px 1px 1px'; |
|
| 1858 | + if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) { |
|
| 1859 | + $data[1] = '0 -2px 1px'; |
|
| 1860 | + } elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) { |
|
| 1861 | + $data[1] = '2px 0 1px'; |
|
| 1862 | + } elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) { |
|
| 1863 | + $data[1] = '0 2px 1px'; |
|
| 1864 | + } elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) { |
|
| 1865 | + $data[1] = '-2px 0 1px'; |
|
| 1866 | + } else { |
|
| 1867 | + $data[1] = '1px 1px 1px'; |
|
| 1868 | + } |
|
| 1794 | 1869 | }, |
| 1795 | 1870 | ), |
| 1796 | 1871 | array( |
@@ -1846,10 +1921,11 @@ discard block |
||
| 1846 | 1921 | 'content' => '$1', |
| 1847 | 1922 | 'validate' => function (&$tag, &$data, $disabled) |
| 1848 | 1923 | { |
| 1849 | - if (is_numeric($data)) |
|
| 1850 | - $data = timeformat($data); |
|
| 1851 | - else |
|
| 1852 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1924 | + if (is_numeric($data)) { |
|
| 1925 | + $data = timeformat($data); |
|
| 1926 | + } else { |
|
| 1927 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1928 | + } |
|
| 1853 | 1929 | }, |
| 1854 | 1930 | ), |
| 1855 | 1931 | array( |
@@ -1881,8 +1957,9 @@ discard block |
||
| 1881 | 1957 | { |
| 1882 | 1958 | $data = strtr($data, array('<br>' => '')); |
| 1883 | 1959 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1884 | - if (empty($scheme)) |
|
| 1885 | - $data = '//' . ltrim($data, ':/'); |
|
| 1960 | + if (empty($scheme)) { |
|
| 1961 | + $data = '//' . ltrim($data, ':/'); |
|
| 1962 | + } |
|
| 1886 | 1963 | }, |
| 1887 | 1964 | ), |
| 1888 | 1965 | array( |
@@ -1894,8 +1971,9 @@ discard block |
||
| 1894 | 1971 | 'validate' => function (&$tag, &$data, $disabled) |
| 1895 | 1972 | { |
| 1896 | 1973 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1897 | - if (empty($scheme)) |
|
| 1898 | - $data = '//' . ltrim($data, ':/'); |
|
| 1974 | + if (empty($scheme)) { |
|
| 1975 | + $data = '//' . ltrim($data, ':/'); |
|
| 1976 | + } |
|
| 1899 | 1977 | }, |
| 1900 | 1978 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1901 | 1979 | 'disabled_after' => ' ($1)', |
@@ -1915,12 +1993,13 @@ discard block |
||
| 1915 | 1993 | ); |
| 1916 | 1994 | |
| 1917 | 1995 | // Handle legacy bbc codes. |
| 1918 | - foreach ($context['legacy_bbc'] as $bbc) |
|
| 1919 | - $codes[] = array( |
|
| 1996 | + foreach ($context['legacy_bbc'] as $bbc) { |
|
| 1997 | + $codes[] = array( |
|
| 1920 | 1998 | 'tag' => $bbc, |
| 1921 | 1999 | 'before' => '', |
| 1922 | 2000 | 'after' => '', |
| 1923 | 2001 | ); |
| 2002 | + } |
|
| 1924 | 2003 | |
| 1925 | 2004 | // Let mods add new BBC without hassle. |
| 1926 | 2005 | call_integration_hook('integrate_bbc_codes', array(&$codes, &$no_autolink_tags)); |
@@ -1928,8 +2007,9 @@ discard block |
||
| 1928 | 2007 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1929 | 2008 | if ($message === false) |
| 1930 | 2009 | { |
| 1931 | - if (isset($temp_bbc)) |
|
| 1932 | - $bbc_codes = $temp_bbc; |
|
| 2010 | + if (isset($temp_bbc)) { |
|
| 2011 | + $bbc_codes = $temp_bbc; |
|
| 2012 | + } |
|
| 1933 | 2013 | usort($codes, function ($a, $b) { |
| 1934 | 2014 | return strcmp($a['tag'], $b['tag']); |
| 1935 | 2015 | }); |
@@ -1949,8 +2029,9 @@ discard block |
||
| 1949 | 2029 | ); |
| 1950 | 2030 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1951 | 2031 | { |
| 1952 | - foreach ($itemcodes as $c => $dummy) |
|
| 1953 | - $bbc_codes[$c] = array(); |
|
| 2032 | + foreach ($itemcodes as $c => $dummy) { |
|
| 2033 | + $bbc_codes[$c] = array(); |
|
| 2034 | + } |
|
| 1954 | 2035 | } |
| 1955 | 2036 | |
| 1956 | 2037 | // Shhhh! |
@@ -1971,12 +2052,14 @@ discard block |
||
| 1971 | 2052 | foreach ($codes as $code) |
| 1972 | 2053 | { |
| 1973 | 2054 | // Make it easier to process parameters later |
| 1974 | - if (!empty($code['parameters'])) |
|
| 1975 | - ksort($code['parameters'], SORT_STRING); |
|
| 2055 | + if (!empty($code['parameters'])) { |
|
| 2056 | + ksort($code['parameters'], SORT_STRING); |
|
| 2057 | + } |
|
| 1976 | 2058 | |
| 1977 | 2059 | // If we are not doing every tag only do ones we are interested in. |
| 1978 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1979 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 2060 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 2061 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 2062 | + } |
|
| 1980 | 2063 | } |
| 1981 | 2064 | $codes = null; |
| 1982 | 2065 | } |
@@ -1987,8 +2070,9 @@ discard block |
||
| 1987 | 2070 | // It's likely this will change if the message is modified. |
| 1988 | 2071 | $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']); |
| 1989 | 2072 | |
| 1990 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1991 | - return $temp; |
|
| 2073 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 2074 | + return $temp; |
|
| 2075 | + } |
|
| 1992 | 2076 | |
| 1993 | 2077 | $cache_t = microtime(); |
| 1994 | 2078 | } |
@@ -2020,8 +2104,9 @@ discard block |
||
| 2020 | 2104 | $disabled['flash'] = true; |
| 2021 | 2105 | |
| 2022 | 2106 | // @todo Change maybe? |
| 2023 | - if (!isset($_GET['images'])) |
|
| 2024 | - $disabled['img'] = true; |
|
| 2107 | + if (!isset($_GET['images'])) { |
|
| 2108 | + $disabled['img'] = true; |
|
| 2109 | + } |
|
| 2025 | 2110 | |
| 2026 | 2111 | // @todo Interface/setting to add more? |
| 2027 | 2112 | } |
@@ -2032,8 +2117,9 @@ discard block |
||
| 2032 | 2117 | $alltags = array(); |
| 2033 | 2118 | foreach ($bbc_codes as $section) |
| 2034 | 2119 | { |
| 2035 | - foreach ($section as $code) |
|
| 2036 | - $alltags[] = $code['tag']; |
|
| 2120 | + foreach ($section as $code) { |
|
| 2121 | + $alltags[] = $code['tag']; |
|
| 2122 | + } |
|
| 2037 | 2123 | } |
| 2038 | 2124 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
| 2039 | 2125 | |
@@ -2045,8 +2131,9 @@ discard block |
||
| 2045 | 2131 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 2046 | 2132 | |
| 2047 | 2133 | // Failsafe. |
| 2048 | - if ($pos === false || $last_pos > $pos) |
|
| 2049 | - $pos = strlen($message) + 1; |
|
| 2134 | + if ($pos === false || $last_pos > $pos) { |
|
| 2135 | + $pos = strlen($message) + 1; |
|
| 2136 | + } |
|
| 2050 | 2137 | |
| 2051 | 2138 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 2052 | 2139 | if ($last_pos < $pos - 1) |
@@ -2064,8 +2151,9 @@ discard block |
||
| 2064 | 2151 | |
| 2065 | 2152 | // <br> should be empty. |
| 2066 | 2153 | $empty_tags = array('br', 'hr'); |
| 2067 | - foreach ($empty_tags as $tag) |
|
| 2068 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 2154 | + foreach ($empty_tags as $tag) { |
|
| 2155 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 2156 | + } |
|
| 2069 | 2157 | |
| 2070 | 2158 | // b, u, i, s, pre... basic tags. |
| 2071 | 2159 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -2074,8 +2162,9 @@ discard block |
||
| 2074 | 2162 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 2075 | 2163 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 2076 | 2164 | |
| 2077 | - if ($diff > 0) |
|
| 2078 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 2165 | + if ($diff > 0) { |
|
| 2166 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 2167 | + } |
|
| 2079 | 2168 | } |
| 2080 | 2169 | |
| 2081 | 2170 | // Do <img ...> - with security... action= -> action-. |
@@ -2088,8 +2177,9 @@ discard block |
||
| 2088 | 2177 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 2089 | 2178 | |
| 2090 | 2179 | // Remove action= from the URL - no funny business, now. |
| 2091 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 2092 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2180 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 2181 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2182 | + } |
|
| 2093 | 2183 | |
| 2094 | 2184 | $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
| 2095 | 2185 | } |
@@ -2104,16 +2194,18 @@ discard block |
||
| 2104 | 2194 | $no_autolink_area = false; |
| 2105 | 2195 | if (!empty($open_tags)) |
| 2106 | 2196 | { |
| 2107 | - foreach ($open_tags as $open_tag) |
|
| 2108 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2197 | + foreach ($open_tags as $open_tag) { |
|
| 2198 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2109 | 2199 | $no_autolink_area = true; |
| 2200 | + } |
|
| 2110 | 2201 | } |
| 2111 | 2202 | |
| 2112 | 2203 | // Don't go backwards. |
| 2113 | 2204 | // @todo Don't think is the real solution.... |
| 2114 | 2205 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 2115 | - if ($pos < $lastAutoPos) |
|
| 2116 | - $no_autolink_area = true; |
|
| 2206 | + if ($pos < $lastAutoPos) { |
|
| 2207 | + $no_autolink_area = true; |
|
| 2208 | + } |
|
| 2117 | 2209 | $lastAutoPos = $pos; |
| 2118 | 2210 | |
| 2119 | 2211 | if (!$no_autolink_area) |
@@ -2218,29 +2310,33 @@ discard block |
||
| 2218 | 2310 | $url = array_shift($matches); |
| 2219 | 2311 | |
| 2220 | 2312 | // If this isn't a clean URL, bail out |
| 2221 | - if ($url != sanitize_iri($url)) |
|
| 2222 | - return $url; |
|
| 2313 | + if ($url != sanitize_iri($url)) { |
|
| 2314 | + return $url; |
|
| 2315 | + } |
|
| 2223 | 2316 | |
| 2224 | 2317 | $scheme = parse_url($url, PHP_URL_SCHEME); |
| 2225 | 2318 | |
| 2226 | 2319 | if ($scheme == 'mailto') |
| 2227 | 2320 | { |
| 2228 | 2321 | $email_address = str_replace('mailto:', '', $url); |
| 2229 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 2230 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2231 | - else |
|
| 2232 | - return $url; |
|
| 2322 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2323 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2324 | + } else { |
|
| 2325 | + return $url; |
|
| 2326 | + } |
|
| 2233 | 2327 | } |
| 2234 | 2328 | |
| 2235 | 2329 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 2236 | - if (empty($scheme)) |
|
| 2237 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2238 | - else |
|
| 2239 | - $fullUrl = $url; |
|
| 2330 | + if (empty($scheme)) { |
|
| 2331 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2332 | + } else { |
|
| 2333 | + $fullUrl = $url; |
|
| 2334 | + } |
|
| 2240 | 2335 | |
| 2241 | 2336 | // Make sure that $fullUrl really is valid |
| 2242 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
| 2243 | - return $url; |
|
| 2337 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) { |
|
| 2338 | + return $url; |
|
| 2339 | + } |
|
| 2244 | 2340 | |
| 2245 | 2341 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2246 | 2342 | }, $data); |
@@ -2289,22 +2385,25 @@ discard block |
||
| 2289 | 2385 | } |
| 2290 | 2386 | |
| 2291 | 2387 | // Are we there yet? Are we there yet? |
| 2292 | - if ($pos >= strlen($message) - 1) |
|
| 2293 | - break; |
|
| 2388 | + if ($pos >= strlen($message) - 1) { |
|
| 2389 | + break; |
|
| 2390 | + } |
|
| 2294 | 2391 | |
| 2295 | 2392 | $tags = strtolower($message[$pos + 1]); |
| 2296 | 2393 | |
| 2297 | 2394 | if ($tags == '/' && !empty($open_tags)) |
| 2298 | 2395 | { |
| 2299 | 2396 | $pos2 = strpos($message, ']', $pos + 1); |
| 2300 | - if ($pos2 == $pos + 2) |
|
| 2301 | - continue; |
|
| 2397 | + if ($pos2 == $pos + 2) { |
|
| 2398 | + continue; |
|
| 2399 | + } |
|
| 2302 | 2400 | |
| 2303 | 2401 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2304 | 2402 | |
| 2305 | 2403 | // A closing tag that doesn't match any open tags? Skip it. |
| 2306 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
| 2307 | - continue; |
|
| 2404 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
| 2405 | + continue; |
|
| 2406 | + } |
|
| 2308 | 2407 | |
| 2309 | 2408 | $to_close = array(); |
| 2310 | 2409 | $block_level = null; |
@@ -2312,8 +2411,9 @@ discard block |
||
| 2312 | 2411 | do |
| 2313 | 2412 | { |
| 2314 | 2413 | $tag = array_pop($open_tags); |
| 2315 | - if (!$tag) |
|
| 2316 | - break; |
|
| 2414 | + if (!$tag) { |
|
| 2415 | + break; |
|
| 2416 | + } |
|
| 2317 | 2417 | |
| 2318 | 2418 | if (!empty($tag['block_level'])) |
| 2319 | 2419 | { |
@@ -2327,10 +2427,11 @@ discard block |
||
| 2327 | 2427 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2328 | 2428 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2329 | 2429 | { |
| 2330 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2331 | - if ($temp['tag'] == $look_for) |
|
| 2430 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2431 | + if ($temp['tag'] == $look_for) |
|
| 2332 | 2432 | { |
| 2333 | 2433 | $block_level = !empty($temp['block_level']); |
| 2434 | + } |
|
| 2334 | 2435 | break; |
| 2335 | 2436 | } |
| 2336 | 2437 | } |
@@ -2352,15 +2453,15 @@ discard block |
||
| 2352 | 2453 | { |
| 2353 | 2454 | $open_tags = $to_close; |
| 2354 | 2455 | continue; |
| 2355 | - } |
|
| 2356 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2456 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2357 | 2457 | { |
| 2358 | 2458 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2359 | 2459 | { |
| 2360 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2361 | - if ($temp['tag'] == $look_for) |
|
| 2460 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2461 | + if ($temp['tag'] == $look_for) |
|
| 2362 | 2462 | { |
| 2363 | 2463 | $block_level = !empty($temp['block_level']); |
| 2464 | + } |
|
| 2364 | 2465 | break; |
| 2365 | 2466 | } |
| 2366 | 2467 | } |
@@ -2368,8 +2469,9 @@ discard block |
||
| 2368 | 2469 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2369 | 2470 | if (!$block_level) |
| 2370 | 2471 | { |
| 2371 | - foreach ($to_close as $tag) |
|
| 2372 | - array_push($open_tags, $tag); |
|
| 2472 | + foreach ($to_close as $tag) { |
|
| 2473 | + array_push($open_tags, $tag); |
|
| 2474 | + } |
|
| 2373 | 2475 | continue; |
| 2374 | 2476 | } |
| 2375 | 2477 | } |
@@ -2382,14 +2484,17 @@ discard block |
||
| 2382 | 2484 | |
| 2383 | 2485 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2384 | 2486 | $whitespace_regex = ''; |
| 2385 | - if (!empty($tag['block_level'])) |
|
| 2386 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2487 | + if (!empty($tag['block_level'])) { |
|
| 2488 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2489 | + } |
|
| 2387 | 2490 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2388 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2389 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2491 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2492 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2493 | + } |
|
| 2390 | 2494 | |
| 2391 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2392 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2495 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2496 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2497 | + } |
|
| 2393 | 2498 | } |
| 2394 | 2499 | |
| 2395 | 2500 | if (!empty($to_close)) |
@@ -2402,8 +2507,9 @@ discard block |
||
| 2402 | 2507 | } |
| 2403 | 2508 | |
| 2404 | 2509 | // No tags for this character, so just keep going (fastest possible course.) |
| 2405 | - if (!isset($bbc_codes[$tags])) |
|
| 2406 | - continue; |
|
| 2510 | + if (!isset($bbc_codes[$tags])) { |
|
| 2511 | + continue; |
|
| 2512 | + } |
|
| 2407 | 2513 | |
| 2408 | 2514 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2409 | 2515 | $tag = null; |
@@ -2412,48 +2518,57 @@ discard block |
||
| 2412 | 2518 | $pt_strlen = strlen($possible['tag']); |
| 2413 | 2519 | |
| 2414 | 2520 | // Not a match? |
| 2415 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2416 | - continue; |
|
| 2521 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2522 | + continue; |
|
| 2523 | + } |
|
| 2417 | 2524 | |
| 2418 | 2525 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
| 2419 | 2526 | |
| 2420 | 2527 | // A tag is the last char maybe |
| 2421 | - if ($next_c == '') |
|
| 2422 | - break; |
|
| 2528 | + if ($next_c == '') { |
|
| 2529 | + break; |
|
| 2530 | + } |
|
| 2423 | 2531 | |
| 2424 | 2532 | // A test validation? |
| 2425 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2426 | - continue; |
|
| 2533 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2534 | + continue; |
|
| 2535 | + } |
|
| 2427 | 2536 | // Do we want parameters? |
| 2428 | 2537 | elseif (!empty($possible['parameters'])) |
| 2429 | 2538 | { |
| 2430 | - if ($next_c != ' ') |
|
| 2431 | - continue; |
|
| 2432 | - } |
|
| 2433 | - elseif (isset($possible['type'])) |
|
| 2539 | + if ($next_c != ' ') { |
|
| 2540 | + continue; |
|
| 2541 | + } |
|
| 2542 | + } elseif (isset($possible['type'])) |
|
| 2434 | 2543 | { |
| 2435 | 2544 | // Do we need an equal sign? |
| 2436 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2437 | - continue; |
|
| 2545 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2546 | + continue; |
|
| 2547 | + } |
|
| 2438 | 2548 | // Maybe we just want a /... |
| 2439 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2440 | - continue; |
|
| 2549 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2550 | + continue; |
|
| 2551 | + } |
|
| 2441 | 2552 | // An immediate ]? |
| 2442 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2443 | - continue; |
|
| 2553 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2554 | + continue; |
|
| 2555 | + } |
|
| 2444 | 2556 | } |
| 2445 | 2557 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2446 | - elseif ($next_c != ']') |
|
| 2447 | - continue; |
|
| 2558 | + elseif ($next_c != ']') { |
|
| 2559 | + continue; |
|
| 2560 | + } |
|
| 2448 | 2561 | |
| 2449 | 2562 | // Check allowed tree? |
| 2450 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2451 | - continue; |
|
| 2452 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2453 | - continue; |
|
| 2563 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2564 | + continue; |
|
| 2565 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2566 | + continue; |
|
| 2567 | + } |
|
| 2454 | 2568 | // If this is in the list of disallowed child tags, don't parse it. |
| 2455 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2456 | - continue; |
|
| 2569 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2457 | 2572 | |
| 2458 | 2573 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2459 | 2574 | |
@@ -2465,8 +2580,9 @@ discard block |
||
| 2465 | 2580 | foreach ($open_tags as $open_quote) |
| 2466 | 2581 | { |
| 2467 | 2582 | // Every parent quote this quote has flips the styling |
| 2468 | - if ($open_quote['tag'] == 'quote') |
|
| 2469 | - $quote_alt = !$quote_alt; |
|
| 2583 | + if ($open_quote['tag'] == 'quote') { |
|
| 2584 | + $quote_alt = !$quote_alt; |
|
| 2585 | + } |
|
| 2470 | 2586 | } |
| 2471 | 2587 | // Add a class to the quote to style alternating blockquotes |
| 2472 | 2588 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2477,8 +2593,9 @@ discard block |
||
| 2477 | 2593 | { |
| 2478 | 2594 | // Build a regular expression for each parameter for the current tag. |
| 2479 | 2595 | $preg = array(); |
| 2480 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2481 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2596 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2597 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2598 | + } |
|
| 2482 | 2599 | |
| 2483 | 2600 | // Extract the string that potentially holds our parameters. |
| 2484 | 2601 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2497,24 +2614,27 @@ discard block |
||
| 2497 | 2614 | |
| 2498 | 2615 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2499 | 2616 | |
| 2500 | - if ($match) |
|
| 2501 | - $blob_counter = count($blobs) + 1; |
|
| 2617 | + if ($match) { |
|
| 2618 | + $blob_counter = count($blobs) + 1; |
|
| 2619 | + } |
|
| 2502 | 2620 | } |
| 2503 | 2621 | |
| 2504 | 2622 | // Didn't match our parameter list, try the next possible. |
| 2505 | - if (!$match) |
|
| 2506 | - continue; |
|
| 2623 | + if (!$match) { |
|
| 2624 | + continue; |
|
| 2625 | + } |
|
| 2507 | 2626 | |
| 2508 | 2627 | $params = array(); |
| 2509 | 2628 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2510 | 2629 | { |
| 2511 | 2630 | $key = strtok(ltrim($matches[$i]), '='); |
| 2512 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2513 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2514 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2515 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2516 | - else |
|
| 2517 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2631 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2632 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2633 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2634 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2635 | + } else { |
|
| 2636 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2637 | + } |
|
| 2518 | 2638 | |
| 2519 | 2639 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2520 | 2640 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2522,23 +2642,26 @@ discard block |
||
| 2522 | 2642 | |
| 2523 | 2643 | foreach ($possible['parameters'] as $p => $info) |
| 2524 | 2644 | { |
| 2525 | - if (!isset($params['{' . $p . '}'])) |
|
| 2526 | - $params['{' . $p . '}'] = ''; |
|
| 2645 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2646 | + $params['{' . $p . '}'] = ''; |
|
| 2647 | + } |
|
| 2527 | 2648 | } |
| 2528 | 2649 | |
| 2529 | 2650 | $tag = $possible; |
| 2530 | 2651 | |
| 2531 | 2652 | // Put the parameters into the string. |
| 2532 | - if (isset($tag['before'])) |
|
| 2533 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2534 | - if (isset($tag['after'])) |
|
| 2535 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2536 | - if (isset($tag['content'])) |
|
| 2537 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2653 | + if (isset($tag['before'])) { |
|
| 2654 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2655 | + } |
|
| 2656 | + if (isset($tag['after'])) { |
|
| 2657 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2658 | + } |
|
| 2659 | + if (isset($tag['content'])) { |
|
| 2660 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2661 | + } |
|
| 2538 | 2662 | |
| 2539 | 2663 | $pos1 += strlen($given_param_string); |
| 2540 | - } |
|
| 2541 | - else |
|
| 2664 | + } else |
|
| 2542 | 2665 | { |
| 2543 | 2666 | $tag = $possible; |
| 2544 | 2667 | $params = array(); |
@@ -2549,8 +2672,9 @@ discard block |
||
| 2549 | 2672 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2550 | 2673 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2551 | 2674 | { |
| 2552 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2553 | - continue; |
|
| 2675 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2676 | + continue; |
|
| 2677 | + } |
|
| 2554 | 2678 | |
| 2555 | 2679 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2556 | 2680 | |
@@ -2571,9 +2695,9 @@ discard block |
||
| 2571 | 2695 | { |
| 2572 | 2696 | array_pop($open_tags); |
| 2573 | 2697 | $code = '</li>'; |
| 2698 | + } else { |
|
| 2699 | + $code = ''; |
|
| 2574 | 2700 | } |
| 2575 | - else |
|
| 2576 | - $code = ''; |
|
| 2577 | 2701 | |
| 2578 | 2702 | // Now we open a new tag. |
| 2579 | 2703 | $open_tags[] = array( |
@@ -2620,12 +2744,14 @@ discard block |
||
| 2620 | 2744 | } |
| 2621 | 2745 | |
| 2622 | 2746 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2623 | - if ($tag === null) |
|
| 2624 | - continue; |
|
| 2747 | + if ($tag === null) { |
|
| 2748 | + continue; |
|
| 2749 | + } |
|
| 2625 | 2750 | |
| 2626 | 2751 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2627 | - if (isset($inside['disallow_children'])) |
|
| 2628 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2752 | + if (isset($inside['disallow_children'])) { |
|
| 2753 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2754 | + } |
|
| 2629 | 2755 | |
| 2630 | 2756 | // Is this tag disabled? |
| 2631 | 2757 | if (isset($disabled[$tag['tag']])) |
@@ -2635,14 +2761,13 @@ discard block |
||
| 2635 | 2761 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2636 | 2762 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2637 | 2763 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2638 | - } |
|
| 2639 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2764 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2640 | 2765 | { |
| 2641 | 2766 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2642 | 2767 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2768 | + } else { |
|
| 2769 | + $tag['content'] = $tag['disabled_content']; |
|
| 2643 | 2770 | } |
| 2644 | - else |
|
| 2645 | - $tag['content'] = $tag['disabled_content']; |
|
| 2646 | 2771 | } |
| 2647 | 2772 | |
| 2648 | 2773 | // we use this a lot |
@@ -2652,8 +2777,9 @@ discard block |
||
| 2652 | 2777 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2653 | 2778 | { |
| 2654 | 2779 | $n = count($open_tags) - 1; |
| 2655 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2656 | - $n--; |
|
| 2780 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2781 | + $n--; |
|
| 2782 | + } |
|
| 2657 | 2783 | |
| 2658 | 2784 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2659 | 2785 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2665,12 +2791,15 @@ discard block |
||
| 2665 | 2791 | |
| 2666 | 2792 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2667 | 2793 | $whitespace_regex = ''; |
| 2668 | - if (!empty($tag['block_level'])) |
|
| 2669 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2670 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2671 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2672 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2673 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2794 | + if (!empty($tag['block_level'])) { |
|
| 2795 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2796 | + } |
|
| 2797 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2798 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2799 | + } |
|
| 2800 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2801 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2802 | + } |
|
| 2674 | 2803 | |
| 2675 | 2804 | array_pop($open_tags); |
| 2676 | 2805 | } |
@@ -2691,16 +2820,19 @@ discard block |
||
| 2691 | 2820 | elseif ($tag['type'] == 'unparsed_content') |
| 2692 | 2821 | { |
| 2693 | 2822 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2694 | - if ($pos2 === false) |
|
| 2695 | - continue; |
|
| 2823 | + if ($pos2 === false) { |
|
| 2824 | + continue; |
|
| 2825 | + } |
|
| 2696 | 2826 | |
| 2697 | 2827 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2698 | 2828 | |
| 2699 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2700 | - $data = substr($data, 4); |
|
| 2829 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2830 | + $data = substr($data, 4); |
|
| 2831 | + } |
|
| 2701 | 2832 | |
| 2702 | - if (isset($tag['validate'])) |
|
| 2703 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2833 | + if (isset($tag['validate'])) { |
|
| 2834 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2835 | + } |
|
| 2704 | 2836 | |
| 2705 | 2837 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2706 | 2838 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2715,34 +2847,40 @@ discard block |
||
| 2715 | 2847 | if (isset($tag['quoted'])) |
| 2716 | 2848 | { |
| 2717 | 2849 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2718 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2719 | - continue; |
|
| 2850 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2851 | + continue; |
|
| 2852 | + } |
|
| 2720 | 2853 | |
| 2721 | - if ($quoted) |
|
| 2722 | - $pos1 += 6; |
|
| 2854 | + if ($quoted) { |
|
| 2855 | + $pos1 += 6; |
|
| 2856 | + } |
|
| 2857 | + } else { |
|
| 2858 | + $quoted = false; |
|
| 2723 | 2859 | } |
| 2724 | - else |
|
| 2725 | - $quoted = false; |
|
| 2726 | 2860 | |
| 2727 | 2861 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2728 | - if ($pos2 === false) |
|
| 2729 | - continue; |
|
| 2862 | + if ($pos2 === false) { |
|
| 2863 | + continue; |
|
| 2864 | + } |
|
| 2730 | 2865 | |
| 2731 | 2866 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2732 | - if ($pos3 === false) |
|
| 2733 | - continue; |
|
| 2867 | + if ($pos3 === false) { |
|
| 2868 | + continue; |
|
| 2869 | + } |
|
| 2734 | 2870 | |
| 2735 | 2871 | $data = array( |
| 2736 | 2872 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2737 | 2873 | substr($message, $pos1, $pos2 - $pos1) |
| 2738 | 2874 | ); |
| 2739 | 2875 | |
| 2740 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2741 | - $data[0] = substr($data[0], 4); |
|
| 2876 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2877 | + $data[0] = substr($data[0], 4); |
|
| 2878 | + } |
|
| 2742 | 2879 | |
| 2743 | 2880 | // Validation for my parking, please! |
| 2744 | - if (isset($tag['validate'])) |
|
| 2745 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2881 | + if (isset($tag['validate'])) { |
|
| 2882 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2883 | + } |
|
| 2746 | 2884 | |
| 2747 | 2885 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2748 | 2886 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2759,23 +2897,27 @@ discard block |
||
| 2759 | 2897 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2760 | 2898 | { |
| 2761 | 2899 | $pos2 = strpos($message, ']', $pos1); |
| 2762 | - if ($pos2 === false) |
|
| 2763 | - continue; |
|
| 2900 | + if ($pos2 === false) { |
|
| 2901 | + continue; |
|
| 2902 | + } |
|
| 2764 | 2903 | |
| 2765 | 2904 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2766 | - if ($pos3 === false) |
|
| 2767 | - continue; |
|
| 2905 | + if ($pos3 === false) { |
|
| 2906 | + continue; |
|
| 2907 | + } |
|
| 2768 | 2908 | |
| 2769 | 2909 | // We want $1 to be the content, and the rest to be csv. |
| 2770 | 2910 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2771 | 2911 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2772 | 2912 | |
| 2773 | - if (isset($tag['validate'])) |
|
| 2774 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2913 | + if (isset($tag['validate'])) { |
|
| 2914 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2915 | + } |
|
| 2775 | 2916 | |
| 2776 | 2917 | $code = $tag['content']; |
| 2777 | - foreach ($data as $k => $d) |
|
| 2778 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2918 | + foreach ($data as $k => $d) { |
|
| 2919 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2920 | + } |
|
| 2779 | 2921 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2780 | 2922 | $pos += strlen($code) - 1 + 2; |
| 2781 | 2923 | } |
@@ -2783,24 +2925,28 @@ discard block |
||
| 2783 | 2925 | elseif ($tag['type'] == 'unparsed_commas') |
| 2784 | 2926 | { |
| 2785 | 2927 | $pos2 = strpos($message, ']', $pos1); |
| 2786 | - if ($pos2 === false) |
|
| 2787 | - continue; |
|
| 2928 | + if ($pos2 === false) { |
|
| 2929 | + continue; |
|
| 2930 | + } |
|
| 2788 | 2931 | |
| 2789 | 2932 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2790 | 2933 | |
| 2791 | - if (isset($tag['validate'])) |
|
| 2792 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2934 | + if (isset($tag['validate'])) { |
|
| 2935 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2936 | + } |
|
| 2793 | 2937 | |
| 2794 | 2938 | // Fix after, for disabled code mainly. |
| 2795 | - foreach ($data as $k => $d) |
|
| 2796 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2939 | + foreach ($data as $k => $d) { |
|
| 2940 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2941 | + } |
|
| 2797 | 2942 | |
| 2798 | 2943 | $open_tags[] = $tag; |
| 2799 | 2944 | |
| 2800 | 2945 | // Replace them out, $1, $2, $3, $4, etc. |
| 2801 | 2946 | $code = $tag['before']; |
| 2802 | - foreach ($data as $k => $d) |
|
| 2803 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2947 | + foreach ($data as $k => $d) { |
|
| 2948 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2949 | + } |
|
| 2804 | 2950 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2805 | 2951 | $pos += strlen($code) - 1 + 2; |
| 2806 | 2952 | } |
@@ -2811,28 +2957,33 @@ discard block |
||
| 2811 | 2957 | if (isset($tag['quoted'])) |
| 2812 | 2958 | { |
| 2813 | 2959 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2814 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2815 | - continue; |
|
| 2960 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2961 | + continue; |
|
| 2962 | + } |
|
| 2816 | 2963 | |
| 2817 | - if ($quoted) |
|
| 2818 | - $pos1 += 6; |
|
| 2964 | + if ($quoted) { |
|
| 2965 | + $pos1 += 6; |
|
| 2966 | + } |
|
| 2967 | + } else { |
|
| 2968 | + $quoted = false; |
|
| 2819 | 2969 | } |
| 2820 | - else |
|
| 2821 | - $quoted = false; |
|
| 2822 | 2970 | |
| 2823 | 2971 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2824 | - if ($pos2 === false) |
|
| 2825 | - continue; |
|
| 2972 | + if ($pos2 === false) { |
|
| 2973 | + continue; |
|
| 2974 | + } |
|
| 2826 | 2975 | |
| 2827 | 2976 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2828 | 2977 | |
| 2829 | 2978 | // Validation for my parking, please! |
| 2830 | - if (isset($tag['validate'])) |
|
| 2831 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2979 | + if (isset($tag['validate'])) { |
|
| 2980 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2981 | + } |
|
| 2832 | 2982 | |
| 2833 | 2983 | // For parsed content, we must recurse to avoid security problems. |
| 2834 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2835 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2984 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2985 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2986 | + } |
|
| 2836 | 2987 | |
| 2837 | 2988 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2838 | 2989 | |
@@ -2844,34 +2995,40 @@ discard block |
||
| 2844 | 2995 | } |
| 2845 | 2996 | |
| 2846 | 2997 | // If this is block level, eat any breaks after it. |
| 2847 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2848 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2998 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2999 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 3000 | + } |
|
| 2849 | 3001 | |
| 2850 | 3002 | // Are we trimming outside this tag? |
| 2851 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2852 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 3003 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 3004 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 3005 | + } |
|
| 2853 | 3006 | } |
| 2854 | 3007 | |
| 2855 | 3008 | // Close any remaining tags. |
| 2856 | - while ($tag = array_pop($open_tags)) |
|
| 2857 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 3009 | + while ($tag = array_pop($open_tags)) { |
|
| 3010 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 3011 | + } |
|
| 2858 | 3012 | |
| 2859 | 3013 | // Parse the smileys within the parts where it can be done safely. |
| 2860 | 3014 | if ($smileys === true) |
| 2861 | 3015 | { |
| 2862 | 3016 | $message_parts = explode("\n", $message); |
| 2863 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2864 | - parsesmileys($message_parts[$i]); |
|
| 3017 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 3018 | + parsesmileys($message_parts[$i]); |
|
| 3019 | + } |
|
| 2865 | 3020 | |
| 2866 | 3021 | $message = implode('', $message_parts); |
| 2867 | 3022 | } |
| 2868 | 3023 | |
| 2869 | 3024 | // No smileys, just get rid of the markers. |
| 2870 | - else |
|
| 2871 | - $message = strtr($message, array("\n" => '')); |
|
| 3025 | + else { |
|
| 3026 | + $message = strtr($message, array("\n" => '')); |
|
| 3027 | + } |
|
| 2872 | 3028 | |
| 2873 | - if ($message !== '' && $message[0] === ' ') |
|
| 2874 | - $message = ' ' . substr($message, 1); |
|
| 3029 | + if ($message !== '' && $message[0] === ' ') { |
|
| 3030 | + $message = ' ' . substr($message, 1); |
|
| 3031 | + } |
|
| 2875 | 3032 | |
| 2876 | 3033 | // Cleanup whitespace. |
| 2877 | 3034 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2880,15 +3037,16 @@ discard block |
||
| 2880 | 3037 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2881 | 3038 | |
| 2882 | 3039 | // Cache the output if it took some time... |
| 2883 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2884 | - cache_put_data($cache_key, $message, 240); |
|
| 3040 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 3041 | + cache_put_data($cache_key, $message, 240); |
|
| 3042 | + } |
|
| 2885 | 3043 | |
| 2886 | 3044 | // If this was a force parse revert if needed. |
| 2887 | 3045 | if (!empty($parse_tags)) |
| 2888 | 3046 | { |
| 2889 | - if (empty($temp_bbc)) |
|
| 2890 | - $bbc_codes = array(); |
|
| 2891 | - else |
|
| 3047 | + if (empty($temp_bbc)) { |
|
| 3048 | + $bbc_codes = array(); |
|
| 3049 | + } else |
|
| 2892 | 3050 | { |
| 2893 | 3051 | $bbc_codes = $temp_bbc; |
| 2894 | 3052 | unset($temp_bbc); |
@@ -2915,8 +3073,9 @@ discard block |
||
| 2915 | 3073 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2916 | 3074 | |
| 2917 | 3075 | // No smiley set at all?! |
| 2918 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2919 | - return; |
|
| 3076 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 3077 | + return; |
|
| 3078 | + } |
|
| 2920 | 3079 | |
| 2921 | 3080 | // Maybe a mod wants to implement an alternative method (e.g. emojis instead of images) |
| 2922 | 3081 | call_integration_hook('integrate_smileys', array(&$smileyPregSearch, &$smileyPregReplacements)); |
@@ -2930,8 +3089,7 @@ discard block |
||
| 2930 | 3089 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2931 | 3090 | $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'); |
| 2932 | 3091 | $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'], '', '', '', ''); |
| 2933 | - } |
|
| 2934 | - else |
|
| 3092 | + } else |
|
| 2935 | 3093 | { |
| 2936 | 3094 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2937 | 3095 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2955,9 +3113,9 @@ discard block |
||
| 2955 | 3113 | $smcFunc['db_free_result']($result); |
| 2956 | 3114 | |
| 2957 | 3115 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 3116 | + } else { |
|
| 3117 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2958 | 3118 | } |
| 2959 | - else |
|
| 2960 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2961 | 3119 | } |
| 2962 | 3120 | |
| 2963 | 3121 | // The non-breaking-space is a complex thing... |
@@ -2979,16 +3137,18 @@ discard block |
||
| 2979 | 3137 | $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
| 2980 | 3138 | if (!empty($alt_images)) |
| 2981 | 3139 | { |
| 2982 | - foreach ($exts as $ext) |
|
| 2983 | - if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images)) |
|
| 3140 | + foreach ($exts as $ext) { |
|
| 3141 | + if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images)) |
|
| 2984 | 3142 | { |
| 2985 | 3143 | $smileysto[$i] = $fname . '.' . $ext; |
| 3144 | + } |
|
| 2986 | 3145 | break; |
| 2987 | 3146 | } |
| 2988 | 3147 | } |
| 2989 | 3148 | // If we have no image, just leave the text version in place |
| 2990 | - else |
|
| 2991 | - continue; |
|
| 3149 | + else { |
|
| 3150 | + continue; |
|
| 3151 | + } |
|
| 2992 | 3152 | } |
| 2993 | 3153 | |
| 2994 | 3154 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
@@ -3056,12 +3216,14 @@ discard block |
||
| 3056 | 3216 | global $boardurl, $image_proxy_enabled, $image_proxy_secret; |
| 3057 | 3217 | |
| 3058 | 3218 | // Only use the proxy if enabled and necessary |
| 3059 | - if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') |
|
| 3060 | - return $url; |
|
| 3219 | + if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') { |
|
| 3220 | + return $url; |
|
| 3221 | + } |
|
| 3061 | 3222 | |
| 3062 | 3223 | // We don't need to proxy our own resources |
| 3063 | - if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) |
|
| 3064 | - return strtr($url, array('http://' => 'https://')); |
|
| 3224 | + if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) { |
|
| 3225 | + return strtr($url, array('http://' => 'https://')); |
|
| 3226 | + } |
|
| 3065 | 3227 | |
| 3066 | 3228 | // By default, use SMF's own image proxy script |
| 3067 | 3229 | $proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret); |
@@ -3086,35 +3248,41 @@ discard block |
||
| 3086 | 3248 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 3087 | 3249 | |
| 3088 | 3250 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 3089 | - if (!empty($context['flush_mail'])) |
|
| 3090 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3251 | + if (!empty($context['flush_mail'])) { |
|
| 3252 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3091 | 3253 | AddMailQueue(true); |
| 3254 | + } |
|
| 3092 | 3255 | |
| 3093 | 3256 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 3094 | 3257 | |
| 3095 | - if ($add) |
|
| 3096 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3258 | + if ($add) { |
|
| 3259 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3260 | + } |
|
| 3097 | 3261 | |
| 3098 | 3262 | // Put the session ID in. |
| 3099 | - if (defined('SID') && SID != '') |
|
| 3100 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3263 | + if (defined('SID') && SID != '') { |
|
| 3264 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3265 | + } |
|
| 3101 | 3266 | // Keep that debug in their for template debugging! |
| 3102 | - elseif (isset($_GET['debug'])) |
|
| 3103 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3267 | + elseif (isset($_GET['debug'])) { |
|
| 3268 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3269 | + } |
|
| 3104 | 3270 | |
| 3105 | 3271 | 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']))) |
| 3106 | 3272 | { |
| 3107 | - if (defined('SID') && SID != '') |
|
| 3108 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3273 | + if (defined('SID') && SID != '') { |
|
| 3274 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3109 | 3275 | function ($m) use ($scripturl) |
| 3110 | 3276 | { |
| 3111 | 3277 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 3278 | + } |
|
| 3112 | 3279 | }, $setLocation); |
| 3113 | - else |
|
| 3114 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3280 | + else { |
|
| 3281 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3115 | 3282 | function ($m) use ($scripturl) |
| 3116 | 3283 | { |
| 3117 | 3284 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3285 | + } |
|
| 3118 | 3286 | }, $setLocation); |
| 3119 | 3287 | } |
| 3120 | 3288 | |
@@ -3125,8 +3293,9 @@ discard block |
||
| 3125 | 3293 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 3126 | 3294 | |
| 3127 | 3295 | // Debugging. |
| 3128 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3129 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 3296 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3297 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 3298 | + } |
|
| 3130 | 3299 | |
| 3131 | 3300 | obExit(false); |
| 3132 | 3301 | } |
@@ -3145,51 +3314,60 @@ discard block |
||
| 3145 | 3314 | |
| 3146 | 3315 | // Attempt to prevent a recursive loop. |
| 3147 | 3316 | ++$level; |
| 3148 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 3149 | - exit; |
|
| 3150 | - if ($from_fatal_error) |
|
| 3151 | - $has_fatal_error = true; |
|
| 3317 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 3318 | + exit; |
|
| 3319 | + } |
|
| 3320 | + if ($from_fatal_error) { |
|
| 3321 | + $has_fatal_error = true; |
|
| 3322 | + } |
|
| 3152 | 3323 | |
| 3153 | 3324 | // Clear out the stat cache. |
| 3154 | 3325 | trackStats(); |
| 3155 | 3326 | |
| 3156 | 3327 | // If we have mail to send, send it. |
| 3157 | - if (!empty($context['flush_mail'])) |
|
| 3158 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3328 | + if (!empty($context['flush_mail'])) { |
|
| 3329 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3159 | 3330 | AddMailQueue(true); |
| 3331 | + } |
|
| 3160 | 3332 | |
| 3161 | 3333 | $do_header = $header === null ? !$header_done : $header; |
| 3162 | - if ($do_footer === null) |
|
| 3163 | - $do_footer = $do_header; |
|
| 3334 | + if ($do_footer === null) { |
|
| 3335 | + $do_footer = $do_header; |
|
| 3336 | + } |
|
| 3164 | 3337 | |
| 3165 | 3338 | // Has the template/header been done yet? |
| 3166 | 3339 | if ($do_header) |
| 3167 | 3340 | { |
| 3168 | 3341 | // Was the page title set last minute? Also update the HTML safe one. |
| 3169 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 3170 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3342 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3343 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3344 | + } |
|
| 3171 | 3345 | |
| 3172 | 3346 | // Start up the session URL fixer. |
| 3173 | 3347 | ob_start('ob_sessrewrite'); |
| 3174 | 3348 | |
| 3175 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 3176 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 3177 | - elseif (!empty($settings['output_buffers'])) |
|
| 3178 | - $buffers = $settings['output_buffers']; |
|
| 3179 | - else |
|
| 3180 | - $buffers = array(); |
|
| 3349 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3350 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3351 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3352 | + $buffers = $settings['output_buffers']; |
|
| 3353 | + } else { |
|
| 3354 | + $buffers = array(); |
|
| 3355 | + } |
|
| 3181 | 3356 | |
| 3182 | - if (isset($modSettings['integrate_buffer'])) |
|
| 3183 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3357 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3358 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3359 | + } |
|
| 3184 | 3360 | |
| 3185 | - if (!empty($buffers)) |
|
| 3186 | - foreach ($buffers as $function) |
|
| 3361 | + if (!empty($buffers)) { |
|
| 3362 | + foreach ($buffers as $function) |
|
| 3187 | 3363 | { |
| 3188 | 3364 | $call = call_helper($function, true); |
| 3365 | + } |
|
| 3189 | 3366 | |
| 3190 | 3367 | // Is it valid? |
| 3191 | - if (!empty($call)) |
|
| 3192 | - ob_start($call); |
|
| 3368 | + if (!empty($call)) { |
|
| 3369 | + ob_start($call); |
|
| 3370 | + } |
|
| 3193 | 3371 | } |
| 3194 | 3372 | |
| 3195 | 3373 | // Display the screen in the logical order. |
@@ -3201,8 +3379,9 @@ discard block |
||
| 3201 | 3379 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 3202 | 3380 | |
| 3203 | 3381 | // Anything special to put out? |
| 3204 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 3205 | - echo $context['insert_after_template']; |
|
| 3382 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3383 | + echo $context['insert_after_template']; |
|
| 3384 | + } |
|
| 3206 | 3385 | |
| 3207 | 3386 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 3208 | 3387 | if (!$footer_done) |
@@ -3211,14 +3390,16 @@ discard block |
||
| 3211 | 3390 | template_footer(); |
| 3212 | 3391 | |
| 3213 | 3392 | // (since this is just debugging... it's okay that it's after </html>.) |
| 3214 | - if (!isset($_REQUEST['xml'])) |
|
| 3215 | - displayDebug(); |
|
| 3393 | + if (!isset($_REQUEST['xml'])) { |
|
| 3394 | + displayDebug(); |
|
| 3395 | + } |
|
| 3216 | 3396 | } |
| 3217 | 3397 | } |
| 3218 | 3398 | |
| 3219 | 3399 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 3220 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 3221 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3400 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3401 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3402 | + } |
|
| 3222 | 3403 | |
| 3223 | 3404 | // For session check verification.... don't switch browsers... |
| 3224 | 3405 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3227,9 +3408,10 @@ discard block |
||
| 3227 | 3408 | call_integration_hook('integrate_exit', array($do_footer)); |
| 3228 | 3409 | |
| 3229 | 3410 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 3230 | - if (!$from_index) |
|
| 3231 | - exit; |
|
| 3232 | -} |
|
| 3411 | + if (!$from_index) { |
|
| 3412 | + exit; |
|
| 3413 | + } |
|
| 3414 | + } |
|
| 3233 | 3415 | |
| 3234 | 3416 | /** |
| 3235 | 3417 | * Get the size of a specified image with better error handling. |
@@ -3248,8 +3430,9 @@ discard block |
||
| 3248 | 3430 | $url = str_replace(' ', '%20', $url); |
| 3249 | 3431 | |
| 3250 | 3432 | // Can we pull this from the cache... please please? |
| 3251 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 3252 | - return $temp; |
|
| 3433 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3434 | + return $temp; |
|
| 3435 | + } |
|
| 3253 | 3436 | $t = microtime(); |
| 3254 | 3437 | |
| 3255 | 3438 | // Get the host to pester... |
@@ -3259,12 +3442,10 @@ discard block |
||
| 3259 | 3442 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 3260 | 3443 | { |
| 3261 | 3444 | return false; |
| 3262 | - } |
|
| 3263 | - elseif (!isset($match[1])) |
|
| 3445 | + } elseif (!isset($match[1])) |
|
| 3264 | 3446 | { |
| 3265 | 3447 | $size = @getimagesize($url); |
| 3266 | - } |
|
| 3267 | - else |
|
| 3448 | + } else |
|
| 3268 | 3449 | { |
| 3269 | 3450 | // Try to connect to the server... give it half a second. |
| 3270 | 3451 | $temp = 0; |
@@ -3301,12 +3482,14 @@ discard block |
||
| 3301 | 3482 | } |
| 3302 | 3483 | |
| 3303 | 3484 | // If we didn't get it, we failed. |
| 3304 | - if (!isset($size)) |
|
| 3305 | - $size = false; |
|
| 3485 | + if (!isset($size)) { |
|
| 3486 | + $size = false; |
|
| 3487 | + } |
|
| 3306 | 3488 | |
| 3307 | 3489 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3308 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3309 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3490 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3491 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3492 | + } |
|
| 3310 | 3493 | |
| 3311 | 3494 | // Didn't work. |
| 3312 | 3495 | return $size; |
@@ -3324,8 +3507,9 @@ discard block |
||
| 3324 | 3507 | |
| 3325 | 3508 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3326 | 3509 | // So only run the function once unless we are forced to run it again. |
| 3327 | - if ($loaded && !$forceload) |
|
| 3328 | - return; |
|
| 3510 | + if ($loaded && !$forceload) { |
|
| 3511 | + return; |
|
| 3512 | + } |
|
| 3329 | 3513 | |
| 3330 | 3514 | $loaded = true; |
| 3331 | 3515 | |
@@ -3337,14 +3521,16 @@ discard block |
||
| 3337 | 3521 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3338 | 3522 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3339 | 3523 | { |
| 3340 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3341 | - continue; |
|
| 3524 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3525 | + continue; |
|
| 3526 | + } |
|
| 3342 | 3527 | |
| 3343 | 3528 | // Clean it up for presentation ;). |
| 3344 | 3529 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3345 | 3530 | } |
| 3346 | - if (!empty($context['news_lines'])) |
|
| 3347 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3531 | + if (!empty($context['news_lines'])) { |
|
| 3532 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3533 | + } |
|
| 3348 | 3534 | |
| 3349 | 3535 | if (!$user_info['is_guest']) |
| 3350 | 3536 | { |
@@ -3353,40 +3539,48 @@ discard block |
||
| 3353 | 3539 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3354 | 3540 | |
| 3355 | 3541 | // Personal message popup... |
| 3356 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3357 | - $context['user']['popup_messages'] = true; |
|
| 3358 | - else |
|
| 3359 | - $context['user']['popup_messages'] = false; |
|
| 3542 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3543 | + $context['user']['popup_messages'] = true; |
|
| 3544 | + } else { |
|
| 3545 | + $context['user']['popup_messages'] = false; |
|
| 3546 | + } |
|
| 3360 | 3547 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3361 | 3548 | |
| 3362 | - if (allowedTo('moderate_forum')) |
|
| 3363 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3549 | + if (allowedTo('moderate_forum')) { |
|
| 3550 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3551 | + } |
|
| 3364 | 3552 | |
| 3365 | 3553 | $context['user']['avatar'] = array(); |
| 3366 | 3554 | |
| 3367 | 3555 | // Check for gravatar first since we might be forcing them... |
| 3368 | 3556 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3369 | 3557 | { |
| 3370 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3371 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3372 | - else |
|
| 3373 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3558 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3559 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3560 | + } else { |
|
| 3561 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3562 | + } |
|
| 3374 | 3563 | } |
| 3375 | 3564 | // Uploaded? |
| 3376 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3377 | - $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'; |
|
| 3565 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3566 | + $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'; |
|
| 3567 | + } |
|
| 3378 | 3568 | // Full URL? |
| 3379 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3380 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3569 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3570 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3571 | + } |
|
| 3381 | 3572 | // Otherwise we assume it's server stored. |
| 3382 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3383 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3573 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3574 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3575 | + } |
|
| 3384 | 3576 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3385 | - else |
|
| 3386 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3577 | + else { |
|
| 3578 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3579 | + } |
|
| 3387 | 3580 | |
| 3388 | - if (!empty($context['user']['avatar'])) |
|
| 3389 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3581 | + if (!empty($context['user']['avatar'])) { |
|
| 3582 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3583 | + } |
|
| 3390 | 3584 | |
| 3391 | 3585 | // Figure out how long they've been logged in. |
| 3392 | 3586 | $context['user']['total_time_logged_in'] = array( |
@@ -3394,8 +3588,7 @@ discard block |
||
| 3394 | 3588 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3395 | 3589 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3396 | 3590 | ); |
| 3397 | - } |
|
| 3398 | - else |
|
| 3591 | + } else |
|
| 3399 | 3592 | { |
| 3400 | 3593 | $context['user']['messages'] = 0; |
| 3401 | 3594 | $context['user']['unread_messages'] = 0; |
@@ -3403,12 +3596,14 @@ discard block |
||
| 3403 | 3596 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3404 | 3597 | $context['user']['popup_messages'] = false; |
| 3405 | 3598 | |
| 3406 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3407 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3599 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3600 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3601 | + } |
|
| 3408 | 3602 | |
| 3409 | 3603 | // If we've upgraded recently, go easy on the passwords. |
| 3410 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3411 | - $context['disable_login_hashing'] = true; |
|
| 3604 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3605 | + $context['disable_login_hashing'] = true; |
|
| 3606 | + } |
|
| 3412 | 3607 | } |
| 3413 | 3608 | |
| 3414 | 3609 | // Setup the main menu items. |
@@ -3421,8 +3616,8 @@ discard block |
||
| 3421 | 3616 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3422 | 3617 | |
| 3423 | 3618 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3424 | - if ($context['show_pm_popup']) |
|
| 3425 | - addInlineJavaScript(' |
|
| 3619 | + if ($context['show_pm_popup']) { |
|
| 3620 | + addInlineJavaScript(' |
|
| 3426 | 3621 | jQuery(document).ready(function($) { |
| 3427 | 3622 | new smc_Popup({ |
| 3428 | 3623 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3430,24 +3625,28 @@ discard block |
||
| 3430 | 3625 | icon_class: \'generic_icons mail_new\' |
| 3431 | 3626 | }); |
| 3432 | 3627 | });'); |
| 3628 | + } |
|
| 3433 | 3629 | |
| 3434 | 3630 | // Add a generic "Are you sure?" confirmation message. |
| 3435 | 3631 | addInlineJavaScript(' |
| 3436 | 3632 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3437 | 3633 | |
| 3438 | 3634 | // Now add the capping code for avatars. |
| 3439 | - 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') |
|
| 3440 | - addInlineCss(' |
|
| 3635 | + 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') { |
|
| 3636 | + addInlineCss(' |
|
| 3441 | 3637 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3638 | + } |
|
| 3442 | 3639 | |
| 3443 | 3640 | // Add max image limits |
| 3444 | - if (!empty($modSettings['max_image_width'])) |
|
| 3445 | - addInlineCss(' |
|
| 3641 | + if (!empty($modSettings['max_image_width'])) { |
|
| 3642 | + addInlineCss(' |
|
| 3446 | 3643 | .postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }'); |
| 3644 | + } |
|
| 3447 | 3645 | |
| 3448 | - if (!empty($modSettings['max_image_height'])) |
|
| 3449 | - addInlineCss(' |
|
| 3646 | + if (!empty($modSettings['max_image_height'])) { |
|
| 3647 | + addInlineCss(' |
|
| 3450 | 3648 | .postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }'); |
| 3649 | + } |
|
| 3451 | 3650 | |
| 3452 | 3651 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3453 | 3652 | $context['common_stats']['latest_member'] = array( |
@@ -3464,11 +3663,13 @@ discard block |
||
| 3464 | 3663 | ); |
| 3465 | 3664 | $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']); |
| 3466 | 3665 | |
| 3467 | - if (empty($settings['theme_version'])) |
|
| 3468 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3666 | + if (empty($settings['theme_version'])) { |
|
| 3667 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3668 | + } |
|
| 3469 | 3669 | |
| 3470 | - if (!isset($context['page_title'])) |
|
| 3471 | - $context['page_title'] = ''; |
|
| 3670 | + if (!isset($context['page_title'])) { |
|
| 3671 | + $context['page_title'] = ''; |
|
| 3672 | + } |
|
| 3472 | 3673 | |
| 3473 | 3674 | // Set some specific vars. |
| 3474 | 3675 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3478,21 +3679,23 @@ discard block |
||
| 3478 | 3679 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3479 | 3680 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3480 | 3681 | |
| 3481 | - if (!empty($context['meta_keywords'])) |
|
| 3482 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3682 | + if (!empty($context['meta_keywords'])) { |
|
| 3683 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3684 | + } |
|
| 3483 | 3685 | |
| 3484 | - if (!empty($context['canonical_url'])) |
|
| 3485 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3686 | + if (!empty($context['canonical_url'])) { |
|
| 3687 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3688 | + } |
|
| 3486 | 3689 | |
| 3487 | - if (!empty($settings['og_image'])) |
|
| 3488 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3690 | + if (!empty($settings['og_image'])) { |
|
| 3691 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3692 | + } |
|
| 3489 | 3693 | |
| 3490 | 3694 | if (!empty($context['meta_description'])) |
| 3491 | 3695 | { |
| 3492 | 3696 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3493 | 3697 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3494 | - } |
|
| 3495 | - else |
|
| 3698 | + } else |
|
| 3496 | 3699 | { |
| 3497 | 3700 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3498 | 3701 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3517,8 +3720,9 @@ discard block |
||
| 3517 | 3720 | $memory_needed = memoryReturnBytes($needed); |
| 3518 | 3721 | |
| 3519 | 3722 | // should we account for how much is currently being used? |
| 3520 | - if ($in_use) |
|
| 3521 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3723 | + if ($in_use) { |
|
| 3724 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3725 | + } |
|
| 3522 | 3726 | |
| 3523 | 3727 | // if more is needed, request it |
| 3524 | 3728 | if ($memory_current < $memory_needed) |
@@ -3541,8 +3745,9 @@ discard block |
||
| 3541 | 3745 | */ |
| 3542 | 3746 | function memoryReturnBytes($val) |
| 3543 | 3747 | { |
| 3544 | - if (is_integer($val)) |
|
| 3545 | - return $val; |
|
| 3748 | + if (is_integer($val)) { |
|
| 3749 | + return $val; |
|
| 3750 | + } |
|
| 3546 | 3751 | |
| 3547 | 3752 | // Separate the number from the designator |
| 3548 | 3753 | $val = trim($val); |
@@ -3578,10 +3783,11 @@ discard block |
||
| 3578 | 3783 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3579 | 3784 | |
| 3580 | 3785 | // Are we debugging the template/html content? |
| 3581 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3582 | - header('content-type: application/xhtml+xml'); |
|
| 3583 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3584 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3786 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3787 | + header('content-type: application/xhtml+xml'); |
|
| 3788 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3789 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3790 | + } |
|
| 3585 | 3791 | } |
| 3586 | 3792 | |
| 3587 | 3793 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3590,8 +3796,9 @@ discard block |
||
| 3590 | 3796 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3591 | 3797 | { |
| 3592 | 3798 | $position = array_search('body', $context['template_layers']); |
| 3593 | - if ($position === false) |
|
| 3594 | - $position = array_search('main', $context['template_layers']); |
|
| 3799 | + if ($position === false) { |
|
| 3800 | + $position = array_search('main', $context['template_layers']); |
|
| 3801 | + } |
|
| 3595 | 3802 | |
| 3596 | 3803 | if ($position !== false) |
| 3597 | 3804 | { |
@@ -3619,23 +3826,25 @@ discard block |
||
| 3619 | 3826 | |
| 3620 | 3827 | foreach ($securityFiles as $i => $securityFile) |
| 3621 | 3828 | { |
| 3622 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3623 | - unset($securityFiles[$i]); |
|
| 3829 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3830 | + unset($securityFiles[$i]); |
|
| 3831 | + } |
|
| 3624 | 3832 | } |
| 3625 | 3833 | |
| 3626 | 3834 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3627 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3628 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3629 | - |
|
| 3630 | - else |
|
| 3631 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3835 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3836 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3837 | + } else { |
|
| 3838 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3839 | + } |
|
| 3632 | 3840 | |
| 3633 | 3841 | secureDirectory($path, true); |
| 3634 | 3842 | secureDirectory($cachedir); |
| 3635 | 3843 | |
| 3636 | 3844 | // If agreement is enabled, at least the english version shall exists |
| 3637 | - if ($modSettings['requireAgreement']) |
|
| 3638 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3845 | + if ($modSettings['requireAgreement']) { |
|
| 3846 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3847 | + } |
|
| 3639 | 3848 | |
| 3640 | 3849 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3641 | 3850 | { |
@@ -3650,18 +3859,21 @@ discard block |
||
| 3650 | 3859 | echo ' |
| 3651 | 3860 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3652 | 3861 | |
| 3653 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3654 | - echo ' |
|
| 3862 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3863 | + echo ' |
|
| 3655 | 3864 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3865 | + } |
|
| 3656 | 3866 | } |
| 3657 | 3867 | |
| 3658 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3659 | - echo ' |
|
| 3868 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3869 | + echo ' |
|
| 3660 | 3870 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3871 | + } |
|
| 3661 | 3872 | |
| 3662 | - if (!empty($agreement)) |
|
| 3663 | - echo ' |
|
| 3873 | + if (!empty($agreement)) { |
|
| 3874 | + echo ' |
|
| 3664 | 3875 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3876 | + } |
|
| 3665 | 3877 | |
| 3666 | 3878 | echo ' |
| 3667 | 3879 | </p> |
@@ -3676,16 +3888,18 @@ discard block |
||
| 3676 | 3888 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3677 | 3889 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3678 | 3890 | |
| 3679 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3680 | - echo ' |
|
| 3891 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3892 | + echo ' |
|
| 3681 | 3893 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3894 | + } |
|
| 3682 | 3895 | |
| 3683 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3684 | - echo ' |
|
| 3896 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3897 | + echo ' |
|
| 3685 | 3898 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3686 | - else |
|
| 3687 | - echo ' |
|
| 3899 | + } else { |
|
| 3900 | + echo ' |
|
| 3688 | 3901 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3902 | + } |
|
| 3689 | 3903 | |
| 3690 | 3904 | echo ' |
| 3691 | 3905 | </div>'; |
@@ -3701,8 +3915,9 @@ discard block |
||
| 3701 | 3915 | global $forum_copyright, $software_year, $forum_version; |
| 3702 | 3916 | |
| 3703 | 3917 | // Don't display copyright for things like SSI. |
| 3704 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3705 | - return; |
|
| 3918 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3919 | + return; |
|
| 3920 | + } |
|
| 3706 | 3921 | |
| 3707 | 3922 | // Put in the version... |
| 3708 | 3923 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3720,9 +3935,10 @@ discard block |
||
| 3720 | 3935 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
| 3721 | 3936 | $context['load_queries'] = $db_count; |
| 3722 | 3937 | |
| 3723 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3724 | - loadSubTemplate($layer . '_below', true); |
|
| 3725 | -} |
|
| 3938 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3939 | + loadSubTemplate($layer . '_below', true); |
|
| 3940 | + } |
|
| 3941 | + } |
|
| 3726 | 3942 | |
| 3727 | 3943 | /** |
| 3728 | 3944 | * Output the Javascript files |
@@ -3756,8 +3972,7 @@ discard block |
||
| 3756 | 3972 | { |
| 3757 | 3973 | echo ' |
| 3758 | 3974 | var ', $key, ';'; |
| 3759 | - } |
|
| 3760 | - else |
|
| 3975 | + } else |
|
| 3761 | 3976 | { |
| 3762 | 3977 | echo ' |
| 3763 | 3978 | var ', $key, ' = ', $value, ';'; |
@@ -3776,27 +3991,29 @@ discard block |
||
| 3776 | 3991 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3777 | 3992 | { |
| 3778 | 3993 | // Last minute call! allow theme authors to disable single files. |
| 3779 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3780 | - continue; |
|
| 3994 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3995 | + continue; |
|
| 3996 | + } |
|
| 3781 | 3997 | |
| 3782 | 3998 | // By default files don't get minimized unless the file explicitly says so! |
| 3783 | 3999 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3784 | 4000 | { |
| 3785 | - if (!empty($js_file['options']['async'])) |
|
| 3786 | - $toMinify['async'][] = $js_file; |
|
| 3787 | - elseif (!empty($js_file['options']['defer'])) |
|
| 3788 | - $toMinify['defer'][] = $js_file; |
|
| 3789 | - else |
|
| 3790 | - $toMinify['standard'][] = $js_file; |
|
| 4001 | + if (!empty($js_file['options']['async'])) { |
|
| 4002 | + $toMinify['async'][] = $js_file; |
|
| 4003 | + } elseif (!empty($js_file['options']['defer'])) { |
|
| 4004 | + $toMinify['defer'][] = $js_file; |
|
| 4005 | + } else { |
|
| 4006 | + $toMinify['standard'][] = $js_file; |
|
| 4007 | + } |
|
| 3791 | 4008 | |
| 3792 | 4009 | // Grab a random seed. |
| 3793 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
| 3794 | - $minSeed = $js_file['options']['seed']; |
|
| 3795 | - } |
|
| 3796 | - |
|
| 3797 | - else |
|
| 3798 | - echo ' |
|
| 4010 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
| 4011 | + $minSeed = $js_file['options']['seed']; |
|
| 4012 | + } |
|
| 4013 | + } else { |
|
| 4014 | + echo ' |
|
| 3799 | 4015 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>'; |
| 4016 | + } |
|
| 3800 | 4017 | } |
| 3801 | 4018 | |
| 3802 | 4019 | foreach ($toMinify as $js_files) |
@@ -3807,9 +4024,10 @@ discard block |
||
| 3807 | 4024 | |
| 3808 | 4025 | $minSuccessful = array_keys($result) === array('smf_minified'); |
| 3809 | 4026 | |
| 3810 | - foreach ($result as $minFile) |
|
| 3811 | - echo ' |
|
| 4027 | + foreach ($result as $minFile) { |
|
| 4028 | + echo ' |
|
| 3812 | 4029 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>'; |
| 4030 | + } |
|
| 3813 | 4031 | } |
| 3814 | 4032 | } |
| 3815 | 4033 | } |
@@ -3823,8 +4041,9 @@ discard block |
||
| 3823 | 4041 | <script> |
| 3824 | 4042 | window.addEventListener("DOMContentLoaded", function() {'; |
| 3825 | 4043 | |
| 3826 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3827 | - echo $js_code; |
|
| 4044 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 4045 | + echo $js_code; |
|
| 4046 | + } |
|
| 3828 | 4047 | |
| 3829 | 4048 | echo ' |
| 3830 | 4049 | }); |
@@ -3836,8 +4055,9 @@ discard block |
||
| 3836 | 4055 | echo ' |
| 3837 | 4056 | <script>'; |
| 3838 | 4057 | |
| 3839 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3840 | - echo $js_code; |
|
| 4058 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 4059 | + echo $js_code; |
|
| 4060 | + } |
|
| 3841 | 4061 | |
| 3842 | 4062 | echo ' |
| 3843 | 4063 | </script>'; |
@@ -3865,23 +4085,26 @@ discard block |
||
| 3865 | 4085 | foreach ($context['css_files'] as $id => $file) |
| 3866 | 4086 | { |
| 3867 | 4087 | // Last minute call! allow theme authors to disable single files. |
| 3868 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3869 | - continue; |
|
| 4088 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 4089 | + continue; |
|
| 4090 | + } |
|
| 3870 | 4091 | |
| 3871 | 4092 | // Files are minimized unless they explicitly opt out. |
| 3872 | - if (!isset($file['options']['minimize'])) |
|
| 3873 | - $file['options']['minimize'] = true; |
|
| 4093 | + if (!isset($file['options']['minimize'])) { |
|
| 4094 | + $file['options']['minimize'] = true; |
|
| 4095 | + } |
|
| 3874 | 4096 | |
| 3875 | 4097 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3876 | 4098 | { |
| 3877 | 4099 | $toMinify[] = $file; |
| 3878 | 4100 | |
| 3879 | 4101 | // Grab a random seed. |
| 3880 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
| 3881 | - $minSeed = $file['options']['seed']; |
|
| 4102 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
| 4103 | + $minSeed = $file['options']['seed']; |
|
| 4104 | + } |
|
| 4105 | + } else { |
|
| 4106 | + $normal[] = $file['fileUrl']; |
|
| 3882 | 4107 | } |
| 3883 | - else |
|
| 3884 | - $normal[] = $file['fileUrl']; |
|
| 3885 | 4108 | } |
| 3886 | 4109 | |
| 3887 | 4110 | if (!empty($toMinify)) |
@@ -3890,23 +4113,26 @@ discard block |
||
| 3890 | 4113 | |
| 3891 | 4114 | $minSuccessful = array_keys($result) === array('smf_minified'); |
| 3892 | 4115 | |
| 3893 | - foreach ($result as $minFile) |
|
| 3894 | - echo ' |
|
| 4116 | + foreach ($result as $minFile) { |
|
| 4117 | + echo ' |
|
| 3895 | 4118 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
| 4119 | + } |
|
| 3896 | 4120 | } |
| 3897 | 4121 | |
| 3898 | 4122 | // Print the rest after the minified files. |
| 3899 | - if (!empty($normal)) |
|
| 3900 | - foreach ($normal as $nf) |
|
| 4123 | + if (!empty($normal)) { |
|
| 4124 | + foreach ($normal as $nf) |
|
| 3901 | 4125 | echo ' |
| 3902 | 4126 | <link rel="stylesheet" href="', $nf ,'">'; |
| 4127 | + } |
|
| 3903 | 4128 | |
| 3904 | 4129 | if ($db_show_debug === true) |
| 3905 | 4130 | { |
| 3906 | 4131 | // Try to keep only what's useful. |
| 3907 | 4132 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3908 | - foreach ($context['css_files'] as $file) |
|
| 3909 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 4133 | + foreach ($context['css_files'] as $file) { |
|
| 4134 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 4135 | + } |
|
| 3910 | 4136 | } |
| 3911 | 4137 | |
| 3912 | 4138 | if (!empty($context['css_header'])) |
@@ -3914,9 +4140,10 @@ discard block |
||
| 3914 | 4140 | echo ' |
| 3915 | 4141 | <style>'; |
| 3916 | 4142 | |
| 3917 | - foreach ($context['css_header'] as $css) |
|
| 3918 | - echo $css .' |
|
| 4143 | + foreach ($context['css_header'] as $css) { |
|
| 4144 | + echo $css .' |
|
| 3919 | 4145 | '; |
| 4146 | + } |
|
| 3920 | 4147 | |
| 3921 | 4148 | echo' |
| 3922 | 4149 | </style>'; |
@@ -3939,8 +4166,9 @@ discard block |
||
| 3939 | 4166 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3940 | 4167 | $data = is_array($data) ? $data : array(); |
| 3941 | 4168 | |
| 3942 | - if (empty($type) || empty($data)) |
|
| 3943 | - return $data; |
|
| 4169 | + if (empty($type) || empty($data)) { |
|
| 4170 | + return $data; |
|
| 4171 | + } |
|
| 3944 | 4172 | |
| 3945 | 4173 | // Different pages include different files, so we use a hash to label the different combinations |
| 3946 | 4174 | $hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data))); |
@@ -3949,13 +4177,14 @@ discard block |
||
| 3949 | 4177 | list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null); |
| 3950 | 4178 | |
| 3951 | 4179 | // Already done? |
| 3952 | - if (!empty($toCache)) |
|
| 3953 | - return array('smf_minified' => array( |
|
| 4180 | + if (!empty($toCache)) { |
|
| 4181 | + return array('smf_minified' => array( |
|
| 3954 | 4182 | 'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache), |
| 3955 | 4183 | 'filePath' => $toCache, |
| 3956 | 4184 | 'fileName' => basename($toCache), |
| 3957 | 4185 | 'options' => array('async' => !empty($async), 'defer' => !empty($defer)), |
| 3958 | 4186 | )); |
| 4187 | + } |
|
| 3959 | 4188 | |
| 3960 | 4189 | |
| 3961 | 4190 | // No namespaces, sorry! |
@@ -3985,9 +4214,9 @@ discard block |
||
| 3985 | 4214 | |
| 3986 | 4215 | foreach ($data as $id => $file) |
| 3987 | 4216 | { |
| 3988 | - if (empty($file['filePath'])) |
|
| 3989 | - $toAdd = false; |
|
| 3990 | - else |
|
| 4217 | + if (empty($file['filePath'])) { |
|
| 4218 | + $toAdd = false; |
|
| 4219 | + } else |
|
| 3991 | 4220 | { |
| 3992 | 4221 | $seed = isset($file['options']['seed']) ? $file['options']['seed'] : ''; |
| 3993 | 4222 | $tempFile = str_replace($seed, '', $file['filePath']); |
@@ -3995,12 +4224,14 @@ discard block |
||
| 3995 | 4224 | } |
| 3996 | 4225 | |
| 3997 | 4226 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
| 3998 | - if (empty($file['options']['async'])) |
|
| 3999 | - $async = false; |
|
| 4227 | + if (empty($file['options']['async'])) { |
|
| 4228 | + $async = false; |
|
| 4229 | + } |
|
| 4000 | 4230 | |
| 4001 | 4231 | // A minified script should only be deferred if all its components wanted to be. |
| 4002 | - if (empty($file['options']['defer'])) |
|
| 4003 | - $defer = false; |
|
| 4232 | + if (empty($file['options']['defer'])) { |
|
| 4233 | + $defer = false; |
|
| 4234 | + } |
|
| 4004 | 4235 | |
| 4005 | 4236 | // The file couldn't be located so it won't be added. Log this error. |
| 4006 | 4237 | if (empty($toAdd)) |
@@ -4066,12 +4297,14 @@ discard block |
||
| 4066 | 4297 | foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename) |
| 4067 | 4298 | { |
| 4068 | 4299 | // Remove the cache entry |
| 4069 | - if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) |
|
| 4070 | - cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
| 4300 | + if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) { |
|
| 4301 | + cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
| 4302 | + } |
|
| 4071 | 4303 | |
| 4072 | 4304 | // Try to delete the file. Add it to our error list if it fails. |
| 4073 | - if (!@unlink($filename)) |
|
| 4074 | - $not_deleted[] = $filename; |
|
| 4305 | + if (!@unlink($filename)) { |
|
| 4306 | + $not_deleted[] = $filename; |
|
| 4307 | + } |
|
| 4075 | 4308 | } |
| 4076 | 4309 | } |
| 4077 | 4310 | } |
@@ -4103,8 +4336,9 @@ discard block |
||
| 4103 | 4336 | global $modSettings, $smcFunc; |
| 4104 | 4337 | |
| 4105 | 4338 | // Just make up a nice hash... |
| 4106 | - if ($new) |
|
| 4107 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 4339 | + if ($new) { |
|
| 4340 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 4341 | + } |
|
| 4108 | 4342 | |
| 4109 | 4343 | // Just make sure that attachment id is only a int |
| 4110 | 4344 | $attachment_id = (int) $attachment_id; |
@@ -4121,23 +4355,25 @@ discard block |
||
| 4121 | 4355 | 'id_attach' => $attachment_id, |
| 4122 | 4356 | )); |
| 4123 | 4357 | |
| 4124 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 4125 | - return false; |
|
| 4358 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 4359 | + return false; |
|
| 4360 | + } |
|
| 4126 | 4361 | |
| 4127 | 4362 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 4128 | 4363 | $smcFunc['db_free_result']($request); |
| 4129 | 4364 | } |
| 4130 | 4365 | |
| 4131 | 4366 | // Still no hash? mmm... |
| 4132 | - if (empty($file_hash)) |
|
| 4133 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4367 | + if (empty($file_hash)) { |
|
| 4368 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4369 | + } |
|
| 4134 | 4370 | |
| 4135 | 4371 | // Are we using multiple directories? |
| 4136 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 4137 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4138 | - |
|
| 4139 | - else |
|
| 4140 | - $path = $modSettings['attachmentUploadDir']; |
|
| 4372 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 4373 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4374 | + } else { |
|
| 4375 | + $path = $modSettings['attachmentUploadDir']; |
|
| 4376 | + } |
|
| 4141 | 4377 | |
| 4142 | 4378 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 4143 | 4379 | } |
@@ -4152,8 +4388,9 @@ discard block |
||
| 4152 | 4388 | function ip2range($fullip) |
| 4153 | 4389 | { |
| 4154 | 4390 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 4155 | - if ($fullip == 'unknown') |
|
| 4156 | - $fullip = '255.255.255.255'; |
|
| 4391 | + if ($fullip == 'unknown') { |
|
| 4392 | + $fullip = '255.255.255.255'; |
|
| 4393 | + } |
|
| 4157 | 4394 | |
| 4158 | 4395 | $ip_parts = explode('-', $fullip); |
| 4159 | 4396 | $ip_array = array(); |
@@ -4177,10 +4414,11 @@ discard block |
||
| 4177 | 4414 | $ip_array['low'] = $ip_parts[0]; |
| 4178 | 4415 | $ip_array['high'] = $ip_parts[1]; |
| 4179 | 4416 | return $ip_array; |
| 4180 | - } |
|
| 4181 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 4417 | + } elseif (count($ip_parts) == 2) { |
|
| 4418 | + // if ip 22.22.*-22.22.* |
|
| 4182 | 4419 | { |
| 4183 | 4420 | $valid_low = isValidIP($ip_parts[0]); |
| 4421 | + } |
|
| 4184 | 4422 | $valid_high = isValidIP($ip_parts[1]); |
| 4185 | 4423 | $count = 0; |
| 4186 | 4424 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -4195,7 +4433,9 @@ discard block |
||
| 4195 | 4433 | $ip_parts[0] .= $mode . $min; |
| 4196 | 4434 | $valid_low = isValidIP($ip_parts[0]); |
| 4197 | 4435 | $count++; |
| 4198 | - if ($count > 9) break; |
|
| 4436 | + if ($count > 9) { |
|
| 4437 | + break; |
|
| 4438 | + } |
|
| 4199 | 4439 | } |
| 4200 | 4440 | } |
| 4201 | 4441 | |
@@ -4209,7 +4449,9 @@ discard block |
||
| 4209 | 4449 | $ip_parts[1] .= $mode . $max; |
| 4210 | 4450 | $valid_high = isValidIP($ip_parts[1]); |
| 4211 | 4451 | $count++; |
| 4212 | - if ($count > 9) break; |
|
| 4452 | + if ($count > 9) { |
|
| 4453 | + break; |
|
| 4454 | + } |
|
| 4213 | 4455 | } |
| 4214 | 4456 | } |
| 4215 | 4457 | |
@@ -4233,46 +4475,54 @@ discard block |
||
| 4233 | 4475 | { |
| 4234 | 4476 | global $modSettings; |
| 4235 | 4477 | |
| 4236 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 4237 | - return $host; |
|
| 4478 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4479 | + return $host; |
|
| 4480 | + } |
|
| 4238 | 4481 | $t = microtime(); |
| 4239 | 4482 | |
| 4240 | 4483 | // Try the Linux host command, perhaps? |
| 4241 | 4484 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 4242 | 4485 | { |
| 4243 | - if (!isset($modSettings['host_to_dis'])) |
|
| 4244 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4245 | - else |
|
| 4246 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4486 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4487 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4488 | + } else { |
|
| 4489 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4490 | + } |
|
| 4247 | 4491 | |
| 4248 | 4492 | // Did host say it didn't find anything? |
| 4249 | - if (strpos($test, 'not found') !== false) |
|
| 4250 | - $host = ''; |
|
| 4493 | + if (strpos($test, 'not found') !== false) { |
|
| 4494 | + $host = ''; |
|
| 4495 | + } |
|
| 4251 | 4496 | // Invalid server option? |
| 4252 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 4253 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4497 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4498 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4499 | + } |
|
| 4254 | 4500 | // Maybe it found something, after all? |
| 4255 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 4256 | - $host = $match[1]; |
|
| 4501 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4502 | + $host = $match[1]; |
|
| 4503 | + } |
|
| 4257 | 4504 | } |
| 4258 | 4505 | |
| 4259 | 4506 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 4260 | 4507 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 4261 | 4508 | { |
| 4262 | 4509 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 4263 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 4264 | - $host = ''; |
|
| 4265 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 4266 | - $host = $match[1]; |
|
| 4510 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4511 | + $host = ''; |
|
| 4512 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4513 | + $host = $match[1]; |
|
| 4514 | + } |
|
| 4267 | 4515 | } |
| 4268 | 4516 | |
| 4269 | 4517 | // This is the last try :/. |
| 4270 | - if (!isset($host) || $host === false) |
|
| 4271 | - $host = @gethostbyaddr($ip); |
|
| 4518 | + if (!isset($host) || $host === false) { |
|
| 4519 | + $host = @gethostbyaddr($ip); |
|
| 4520 | + } |
|
| 4272 | 4521 | |
| 4273 | 4522 | // It took a long time, so let's cache it! |
| 4274 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 4275 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4523 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4524 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4525 | + } |
|
| 4276 | 4526 | |
| 4277 | 4527 | return $host; |
| 4278 | 4528 | } |
@@ -4308,20 +4558,21 @@ discard block |
||
| 4308 | 4558 | { |
| 4309 | 4559 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 4310 | 4560 | $total = 0; |
| 4311 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 4312 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4561 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4562 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4563 | + } |
|
| 4313 | 4564 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 4314 | 4565 | } |
| 4315 | 4566 | } |
| 4316 | 4567 | return array_unique($returned_ints); |
| 4317 | - } |
|
| 4318 | - else |
|
| 4568 | + } else |
|
| 4319 | 4569 | { |
| 4320 | 4570 | // Trim characters before and after and add slashes for database insertion. |
| 4321 | 4571 | $returned_words = array(); |
| 4322 | - foreach ($words as $word) |
|
| 4323 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4572 | + foreach ($words as $word) { |
|
| 4573 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 4324 | 4574 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4575 | + } |
|
| 4325 | 4576 | |
| 4326 | 4577 | // Filter out all words that occur more than once. |
| 4327 | 4578 | return array_unique($returned_words); |
@@ -4343,16 +4594,18 @@ discard block |
||
| 4343 | 4594 | global $settings, $txt; |
| 4344 | 4595 | |
| 4345 | 4596 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 4346 | - if (function_exists('template_create_button') && !$force_use) |
|
| 4347 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4597 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4598 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4599 | + } |
|
| 4348 | 4600 | |
| 4349 | - if (!$settings['use_image_buttons']) |
|
| 4350 | - return $txt[$alt]; |
|
| 4351 | - elseif (!empty($settings['use_buttons'])) |
|
| 4352 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4353 | - else |
|
| 4354 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4355 | -} |
|
| 4601 | + if (!$settings['use_image_buttons']) { |
|
| 4602 | + return $txt[$alt]; |
|
| 4603 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4604 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4605 | + } else { |
|
| 4606 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4607 | + } |
|
| 4608 | + } |
|
| 4356 | 4609 | |
| 4357 | 4610 | /** |
| 4358 | 4611 | * Sets up all of the top menu buttons |
@@ -4395,9 +4648,10 @@ discard block |
||
| 4395 | 4648 | var user_menus = new smc_PopupMenu(); |
| 4396 | 4649 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4397 | 4650 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 4398 | - if ($context['allow_pm']) |
|
| 4399 | - addInlineJavaScript(' |
|
| 4651 | + if ($context['allow_pm']) { |
|
| 4652 | + addInlineJavaScript(' |
|
| 4400 | 4653 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4654 | + } |
|
| 4401 | 4655 | |
| 4402 | 4656 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4403 | 4657 | { |
@@ -4557,88 +4811,96 @@ discard block |
||
| 4557 | 4811 | |
| 4558 | 4812 | // Now we put the buttons in the context so the theme can use them. |
| 4559 | 4813 | $menu_buttons = array(); |
| 4560 | - foreach ($buttons as $act => $button) |
|
| 4561 | - if (!empty($button['show'])) |
|
| 4814 | + foreach ($buttons as $act => $button) { |
|
| 4815 | + if (!empty($button['show'])) |
|
| 4562 | 4816 | { |
| 4563 | 4817 | $button['active_button'] = false; |
| 4818 | + } |
|
| 4564 | 4819 | |
| 4565 | 4820 | // This button needs some action. |
| 4566 | - if (isset($button['action_hook'])) |
|
| 4567 | - $needs_action_hook = true; |
|
| 4821 | + if (isset($button['action_hook'])) { |
|
| 4822 | + $needs_action_hook = true; |
|
| 4823 | + } |
|
| 4568 | 4824 | |
| 4569 | 4825 | // Make sure the last button truly is the last button. |
| 4570 | 4826 | if (!empty($button['is_last'])) |
| 4571 | 4827 | { |
| 4572 | - if (isset($last_button)) |
|
| 4573 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4828 | + if (isset($last_button)) { |
|
| 4829 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4830 | + } |
|
| 4574 | 4831 | $last_button = $act; |
| 4575 | 4832 | } |
| 4576 | 4833 | |
| 4577 | 4834 | // Go through the sub buttons if there are any. |
| 4578 | - if (!empty($button['sub_buttons'])) |
|
| 4579 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4835 | + if (!empty($button['sub_buttons'])) { |
|
| 4836 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4580 | 4837 | { |
| 4581 | 4838 | if (empty($subbutton['show'])) |
| 4582 | 4839 | unset($button['sub_buttons'][$key]); |
| 4840 | + } |
|
| 4583 | 4841 | |
| 4584 | 4842 | // 2nd level sub buttons next... |
| 4585 | 4843 | if (!empty($subbutton['sub_buttons'])) |
| 4586 | 4844 | { |
| 4587 | 4845 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4588 | 4846 | { |
| 4589 | - if (empty($sub_button2['show'])) |
|
| 4590 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4847 | + if (empty($sub_button2['show'])) { |
|
| 4848 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4849 | + } |
|
| 4591 | 4850 | } |
| 4592 | 4851 | } |
| 4593 | 4852 | } |
| 4594 | 4853 | |
| 4595 | 4854 | // Does this button have its own icon? |
| 4596 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4597 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4598 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4599 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4600 | - elseif (isset($button['icon'])) |
|
| 4601 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4602 | - else |
|
| 4603 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4855 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4856 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4857 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4858 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4859 | + } elseif (isset($button['icon'])) { |
|
| 4860 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4861 | + } else { |
|
| 4862 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4863 | + } |
|
| 4604 | 4864 | |
| 4605 | 4865 | $menu_buttons[$act] = $button; |
| 4606 | 4866 | } |
| 4607 | 4867 | |
| 4608 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4609 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4868 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4869 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4870 | + } |
|
| 4610 | 4871 | } |
| 4611 | 4872 | |
| 4612 | 4873 | $context['menu_buttons'] = $menu_buttons; |
| 4613 | 4874 | |
| 4614 | 4875 | // Logging out requires the session id in the url. |
| 4615 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4616 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4876 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4877 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4878 | + } |
|
| 4617 | 4879 | |
| 4618 | 4880 | // Figure out which action we are doing so we can set the active tab. |
| 4619 | 4881 | // Default to home. |
| 4620 | 4882 | $current_action = 'home'; |
| 4621 | 4883 | |
| 4622 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4623 | - $current_action = $context['current_action']; |
|
| 4624 | - elseif ($context['current_action'] == 'search2') |
|
| 4625 | - $current_action = 'search'; |
|
| 4626 | - elseif ($context['current_action'] == 'theme') |
|
| 4627 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4628 | - elseif ($context['current_action'] == 'register2') |
|
| 4629 | - $current_action = 'register'; |
|
| 4630 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4631 | - $current_action = 'login'; |
|
| 4632 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4633 | - $current_action = 'moderate'; |
|
| 4884 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4885 | + $current_action = $context['current_action']; |
|
| 4886 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4887 | + $current_action = 'search'; |
|
| 4888 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4889 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4890 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4891 | + $current_action = 'register'; |
|
| 4892 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4893 | + $current_action = 'login'; |
|
| 4894 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4895 | + $current_action = 'moderate'; |
|
| 4896 | + } |
|
| 4634 | 4897 | |
| 4635 | 4898 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4636 | 4899 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4637 | 4900 | { |
| 4638 | 4901 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4639 | 4902 | $context[$current_action] = true; |
| 4640 | - } |
|
| 4641 | - elseif ($context['current_action'] == 'pm') |
|
| 4903 | + } elseif ($context['current_action'] == 'pm') |
|
| 4642 | 4904 | { |
| 4643 | 4905 | $current_action = 'self_pm'; |
| 4644 | 4906 | $context['self_pm'] = true; |
@@ -4695,12 +4957,14 @@ discard block |
||
| 4695 | 4957 | } |
| 4696 | 4958 | |
| 4697 | 4959 | // Not all actions are simple. |
| 4698 | - if (!empty($needs_action_hook)) |
|
| 4699 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4960 | + if (!empty($needs_action_hook)) { |
|
| 4961 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4962 | + } |
|
| 4700 | 4963 | |
| 4701 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4702 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4703 | -} |
|
| 4964 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4965 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4966 | + } |
|
| 4967 | + } |
|
| 4704 | 4968 | |
| 4705 | 4969 | /** |
| 4706 | 4970 | * Generate a random seed and ensure it's stored in settings. |
@@ -4724,30 +4988,35 @@ discard block |
||
| 4724 | 4988 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4725 | 4989 | global $context, $txt; |
| 4726 | 4990 | |
| 4727 | - if ($db_show_debug === true) |
|
| 4728 | - $context['debug']['hooks'][] = $hook; |
|
| 4991 | + if ($db_show_debug === true) { |
|
| 4992 | + $context['debug']['hooks'][] = $hook; |
|
| 4993 | + } |
|
| 4729 | 4994 | |
| 4730 | 4995 | // Need to have some control. |
| 4731 | - if (!isset($context['instances'])) |
|
| 4732 | - $context['instances'] = array(); |
|
| 4996 | + if (!isset($context['instances'])) { |
|
| 4997 | + $context['instances'] = array(); |
|
| 4998 | + } |
|
| 4733 | 4999 | |
| 4734 | 5000 | $results = array(); |
| 4735 | - if (empty($modSettings[$hook])) |
|
| 4736 | - return $results; |
|
| 5001 | + if (empty($modSettings[$hook])) { |
|
| 5002 | + return $results; |
|
| 5003 | + } |
|
| 4737 | 5004 | |
| 4738 | 5005 | $functions = explode(',', $modSettings[$hook]); |
| 4739 | 5006 | // Loop through each function. |
| 4740 | 5007 | foreach ($functions as $function) |
| 4741 | 5008 | { |
| 4742 | 5009 | // Hook has been marked as "disabled". Skip it! |
| 4743 | - if (strpos($function, '!') !== false) |
|
| 4744 | - continue; |
|
| 5010 | + if (strpos($function, '!') !== false) { |
|
| 5011 | + continue; |
|
| 5012 | + } |
|
| 4745 | 5013 | |
| 4746 | 5014 | $call = call_helper($function, true); |
| 4747 | 5015 | |
| 4748 | 5016 | // Is it valid? |
| 4749 | - if (!empty($call)) |
|
| 4750 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 5017 | + if (!empty($call)) { |
|
| 5018 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 5019 | + } |
|
| 4751 | 5020 | |
| 4752 | 5021 | // Whatever it was suppose to call, it failed :( |
| 4753 | 5022 | elseif (!empty($function)) |
@@ -4763,8 +5032,9 @@ discard block |
||
| 4763 | 5032 | } |
| 4764 | 5033 | |
| 4765 | 5034 | // "Assume" the file resides on $boarddir somewhere... |
| 4766 | - else |
|
| 4767 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 5035 | + else { |
|
| 5036 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 5037 | + } |
|
| 4768 | 5038 | } |
| 4769 | 5039 | } |
| 4770 | 5040 | |
@@ -4786,12 +5056,14 @@ discard block |
||
| 4786 | 5056 | global $smcFunc, $modSettings; |
| 4787 | 5057 | |
| 4788 | 5058 | // Any objects? |
| 4789 | - if ($object) |
|
| 4790 | - $function = $function . '#'; |
|
| 5059 | + if ($object) { |
|
| 5060 | + $function = $function . '#'; |
|
| 5061 | + } |
|
| 4791 | 5062 | |
| 4792 | 5063 | // Any files to load? |
| 4793 | - if (!empty($file) && is_string($file)) |
|
| 4794 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 5064 | + if (!empty($file) && is_string($file)) { |
|
| 5065 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 5066 | + } |
|
| 4795 | 5067 | |
| 4796 | 5068 | // Get the correct string. |
| 4797 | 5069 | $integration_call = $function; |
@@ -4813,13 +5085,14 @@ discard block |
||
| 4813 | 5085 | if (!empty($current_functions)) |
| 4814 | 5086 | { |
| 4815 | 5087 | $current_functions = explode(',', $current_functions); |
| 4816 | - if (in_array($integration_call, $current_functions)) |
|
| 4817 | - return; |
|
| 5088 | + if (in_array($integration_call, $current_functions)) { |
|
| 5089 | + return; |
|
| 5090 | + } |
|
| 4818 | 5091 | |
| 4819 | 5092 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 5093 | + } else { |
|
| 5094 | + $permanent_functions = array($integration_call); |
|
| 4820 | 5095 | } |
| 4821 | - else |
|
| 4822 | - $permanent_functions = array($integration_call); |
|
| 4823 | 5096 | |
| 4824 | 5097 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4825 | 5098 | } |
@@ -4828,8 +5101,9 @@ discard block |
||
| 4828 | 5101 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4829 | 5102 | |
| 4830 | 5103 | // Do nothing, if it's already there. |
| 4831 | - if (in_array($integration_call, $functions)) |
|
| 4832 | - return; |
|
| 5104 | + if (in_array($integration_call, $functions)) { |
|
| 5105 | + return; |
|
| 5106 | + } |
|
| 4833 | 5107 | |
| 4834 | 5108 | $functions[] = $integration_call; |
| 4835 | 5109 | $modSettings[$hook] = implode(',', $functions); |
@@ -4852,12 +5126,14 @@ discard block |
||
| 4852 | 5126 | global $smcFunc, $modSettings; |
| 4853 | 5127 | |
| 4854 | 5128 | // Any objects? |
| 4855 | - if ($object) |
|
| 4856 | - $function = $function . '#'; |
|
| 5129 | + if ($object) { |
|
| 5130 | + $function = $function . '#'; |
|
| 5131 | + } |
|
| 4857 | 5132 | |
| 4858 | 5133 | // Any files to load? |
| 4859 | - if (!empty($file) && is_string($file)) |
|
| 4860 | - $function = $file . '|' . $function; |
|
| 5134 | + if (!empty($file) && is_string($file)) { |
|
| 5135 | + $function = $file . '|' . $function; |
|
| 5136 | + } |
|
| 4861 | 5137 | |
| 4862 | 5138 | // Get the correct string. |
| 4863 | 5139 | $integration_call = $function; |
@@ -4878,16 +5154,18 @@ discard block |
||
| 4878 | 5154 | { |
| 4879 | 5155 | $current_functions = explode(',', $current_functions); |
| 4880 | 5156 | |
| 4881 | - if (in_array($integration_call, $current_functions)) |
|
| 4882 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 5157 | + if (in_array($integration_call, $current_functions)) { |
|
| 5158 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 5159 | + } |
|
| 4883 | 5160 | } |
| 4884 | 5161 | |
| 4885 | 5162 | // Turn the function list into something usable. |
| 4886 | 5163 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4887 | 5164 | |
| 4888 | 5165 | // You can only remove it if it's available. |
| 4889 | - if (!in_array($integration_call, $functions)) |
|
| 4890 | - return; |
|
| 5166 | + if (!in_array($integration_call, $functions)) { |
|
| 5167 | + return; |
|
| 5168 | + } |
|
| 4891 | 5169 | |
| 4892 | 5170 | $functions = array_diff($functions, array($integration_call)); |
| 4893 | 5171 | $modSettings[$hook] = implode(',', $functions); |
@@ -4908,17 +5186,20 @@ discard block |
||
| 4908 | 5186 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4909 | 5187 | |
| 4910 | 5188 | // Really? |
| 4911 | - if (empty($string)) |
|
| 4912 | - return false; |
|
| 5189 | + if (empty($string)) { |
|
| 5190 | + return false; |
|
| 5191 | + } |
|
| 4913 | 5192 | |
| 4914 | 5193 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4915 | 5194 | // A closure? should be a callable one. |
| 4916 | - if (is_array($string) || $string instanceof Closure) |
|
| 4917 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 5195 | + if (is_array($string) || $string instanceof Closure) { |
|
| 5196 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 5197 | + } |
|
| 4918 | 5198 | |
| 4919 | 5199 | // No full objects, sorry! pass a method or a property instead! |
| 4920 | - if (is_object($string)) |
|
| 4921 | - return false; |
|
| 5200 | + if (is_object($string)) { |
|
| 5201 | + return false; |
|
| 5202 | + } |
|
| 4922 | 5203 | |
| 4923 | 5204 | // Stay vitaminized my friends... |
| 4924 | 5205 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4927,8 +5208,9 @@ discard block |
||
| 4927 | 5208 | $string = load_file($string); |
| 4928 | 5209 | |
| 4929 | 5210 | // Loaded file failed |
| 4930 | - if (empty($string)) |
|
| 4931 | - return false; |
|
| 5211 | + if (empty($string)) { |
|
| 5212 | + return false; |
|
| 5213 | + } |
|
| 4932 | 5214 | |
| 4933 | 5215 | // Found a method. |
| 4934 | 5216 | if (strpos($string, '::') !== false) |
@@ -4949,8 +5231,9 @@ discard block |
||
| 4949 | 5231 | // Add another one to the list. |
| 4950 | 5232 | if ($db_show_debug === true) |
| 4951 | 5233 | { |
| 4952 | - if (!isset($context['debug']['instances'])) |
|
| 4953 | - $context['debug']['instances'] = array(); |
|
| 5234 | + if (!isset($context['debug']['instances'])) { |
|
| 5235 | + $context['debug']['instances'] = array(); |
|
| 5236 | + } |
|
| 4954 | 5237 | |
| 4955 | 5238 | $context['debug']['instances'][$class] = $class; |
| 4956 | 5239 | } |
@@ -4960,13 +5243,15 @@ discard block |
||
| 4960 | 5243 | } |
| 4961 | 5244 | |
| 4962 | 5245 | // Right then. This is a call to a static method. |
| 4963 | - else |
|
| 4964 | - $func = array($class, $method); |
|
| 5246 | + else { |
|
| 5247 | + $func = array($class, $method); |
|
| 5248 | + } |
|
| 4965 | 5249 | } |
| 4966 | 5250 | |
| 4967 | 5251 | // Nope! just a plain regular function. |
| 4968 | - else |
|
| 4969 | - $func = $string; |
|
| 5252 | + else { |
|
| 5253 | + $func = $string; |
|
| 5254 | + } |
|
| 4970 | 5255 | |
| 4971 | 5256 | // Right, we got what we need, time to do some checks. |
| 4972 | 5257 | if (!is_callable($func, false, $callable_name)) |
@@ -4982,17 +5267,18 @@ discard block |
||
| 4982 | 5267 | else |
| 4983 | 5268 | { |
| 4984 | 5269 | // What are we gonna do about it? |
| 4985 | - if ($return) |
|
| 4986 | - return $func; |
|
| 5270 | + if ($return) { |
|
| 5271 | + return $func; |
|
| 5272 | + } |
|
| 4987 | 5273 | |
| 4988 | 5274 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4989 | 5275 | else |
| 4990 | 5276 | { |
| 4991 | - if (is_array($func)) |
|
| 4992 | - call_user_func($func); |
|
| 4993 | - |
|
| 4994 | - else |
|
| 4995 | - $func(); |
|
| 5277 | + if (is_array($func)) { |
|
| 5278 | + call_user_func($func); |
|
| 5279 | + } else { |
|
| 5280 | + $func(); |
|
| 5281 | + } |
|
| 4996 | 5282 | } |
| 4997 | 5283 | } |
| 4998 | 5284 | } |
@@ -5009,31 +5295,34 @@ discard block |
||
| 5009 | 5295 | { |
| 5010 | 5296 | global $sourcedir, $txt, $boarddir, $settings; |
| 5011 | 5297 | |
| 5012 | - if (empty($string)) |
|
| 5013 | - return false; |
|
| 5298 | + if (empty($string)) { |
|
| 5299 | + return false; |
|
| 5300 | + } |
|
| 5014 | 5301 | |
| 5015 | 5302 | if (strpos($string, '|') !== false) |
| 5016 | 5303 | { |
| 5017 | 5304 | list ($file, $string) = explode('|', $string); |
| 5018 | 5305 | |
| 5019 | 5306 | // Match the wildcards to their regular vars. |
| 5020 | - if (empty($settings['theme_dir'])) |
|
| 5021 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 5022 | - |
|
| 5023 | - else |
|
| 5024 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 5307 | + if (empty($settings['theme_dir'])) { |
|
| 5308 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 5309 | + } else { |
|
| 5310 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 5311 | + } |
|
| 5025 | 5312 | |
| 5026 | 5313 | // Load the file if it can be loaded. |
| 5027 | - if (file_exists($absPath)) |
|
| 5028 | - require_once($absPath); |
|
| 5314 | + if (file_exists($absPath)) { |
|
| 5315 | + require_once($absPath); |
|
| 5316 | + } |
|
| 5029 | 5317 | |
| 5030 | 5318 | // No? try a fallback to $sourcedir |
| 5031 | 5319 | else |
| 5032 | 5320 | { |
| 5033 | 5321 | $absPath = $sourcedir .'/'. $file; |
| 5034 | 5322 | |
| 5035 | - if (file_exists($absPath)) |
|
| 5036 | - require_once($absPath); |
|
| 5323 | + if (file_exists($absPath)) { |
|
| 5324 | + require_once($absPath); |
|
| 5325 | + } |
|
| 5037 | 5326 | |
| 5038 | 5327 | // Sorry, can't do much for you at this point. |
| 5039 | 5328 | else |
@@ -5072,8 +5361,9 @@ discard block |
||
| 5072 | 5361 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
| 5073 | 5362 | |
| 5074 | 5363 | // No scheme? No data for you! |
| 5075 | - if (empty($match[1])) |
|
| 5076 | - return false; |
|
| 5364 | + if (empty($match[1])) { |
|
| 5365 | + return false; |
|
| 5366 | + } |
|
| 5077 | 5367 | |
| 5078 | 5368 | // An FTP url. We should try connecting and RETRieving it... |
| 5079 | 5369 | elseif ($match[1] == 'ftp') |
@@ -5083,23 +5373,26 @@ discard block |
||
| 5083 | 5373 | |
| 5084 | 5374 | // Establish a connection and attempt to enable passive mode. |
| 5085 | 5375 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
| 5086 | - if ($ftp->error !== false || !$ftp->passive()) |
|
| 5087 | - return false; |
|
| 5376 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
| 5377 | + return false; |
|
| 5378 | + } |
|
| 5088 | 5379 | |
| 5089 | 5380 | // I want that one *points*! |
| 5090 | 5381 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
| 5091 | 5382 | |
| 5092 | 5383 | // Since passive mode worked (or we would have returned already!) open the connection. |
| 5093 | 5384 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
| 5094 | - if (!$fp) |
|
| 5095 | - return false; |
|
| 5385 | + if (!$fp) { |
|
| 5386 | + return false; |
|
| 5387 | + } |
|
| 5096 | 5388 | |
| 5097 | 5389 | // The server should now say something in acknowledgement. |
| 5098 | 5390 | $ftp->check_response(150); |
| 5099 | 5391 | |
| 5100 | 5392 | $data = ''; |
| 5101 | - while (!feof($fp)) |
|
| 5102 | - $data .= fread($fp, 4096); |
|
| 5393 | + while (!feof($fp)) { |
|
| 5394 | + $data .= fread($fp, 4096); |
|
| 5395 | + } |
|
| 5103 | 5396 | fclose($fp); |
| 5104 | 5397 | |
| 5105 | 5398 | // All done, right? Good. |
@@ -5111,8 +5404,9 @@ discard block |
||
| 5111 | 5404 | elseif (isset($match[1]) && $match[1] == 'http') |
| 5112 | 5405 | { |
| 5113 | 5406 | // First try to use fsockopen, because it is fastest. |
| 5114 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
| 5115 | - $fp = $keep_alive_fp; |
|
| 5407 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
| 5408 | + $fp = $keep_alive_fp; |
|
| 5409 | + } |
|
| 5116 | 5410 | if (empty($fp)) |
| 5117 | 5411 | { |
| 5118 | 5412 | // Open the socket on the port we want... |
@@ -5132,20 +5426,21 @@ discard block |
||
| 5132 | 5426 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
| 5133 | 5427 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 5134 | 5428 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
| 5135 | - if ($keep_alive) |
|
| 5136 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
| 5137 | - else |
|
| 5138 | - fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
| 5139 | - } |
|
| 5140 | - else |
|
| 5429 | + if ($keep_alive) { |
|
| 5430 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
| 5431 | + } else { |
|
| 5432 | + fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
| 5433 | + } |
|
| 5434 | + } else |
|
| 5141 | 5435 | { |
| 5142 | 5436 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
| 5143 | 5437 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 5144 | 5438 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
| 5145 | - if ($keep_alive) |
|
| 5146 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
| 5147 | - else |
|
| 5148 | - fwrite($fp, 'connection: close' . "\r\n"); |
|
| 5439 | + if ($keep_alive) { |
|
| 5440 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
| 5441 | + } else { |
|
| 5442 | + fwrite($fp, 'connection: close' . "\r\n"); |
|
| 5443 | + } |
|
| 5149 | 5444 | fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n"); |
| 5150 | 5445 | fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n"); |
| 5151 | 5446 | fwrite($fp, $post_data); |
@@ -5158,30 +5453,33 @@ discard block |
||
| 5158 | 5453 | { |
| 5159 | 5454 | $header = ''; |
| 5160 | 5455 | $location = ''; |
| 5161 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
| 5162 | - if (strpos($header, 'location:') !== false) |
|
| 5456 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
| 5457 | + if (strpos($header, 'location:') !== false) |
|
| 5163 | 5458 | $location = trim(substr($header, strpos($header, ':') + 1)); |
| 5459 | + } |
|
| 5164 | 5460 | |
| 5165 | - if (empty($location)) |
|
| 5166 | - return false; |
|
| 5167 | - else |
|
| 5461 | + if (empty($location)) { |
|
| 5462 | + return false; |
|
| 5463 | + } else |
|
| 5168 | 5464 | { |
| 5169 | - if (!$keep_alive) |
|
| 5170 | - fclose($fp); |
|
| 5465 | + if (!$keep_alive) { |
|
| 5466 | + fclose($fp); |
|
| 5467 | + } |
|
| 5171 | 5468 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
| 5172 | 5469 | } |
| 5173 | 5470 | } |
| 5174 | 5471 | |
| 5175 | 5472 | // Make sure we get a 200 OK. |
| 5176 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
| 5177 | - return false; |
|
| 5473 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
| 5474 | + return false; |
|
| 5475 | + } |
|
| 5178 | 5476 | |
| 5179 | 5477 | // Skip the headers... |
| 5180 | 5478 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
| 5181 | 5479 | { |
| 5182 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
| 5183 | - $content_length = $match[1]; |
|
| 5184 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
| 5480 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
| 5481 | + $content_length = $match[1]; |
|
| 5482 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
| 5185 | 5483 | { |
| 5186 | 5484 | $keep_alive_dom = null; |
| 5187 | 5485 | $keep_alive = false; |
@@ -5193,17 +5491,19 @@ discard block |
||
| 5193 | 5491 | $data = ''; |
| 5194 | 5492 | if (isset($content_length)) |
| 5195 | 5493 | { |
| 5196 | - while (!feof($fp) && strlen($data) < $content_length) |
|
| 5197 | - $data .= fread($fp, $content_length - strlen($data)); |
|
| 5198 | - } |
|
| 5199 | - else |
|
| 5494 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
| 5495 | + $data .= fread($fp, $content_length - strlen($data)); |
|
| 5496 | + } |
|
| 5497 | + } else |
|
| 5200 | 5498 | { |
| 5201 | - while (!feof($fp)) |
|
| 5202 | - $data .= fread($fp, 4096); |
|
| 5499 | + while (!feof($fp)) { |
|
| 5500 | + $data .= fread($fp, 4096); |
|
| 5501 | + } |
|
| 5203 | 5502 | } |
| 5204 | 5503 | |
| 5205 | - if (!$keep_alive) |
|
| 5206 | - fclose($fp); |
|
| 5504 | + if (!$keep_alive) { |
|
| 5505 | + fclose($fp); |
|
| 5506 | + } |
|
| 5207 | 5507 | } |
| 5208 | 5508 | |
| 5209 | 5509 | // If using fsockopen didn't work, try to use cURL if available. |
@@ -5216,17 +5516,18 @@ discard block |
||
| 5216 | 5516 | $fetch_data->get_url_data($url, $post_data); |
| 5217 | 5517 | |
| 5218 | 5518 | // no errors and a 200 result, then we have a good dataset, well we at least have data. ;) |
| 5219 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
| 5220 | - $data = $fetch_data->result('body'); |
|
| 5221 | - else |
|
| 5222 | - return false; |
|
| 5519 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
| 5520 | + $data = $fetch_data->result('body'); |
|
| 5521 | + } else { |
|
| 5522 | + return false; |
|
| 5523 | + } |
|
| 5223 | 5524 | } |
| 5224 | 5525 | |
| 5225 | 5526 | // Neither fsockopen nor curl are available. Well, phooey. |
| 5226 | - else |
|
| 5227 | - return false; |
|
| 5228 | - } |
|
| 5229 | - else |
|
| 5527 | + else { |
|
| 5528 | + return false; |
|
| 5529 | + } |
|
| 5530 | + } else |
|
| 5230 | 5531 | { |
| 5231 | 5532 | // Umm, this shouldn't happen? |
| 5232 | 5533 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -5246,8 +5547,9 @@ discard block |
||
| 5246 | 5547 | global $user_info, $smcFunc; |
| 5247 | 5548 | |
| 5248 | 5549 | // Make sure we have something to work with. |
| 5249 | - if (empty($topic)) |
|
| 5250 | - return array(); |
|
| 5550 | + if (empty($topic)) { |
|
| 5551 | + return array(); |
|
| 5552 | + } |
|
| 5251 | 5553 | |
| 5252 | 5554 | |
| 5253 | 5555 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -5270,8 +5572,9 @@ discard block |
||
| 5270 | 5572 | 'topic' => $topic, |
| 5271 | 5573 | ) |
| 5272 | 5574 | ); |
| 5273 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 5274 | - $temp[] = (int) $row['content_id']; |
|
| 5575 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5576 | + $temp[] = (int) $row['content_id']; |
|
| 5577 | + } |
|
| 5275 | 5578 | |
| 5276 | 5579 | cache_put_data($cache_key, $temp, $ttl); |
| 5277 | 5580 | } |
@@ -5292,8 +5595,9 @@ discard block |
||
| 5292 | 5595 | { |
| 5293 | 5596 | global $context; |
| 5294 | 5597 | |
| 5295 | - if (empty($string)) |
|
| 5296 | - return $string; |
|
| 5598 | + if (empty($string)) { |
|
| 5599 | + return $string; |
|
| 5600 | + } |
|
| 5297 | 5601 | |
| 5298 | 5602 | // UTF-8 occurences of MS special characters |
| 5299 | 5603 | $findchars_utf8 = array( |
@@ -5334,10 +5638,11 @@ discard block |
||
| 5334 | 5638 | '--', // — |
| 5335 | 5639 | ); |
| 5336 | 5640 | |
| 5337 | - if ($context['utf8']) |
|
| 5338 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5339 | - else |
|
| 5340 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5641 | + if ($context['utf8']) { |
|
| 5642 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5643 | + } else { |
|
| 5644 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5645 | + } |
|
| 5341 | 5646 | |
| 5342 | 5647 | return $string; |
| 5343 | 5648 | } |
@@ -5356,49 +5661,59 @@ discard block |
||
| 5356 | 5661 | { |
| 5357 | 5662 | global $context; |
| 5358 | 5663 | |
| 5359 | - if (!isset($matches[2])) |
|
| 5360 | - return ''; |
|
| 5664 | + if (!isset($matches[2])) { |
|
| 5665 | + return ''; |
|
| 5666 | + } |
|
| 5361 | 5667 | |
| 5362 | 5668 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 5363 | 5669 | |
| 5364 | 5670 | // remove left to right / right to left overrides |
| 5365 | - if ($num === 0x202D || $num === 0x202E) |
|
| 5366 | - return ''; |
|
| 5671 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5672 | + return ''; |
|
| 5673 | + } |
|
| 5367 | 5674 | |
| 5368 | 5675 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 5369 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 5370 | - return '&#' . $num . ';'; |
|
| 5676 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5677 | + return '&#' . $num . ';'; |
|
| 5678 | + } |
|
| 5371 | 5679 | |
| 5372 | 5680 | if (empty($context['utf8'])) |
| 5373 | 5681 | { |
| 5374 | 5682 | // no control characters |
| 5375 | - if ($num < 0x20) |
|
| 5376 | - return ''; |
|
| 5683 | + if ($num < 0x20) { |
|
| 5684 | + return ''; |
|
| 5685 | + } |
|
| 5377 | 5686 | // text is text |
| 5378 | - elseif ($num < 0x80) |
|
| 5379 | - return chr($num); |
|
| 5687 | + elseif ($num < 0x80) { |
|
| 5688 | + return chr($num); |
|
| 5689 | + } |
|
| 5380 | 5690 | // all others get html-ised |
| 5381 | - else |
|
| 5382 | - return '&#' . $matches[2] . ';'; |
|
| 5383 | - } |
|
| 5384 | - else |
|
| 5691 | + else { |
|
| 5692 | + return '&#' . $matches[2] . ';'; |
|
| 5693 | + } |
|
| 5694 | + } else |
|
| 5385 | 5695 | { |
| 5386 | 5696 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 5387 | 5697 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 5388 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 5389 | - return ''; |
|
| 5698 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5699 | + return ''; |
|
| 5700 | + } |
|
| 5390 | 5701 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 5391 | - elseif ($num < 0x80) |
|
| 5392 | - return chr($num); |
|
| 5702 | + elseif ($num < 0x80) { |
|
| 5703 | + return chr($num); |
|
| 5704 | + } |
|
| 5393 | 5705 | // <0x800 (2048) |
| 5394 | - elseif ($num < 0x800) |
|
| 5395 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5706 | + elseif ($num < 0x800) { |
|
| 5707 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5708 | + } |
|
| 5396 | 5709 | // < 0x10000 (65536) |
| 5397 | - elseif ($num < 0x10000) |
|
| 5398 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5710 | + elseif ($num < 0x10000) { |
|
| 5711 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5712 | + } |
|
| 5399 | 5713 | // <= 0x10FFFF (1114111) |
| 5400 | - else |
|
| 5401 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5714 | + else { |
|
| 5715 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5716 | + } |
|
| 5402 | 5717 | } |
| 5403 | 5718 | } |
| 5404 | 5719 | |
@@ -5414,28 +5729,34 @@ discard block |
||
| 5414 | 5729 | */ |
| 5415 | 5730 | function fixchar__callback($matches) |
| 5416 | 5731 | { |
| 5417 | - if (!isset($matches[1])) |
|
| 5418 | - return ''; |
|
| 5732 | + if (!isset($matches[1])) { |
|
| 5733 | + return ''; |
|
| 5734 | + } |
|
| 5419 | 5735 | |
| 5420 | 5736 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 5421 | 5737 | |
| 5422 | 5738 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 5423 | 5739 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 5424 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 5425 | - return ''; |
|
| 5740 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5741 | + return ''; |
|
| 5742 | + } |
|
| 5426 | 5743 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 5427 | - elseif ($num < 0x80) |
|
| 5428 | - return chr($num); |
|
| 5744 | + elseif ($num < 0x80) { |
|
| 5745 | + return chr($num); |
|
| 5746 | + } |
|
| 5429 | 5747 | // <0x800 (2048) |
| 5430 | - elseif ($num < 0x800) |
|
| 5431 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5748 | + elseif ($num < 0x800) { |
|
| 5749 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5750 | + } |
|
| 5432 | 5751 | // < 0x10000 (65536) |
| 5433 | - elseif ($num < 0x10000) |
|
| 5434 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5752 | + elseif ($num < 0x10000) { |
|
| 5753 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5754 | + } |
|
| 5435 | 5755 | // <= 0x10FFFF (1114111) |
| 5436 | - else |
|
| 5437 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5438 | -} |
|
| 5756 | + else { |
|
| 5757 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5758 | + } |
|
| 5759 | + } |
|
| 5439 | 5760 | |
| 5440 | 5761 | /** |
| 5441 | 5762 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -5448,17 +5769,19 @@ discard block |
||
| 5448 | 5769 | */ |
| 5449 | 5770 | function entity_fix__callback($matches) |
| 5450 | 5771 | { |
| 5451 | - if (!isset($matches[2])) |
|
| 5452 | - return ''; |
|
| 5772 | + if (!isset($matches[2])) { |
|
| 5773 | + return ''; |
|
| 5774 | + } |
|
| 5453 | 5775 | |
| 5454 | 5776 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 5455 | 5777 | |
| 5456 | 5778 | // we don't allow control characters, characters out of range, byte markers, etc |
| 5457 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 5458 | - return ''; |
|
| 5459 | - else |
|
| 5460 | - return '&#' . $num . ';'; |
|
| 5461 | -} |
|
| 5779 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5780 | + return ''; |
|
| 5781 | + } else { |
|
| 5782 | + return '&#' . $num . ';'; |
|
| 5783 | + } |
|
| 5784 | + } |
|
| 5462 | 5785 | |
| 5463 | 5786 | /** |
| 5464 | 5787 | * Return a Gravatar URL based on |
@@ -5482,18 +5805,23 @@ discard block |
||
| 5482 | 5805 | $ratings = array('G', 'PG', 'R', 'X'); |
| 5483 | 5806 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 5484 | 5807 | $url_params = array(); |
| 5485 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 5486 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5487 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 5488 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5489 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 5490 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5491 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 5492 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5808 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5809 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5810 | + } |
|
| 5811 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5812 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5813 | + } |
|
| 5814 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5815 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5816 | + } |
|
| 5817 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5818 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5493 | 5819 | $size_string = $modSettings['avatar_max_height_external']; |
| 5820 | + } |
|
| 5494 | 5821 | |
| 5495 | - if (!empty($size_string)) |
|
| 5496 | - $url_params[] = 's=' . $size_string; |
|
| 5822 | + if (!empty($size_string)) { |
|
| 5823 | + $url_params[] = 's=' . $size_string; |
|
| 5824 | + } |
|
| 5497 | 5825 | } |
| 5498 | 5826 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
| 5499 | 5827 | |
@@ -5512,22 +5840,26 @@ discard block |
||
| 5512 | 5840 | static $timezones = null, $lastwhen = null; |
| 5513 | 5841 | |
| 5514 | 5842 | // No point doing this over if we already did it once |
| 5515 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 5516 | - return $timezones; |
|
| 5517 | - else |
|
| 5518 | - $lastwhen = $when; |
|
| 5843 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5844 | + return $timezones; |
|
| 5845 | + } else { |
|
| 5846 | + $lastwhen = $when; |
|
| 5847 | + } |
|
| 5519 | 5848 | |
| 5520 | 5849 | // Parseable datetime string? |
| 5521 | - if (is_int($timestamp = strtotime($when))) |
|
| 5522 | - $when = $timestamp; |
|
| 5850 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5851 | + $when = $timestamp; |
|
| 5852 | + } |
|
| 5523 | 5853 | |
| 5524 | 5854 | // A Unix timestamp? |
| 5525 | - elseif (is_numeric($when)) |
|
| 5526 | - $when = intval($when); |
|
| 5855 | + elseif (is_numeric($when)) { |
|
| 5856 | + $when = intval($when); |
|
| 5857 | + } |
|
| 5527 | 5858 | |
| 5528 | 5859 | // Invalid value? Just get current Unix timestamp. |
| 5529 | - else |
|
| 5530 | - $when = time(); |
|
| 5860 | + else { |
|
| 5861 | + $when = time(); |
|
| 5862 | + } |
|
| 5531 | 5863 | |
| 5532 | 5864 | // We'll need these too |
| 5533 | 5865 | $date_when = date_create('@' . $when); |
@@ -5542,8 +5874,9 @@ discard block |
||
| 5542 | 5874 | foreach ($priority_countries as $country) |
| 5543 | 5875 | { |
| 5544 | 5876 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 5545 | - if (!empty($country_tzids)) |
|
| 5546 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5877 | + if (!empty($country_tzids)) { |
|
| 5878 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5879 | + } |
|
| 5547 | 5880 | } |
| 5548 | 5881 | |
| 5549 | 5882 | // Antarctic research stations should be listed last, unless you're running a penguin forum |
@@ -5557,8 +5890,9 @@ discard block |
||
| 5557 | 5890 | foreach ($tzids as $tzid) |
| 5558 | 5891 | { |
| 5559 | 5892 | // We don't want UTC right now |
| 5560 | - if ($tzid == 'UTC') |
|
| 5561 | - continue; |
|
| 5893 | + if ($tzid == 'UTC') { |
|
| 5894 | + continue; |
|
| 5895 | + } |
|
| 5562 | 5896 | |
| 5563 | 5897 | $tz = timezone_open($tzid); |
| 5564 | 5898 | |
@@ -5579,13 +5913,14 @@ discard block |
||
| 5579 | 5913 | } |
| 5580 | 5914 | |
| 5581 | 5915 | // A time zone from a prioritized country? |
| 5582 | - if (in_array($tzid, $priority_tzids)) |
|
| 5583 | - $priority_zones[$tzkey] = true; |
|
| 5916 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5917 | + $priority_zones[$tzkey] = true; |
|
| 5918 | + } |
|
| 5584 | 5919 | |
| 5585 | 5920 | // Keep track of the location and offset for this tzid |
| 5586 | - if (!empty($txt[$tzid])) |
|
| 5587 | - $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
| 5588 | - else |
|
| 5921 | + if (!empty($txt[$tzid])) { |
|
| 5922 | + $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
| 5923 | + } else |
|
| 5589 | 5924 | { |
| 5590 | 5925 | $tzid_parts = explode('/', $tzid); |
| 5591 | 5926 | $zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop($tzid_parts)); |
@@ -5605,23 +5940,27 @@ discard block |
||
| 5605 | 5940 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5606 | 5941 | |
| 5607 | 5942 | // Use the custom description, if there is one |
| 5608 | - if (!empty($tztxt[$tzvalue['tzid']])) |
|
| 5609 | - $desc = $tztxt[$tzvalue['tzid']]; |
|
| 5943 | + if (!empty($tztxt[$tzvalue['tzid']])) { |
|
| 5944 | + $desc = $tztxt[$tzvalue['tzid']]; |
|
| 5945 | + } |
|
| 5610 | 5946 | // Otherwise, use the list of locations (max 5, so things don't get silly) |
| 5611 | - else |
|
| 5612 | - $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
| 5947 | + else { |
|
| 5948 | + $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
| 5949 | + } |
|
| 5613 | 5950 | |
| 5614 | 5951 | // Show the UTC offset and the abbreviation, if it's something like 'MST' and not '-06' |
| 5615 | 5952 | $desc = '[UTC' . date_format($date_when, 'P') . '] - ' . (!strspn($tzvalue['abbr'], '+-') ? $tzvalue['abbr'] . ' - ' : '') . $desc; |
| 5616 | 5953 | |
| 5617 | - if (isset($priority_zones[$tzkey])) |
|
| 5618 | - $priority_timezones[$tzvalue['tzid']] = $desc; |
|
| 5619 | - else |
|
| 5620 | - $timezones[$tzvalue['tzid']] = $desc; |
|
| 5954 | + if (isset($priority_zones[$tzkey])) { |
|
| 5955 | + $priority_timezones[$tzvalue['tzid']] = $desc; |
|
| 5956 | + } else { |
|
| 5957 | + $timezones[$tzvalue['tzid']] = $desc; |
|
| 5958 | + } |
|
| 5621 | 5959 | } |
| 5622 | 5960 | |
| 5623 | - if (!empty($priority_timezones)) |
|
| 5624 | - $priority_timezones[] = '-----'; |
|
| 5961 | + if (!empty($priority_timezones)) { |
|
| 5962 | + $priority_timezones[] = '-----'; |
|
| 5963 | + } |
|
| 5625 | 5964 | |
| 5626 | 5965 | $timezones = array_merge( |
| 5627 | 5966 | $priority_timezones, |
@@ -5638,8 +5977,9 @@ discard block |
||
| 5638 | 5977 | */ |
| 5639 | 5978 | function inet_ptod($ip_address) |
| 5640 | 5979 | { |
| 5641 | - if (!isValidIP($ip_address)) |
|
| 5642 | - return $ip_address; |
|
| 5980 | + if (!isValidIP($ip_address)) { |
|
| 5981 | + return $ip_address; |
|
| 5982 | + } |
|
| 5643 | 5983 | |
| 5644 | 5984 | $bin = inet_pton($ip_address); |
| 5645 | 5985 | return $bin; |
@@ -5651,13 +5991,15 @@ discard block |
||
| 5651 | 5991 | */ |
| 5652 | 5992 | function inet_dtop($bin) |
| 5653 | 5993 | { |
| 5654 | - if(empty($bin)) |
|
| 5655 | - return ''; |
|
| 5994 | + if(empty($bin)) { |
|
| 5995 | + return ''; |
|
| 5996 | + } |
|
| 5656 | 5997 | |
| 5657 | 5998 | global $db_type; |
| 5658 | 5999 | |
| 5659 | - if ($db_type == 'postgresql') |
|
| 5660 | - return $bin; |
|
| 6000 | + if ($db_type == 'postgresql') { |
|
| 6001 | + return $bin; |
|
| 6002 | + } |
|
| 5661 | 6003 | |
| 5662 | 6004 | $ip_address = inet_ntop($bin); |
| 5663 | 6005 | |
@@ -5682,26 +6024,32 @@ discard block |
||
| 5682 | 6024 | */ |
| 5683 | 6025 | function _safe_serialize($value) |
| 5684 | 6026 | { |
| 5685 | - if(is_null($value)) |
|
| 5686 | - return 'N;'; |
|
| 6027 | + if(is_null($value)) { |
|
| 6028 | + return 'N;'; |
|
| 6029 | + } |
|
| 5687 | 6030 | |
| 5688 | - if(is_bool($value)) |
|
| 5689 | - return 'b:'. (int) $value .';'; |
|
| 6031 | + if(is_bool($value)) { |
|
| 6032 | + return 'b:'. (int) $value .';'; |
|
| 6033 | + } |
|
| 5690 | 6034 | |
| 5691 | - if(is_int($value)) |
|
| 5692 | - return 'i:'. $value .';'; |
|
| 6035 | + if(is_int($value)) { |
|
| 6036 | + return 'i:'. $value .';'; |
|
| 6037 | + } |
|
| 5693 | 6038 | |
| 5694 | - if(is_float($value)) |
|
| 5695 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 6039 | + if(is_float($value)) { |
|
| 6040 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 6041 | + } |
|
| 5696 | 6042 | |
| 5697 | - if(is_string($value)) |
|
| 5698 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 6043 | + if(is_string($value)) { |
|
| 6044 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 6045 | + } |
|
| 5699 | 6046 | |
| 5700 | 6047 | if(is_array($value)) |
| 5701 | 6048 | { |
| 5702 | 6049 | $out = ''; |
| 5703 | - foreach($value as $k => $v) |
|
| 5704 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 6050 | + foreach($value as $k => $v) { |
|
| 6051 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 6052 | + } |
|
| 5705 | 6053 | |
| 5706 | 6054 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5707 | 6055 | } |
@@ -5727,8 +6075,9 @@ discard block |
||
| 5727 | 6075 | |
| 5728 | 6076 | $out = _safe_serialize($value); |
| 5729 | 6077 | |
| 5730 | - if (isset($mbIntEnc)) |
|
| 5731 | - mb_internal_encoding($mbIntEnc); |
|
| 6078 | + if (isset($mbIntEnc)) { |
|
| 6079 | + mb_internal_encoding($mbIntEnc); |
|
| 6080 | + } |
|
| 5732 | 6081 | |
| 5733 | 6082 | return $out; |
| 5734 | 6083 | } |
@@ -5745,8 +6094,9 @@ discard block |
||
| 5745 | 6094 | function _safe_unserialize($str) |
| 5746 | 6095 | { |
| 5747 | 6096 | // Input is not a string. |
| 5748 | - if(empty($str) || !is_string($str)) |
|
| 5749 | - return false; |
|
| 6097 | + if(empty($str) || !is_string($str)) { |
|
| 6098 | + return false; |
|
| 6099 | + } |
|
| 5750 | 6100 | |
| 5751 | 6101 | $stack = array(); |
| 5752 | 6102 | $expected = array(); |
@@ -5762,43 +6112,38 @@ discard block |
||
| 5762 | 6112 | while($state != 1) |
| 5763 | 6113 | { |
| 5764 | 6114 | $type = isset($str[0]) ? $str[0] : ''; |
| 5765 | - if($type == '}') |
|
| 5766 | - $str = substr($str, 1); |
|
| 5767 | - |
|
| 5768 | - else if($type == 'N' && $str[1] == ';') |
|
| 6115 | + if($type == '}') { |
|
| 6116 | + $str = substr($str, 1); |
|
| 6117 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5769 | 6118 | { |
| 5770 | 6119 | $value = null; |
| 5771 | 6120 | $str = substr($str, 2); |
| 5772 | - } |
|
| 5773 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 6121 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5774 | 6122 | { |
| 5775 | 6123 | $value = $matches[1] == '1' ? true : false; |
| 5776 | 6124 | $str = substr($str, 4); |
| 5777 | - } |
|
| 5778 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 6125 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5779 | 6126 | { |
| 5780 | 6127 | $value = (int)$matches[1]; |
| 5781 | 6128 | $str = $matches[2]; |
| 5782 | - } |
|
| 5783 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 6129 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5784 | 6130 | { |
| 5785 | 6131 | $value = (float)$matches[1]; |
| 5786 | 6132 | $str = $matches[3]; |
| 5787 | - } |
|
| 5788 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 6133 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5789 | 6134 | { |
| 5790 | 6135 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5791 | 6136 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5792 | - } |
|
| 5793 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 6137 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5794 | 6138 | { |
| 5795 | 6139 | $expectedLength = (int)$matches[1]; |
| 5796 | 6140 | $str = $matches[2]; |
| 5797 | 6141 | } |
| 5798 | 6142 | |
| 5799 | 6143 | // Object or unknown/malformed type. |
| 5800 | - else |
|
| 5801 | - return false; |
|
| 6144 | + else { |
|
| 6145 | + return false; |
|
| 6146 | + } |
|
| 5802 | 6147 | |
| 5803 | 6148 | switch($state) |
| 5804 | 6149 | { |
@@ -5826,8 +6171,9 @@ discard block |
||
| 5826 | 6171 | if($type == '}') |
| 5827 | 6172 | { |
| 5828 | 6173 | // Array size is less than expected. |
| 5829 | - if(count($list) < end($expected)) |
|
| 5830 | - return false; |
|
| 6174 | + if(count($list) < end($expected)) { |
|
| 6175 | + return false; |
|
| 6176 | + } |
|
| 5831 | 6177 | |
| 5832 | 6178 | unset($list); |
| 5833 | 6179 | $list = &$stack[count($stack)-1]; |
@@ -5836,8 +6182,9 @@ discard block |
||
| 5836 | 6182 | // Go to terminal state if we're at the end of the root array. |
| 5837 | 6183 | array_pop($expected); |
| 5838 | 6184 | |
| 5839 | - if(count($expected) == 0) |
|
| 5840 | - $state = 1; |
|
| 6185 | + if(count($expected) == 0) { |
|
| 6186 | + $state = 1; |
|
| 6187 | + } |
|
| 5841 | 6188 | |
| 5842 | 6189 | break; |
| 5843 | 6190 | } |
@@ -5845,8 +6192,9 @@ discard block |
||
| 5845 | 6192 | if($type == 'i' || $type == 's') |
| 5846 | 6193 | { |
| 5847 | 6194 | // Array size exceeds expected length. |
| 5848 | - if(count($list) >= end($expected)) |
|
| 5849 | - return false; |
|
| 6195 | + if(count($list) >= end($expected)) { |
|
| 6196 | + return false; |
|
| 6197 | + } |
|
| 5850 | 6198 | |
| 5851 | 6199 | $key = $value; |
| 5852 | 6200 | $state = 3; |
@@ -5880,8 +6228,9 @@ discard block |
||
| 5880 | 6228 | } |
| 5881 | 6229 | |
| 5882 | 6230 | // Trailing data in input. |
| 5883 | - if(!empty($str)) |
|
| 5884 | - return false; |
|
| 6231 | + if(!empty($str)) { |
|
| 6232 | + return false; |
|
| 6233 | + } |
|
| 5885 | 6234 | |
| 5886 | 6235 | return $data; |
| 5887 | 6236 | } |
@@ -5904,8 +6253,9 @@ discard block |
||
| 5904 | 6253 | |
| 5905 | 6254 | $out = _safe_unserialize($str); |
| 5906 | 6255 | |
| 5907 | - if (isset($mbIntEnc)) |
|
| 5908 | - mb_internal_encoding($mbIntEnc); |
|
| 6256 | + if (isset($mbIntEnc)) { |
|
| 6257 | + mb_internal_encoding($mbIntEnc); |
|
| 6258 | + } |
|
| 5909 | 6259 | |
| 5910 | 6260 | return $out; |
| 5911 | 6261 | } |
@@ -5920,12 +6270,14 @@ discard block |
||
| 5920 | 6270 | function smf_chmod($file, $value = 0) |
| 5921 | 6271 | { |
| 5922 | 6272 | // No file? no checks! |
| 5923 | - if (empty($file)) |
|
| 5924 | - return false; |
|
| 6273 | + if (empty($file)) { |
|
| 6274 | + return false; |
|
| 6275 | + } |
|
| 5925 | 6276 | |
| 5926 | 6277 | // Already writable? |
| 5927 | - if (is_writable($file)) |
|
| 5928 | - return true; |
|
| 6278 | + if (is_writable($file)) { |
|
| 6279 | + return true; |
|
| 6280 | + } |
|
| 5929 | 6281 | |
| 5930 | 6282 | // Do we have a file or a dir? |
| 5931 | 6283 | $isDir = is_dir($file); |
@@ -5941,10 +6293,9 @@ discard block |
||
| 5941 | 6293 | { |
| 5942 | 6294 | $isWritable = true; |
| 5943 | 6295 | break; |
| 6296 | + } else { |
|
| 6297 | + @chmod($file, $val); |
|
| 5944 | 6298 | } |
| 5945 | - |
|
| 5946 | - else |
|
| 5947 | - @chmod($file, $val); |
|
| 5948 | 6299 | } |
| 5949 | 6300 | |
| 5950 | 6301 | return $isWritable; |
@@ -5963,8 +6314,9 @@ discard block |
||
| 5963 | 6314 | global $txt; |
| 5964 | 6315 | |
| 5965 | 6316 | // Come on... |
| 5966 | - if (empty($json) || !is_string($json)) |
|
| 5967 | - return array(); |
|
| 6317 | + if (empty($json) || !is_string($json)) { |
|
| 6318 | + return array(); |
|
| 6319 | + } |
|
| 5968 | 6320 | |
| 5969 | 6321 | $returnArray = @json_decode($json, $returnAsArray); |
| 5970 | 6322 | |
@@ -6002,11 +6354,11 @@ discard block |
||
| 6002 | 6354 | $jsonDebug = $jsonDebug[0]; |
| 6003 | 6355 | loadLanguage('Errors'); |
| 6004 | 6356 | |
| 6005 | - if (!empty($jsonDebug)) |
|
| 6006 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6007 | - |
|
| 6008 | - else |
|
| 6009 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6357 | + if (!empty($jsonDebug)) { |
|
| 6358 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6359 | + } else { |
|
| 6360 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6361 | + } |
|
| 6010 | 6362 | |
| 6011 | 6363 | // Everyone expects an array. |
| 6012 | 6364 | return array(); |
@@ -6040,8 +6392,9 @@ discard block |
||
| 6040 | 6392 | global $db_show_debug, $modSettings; |
| 6041 | 6393 | |
| 6042 | 6394 | // Defensive programming anyone? |
| 6043 | - if (empty($data)) |
|
| 6044 | - return false; |
|
| 6395 | + if (empty($data)) { |
|
| 6396 | + return false; |
|
| 6397 | + } |
|
| 6045 | 6398 | |
| 6046 | 6399 | // Don't need extra stuff... |
| 6047 | 6400 | $db_show_debug = false; |
@@ -6049,11 +6402,11 @@ discard block |
||
| 6049 | 6402 | // Kill anything else. |
| 6050 | 6403 | ob_end_clean(); |
| 6051 | 6404 | |
| 6052 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 6053 | - @ob_start('ob_gzhandler'); |
|
| 6054 | - |
|
| 6055 | - else |
|
| 6056 | - ob_start(); |
|
| 6405 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 6406 | + @ob_start('ob_gzhandler'); |
|
| 6407 | + } else { |
|
| 6408 | + ob_start(); |
|
| 6409 | + } |
|
| 6057 | 6410 | |
| 6058 | 6411 | // Set the header. |
| 6059 | 6412 | header($type); |
@@ -6085,8 +6438,9 @@ discard block |
||
| 6085 | 6438 | static $done = false; |
| 6086 | 6439 | |
| 6087 | 6440 | // If we don't need to do anything, don't |
| 6088 | - if (!$update && $done) |
|
| 6089 | - return; |
|
| 6441 | + if (!$update && $done) { |
|
| 6442 | + return; |
|
| 6443 | + } |
|
| 6090 | 6444 | |
| 6091 | 6445 | // Should we get a new copy of the official list of TLDs? |
| 6092 | 6446 | if ($update) |
@@ -6098,8 +6452,9 @@ discard block |
||
| 6098 | 6452 | // marauding bandits roaming on the surface. We don't want to waste precious electricity on |
| 6099 | 6453 | // pointlessly repeating background tasks, so we'll wait until the next regularly scheduled |
| 6100 | 6454 | // update to see if civilization has been restored. |
| 6101 | - if ($tlds === false) |
|
| 6102 | - $postapocalypticNightmare = true; |
|
| 6455 | + if ($tlds === false) { |
|
| 6456 | + $postapocalypticNightmare = true; |
|
| 6457 | + } |
|
| 6103 | 6458 | } |
| 6104 | 6459 | // If we aren't updating and the regex is valid, we're done |
| 6105 | 6460 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -6114,10 +6469,11 @@ discard block |
||
| 6114 | 6469 | // Clean $tlds and convert it to an array |
| 6115 | 6470 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 6116 | 6471 | $line = trim($line); |
| 6117 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 6118 | - return false; |
|
| 6119 | - else |
|
| 6120 | - return true; |
|
| 6472 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 6473 | + return false; |
|
| 6474 | + } else { |
|
| 6475 | + return true; |
|
| 6476 | + } |
|
| 6121 | 6477 | }); |
| 6122 | 6478 | |
| 6123 | 6479 | // Convert Punycode to Unicode |
@@ -6209,8 +6565,7 @@ discard block |
||
| 6209 | 6565 | |
| 6210 | 6566 | $strlen = 'mb_strlen'; |
| 6211 | 6567 | $substr = 'mb_substr'; |
| 6212 | - } |
|
| 6213 | - else |
|
| 6568 | + } else |
|
| 6214 | 6569 | { |
| 6215 | 6570 | $strlen = $smcFunc['strlen']; |
| 6216 | 6571 | $substr = $smcFunc['substr']; |
@@ -6224,20 +6579,21 @@ discard block |
||
| 6224 | 6579 | |
| 6225 | 6580 | $first = $substr($string, 0, 1); |
| 6226 | 6581 | |
| 6227 | - if (empty($index[$first])) |
|
| 6228 | - $index[$first] = array(); |
|
| 6582 | + if (empty($index[$first])) { |
|
| 6583 | + $index[$first] = array(); |
|
| 6584 | + } |
|
| 6229 | 6585 | |
| 6230 | 6586 | if ($strlen($string) > 1) |
| 6231 | 6587 | { |
| 6232 | 6588 | // Sanity check on recursion |
| 6233 | - if ($depth > 99) |
|
| 6234 | - $index[$first][$substr($string, 1)] = ''; |
|
| 6235 | - |
|
| 6236 | - else |
|
| 6237 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6589 | + if ($depth > 99) { |
|
| 6590 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6591 | + } else { |
|
| 6592 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6593 | + } |
|
| 6594 | + } else { |
|
| 6595 | + $index[$first][''] = ''; |
|
| 6238 | 6596 | } |
| 6239 | - else |
|
| 6240 | - $index[$first][''] = ''; |
|
| 6241 | 6597 | |
| 6242 | 6598 | $depth--; |
| 6243 | 6599 | return $index; |
@@ -6260,9 +6616,9 @@ discard block |
||
| 6260 | 6616 | $key_regex = preg_quote($key, $delim); |
| 6261 | 6617 | $new_key = $key; |
| 6262 | 6618 | |
| 6263 | - if (empty($value)) |
|
| 6264 | - $sub_regex = ''; |
|
| 6265 | - else |
|
| 6619 | + if (empty($value)) { |
|
| 6620 | + $sub_regex = ''; |
|
| 6621 | + } else |
|
| 6266 | 6622 | { |
| 6267 | 6623 | $sub_regex = $index_to_regex($value, $delim); |
| 6268 | 6624 | |
@@ -6270,22 +6626,22 @@ discard block |
||
| 6270 | 6626 | { |
| 6271 | 6627 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 6272 | 6628 | $new_key .= $new_key_array[0]; |
| 6629 | + } else { |
|
| 6630 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6273 | 6631 | } |
| 6274 | - else |
|
| 6275 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6276 | 6632 | } |
| 6277 | 6633 | |
| 6278 | - if ($depth > 1) |
|
| 6279 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6280 | - else |
|
| 6634 | + if ($depth > 1) { |
|
| 6635 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6636 | + } else |
|
| 6281 | 6637 | { |
| 6282 | 6638 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 6283 | 6639 | { |
| 6284 | 6640 | $regex[$new_key] = $key_regex . $sub_regex; |
| 6285 | 6641 | unset($index[$key]); |
| 6642 | + } else { |
|
| 6643 | + break; |
|
| 6286 | 6644 | } |
| 6287 | - else |
|
| 6288 | - break; |
|
| 6289 | 6645 | } |
| 6290 | 6646 | } |
| 6291 | 6647 | |
@@ -6294,10 +6650,11 @@ discard block |
||
| 6294 | 6650 | $l1 = $strlen($k1); |
| 6295 | 6651 | $l2 = $strlen($k2); |
| 6296 | 6652 | |
| 6297 | - if ($l1 == $l2) |
|
| 6298 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6299 | - else |
|
| 6300 | - return $l1 > $l2 ? -1 : 1; |
|
| 6653 | + if ($l1 == $l2) { |
|
| 6654 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6655 | + } else { |
|
| 6656 | + return $l1 > $l2 ? -1 : 1; |
|
| 6657 | + } |
|
| 6301 | 6658 | }); |
| 6302 | 6659 | |
| 6303 | 6660 | $depth--; |
@@ -6308,21 +6665,24 @@ discard block |
||
| 6308 | 6665 | $index = array(); |
| 6309 | 6666 | $regex = ''; |
| 6310 | 6667 | |
| 6311 | - foreach ($strings as $string) |
|
| 6312 | - $index = $add_string_to_index($string, $index); |
|
| 6668 | + foreach ($strings as $string) { |
|
| 6669 | + $index = $add_string_to_index($string, $index); |
|
| 6670 | + } |
|
| 6313 | 6671 | |
| 6314 | 6672 | if ($returnArray === true) |
| 6315 | 6673 | { |
| 6316 | 6674 | $regex = array(); |
| 6317 | - while (!empty($index)) |
|
| 6318 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6675 | + while (!empty($index)) { |
|
| 6676 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6677 | + } |
|
| 6678 | + } else { |
|
| 6679 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6319 | 6680 | } |
| 6320 | - else |
|
| 6321 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6322 | 6681 | |
| 6323 | 6682 | // Restore PHP's internal character encoding to whatever it was originally |
| 6324 | - if (!empty($current_encoding)) |
|
| 6325 | - mb_internal_encoding($current_encoding); |
|
| 6683 | + if (!empty($current_encoding)) { |
|
| 6684 | + mb_internal_encoding($current_encoding); |
|
| 6685 | + } |
|
| 6326 | 6686 | |
| 6327 | 6687 | return $regex; |
| 6328 | 6688 | } |
@@ -6365,13 +6725,15 @@ discard block |
||
| 6365 | 6725 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
| 6366 | 6726 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
| 6367 | 6727 | $headers = @get_headers($url); |
| 6368 | - if ($headers === false) |
|
| 6369 | - return false; |
|
| 6728 | + if ($headers === false) { |
|
| 6729 | + return false; |
|
| 6730 | + } |
|
| 6370 | 6731 | |
| 6371 | 6732 | // Now to see if it came back https... |
| 6372 | 6733 | // First check for a redirect status code in first row (301, 302, 307) |
| 6373 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
| 6374 | - return false; |
|
| 6734 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
| 6735 | + return false; |
|
| 6736 | + } |
|
| 6375 | 6737 | |
| 6376 | 6738 | // Search for the location entry to confirm https |
| 6377 | 6739 | $result = false; |
@@ -6409,8 +6771,7 @@ discard block |
||
| 6409 | 6771 | $is_admin = $user_info['is_admin']; |
| 6410 | 6772 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
| 6411 | 6773 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
| 6412 | - } |
|
| 6413 | - else |
|
| 6774 | + } else |
|
| 6414 | 6775 | { |
| 6415 | 6776 | $request = $smcFunc['db_query']('', ' |
| 6416 | 6777 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6424,17 +6785,19 @@ discard block |
||
| 6424 | 6785 | |
| 6425 | 6786 | $row = $smcFunc['db_fetch_assoc']($request); |
| 6426 | 6787 | |
| 6427 | - if (empty($row['additional_groups'])) |
|
| 6428 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6429 | - else |
|
| 6430 | - $groups = array_merge( |
|
| 6788 | + if (empty($row['additional_groups'])) { |
|
| 6789 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6790 | + } else { |
|
| 6791 | + $groups = array_merge( |
|
| 6431 | 6792 | array($row['id_group'], $row['id_post_group']), |
| 6432 | 6793 | explode(',', $row['additional_groups']) |
| 6433 | 6794 | ); |
| 6795 | + } |
|
| 6434 | 6796 | |
| 6435 | 6797 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 6436 | - foreach ($groups as $k => $v) |
|
| 6437 | - $groups[$k] = (int) $v; |
|
| 6798 | + foreach ($groups as $k => $v) { |
|
| 6799 | + $groups[$k] = (int) $v; |
|
| 6800 | + } |
|
| 6438 | 6801 | |
| 6439 | 6802 | $is_admin = in_array(1, $groups); |
| 6440 | 6803 | |
@@ -6451,8 +6814,9 @@ discard block |
||
| 6451 | 6814 | 'current_member' => $userid, |
| 6452 | 6815 | ) |
| 6453 | 6816 | ); |
| 6454 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6455 | - $boards_mod[] = $row['id_board']; |
|
| 6817 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6818 | + $boards_mod[] = $row['id_board']; |
|
| 6819 | + } |
|
| 6456 | 6820 | $smcFunc['db_free_result']($request); |
| 6457 | 6821 | |
| 6458 | 6822 | // Can any of the groups they're in moderate any of the boards? |
@@ -6464,8 +6828,9 @@ discard block |
||
| 6464 | 6828 | 'groups' => $groups, |
| 6465 | 6829 | ) |
| 6466 | 6830 | ); |
| 6467 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6468 | - $boards_mod[] = $row['id_board']; |
|
| 6831 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6832 | + $boards_mod[] = $row['id_board']; |
|
| 6833 | + } |
|
| 6469 | 6834 | $smcFunc['db_free_result']($request); |
| 6470 | 6835 | |
| 6471 | 6836 | // Just in case we've got duplicates here... |
@@ -6475,21 +6840,25 @@ discard block |
||
| 6475 | 6840 | } |
| 6476 | 6841 | |
| 6477 | 6842 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 6478 | - if ($is_admin) |
|
| 6479 | - $query_part['query_see_board'] = '1=1'; |
|
| 6843 | + if ($is_admin) { |
|
| 6844 | + $query_part['query_see_board'] = '1=1'; |
|
| 6845 | + } |
|
| 6480 | 6846 | // Otherwise just the groups in $user_info['groups']. |
| 6481 | - else |
|
| 6482 | - $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'] : '') . ')'; |
|
| 6847 | + else { |
|
| 6848 | + $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'] : '') . ')'; |
|
| 6849 | + } |
|
| 6483 | 6850 | |
| 6484 | 6851 | // Build the list of boards they WANT to see. |
| 6485 | 6852 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 6486 | 6853 | |
| 6487 | 6854 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 6488 | - if (empty($ignoreboards)) |
|
| 6489 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6855 | + if (empty($ignoreboards)) { |
|
| 6856 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6857 | + } |
|
| 6490 | 6858 | // Ok I guess they don't want to see all the boards |
| 6491 | - else |
|
| 6492 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6859 | + else { |
|
| 6860 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6861 | + } |
|
| 6493 | 6862 | |
| 6494 | 6863 | return $query_part; |
| 6495 | 6864 | } |
@@ -6503,10 +6872,11 @@ discard block |
||
| 6503 | 6872 | { |
| 6504 | 6873 | $secure = false; |
| 6505 | 6874 | |
| 6506 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 6507 | - $secure = true; |
|
| 6508 | - 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') |
|
| 6509 | - $secure = true; |
|
| 6875 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 6876 | + $secure = true; |
|
| 6877 | + } 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') { |
|
| 6878 | + $secure = true; |
|
| 6879 | + } |
|
| 6510 | 6880 | |
| 6511 | 6881 | return $secure; |
| 6512 | 6882 | } |
@@ -6523,11 +6893,12 @@ discard block |
||
| 6523 | 6893 | { |
| 6524 | 6894 | $url = iri_to_url($iri); |
| 6525 | 6895 | |
| 6526 | - if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) |
|
| 6527 | - return $iri; |
|
| 6528 | - else |
|
| 6529 | - return false; |
|
| 6530 | -} |
|
| 6896 | + if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) { |
|
| 6897 | + return $iri; |
|
| 6898 | + } else { |
|
| 6899 | + return false; |
|
| 6900 | + } |
|
| 6901 | + } |
|
| 6531 | 6902 | |
| 6532 | 6903 | /** |
| 6533 | 6904 | * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs |
@@ -6570,8 +6941,9 @@ discard block |
||
| 6570 | 6941 | |
| 6571 | 6942 | $host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST); |
| 6572 | 6943 | |
| 6573 | - if (empty($host)) |
|
| 6574 | - return $iri; |
|
| 6944 | + if (empty($host)) { |
|
| 6945 | + return $iri; |
|
| 6946 | + } |
|
| 6575 | 6947 | |
| 6576 | 6948 | // Convert the domain using the Punycode algorithm |
| 6577 | 6949 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6607,8 +6979,9 @@ discard block |
||
| 6607 | 6979 | |
| 6608 | 6980 | $host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST); |
| 6609 | 6981 | |
| 6610 | - if (empty($host)) |
|
| 6611 | - return $url; |
|
| 6982 | + if (empty($host)) { |
|
| 6983 | + return $url; |
|
| 6984 | + } |
|
| 6612 | 6985 | |
| 6613 | 6986 | // Decode the domain from Punycode |
| 6614 | 6987 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6634,8 +7007,9 @@ discard block |
||
| 6634 | 7007 | { |
| 6635 | 7008 | global $user_info, $modSettings, $smcFunc, $txt; |
| 6636 | 7009 | |
| 6637 | - if (empty($modSettings['cron_last_checked'])) |
|
| 6638 | - $modSettings['cron_last_checked'] = 0; |
|
| 7010 | + if (empty($modSettings['cron_last_checked'])) { |
|
| 7011 | + $modSettings['cron_last_checked'] = 0; |
|
| 7012 | + } |
|
| 6639 | 7013 | |
| 6640 | 7014 | if (!empty($modSettings['cron_is_real_cron']) && time() - $modSettings['cron_last_checked'] > 84600) |
| 6641 | 7015 | { |
@@ -6655,9 +7029,9 @@ discard block |
||
| 6655 | 7029 | loadLanguage('ManageScheduledTasks'); |
| 6656 | 7030 | log_error($txt['cron_not_working']); |
| 6657 | 7031 | updateSettings(array('cron_is_real_cron' => 0)); |
| 7032 | + } else { |
|
| 7033 | + updateSettings(array('cron_last_checked' => time())); |
|
| 6658 | 7034 | } |
| 6659 | - else |
|
| 6660 | - updateSettings(array('cron_last_checked' => time())); |
|
| 6661 | 7035 | } |
| 6662 | 7036 | } |
| 6663 | 7037 | |
@@ -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 |
@@ -349,7 +349,7 @@ |
||
| 349 | 349 | SELECT |
| 350 | 350 | t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, |
| 351 | 351 | ' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, COALESCE(lmr.id_msg, -1)) + 1') . ' AS new_from, |
| 352 | - ' . ( $enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
| 352 | + ' . ($enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
| 353 | 353 | ' : '') . ' |
| 354 | 354 | t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time, t.id_redirect_topic, |
| 355 | 355 | ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
| 260 | 273 | // Bring in any changes we want to make before the query. |
| 261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
| 262 | 275 | |
| 263 | - foreach ($sort_methods as $key => $val) |
|
| 264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 276 | + foreach ($sort_methods as $key => $val) { |
|
| 277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 278 | + } |
|
| 265 | 279 | |
| 266 | 280 | // Calculate the fastest way to get the topics. |
| 267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
| 271 | 285 | $fake_ascending = true; |
| 272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
| 273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
| 288 | + } else { |
|
| 289 | + $fake_ascending = false; |
|
| 274 | 290 | } |
| 275 | - else |
|
| 276 | - $fake_ascending = false; |
|
| 277 | 291 | |
| 278 | 292 | // Setup the default topic icons... |
| 279 | 293 | $context['icon_sources'] = array(); |
| 280 | - foreach ($context['stable_icons'] as $icon) |
|
| 281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 294 | + foreach ($context['stable_icons'] as $icon) { |
|
| 295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 296 | + } |
|
| 282 | 297 | |
| 283 | 298 | $topic_ids = array(); |
| 284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
| 316 | 331 | $message_pre_index_parameters |
| 317 | 332 | ); |
| 318 | 333 | $topic_ids = array(); |
| 319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 320 | - $topic_ids[] = $row['id_topic']; |
|
| 334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 335 | + $topic_ids[] = $row['id_topic']; |
|
| 336 | + } |
|
| 321 | 337 | } |
| 322 | 338 | |
| 323 | 339 | // Grab the appropriate topic information... |
@@ -340,10 +356,11 @@ discard block |
||
| 340 | 356 | $message_index_wheres = array(); |
| 341 | 357 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
| 342 | 358 | |
| 343 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
| 344 | - $enableParticipation = true; |
|
| 345 | - else |
|
| 346 | - $enableParticipation = false; |
|
| 359 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
| 360 | + $enableParticipation = true; |
|
| 361 | + } else { |
|
| 362 | + $enableParticipation = false; |
|
| 363 | + } |
|
| 347 | 364 | |
| 348 | 365 | $result = $smcFunc['db_query']('substring', ' |
| 349 | 366 | SELECT |
@@ -382,11 +399,13 @@ discard block |
||
| 382 | 399 | // Begin 'printing' the message index for current board. |
| 383 | 400 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 384 | 401 | { |
| 385 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 386 | - continue; |
|
| 402 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 387 | 405 | |
| 388 | - if (!$pre_query) |
|
| 389 | - $topic_ids[] = $row['id_topic']; |
|
| 406 | + if (!$pre_query) { |
|
| 407 | + $topic_ids[] = $row['id_topic']; |
|
| 408 | + } |
|
| 390 | 409 | |
| 391 | 410 | // Reference the main color class. |
| 392 | 411 | $colorClass = 'windowbg'; |
@@ -396,8 +415,9 @@ discard block |
||
| 396 | 415 | { |
| 397 | 416 | // Limit them to $modSettings['preview_characters'] characters |
| 398 | 417 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 399 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 400 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 418 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 419 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 420 | + } |
|
| 401 | 421 | |
| 402 | 422 | // Censor the subject and message preview. |
| 403 | 423 | censorText($row['first_subject']); |
@@ -408,27 +428,27 @@ discard block |
||
| 408 | 428 | { |
| 409 | 429 | $row['last_subject'] = $row['first_subject']; |
| 410 | 430 | $row['last_body'] = $row['first_body']; |
| 411 | - } |
|
| 412 | - else |
|
| 431 | + } else |
|
| 413 | 432 | { |
| 414 | 433 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 415 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 416 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 434 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 435 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 436 | + } |
|
| 417 | 437 | |
| 418 | 438 | censorText($row['last_subject']); |
| 419 | 439 | censorText($row['last_body']); |
| 420 | 440 | } |
| 421 | - } |
|
| 422 | - else |
|
| 441 | + } else |
|
| 423 | 442 | { |
| 424 | 443 | $row['first_body'] = ''; |
| 425 | 444 | $row['last_body'] = ''; |
| 426 | 445 | censorText($row['first_subject']); |
| 427 | 446 | |
| 428 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 429 | - $row['last_subject'] = $row['first_subject']; |
|
| 430 | - else |
|
| 431 | - censorText($row['last_subject']); |
|
| 447 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 448 | + $row['last_subject'] = $row['first_subject']; |
|
| 449 | + } else { |
|
| 450 | + censorText($row['last_subject']); |
|
| 451 | + } |
|
| 432 | 452 | } |
| 433 | 453 | |
| 434 | 454 | // Decide how many pages the topic should have. |
@@ -439,42 +459,50 @@ discard block |
||
| 439 | 459 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 440 | 460 | |
| 441 | 461 | // If we can use all, show all. |
| 442 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 443 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 462 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 463 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 464 | + } |
|
| 465 | + } else { |
|
| 466 | + $pages = ''; |
|
| 444 | 467 | } |
| 445 | - else |
|
| 446 | - $pages = ''; |
|
| 447 | 468 | |
| 448 | 469 | // We need to check the topic icons exist... |
| 449 | 470 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 450 | 471 | { |
| 451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 452 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 454 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 455 | - } |
|
| 456 | - else |
|
| 472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 473 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 474 | + } |
|
| 475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 476 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 477 | + } |
|
| 478 | + } else |
|
| 457 | 479 | { |
| 458 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 459 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 460 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 461 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 480 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 481 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 482 | + } |
|
| 483 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 484 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 485 | + } |
|
| 462 | 486 | } |
| 463 | 487 | |
| 464 | - if (!empty($board_info['recycle'])) |
|
| 465 | - $row['first_icon'] = 'recycled'; |
|
| 488 | + if (!empty($board_info['recycle'])) { |
|
| 489 | + $row['first_icon'] = 'recycled'; |
|
| 490 | + } |
|
| 466 | 491 | |
| 467 | 492 | // Is this topic pending approval, or does it have any posts pending approval? |
| 468 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 469 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 493 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 494 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 495 | + } |
|
| 470 | 496 | |
| 471 | 497 | // Sticky topics should get a different color, too. |
| 472 | - if ($row['is_sticky']) |
|
| 473 | - $colorClass .= ' sticky'; |
|
| 498 | + if ($row['is_sticky']) { |
|
| 499 | + $colorClass .= ' sticky'; |
|
| 500 | + } |
|
| 474 | 501 | |
| 475 | 502 | // Locked topics get special treatment as well. |
| 476 | - if ($row['locked']) |
|
| 477 | - $colorClass .= ' locked'; |
|
| 503 | + if ($row['locked']) { |
|
| 504 | + $colorClass .= ' locked'; |
|
| 505 | + } |
|
| 478 | 506 | |
| 479 | 507 | // 'Print' the topic info. |
| 480 | 508 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -555,8 +583,9 @@ discard block |
||
| 555 | 583 | $smcFunc['db_free_result']($result); |
| 556 | 584 | |
| 557 | 585 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 558 | - if ($fake_ascending) |
|
| 559 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 586 | + if ($fake_ascending) { |
|
| 587 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 588 | + } |
|
| 560 | 589 | } |
| 561 | 590 | |
| 562 | 591 | $context['jump_to'] = array( |
@@ -579,9 +608,9 @@ discard block |
||
| 579 | 608 | // Can we restore topics? |
| 580 | 609 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 581 | 610 | |
| 582 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 583 | - $context['can_move_any'] = true; |
|
| 584 | - else |
|
| 611 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 612 | + $context['can_move_any'] = true; |
|
| 613 | + } else |
|
| 585 | 614 | { |
| 586 | 615 | // We'll use this in a minute |
| 587 | 616 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -608,11 +637,13 @@ discard block |
||
| 608 | 637 | } |
| 609 | 638 | |
| 610 | 639 | // Can we use quick moderation checkboxes? |
| 611 | - if ($options['display_quick_mod'] == 1) |
|
| 612 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 640 | + if ($options['display_quick_mod'] == 1) { |
|
| 641 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 642 | + } |
|
| 613 | 643 | // Or the icons? |
| 614 | - else |
|
| 615 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 644 | + else { |
|
| 645 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 646 | + } |
|
| 616 | 647 | } |
| 617 | 648 | |
| 618 | 649 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -646,13 +677,15 @@ discard block |
||
| 646 | 677 | ); |
| 647 | 678 | |
| 648 | 679 | // We've seen all these boards now! |
| 649 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 650 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 680 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 681 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 651 | 682 | unset($_SESSION['topicseen_cache'][$k]); |
| 683 | + } |
|
| 652 | 684 | } |
| 653 | 685 | |
| 654 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 655 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 686 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 687 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 688 | + } |
|
| 656 | 689 | |
| 657 | 690 | $request = $smcFunc['db_query']('', ' |
| 658 | 691 | SELECT id_topic, id_board, sent |
@@ -673,8 +706,9 @@ discard block |
||
| 673 | 706 | $context['is_marked_notify'] = true; |
| 674 | 707 | $board_sent = $row['sent']; |
| 675 | 708 | } |
| 676 | - if (!empty($row['id_topic'])) |
|
| 677 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 709 | + if (!empty($row['id_topic'])) { |
|
| 710 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 711 | + } |
|
| 678 | 712 | } |
| 679 | 713 | $smcFunc['db_free_result']($request); |
| 680 | 714 | |
@@ -698,8 +732,7 @@ discard block |
||
| 698 | 732 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 699 | 733 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 700 | 734 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 701 | - } |
|
| 702 | - else |
|
| 735 | + } else |
|
| 703 | 736 | { |
| 704 | 737 | $context['is_marked_notify'] = false; |
| 705 | 738 | $context['board_notification_mode'] = 1; |
@@ -712,23 +745,27 @@ discard block |
||
| 712 | 745 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 713 | 746 | |
| 714 | 747 | // Don't want to show this forever... |
| 715 | - if ($context['becomesUnapproved']) |
|
| 716 | - unset($_SESSION['becomesUnapproved']); |
|
| 748 | + if ($context['becomesUnapproved']) { |
|
| 749 | + unset($_SESSION['becomesUnapproved']); |
|
| 750 | + } |
|
| 717 | 751 | |
| 718 | 752 | // Build the message index button array. |
| 719 | 753 | $context['normal_buttons'] = array(); |
| 720 | 754 | |
| 721 | - if ($context['can_post_new']) |
|
| 722 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 755 | + if ($context['can_post_new']) { |
|
| 756 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 757 | + } |
|
| 723 | 758 | |
| 724 | - if ($context['can_post_poll']) |
|
| 725 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 759 | + if ($context['can_post_poll']) { |
|
| 760 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 761 | + } |
|
| 726 | 762 | |
| 727 | - if ($context['user']['is_logged']) |
|
| 728 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 763 | + if ($context['user']['is_logged']) { |
|
| 764 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 765 | + } |
|
| 729 | 766 | |
| 730 | - if ($context['can_mark_notify']) |
|
| 731 | - $context['normal_buttons']['notify'] = array( |
|
| 767 | + if ($context['can_mark_notify']) { |
|
| 768 | + $context['normal_buttons']['notify'] = array( |
|
| 732 | 769 | 'lang' => true, |
| 733 | 770 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 734 | 771 | 'sub_buttons' => array( |
@@ -746,6 +783,7 @@ discard block |
||
| 746 | 783 | ), |
| 747 | 784 | ), |
| 748 | 785 | ); |
| 786 | + } |
|
| 749 | 787 | |
| 750 | 788 | // Javascript for inline editing. |
| 751 | 789 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -767,18 +805,21 @@ discard block |
||
| 767 | 805 | checkSession('request'); |
| 768 | 806 | |
| 769 | 807 | // Lets go straight to the restore area. |
| 770 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 771 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 808 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 809 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 810 | + } |
|
| 772 | 811 | |
| 773 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 774 | - $_SESSION['topicseen_cache'] = array(); |
|
| 812 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 813 | + $_SESSION['topicseen_cache'] = array(); |
|
| 814 | + } |
|
| 775 | 815 | |
| 776 | 816 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 777 | 817 | require_once($sourcedir . '/Subs-Post.php'); |
| 778 | 818 | |
| 779 | 819 | // Remember the last board they moved things to. |
| 780 | - if (isset($_REQUEST['move_to'])) |
|
| 781 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 820 | + if (isset($_REQUEST['move_to'])) { |
|
| 821 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 822 | + } |
|
| 782 | 823 | |
| 783 | 824 | // Only a few possible actions. |
| 784 | 825 | $possibleActions = array(); |
@@ -798,8 +839,7 @@ discard block |
||
| 798 | 839 | ); |
| 799 | 840 | |
| 800 | 841 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 801 | - } |
|
| 802 | - else |
|
| 842 | + } else |
|
| 803 | 843 | { |
| 804 | 844 | /** |
| 805 | 845 | * @todo Ugly. There's no getting around this, is there? |
@@ -817,8 +857,7 @@ discard block |
||
| 817 | 857 | if (!empty($board)) |
| 818 | 858 | { |
| 819 | 859 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 820 | - } |
|
| 821 | - else |
|
| 860 | + } else |
|
| 822 | 861 | { |
| 823 | 862 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 824 | 863 | } |
@@ -829,55 +868,67 @@ discard block |
||
| 829 | 868 | } |
| 830 | 869 | } |
| 831 | 870 | |
| 832 | - if (!$user_info['is_guest']) |
|
| 833 | - $possibleActions[] = 'markread'; |
|
| 834 | - if (!empty($boards_can['make_sticky'])) |
|
| 835 | - $possibleActions[] = 'sticky'; |
|
| 836 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 837 | - $possibleActions[] = 'move'; |
|
| 838 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 839 | - $possibleActions[] = 'remove'; |
|
| 840 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 841 | - $possibleActions[] = 'lock'; |
|
| 842 | - if (!empty($boards_can['merge_any'])) |
|
| 843 | - $possibleActions[] = 'merge'; |
|
| 844 | - if (!empty($boards_can['approve_posts'])) |
|
| 845 | - $possibleActions[] = 'approve'; |
|
| 871 | + if (!$user_info['is_guest']) { |
|
| 872 | + $possibleActions[] = 'markread'; |
|
| 873 | + } |
|
| 874 | + if (!empty($boards_can['make_sticky'])) { |
|
| 875 | + $possibleActions[] = 'sticky'; |
|
| 876 | + } |
|
| 877 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 878 | + $possibleActions[] = 'move'; |
|
| 879 | + } |
|
| 880 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 881 | + $possibleActions[] = 'remove'; |
|
| 882 | + } |
|
| 883 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 884 | + $possibleActions[] = 'lock'; |
|
| 885 | + } |
|
| 886 | + if (!empty($boards_can['merge_any'])) { |
|
| 887 | + $possibleActions[] = 'merge'; |
|
| 888 | + } |
|
| 889 | + if (!empty($boards_can['approve_posts'])) { |
|
| 890 | + $possibleActions[] = 'approve'; |
|
| 891 | + } |
|
| 846 | 892 | |
| 847 | 893 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 848 | 894 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 849 | 895 | if (!empty($_REQUEST['topics'])) |
| 850 | 896 | { |
| 851 | 897 | // If the action isn't valid, just quit now. |
| 852 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 853 | - redirectexit($redirect_url); |
|
| 898 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 899 | + redirectexit($redirect_url); |
|
| 900 | + } |
|
| 854 | 901 | |
| 855 | 902 | // Merge requires all topics as one parameter and can be done at once. |
| 856 | 903 | if ($_REQUEST['qaction'] == 'merge') |
| 857 | 904 | { |
| 858 | 905 | // Merge requires at least two topics. |
| 859 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 860 | - redirectexit($redirect_url); |
|
| 906 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 907 | + redirectexit($redirect_url); |
|
| 908 | + } |
|
| 861 | 909 | |
| 862 | 910 | require_once($sourcedir . '/SplitTopics.php'); |
| 863 | 911 | return MergeExecute($_REQUEST['topics']); |
| 864 | 912 | } |
| 865 | 913 | |
| 866 | 914 | // Just convert to the other method, to make it easier. |
| 867 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 868 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 915 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 916 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 917 | + } |
|
| 869 | 918 | } |
| 870 | 919 | |
| 871 | 920 | // Weird... how'd you get here? |
| 872 | - if (empty($_REQUEST['actions'])) |
|
| 873 | - redirectexit($redirect_url); |
|
| 921 | + if (empty($_REQUEST['actions'])) { |
|
| 922 | + redirectexit($redirect_url); |
|
| 923 | + } |
|
| 874 | 924 | |
| 875 | 925 | // Validate each action. |
| 876 | 926 | $temp = array(); |
| 877 | 927 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 878 | 928 | { |
| 879 | - if (in_array($action, $possibleActions)) |
|
| 880 | - $temp[(int) $topic] = $action; |
|
| 929 | + if (in_array($action, $possibleActions)) { |
|
| 930 | + $temp[(int) $topic] = $action; |
|
| 931 | + } |
|
| 881 | 932 | } |
| 882 | 933 | $_REQUEST['actions'] = $temp; |
| 883 | 934 | |
@@ -898,27 +949,31 @@ discard block |
||
| 898 | 949 | { |
| 899 | 950 | if (!empty($board)) |
| 900 | 951 | { |
| 901 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 903 | - } |
|
| 904 | - else |
|
| 952 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 953 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 954 | + } |
|
| 955 | + } else |
|
| 905 | 956 | { |
| 906 | 957 | // Don't allow them to act on unapproved posts they can't see... |
| 907 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 908 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 958 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 959 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 960 | + } |
|
| 909 | 961 | // Goodness, this is fun. We need to validate the action. |
| 910 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 911 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 962 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 963 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 964 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 968 | + } |
|
| 916 | 969 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 917 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 918 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 970 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 971 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 972 | + } |
|
| 919 | 973 | // If the topic is approved then you need permission to approve the posts within. |
| 920 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 974 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 975 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 976 | + } |
|
| 922 | 977 | } |
| 923 | 978 | } |
| 924 | 979 | $smcFunc['db_free_result']($request); |
@@ -936,11 +991,11 @@ discard block |
||
| 936 | 991 | { |
| 937 | 992 | $topic = (int) $topic; |
| 938 | 993 | |
| 939 | - if ($action == 'markread') |
|
| 940 | - $markCache[] = $topic; |
|
| 941 | - elseif ($action == 'sticky') |
|
| 942 | - $stickyCache[] = $topic; |
|
| 943 | - elseif ($action == 'move') |
|
| 994 | + if ($action == 'markread') { |
|
| 995 | + $markCache[] = $topic; |
|
| 996 | + } elseif ($action == 'sticky') { |
|
| 997 | + $stickyCache[] = $topic; |
|
| 998 | + } elseif ($action == 'move') |
|
| 944 | 999 | { |
| 945 | 1000 | require_once($sourcedir . '/MoveTopic.php'); |
| 946 | 1001 | moveTopicConcurrence(); |
@@ -948,23 +1003,25 @@ discard block |
||
| 948 | 1003 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 949 | 1004 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 950 | 1005 | |
| 951 | - if (empty($moveCache[1][$topic])) |
|
| 952 | - continue; |
|
| 1006 | + if (empty($moveCache[1][$topic])) { |
|
| 1007 | + continue; |
|
| 1008 | + } |
|
| 953 | 1009 | |
| 954 | 1010 | $moveCache[0][] = $topic; |
| 1011 | + } elseif ($action == 'remove') { |
|
| 1012 | + $removeCache[] = $topic; |
|
| 1013 | + } elseif ($action == 'lock') { |
|
| 1014 | + $lockCache[] = $topic; |
|
| 1015 | + } elseif ($action == 'approve') { |
|
| 1016 | + $approveCache[] = $topic; |
|
| 955 | 1017 | } |
| 956 | - elseif ($action == 'remove') |
|
| 957 | - $removeCache[] = $topic; |
|
| 958 | - elseif ($action == 'lock') |
|
| 959 | - $lockCache[] = $topic; |
|
| 960 | - elseif ($action == 'approve') |
|
| 961 | - $approveCache[] = $topic; |
|
| 962 | 1018 | } |
| 963 | 1019 | |
| 964 | - if (empty($board)) |
|
| 965 | - $affectedBoards = array(); |
|
| 966 | - else |
|
| 967 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1020 | + if (empty($board)) { |
|
| 1021 | + $affectedBoards = array(); |
|
| 1022 | + } else { |
|
| 1023 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1024 | + } |
|
| 968 | 1025 | |
| 969 | 1026 | // Do all the stickies... |
| 970 | 1027 | if (!empty($stickyCache)) |
@@ -1024,14 +1081,16 @@ discard block |
||
| 1024 | 1081 | { |
| 1025 | 1082 | $to = $moveCache[1][$row['id_topic']]; |
| 1026 | 1083 | |
| 1027 | - if (empty($to)) |
|
| 1028 | - continue; |
|
| 1084 | + if (empty($to)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1029 | 1087 | |
| 1030 | 1088 | // Does this topic's board count the posts or not? |
| 1031 | 1089 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1032 | 1090 | |
| 1033 | - if (!isset($moveTos[$to])) |
|
| 1034 | - $moveTos[$to] = array(); |
|
| 1091 | + if (!isset($moveTos[$to])) { |
|
| 1092 | + $moveTos[$to] = array(); |
|
| 1093 | + } |
|
| 1035 | 1094 | |
| 1036 | 1095 | $moveTos[$to][] = $row['id_topic']; |
| 1037 | 1096 | |
@@ -1045,8 +1104,9 @@ discard block |
||
| 1045 | 1104 | require_once($sourcedir . '/MoveTopic.php'); |
| 1046 | 1105 | |
| 1047 | 1106 | // Do the actual moves... |
| 1048 | - foreach ($moveTos as $to => $topics) |
|
| 1049 | - moveTopics($topics, $to); |
|
| 1107 | + foreach ($moveTos as $to => $topics) { |
|
| 1108 | + moveTopics($topics, $to); |
|
| 1109 | + } |
|
| 1050 | 1110 | |
| 1051 | 1111 | // Does the post counts need to be updated? |
| 1052 | 1112 | if (!empty($moveTos)) |
@@ -1095,20 +1155,23 @@ discard block |
||
| 1095 | 1155 | |
| 1096 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1097 | 1157 | { |
| 1098 | - if (!isset($members[$row['id_member']])) |
|
| 1099 | - $members[$row['id_member']] = 0; |
|
| 1158 | + if (!isset($members[$row['id_member']])) { |
|
| 1159 | + $members[$row['id_member']] = 0; |
|
| 1160 | + } |
|
| 1100 | 1161 | |
| 1101 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1102 | - $members[$row['id_member']] += 1; |
|
| 1103 | - else |
|
| 1104 | - $members[$row['id_member']] -= 1; |
|
| 1162 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1163 | + $members[$row['id_member']] += 1; |
|
| 1164 | + } else { |
|
| 1165 | + $members[$row['id_member']] -= 1; |
|
| 1166 | + } |
|
| 1105 | 1167 | } |
| 1106 | 1168 | |
| 1107 | 1169 | $smcFunc['db_free_result']($request); |
| 1108 | 1170 | |
| 1109 | 1171 | // And now update them member's post counts |
| 1110 | - foreach ($members as $id_member => $post_adj) |
|
| 1111 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1172 | + foreach ($members as $id_member => $post_adj) { |
|
| 1173 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1174 | + } |
|
| 1112 | 1175 | } |
| 1113 | 1176 | } |
| 1114 | 1177 | } |
@@ -1187,8 +1250,9 @@ discard block |
||
| 1187 | 1250 | approveTopics($approveCache); |
| 1188 | 1251 | |
| 1189 | 1252 | // Time for some logging! |
| 1190 | - foreach ($approveCache as $topic) |
|
| 1191 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1253 | + foreach ($approveCache as $topic) { |
|
| 1254 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1255 | + } |
|
| 1192 | 1256 | } |
| 1193 | 1257 | } |
| 1194 | 1258 | |
@@ -1223,8 +1287,7 @@ discard block |
||
| 1223 | 1287 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1224 | 1288 | } |
| 1225 | 1289 | $smcFunc['db_free_result']($result); |
| 1226 | - } |
|
| 1227 | - else |
|
| 1290 | + } else |
|
| 1228 | 1291 | { |
| 1229 | 1292 | $result = $smcFunc['db_query']('', ' |
| 1230 | 1293 | SELECT id_topic, locked, id_board |
@@ -1274,13 +1337,15 @@ discard block |
||
| 1274 | 1337 | ) |
| 1275 | 1338 | ); |
| 1276 | 1339 | $logged_topics = array(); |
| 1277 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1278 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1340 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1341 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1342 | + } |
|
| 1279 | 1343 | $smcFunc['db_free_result']($request); |
| 1280 | 1344 | |
| 1281 | 1345 | $markArray = array(); |
| 1282 | - foreach ($markCache as $topic) |
|
| 1283 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1346 | + foreach ($markCache as $topic) { |
|
| 1347 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1348 | + } |
|
| 1284 | 1349 | |
| 1285 | 1350 | $smcFunc['db_insert']('replace', |
| 1286 | 1351 | '{db_prefix}log_topics', |
@@ -1293,8 +1358,9 @@ discard block |
||
| 1293 | 1358 | foreach ($moveCache as $topic) |
| 1294 | 1359 | { |
| 1295 | 1360 | // Didn't actually move anything! |
| 1296 | - if (!isset($topic[0])) |
|
| 1297 | - break; |
|
| 1361 | + if (!isset($topic[0])) { |
|
| 1362 | + break; |
|
| 1363 | + } |
|
| 1298 | 1364 | |
| 1299 | 1365 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1300 | 1366 | sendNotifications($topic[0], 'move'); |
@@ -1316,8 +1382,9 @@ discard block |
||
| 1316 | 1382 | 'calendar_updated' => time(), |
| 1317 | 1383 | )); |
| 1318 | 1384 | |
| 1319 | - if (!empty($affectedBoards)) |
|
| 1320 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1385 | + if (!empty($affectedBoards)) { |
|
| 1386 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1387 | + } |
|
| 1321 | 1388 | |
| 1322 | 1389 | redirectexit($redirect_url); |
| 1323 | 1390 | } |