@@ -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 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | <div class="windowbg2 noup"> |
128 | 128 | <dl class="settings">'; |
129 | 129 | |
130 | - if (!empty($context['table_info'])) |
|
131 | - echo ' |
|
130 | + if (!empty($context['table_info'])) { |
|
131 | + echo ' |
|
132 | 132 | <dt> |
133 | 133 | <strong>', $txt['search_method_messages_table_space'], ':</strong> |
134 | 134 | </dt> |
@@ -141,6 +141,7 @@ discard block |
||
141 | 141 | <dd> |
142 | 142 | ', $context['table_info']['index_length'], ' |
143 | 143 | </dd>'; |
144 | + } |
|
144 | 145 | echo ' |
145 | 146 | </dl> |
146 | 147 | ', $context['double_index'] ? '<div class="noticebox"> |
@@ -163,17 +164,17 @@ discard block |
||
163 | 164 | <dd> |
164 | 165 | <span class="smalltext">'; |
165 | 166 | |
166 | - if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext'])) |
|
167 | - echo ' |
|
167 | + if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext'])) { |
|
168 | + echo ' |
|
168 | 169 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createfulltext;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_method_fulltext_create'], '</a>]'; |
169 | - |
|
170 | - elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext'])) |
|
171 | - echo ' |
|
170 | + } elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext'])) { |
|
171 | + echo ' |
|
172 | 172 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_fulltext_cannot_create']; |
173 | - else |
|
174 | - echo ' |
|
173 | + } else { |
|
174 | + echo ' |
|
175 | 175 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removefulltext;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_method_fulltext_remove'], '</a>]<br> |
176 | 176 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['fulltext_length']; |
177 | + } |
|
177 | 178 | echo ' |
178 | 179 | </span> |
179 | 180 | </dd>'; |
@@ -187,26 +188,27 @@ discard block |
||
187 | 188 | <dd> |
188 | 189 | <span class="smalltext">'; |
189 | 190 | |
190 | - if ($context['custom_index']) |
|
191 | - echo ' |
|
191 | + if ($context['custom_index']) { |
|
192 | + echo ' |
|
192 | 193 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_remove'], '</a>]<br> |
193 | 194 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length']; |
194 | - |
|
195 | - elseif ($context['partial_custom_index']) |
|
196 | - echo ' |
|
195 | + } elseif ($context['partial_custom_index']) { |
|
196 | + echo ' |
|
197 | 197 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_partial'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_remove'], '</a>] [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex;resume;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_resume'], '</a>]<br> |
198 | 198 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length']; |
199 | - else |
|
200 | - echo ' |
|
199 | + } else { |
|
200 | + echo ' |
|
201 | 201 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex">', $txt['search_index_create_custom'], '</a>]'; |
202 | + } |
|
202 | 203 | echo ' |
203 | 204 | </span> |
204 | 205 | </dd>'; |
205 | 206 | |
206 | 207 | foreach ($context['search_apis'] as $api) |
207 | 208 | { |
208 | - if (empty($api['label']) || $api['has_template']) |
|
209 | - continue; |
|
209 | + if (empty($api['label']) || $api['has_template']) { |
|
210 | + continue; |
|
211 | + } |
|
210 | 212 | |
211 | 213 | echo ' |
212 | 214 | <dt> |
@@ -214,11 +216,12 @@ discard block |
||
214 | 216 | ', $api['label'], ' |
215 | 217 | </dt>'; |
216 | 218 | |
217 | - if ($api['desc']) |
|
218 | - echo ' |
|
219 | + if ($api['desc']) { |
|
220 | + echo ' |
|
219 | 221 | <dd> |
220 | 222 | <span class="smalltext">', $api['desc'], '</span> |
221 | 223 | </dd>'; |
224 | + } |
|
222 | 225 | } |
223 | 226 | |
224 | 227 | echo ' |
@@ -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>'; |
@@ -40,9 +40,10 @@ discard block |
||
40 | 40 | <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>'; |
41 | 41 | |
42 | 42 | // Show a list of all the years we allow... |
43 | - for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) |
|
44 | - echo ' |
|
43 | + for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) { |
|
44 | + echo ' |
|
45 | 45 | <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>'; |
46 | + } |
|
46 | 47 | |
47 | 48 | echo ' |
48 | 49 | </select> |
@@ -50,9 +51,10 @@ discard block |
||
50 | 51 | <select name="month" id="month" onchange="generateDays();">'; |
51 | 52 | |
52 | 53 | // There are 12 months per year - ensure that they all get listed. |
53 | - for ($month = 1; $month <= 12; $month++) |
|
54 | - echo ' |
|
54 | + for ($month = 1; $month <= 12; $month++) { |
|
55 | + echo ' |
|
55 | 56 | <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | echo ' |
58 | 60 | </select> |
@@ -60,23 +62,25 @@ discard block |
||
60 | 62 | <select name="day" id="day" onchange="generateDays();">'; |
61 | 63 | |
62 | 64 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
63 | - for ($day = 1; $day <= $context['holiday']['last_day']; $day++) |
|
64 | - echo ' |
|
65 | + for ($day = 1; $day <= $context['holiday']['last_day']; $day++) { |
|
66 | + echo ' |
|
65 | 67 | <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>'; |
68 | + } |
|
66 | 69 | |
67 | 70 | echo ' |
68 | 71 | </select> |
69 | 72 | </dd> |
70 | 73 | </dl>'; |
71 | 74 | |
72 | - if ($context['is_new']) |
|
73 | - echo ' |
|
75 | + if ($context['is_new']) { |
|
76 | + echo ' |
|
74 | 77 | <input type="submit" value="', $txt['holidays_button_add'], '" class="button">'; |
75 | - else |
|
76 | - echo ' |
|
78 | + } else { |
|
79 | + echo ' |
|
77 | 80 | <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button"> |
78 | 81 | <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button"> |
79 | 82 | <input type="hidden" name="holiday" value="', $context['holiday']['id'], '">'; |
83 | + } |
|
80 | 84 | echo ' |
81 | 85 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
82 | 86 | </div><!-- .windowbg2 --> |
@@ -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 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
38 | 39 | |
39 | 40 | // For performance, track the latest post while going through the boards. |
40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
41 | - $latest_post = array( |
|
41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
42 | + $latest_post = array( |
|
42 | 43 | 'timestamp' => 0, |
43 | 44 | 'ref' => 0, |
44 | 45 | ); |
46 | + } |
|
45 | 47 | |
46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
74 | 76 | ); |
75 | 77 | |
76 | 78 | // Start with an empty array. |
77 | - if ($boardIndexOptions['include_categories']) |
|
78 | - $categories = array(); |
|
79 | - else |
|
80 | - $this_category = array(); |
|
79 | + if ($boardIndexOptions['include_categories']) { |
|
80 | + $categories = array(); |
|
81 | + } else { |
|
82 | + $this_category = array(); |
|
83 | + } |
|
81 | 84 | $boards = array(); |
82 | 85 | |
83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
89 | 92 | |
90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
92 | - $boards[] = $row_board['id_board']; |
|
94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
95 | + $boards[] = $row_board['id_board']; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | if ($boardIndexOptions['include_categories']) |
95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | |
113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -161,14 +166,12 @@ discard block |
||
161 | 166 | { |
162 | 167 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
163 | 168 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
164 | - } |
|
165 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
169 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
166 | 170 | { |
167 | 171 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
168 | 172 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
169 | 173 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
170 | - } |
|
171 | - else |
|
174 | + } else |
|
172 | 175 | { |
173 | 176 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
174 | 177 | } |
@@ -219,14 +222,16 @@ discard block |
||
219 | 222 | // Child of a child... just add it on... |
220 | 223 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
221 | 224 | { |
222 | - if (!isset($parent_map)) |
|
223 | - $parent_map = array(); |
|
225 | + if (!isset($parent_map)) { |
|
226 | + $parent_map = array(); |
|
227 | + } |
|
224 | 228 | |
225 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
226 | - foreach ($this_category as $id => $board) |
|
229 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
230 | + foreach ($this_category as $id => $board) |
|
227 | 231 | { |
228 | 232 | if (!isset($board['children'][$row_board['id_parent']])) |
229 | 233 | continue; |
234 | + } |
|
230 | 235 | |
231 | 236 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
232 | 237 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -247,8 +252,9 @@ discard block |
||
247 | 252 | continue; |
248 | 253 | } |
249 | 254 | // Found a child of a child - skip. |
250 | - else |
|
251 | - continue; |
|
255 | + else { |
|
256 | + continue; |
|
257 | + } |
|
252 | 258 | |
253 | 259 | // Prepare the subject, and make sure it's not too long. |
254 | 260 | censorText($row_board['subject']); |
@@ -269,12 +275,13 @@ discard block |
||
269 | 275 | 'topic' => $row_board['id_topic'] |
270 | 276 | ); |
271 | 277 | |
272 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
273 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
278 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
279 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
274 | 280 | 'avatar' => $row_board['avatar'], |
275 | 281 | 'email' => $row_board['email_address'], |
276 | 282 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
277 | 283 | )); |
284 | + } |
|
278 | 285 | |
279 | 286 | // Provide the href and link. |
280 | 287 | if ($row_board['subject'] != '') |
@@ -286,8 +293,7 @@ discard block |
||
286 | 293 | link, href, subject, start (where they should go for the first unread post.), |
287 | 294 | and member. (which has id, name, link, href, username in it.) */ |
288 | 295 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
289 | - } |
|
290 | - else |
|
296 | + } else |
|
291 | 297 | { |
292 | 298 | $this_last_post['href'] = ''; |
293 | 299 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -295,8 +301,9 @@ discard block |
||
295 | 301 | } |
296 | 302 | |
297 | 303 | // Set the last post in the parent board. |
298 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
299 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
304 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
305 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
306 | + } |
|
300 | 307 | // Just in the child...? |
301 | 308 | if ($isChild) |
302 | 309 | { |
@@ -306,15 +313,17 @@ discard block |
||
306 | 313 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
307 | 314 | } |
308 | 315 | // No last post for this board? It's not new then, is it..? |
309 | - elseif ($row_board['poster_name'] == '') |
|
310 | - $this_category[$row_board['id_board']]['new'] = false; |
|
316 | + elseif ($row_board['poster_name'] == '') { |
|
317 | + $this_category[$row_board['id_board']]['new'] = false; |
|
318 | + } |
|
311 | 319 | |
312 | 320 | // Determine a global most recent topic. |
313 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
314 | - $latest_post = array( |
|
321 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
322 | + $latest_post = array( |
|
315 | 323 | 'timestamp' => $row_board['poster_time'], |
316 | 324 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
317 | 325 | ); |
326 | + } |
|
318 | 327 | } |
319 | 328 | $smcFunc['db_free_result']($result_boards); |
320 | 329 | |
@@ -331,8 +340,9 @@ discard block |
||
331 | 340 | if (!empty($moderators[$board['id']])) |
332 | 341 | { |
333 | 342 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
334 | - foreach ($moderators[$board['id']] as $moderator) |
|
335 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
343 | + foreach ($moderators[$board['id']] as $moderator) { |
|
344 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
345 | + } |
|
336 | 346 | } |
337 | 347 | if (!empty($groups[$board['id']])) |
338 | 348 | { |
@@ -345,16 +355,16 @@ discard block |
||
345 | 355 | } |
346 | 356 | } |
347 | 357 | } |
348 | - } |
|
349 | - else |
|
358 | + } else |
|
350 | 359 | { |
351 | 360 | foreach ($this_category as $k => $board) |
352 | 361 | { |
353 | 362 | if (!empty($moderators[$board['id']])) |
354 | 363 | { |
355 | 364 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
356 | - foreach ($moderators[$board['id']] as $moderator) |
|
357 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
365 | + foreach ($moderators[$board['id']] as $moderator) { |
|
366 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
367 | + } |
|
358 | 368 | } |
359 | 369 | if (!empty($groups[$board['id']])) |
360 | 370 | { |
@@ -368,20 +378,23 @@ discard block |
||
368 | 378 | } |
369 | 379 | } |
370 | 380 | |
371 | - if ($boardIndexOptions['include_categories']) |
|
372 | - sortCategories($categories); |
|
373 | - else |
|
374 | - sortBoards($this_category); |
|
381 | + if ($boardIndexOptions['include_categories']) { |
|
382 | + sortCategories($categories); |
|
383 | + } else { |
|
384 | + sortBoards($this_category); |
|
385 | + } |
|
375 | 386 | |
376 | 387 | // By now we should know the most recent post...if we wanna know it that is. |
377 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
378 | - $context['latest_post'] = $latest_post['ref']; |
|
388 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
389 | + $context['latest_post'] = $latest_post['ref']; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
381 | - if ($boardIndexOptions['include_categories']) |
|
382 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
383 | - else |
|
384 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
393 | + if ($boardIndexOptions['include_categories']) { |
|
394 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
395 | + } else { |
|
396 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
397 | + } |
|
385 | 398 | |
386 | 399 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
387 | 400 | } |
@@ -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 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
818 | 818 | if (empty($unsupportedFormats)) |
819 | 819 | { |
820 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
820 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
821 | 821 | { |
822 | 822 | $value = @strftime('%' . $format); |
823 | 823 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
1183 | 1183 | ), |
1184 | 1184 | 'content' => '$1', |
1185 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1185 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1186 | 1186 | { |
1187 | 1187 | $returnContext = ''; |
1188 | 1188 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
1220 | - $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>'; |
|
1220 | + $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>'; |
|
1221 | 1221 | else |
1222 | 1222 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
1223 | 1223 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | 'type' => 'unparsed_content', |
1247 | 1247 | '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>', |
1248 | 1248 | // @todo Maybe this can be simplified? |
1249 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1249 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1250 | 1250 | { |
1251 | 1251 | if (!isset($disabled['code'])) |
1252 | 1252 | { |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | 'type' => 'unparsed_equals_content', |
1284 | 1284 | '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>', |
1285 | 1285 | // @todo Maybe this can be simplified? |
1286 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1286 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1287 | 1287 | { |
1288 | 1288 | if (!isset($disabled['code'])) |
1289 | 1289 | { |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | 'type' => 'unparsed_content', |
1328 | 1328 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
1329 | 1329 | // @todo Should this respect guest_hideContacts? |
1330 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1330 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1331 | 1331 | { |
1332 | 1332 | $data = strtr($data, array('<br>' => '')); |
1333 | 1333 | }, |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | 'type' => 'unparsed_commas_content', |
1347 | 1347 | 'test' => '\d+,\d+\]', |
1348 | 1348 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1349 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1349 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1350 | 1350 | { |
1351 | 1351 | if (isset($disabled['url'])) |
1352 | 1352 | $tag['content'] = '$1'; |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
1363 | 1363 | 'before' => '<div $1>', |
1364 | 1364 | 'after' => '</div>', |
1365 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1365 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1366 | 1366 | { |
1367 | 1367 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1368 | 1368 | |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
1412 | 1412 | ), |
1413 | 1413 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
1414 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1414 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1415 | 1415 | { |
1416 | 1416 | global $image_proxy_enabled, $user_info; |
1417 | 1417 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | 'tag' => 'img', |
1438 | 1438 | 'type' => 'unparsed_content', |
1439 | 1439 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1440 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1440 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1441 | 1441 | { |
1442 | 1442 | global $image_proxy_enabled, $user_info; |
1443 | 1443 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | 'tag' => 'iurl', |
1464 | 1464 | 'type' => 'unparsed_content', |
1465 | 1465 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1466 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1466 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1467 | 1467 | { |
1468 | 1468 | $data = strtr($data, array('<br>' => '')); |
1469 | 1469 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | 'quoted' => 'optional', |
1478 | 1478 | 'before' => '<a href="$1" class="bbc_link">', |
1479 | 1479 | 'after' => '</a>', |
1480 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1480 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1481 | 1481 | { |
1482 | 1482 | if (substr($data, 0, 1) == '#') |
1483 | 1483 | $data = '#post_' . substr($data, 1); |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | 'tag' => 'php', |
1564 | 1564 | 'type' => 'unparsed_content', |
1565 | 1565 | 'content' => '<span class="phpcode">$1</span>', |
1566 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1566 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1567 | 1567 | { |
1568 | 1568 | if (!isset($disabled['php'])) |
1569 | 1569 | { |
@@ -1661,7 +1661,7 @@ discard block |
||
1661 | 1661 | 'test' => '[1-7]\]', |
1662 | 1662 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1663 | 1663 | 'after' => '</span>', |
1664 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1664 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1665 | 1665 | { |
1666 | 1666 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1667 | 1667 | $data = $sizes[$data] . 'em'; |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | 'tag' => 'time', |
1700 | 1700 | 'type' => 'unparsed_content', |
1701 | 1701 | 'content' => '$1', |
1702 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1702 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1703 | 1703 | { |
1704 | 1704 | if (is_numeric($data)) |
1705 | 1705 | $data = timeformat($data); |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | 'tag' => 'url', |
1728 | 1728 | 'type' => 'unparsed_content', |
1729 | 1729 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
1730 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1730 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1731 | 1731 | { |
1732 | 1732 | $data = strtr($data, array('<br>' => '')); |
1733 | 1733 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | 'quoted' => 'optional', |
1742 | 1742 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
1743 | 1743 | 'after' => '</a>', |
1744 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1744 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1745 | 1745 | { |
1746 | 1746 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1747 | 1747 | if (empty($scheme)) |
@@ -1773,7 +1773,7 @@ discard block |
||
1773 | 1773 | { |
1774 | 1774 | if (isset($temp_bbc)) |
1775 | 1775 | $bbc_codes = $temp_bbc; |
1776 | - usort($codes, function ($a, $b) { |
|
1776 | + usort($codes, function($a, $b) { |
|
1777 | 1777 | return strcmp($a['tag'], $b['tag']); |
1778 | 1778 | }); |
1779 | 1779 | return $codes; |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | # a run of Unicode domain name characters and a dot |
1990 | 1990 | [\p{L}\p{M}\p{N}\-.:@]+\. |
1991 | 1991 | # and then a TLD valid in the DNS or the reserved "local" TLD |
1992 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
1992 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
1993 | 1993 | ) |
1994 | 1994 | # followed by a non-domain character or end of line |
1995 | 1995 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2057,7 +2057,7 @@ discard block |
||
2057 | 2057 | )? |
2058 | 2058 | '; |
2059 | 2059 | |
2060 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2060 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2061 | 2061 | $url = array_shift($matches); |
2062 | 2062 | |
2063 | 2063 | // If this isn't a clean URL, bail out |
@@ -2082,7 +2082,7 @@ discard block |
||
2082 | 2082 | $fullUrl = $url; |
2083 | 2083 | |
2084 | 2084 | // Make sure that $fullUrl really is valid |
2085 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
2085 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '') . $fullUrl) === false) |
|
2086 | 2086 | return $url; |
2087 | 2087 | |
2088 | 2088 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
@@ -2146,7 +2146,7 @@ discard block |
||
2146 | 2146 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2147 | 2147 | |
2148 | 2148 | // A closing tag that doesn't match any open tags? Skip it. |
2149 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2149 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
2150 | 2150 | continue; |
2151 | 2151 | |
2152 | 2152 | $to_close = array(); |
@@ -2813,7 +2813,7 @@ discard block |
||
2813 | 2813 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2814 | 2814 | { |
2815 | 2815 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2816 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2816 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2817 | 2817 | |
2818 | 2818 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2819 | 2819 | |
@@ -2830,7 +2830,7 @@ discard block |
||
2830 | 2830 | |
2831 | 2831 | // Replace away! |
2832 | 2832 | $message = preg_replace_callback($smileyPregSearch, |
2833 | - function ($matches) use ($smileyPregReplacements) |
|
2833 | + function($matches) use ($smileyPregReplacements) |
|
2834 | 2834 | { |
2835 | 2835 | return $smileyPregReplacements[$matches[1]]; |
2836 | 2836 | }, $message); |
@@ -2927,13 +2927,13 @@ discard block |
||
2927 | 2927 | { |
2928 | 2928 | if (defined('SID') && SID != '') |
2929 | 2929 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2930 | - function ($m) use ($scripturl) |
|
2930 | + function($m) use ($scripturl) |
|
2931 | 2931 | { |
2932 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2932 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2933 | 2933 | }, $setLocation); |
2934 | 2934 | else |
2935 | 2935 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2936 | - function ($m) use ($scripturl) |
|
2936 | + function($m) use ($scripturl) |
|
2937 | 2937 | { |
2938 | 2938 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2939 | 2939 | }, $setLocation); |
@@ -3254,7 +3254,7 @@ discard block |
||
3254 | 3254 | |
3255 | 3255 | // Add a generic "Are you sure?" confirmation message. |
3256 | 3256 | addInlineJavaScript(' |
3257 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3257 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3258 | 3258 | |
3259 | 3259 | // Now add the capping code for avatars. |
3260 | 3260 | 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') |
@@ -3721,7 +3721,7 @@ discard block |
||
3721 | 3721 | if (!empty($normal)) |
3722 | 3722 | foreach ($normal as $nf) |
3723 | 3723 | echo ' |
3724 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3724 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3725 | 3725 | |
3726 | 3726 | if ($db_show_debug === true) |
3727 | 3727 | { |
@@ -3737,7 +3737,7 @@ discard block |
||
3737 | 3737 | <style>'; |
3738 | 3738 | |
3739 | 3739 | foreach ($context['css_header'] as $css) |
3740 | - echo $css .' |
|
3740 | + echo $css . ' |
|
3741 | 3741 | '; |
3742 | 3742 | |
3743 | 3743 | echo' |
@@ -3781,7 +3781,7 @@ discard block |
||
3781 | 3781 | |
3782 | 3782 | |
3783 | 3783 | // No namespaces, sorry! |
3784 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3784 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3785 | 3785 | |
3786 | 3786 | // Temp path. |
3787 | 3787 | $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
@@ -3961,7 +3961,7 @@ discard block |
||
3961 | 3961 | else |
3962 | 3962 | $path = $modSettings['attachmentUploadDir']; |
3963 | 3963 | |
3964 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3964 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3965 | 3965 | } |
3966 | 3966 | |
3967 | 3967 | /** |
@@ -4005,10 +4005,10 @@ discard block |
||
4005 | 4005 | $valid_low = isValidIP($ip_parts[0]); |
4006 | 4006 | $valid_high = isValidIP($ip_parts[1]); |
4007 | 4007 | $count = 0; |
4008 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
4008 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
4009 | 4009 | $max = ($mode == ':' ? 'ffff' : '255'); |
4010 | 4010 | $min = 0; |
4011 | - if(!$valid_low) |
|
4011 | + if (!$valid_low) |
|
4012 | 4012 | { |
4013 | 4013 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
4014 | 4014 | $valid_low = isValidIP($ip_parts[0]); |
@@ -4022,7 +4022,7 @@ discard block |
||
4022 | 4022 | } |
4023 | 4023 | |
4024 | 4024 | $count = 0; |
4025 | - if(!$valid_high) |
|
4025 | + if (!$valid_high) |
|
4026 | 4026 | { |
4027 | 4027 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
4028 | 4028 | $valid_high = isValidIP($ip_parts[1]); |
@@ -4035,7 +4035,7 @@ discard block |
||
4035 | 4035 | } |
4036 | 4036 | } |
4037 | 4037 | |
4038 | - if($valid_high && $valid_low) |
|
4038 | + if ($valid_high && $valid_low) |
|
4039 | 4039 | { |
4040 | 4040 | $ip_array['low'] = $ip_parts[0]; |
4041 | 4041 | $ip_array['high'] = $ip_parts[1]; |
@@ -4217,7 +4217,7 @@ discard block |
||
4217 | 4217 | addInlineJavaScript(' |
4218 | 4218 | var user_menus = new smc_PopupMenu(); |
4219 | 4219 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4220 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4220 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4221 | 4221 | if ($context['allow_pm']) |
4222 | 4222 | addInlineJavaScript(' |
4223 | 4223 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4853,7 +4853,7 @@ discard block |
||
4853 | 4853 | // No? try a fallback to $sourcedir |
4854 | 4854 | else |
4855 | 4855 | { |
4856 | - $absPath = $sourcedir .'/'. $file; |
|
4856 | + $absPath = $sourcedir . '/' . $file; |
|
4857 | 4857 | |
4858 | 4858 | if (file_exists($absPath)) |
4859 | 4859 | require_once($absPath); |
@@ -5120,15 +5120,15 @@ discard block |
||
5120 | 5120 | |
5121 | 5121 | // UTF-8 occurences of MS special characters |
5122 | 5122 | $findchars_utf8 = array( |
5123 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
5124 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
5125 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
5126 | - "\xe2\x80\x98", // left single curly quote |
|
5127 | - "\xe2\x80\x99", // right single curly quote |
|
5128 | - "\xe2\x80\x9c", // left double curly quote |
|
5129 | - "\xe2\x80\x9d", // right double curly quote |
|
5130 | - "\xe2\x80\x93", // en dash |
|
5131 | - "\xe2\x80\x94", // em dash |
|
5123 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
5124 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
5125 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
5126 | + "\xe2\x80\x98", // left single curly quote |
|
5127 | + "\xe2\x80\x99", // right single curly quote |
|
5128 | + "\xe2\x80\x9c", // left double curly quote |
|
5129 | + "\xe2\x80\x9d", // right double curly quote |
|
5130 | + "\xe2\x80\x93", // en dash |
|
5131 | + "\xe2\x80\x94", // em dash |
|
5132 | 5132 | ); |
5133 | 5133 | |
5134 | 5134 | // windows 1252 / iso equivalents |
@@ -5146,15 +5146,15 @@ discard block |
||
5146 | 5146 | |
5147 | 5147 | // safe replacements |
5148 | 5148 | $replacechars = array( |
5149 | - ',', // ‚ |
|
5150 | - ',,', // „ |
|
5151 | - '...', // … |
|
5152 | - "'", // ‘ |
|
5153 | - "'", // ’ |
|
5154 | - '"', // “ |
|
5155 | - '"', // ” |
|
5156 | - '-', // – |
|
5157 | - '--', // — |
|
5149 | + ',', // ‚ |
|
5150 | + ',,', // „ |
|
5151 | + '...', // … |
|
5152 | + "'", // ‘ |
|
5153 | + "'", // ’ |
|
5154 | + '"', // “ |
|
5155 | + '"', // ” |
|
5156 | + '-', // – |
|
5157 | + '--', // — |
|
5158 | 5158 | ); |
5159 | 5159 | |
5160 | 5160 | if ($context['utf8']) |
@@ -5572,7 +5572,7 @@ discard block |
||
5572 | 5572 | */ |
5573 | 5573 | function inet_dtop($bin) |
5574 | 5574 | { |
5575 | - if(empty($bin)) |
|
5575 | + if (empty($bin)) |
|
5576 | 5576 | return ''; |
5577 | 5577 | |
5578 | 5578 | global $db_type; |
@@ -5603,28 +5603,28 @@ discard block |
||
5603 | 5603 | */ |
5604 | 5604 | function _safe_serialize($value) |
5605 | 5605 | { |
5606 | - if(is_null($value)) |
|
5606 | + if (is_null($value)) |
|
5607 | 5607 | return 'N;'; |
5608 | 5608 | |
5609 | - if(is_bool($value)) |
|
5610 | - return 'b:'. (int) $value .';'; |
|
5609 | + if (is_bool($value)) |
|
5610 | + return 'b:' . (int) $value . ';'; |
|
5611 | 5611 | |
5612 | - if(is_int($value)) |
|
5613 | - return 'i:'. $value .';'; |
|
5612 | + if (is_int($value)) |
|
5613 | + return 'i:' . $value . ';'; |
|
5614 | 5614 | |
5615 | - if(is_float($value)) |
|
5616 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5615 | + if (is_float($value)) |
|
5616 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5617 | 5617 | |
5618 | - if(is_string($value)) |
|
5619 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5618 | + if (is_string($value)) |
|
5619 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5620 | 5620 | |
5621 | - if(is_array($value)) |
|
5621 | + if (is_array($value)) |
|
5622 | 5622 | { |
5623 | 5623 | $out = ''; |
5624 | - foreach($value as $k => $v) |
|
5624 | + foreach ($value as $k => $v) |
|
5625 | 5625 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5626 | 5626 | |
5627 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5627 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5628 | 5628 | } |
5629 | 5629 | |
5630 | 5630 | // safe_serialize cannot serialize resources or objects. |
@@ -5666,7 +5666,7 @@ discard block |
||
5666 | 5666 | function _safe_unserialize($str) |
5667 | 5667 | { |
5668 | 5668 | // Input is not a string. |
5669 | - if(empty($str) || !is_string($str)) |
|
5669 | + if (empty($str) || !is_string($str)) |
|
5670 | 5670 | return false; |
5671 | 5671 | |
5672 | 5672 | $stack = array(); |
@@ -5680,40 +5680,40 @@ discard block |
||
5680 | 5680 | * 3 - in array, expecting value or another array |
5681 | 5681 | */ |
5682 | 5682 | $state = 0; |
5683 | - while($state != 1) |
|
5683 | + while ($state != 1) |
|
5684 | 5684 | { |
5685 | 5685 | $type = isset($str[0]) ? $str[0] : ''; |
5686 | - if($type == '}') |
|
5686 | + if ($type == '}') |
|
5687 | 5687 | $str = substr($str, 1); |
5688 | 5688 | |
5689 | - else if($type == 'N' && $str[1] == ';') |
|
5689 | + else if ($type == 'N' && $str[1] == ';') |
|
5690 | 5690 | { |
5691 | 5691 | $value = null; |
5692 | 5692 | $str = substr($str, 2); |
5693 | 5693 | } |
5694 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5694 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5695 | 5695 | { |
5696 | 5696 | $value = $matches[1] == '1' ? true : false; |
5697 | 5697 | $str = substr($str, 4); |
5698 | 5698 | } |
5699 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5699 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5700 | 5700 | { |
5701 | - $value = (int)$matches[1]; |
|
5701 | + $value = (int) $matches[1]; |
|
5702 | 5702 | $str = $matches[2]; |
5703 | 5703 | } |
5704 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5704 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5705 | 5705 | { |
5706 | - $value = (float)$matches[1]; |
|
5706 | + $value = (float) $matches[1]; |
|
5707 | 5707 | $str = $matches[3]; |
5708 | 5708 | } |
5709 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5709 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5710 | 5710 | { |
5711 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5712 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5711 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5712 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5713 | 5713 | } |
5714 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5714 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5715 | 5715 | { |
5716 | - $expectedLength = (int)$matches[1]; |
|
5716 | + $expectedLength = (int) $matches[1]; |
|
5717 | 5717 | $str = $matches[2]; |
5718 | 5718 | } |
5719 | 5719 | |
@@ -5721,10 +5721,10 @@ discard block |
||
5721 | 5721 | else |
5722 | 5722 | return false; |
5723 | 5723 | |
5724 | - switch($state) |
|
5724 | + switch ($state) |
|
5725 | 5725 | { |
5726 | 5726 | case 3: // In array, expecting value or another array. |
5727 | - if($type == 'a') |
|
5727 | + if ($type == 'a') |
|
5728 | 5728 | { |
5729 | 5729 | $stack[] = &$list; |
5730 | 5730 | $list[$key] = array(); |
@@ -5733,7 +5733,7 @@ discard block |
||
5733 | 5733 | $state = 2; |
5734 | 5734 | break; |
5735 | 5735 | } |
5736 | - if($type != '}') |
|
5736 | + if ($type != '}') |
|
5737 | 5737 | { |
5738 | 5738 | $list[$key] = $value; |
5739 | 5739 | $state = 2; |
@@ -5744,29 +5744,29 @@ discard block |
||
5744 | 5744 | return false; |
5745 | 5745 | |
5746 | 5746 | case 2: // in array, expecting end of array or a key |
5747 | - if($type == '}') |
|
5747 | + if ($type == '}') |
|
5748 | 5748 | { |
5749 | 5749 | // Array size is less than expected. |
5750 | - if(count($list) < end($expected)) |
|
5750 | + if (count($list) < end($expected)) |
|
5751 | 5751 | return false; |
5752 | 5752 | |
5753 | 5753 | unset($list); |
5754 | - $list = &$stack[count($stack)-1]; |
|
5754 | + $list = &$stack[count($stack) - 1]; |
|
5755 | 5755 | array_pop($stack); |
5756 | 5756 | |
5757 | 5757 | // Go to terminal state if we're at the end of the root array. |
5758 | 5758 | array_pop($expected); |
5759 | 5759 | |
5760 | - if(count($expected) == 0) |
|
5760 | + if (count($expected) == 0) |
|
5761 | 5761 | $state = 1; |
5762 | 5762 | |
5763 | 5763 | break; |
5764 | 5764 | } |
5765 | 5765 | |
5766 | - if($type == 'i' || $type == 's') |
|
5766 | + if ($type == 'i' || $type == 's') |
|
5767 | 5767 | { |
5768 | 5768 | // Array size exceeds expected length. |
5769 | - if(count($list) >= end($expected)) |
|
5769 | + if (count($list) >= end($expected)) |
|
5770 | 5770 | return false; |
5771 | 5771 | |
5772 | 5772 | $key = $value; |
@@ -5779,7 +5779,7 @@ discard block |
||
5779 | 5779 | |
5780 | 5780 | // Expecting array or value. |
5781 | 5781 | case 0: |
5782 | - if($type == 'a') |
|
5782 | + if ($type == 'a') |
|
5783 | 5783 | { |
5784 | 5784 | $data = array(); |
5785 | 5785 | $list = &$data; |
@@ -5788,7 +5788,7 @@ discard block |
||
5788 | 5788 | break; |
5789 | 5789 | } |
5790 | 5790 | |
5791 | - if($type != '}') |
|
5791 | + if ($type != '}') |
|
5792 | 5792 | { |
5793 | 5793 | $data = $value; |
5794 | 5794 | $state = 1; |
@@ -5801,7 +5801,7 @@ discard block |
||
5801 | 5801 | } |
5802 | 5802 | |
5803 | 5803 | // Trailing data in input. |
5804 | - if(!empty($str)) |
|
5804 | + if (!empty($str)) |
|
5805 | 5805 | return false; |
5806 | 5806 | |
5807 | 5807 | return $data; |
@@ -5855,7 +5855,7 @@ discard block |
||
5855 | 5855 | // Set different modes. |
5856 | 5856 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5857 | 5857 | |
5858 | - foreach($chmodValues as $val) |
|
5858 | + foreach ($chmodValues as $val) |
|
5859 | 5859 | { |
5860 | 5860 | // If it's writable, break out of the loop. |
5861 | 5861 | if (is_writable($file)) |
@@ -5890,13 +5890,13 @@ discard block |
||
5890 | 5890 | $returnArray = @json_decode($json, $returnAsArray); |
5891 | 5891 | |
5892 | 5892 | // PHP 5.3 so no json_last_error_msg() |
5893 | - switch(json_last_error()) |
|
5893 | + switch (json_last_error()) |
|
5894 | 5894 | { |
5895 | 5895 | case JSON_ERROR_NONE: |
5896 | 5896 | $jsonError = false; |
5897 | 5897 | break; |
5898 | 5898 | case JSON_ERROR_DEPTH: |
5899 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5899 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5900 | 5900 | break; |
5901 | 5901 | case JSON_ERROR_STATE_MISMATCH: |
5902 | 5902 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5924,10 +5924,10 @@ discard block |
||
5924 | 5924 | loadLanguage('Errors'); |
5925 | 5925 | |
5926 | 5926 | if (!empty($jsonDebug)) |
5927 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5927 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5928 | 5928 | |
5929 | 5929 | else |
5930 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5930 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5931 | 5931 | |
5932 | 5932 | // Everyone expects an array. |
5933 | 5933 | return array(); |
@@ -6044,7 +6044,7 @@ discard block |
||
6044 | 6044 | // Convert Punycode to Unicode |
6045 | 6045 | require_once($sourcedir . '/Class-Punycode.php'); |
6046 | 6046 | $Punycode = new Punycode(); |
6047 | - $tlds = array_map(function ($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
6047 | + $tlds = array_map(function($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds); |
|
6048 | 6048 | } |
6049 | 6049 | // Otherwise, use the 2012 list of gTLDs and ccTLDs for now and schedule a background update |
6050 | 6050 | else |
@@ -6138,7 +6138,7 @@ discard block |
||
6138 | 6138 | } |
6139 | 6139 | |
6140 | 6140 | // This recursive function creates the index array from the strings |
6141 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
6141 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
6142 | 6142 | { |
6143 | 6143 | static $depth = 0; |
6144 | 6144 | $depth++; |
@@ -6165,7 +6165,7 @@ discard block |
||
6165 | 6165 | }; |
6166 | 6166 | |
6167 | 6167 | // This recursive function turns the index array into a regular expression |
6168 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
6168 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
6169 | 6169 | { |
6170 | 6170 | static $depth = 0; |
6171 | 6171 | $depth++; |
@@ -6189,11 +6189,11 @@ discard block |
||
6189 | 6189 | |
6190 | 6190 | if (count(array_keys($value)) == 1) |
6191 | 6191 | { |
6192 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
6192 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
6193 | 6193 | $new_key .= $new_key_array[0]; |
6194 | 6194 | } |
6195 | 6195 | else |
6196 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6196 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
6197 | 6197 | } |
6198 | 6198 | |
6199 | 6199 | if ($depth > 1) |
@@ -6236,10 +6236,10 @@ discard block |
||
6236 | 6236 | { |
6237 | 6237 | $regex = array(); |
6238 | 6238 | while (!empty($index)) |
6239 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6239 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6240 | 6240 | } |
6241 | 6241 | else |
6242 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6242 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6243 | 6243 | |
6244 | 6244 | // Restore PHP's internal character encoding to whatever it was originally |
6245 | 6245 | if (!empty($current_encoding)) |
@@ -6461,7 +6461,7 @@ discard block |
||
6461 | 6461 | function sanitize_iri($iri) |
6462 | 6462 | { |
6463 | 6463 | // Encode any non-ASCII characters (but not space or control characters of any sort) |
6464 | - $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function ($matches) { |
|
6464 | + $iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function($matches) { |
|
6465 | 6465 | return rawurlencode($matches[0]); |
6466 | 6466 | }, $iri); |
6467 | 6467 | |
@@ -6503,7 +6503,7 @@ discard block |
||
6503 | 6503 | $unescaped = array( |
6504 | 6504 | '%21'=>'!', '%23'=>'#', '%24'=>'$', '%26'=>'&', |
6505 | 6505 | '%27'=>"'", '%28'=>'(', '%29'=>')', '%2A'=>'*', |
6506 | - '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
6506 | + '%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':', |
|
6507 | 6507 | '%3B'=>';', '%3D'=>'=', '%3F'=>'?', '%40'=>'@', |
6508 | 6508 | ); |
6509 | 6509 | $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,23 +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 | - else |
|
196 | + if ($parameter1 === true) { |
|
197 | + updateSettings(array('totalTopics' => true), true); |
|
198 | + } else |
|
195 | 199 | { |
196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
212 | 216 | |
213 | 217 | case 'postgroups': |
214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
216 | - return; |
|
219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
220 | + return; |
|
221 | + } |
|
217 | 222 | |
218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
228 | 233 | ) |
229 | 234 | ); |
230 | 235 | $postgroups = array(); |
231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
238 | + } |
|
233 | 239 | $smcFunc['db_free_result']($request); |
234 | 240 | |
235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
239 | 245 | } |
240 | 246 | |
241 | 247 | // Oh great, they've screwed their post groups. |
242 | - if (empty($postgroups)) |
|
243 | - return; |
|
248 | + if (empty($postgroups)) { |
|
249 | + return; |
|
250 | + } |
|
244 | 251 | |
245 | 252 | // Set all membergroups from most posts to least posts. |
246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
298 | 305 | { |
299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
300 | 307 | $parameters['members'] = $members; |
301 | - } |
|
302 | - elseif ($members === null) |
|
303 | - $condition = '1=1'; |
|
304 | - else |
|
308 | + } elseif ($members === null) { |
|
309 | + $condition = '1=1'; |
|
310 | + } else |
|
305 | 311 | { |
306 | 312 | $condition = 'id_member = {int:member}'; |
307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
341 | 347 | if (count($vars_to_integrate) != 0) |
342 | 348 | { |
343 | 349 | // Fetch a list of member_names if necessary |
344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
345 | - $member_names = array($user_info['username']); |
|
346 | - else |
|
350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
351 | + $member_names = array($user_info['username']); |
|
352 | + } else |
|
347 | 353 | { |
348 | 354 | $member_names = array(); |
349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
352 | 358 | WHERE ' . $condition, |
353 | 359 | $parameters |
354 | 360 | ); |
355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
356 | - $member_names[] = $row['member_name']; |
|
361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
362 | + $member_names[] = $row['member_name']; |
|
363 | + } |
|
357 | 364 | $smcFunc['db_free_result']($request); |
358 | 365 | } |
359 | 366 | |
360 | - if (!empty($member_names)) |
|
361 | - foreach ($vars_to_integrate as $var) |
|
367 | + if (!empty($member_names)) { |
|
368 | + foreach ($vars_to_integrate as $var) |
|
362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
370 | + } |
|
363 | 371 | } |
364 | 372 | } |
365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
367 | 375 | foreach ($data as $var => $val) |
368 | 376 | { |
369 | 377 | $type = 'string'; |
370 | - if (in_array($var, $knownInts)) |
|
371 | - $type = 'int'; |
|
372 | - elseif (in_array($var, $knownFloats)) |
|
373 | - $type = 'float'; |
|
374 | - elseif ($var == 'birthdate') |
|
375 | - $type = 'date'; |
|
376 | - elseif ($var == 'member_ip') |
|
377 | - $type = 'inet'; |
|
378 | - elseif ($var == 'member_ip2') |
|
379 | - $type = 'inet'; |
|
378 | + if (in_array($var, $knownInts)) { |
|
379 | + $type = 'int'; |
|
380 | + } elseif (in_array($var, $knownFloats)) { |
|
381 | + $type = 'float'; |
|
382 | + } elseif ($var == 'birthdate') { |
|
383 | + $type = 'date'; |
|
384 | + } elseif ($var == 'member_ip') { |
|
385 | + $type = 'inet'; |
|
386 | + } elseif ($var == 'member_ip2') { |
|
387 | + $type = 'inet'; |
|
388 | + } |
|
380 | 389 | |
381 | 390 | // Doing an increment? |
382 | 391 | if ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -385,18 +394,17 @@ discard block |
||
385 | 394 | if (is_array($members)) |
386 | 395 | { |
387 | 396 | $val = 'CASE '; |
388 | - foreach ($members as $k => $v) |
|
389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
397 | + foreach ($members as $k => $v) { |
|
398 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
399 | + } |
|
390 | 400 | $val = $val . ' END'; |
391 | 401 | $type = 'raw'; |
392 | - } |
|
393 | - else |
|
402 | + } else |
|
394 | 403 | { |
395 | 404 | $blub = fetch_alerts($members, false, 0, array(), false); |
396 | 405 | $val = count($blub); |
397 | 406 | } |
398 | - } |
|
399 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
407 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
400 | 408 | { |
401 | 409 | $val = $var . ' ' . $val . ' 1'; |
402 | 410 | $type = 'raw'; |
@@ -407,8 +415,9 @@ discard block |
||
407 | 415 | { |
408 | 416 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
409 | 417 | { |
410 | - if ($match[1] != '+ ') |
|
411 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
418 | + if ($match[1] != '+ ') { |
|
419 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
420 | + } |
|
412 | 421 | $type = 'raw'; |
413 | 422 | } |
414 | 423 | } |
@@ -429,8 +438,9 @@ discard block |
||
429 | 438 | // Clear any caching? |
430 | 439 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
431 | 440 | { |
432 | - if (!is_array($members)) |
|
433 | - $members = array($members); |
|
441 | + if (!is_array($members)) { |
|
442 | + $members = array($members); |
|
443 | + } |
|
434 | 444 | |
435 | 445 | foreach ($members as $member) |
436 | 446 | { |
@@ -463,29 +473,32 @@ discard block |
||
463 | 473 | { |
464 | 474 | global $modSettings, $smcFunc; |
465 | 475 | |
466 | - if (empty($changeArray) || !is_array($changeArray)) |
|
467 | - return; |
|
476 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
477 | + return; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | $toRemove = array(); |
470 | 481 | |
471 | 482 | // Go check if there is any setting to be removed. |
472 | - foreach ($changeArray as $k => $v) |
|
473 | - if ($v === null) |
|
483 | + foreach ($changeArray as $k => $v) { |
|
484 | + if ($v === null) |
|
474 | 485 | { |
475 | 486 | // Found some, remove them from the original array and add them to ours. |
476 | 487 | unset($changeArray[$k]); |
488 | + } |
|
477 | 489 | $toRemove[] = $k; |
478 | 490 | } |
479 | 491 | |
480 | 492 | // Proceed with the deletion. |
481 | - if (!empty($toRemove)) |
|
482 | - $smcFunc['db_query']('', ' |
|
493 | + if (!empty($toRemove)) { |
|
494 | + $smcFunc['db_query']('', ' |
|
483 | 495 | DELETE FROM {db_prefix}settings |
484 | 496 | WHERE variable IN ({array_string:remove})', |
485 | 497 | array( |
486 | 498 | 'remove' => $toRemove, |
487 | 499 | ) |
488 | 500 | ); |
501 | + } |
|
489 | 502 | |
490 | 503 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
491 | 504 | if ($update) |
@@ -514,19 +527,22 @@ discard block |
||
514 | 527 | foreach ($changeArray as $variable => $value) |
515 | 528 | { |
516 | 529 | // Don't bother if it's already like that ;). |
517 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
518 | - continue; |
|
530 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
531 | + continue; |
|
532 | + } |
|
519 | 533 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
520 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
521 | - continue; |
|
534 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
535 | + continue; |
|
536 | + } |
|
522 | 537 | |
523 | 538 | $replaceArray[] = array($variable, $value); |
524 | 539 | |
525 | 540 | $modSettings[$variable] = $value; |
526 | 541 | } |
527 | 542 | |
528 | - if (empty($replaceArray)) |
|
529 | - return; |
|
543 | + if (empty($replaceArray)) { |
|
544 | + return; |
|
545 | + } |
|
530 | 546 | |
531 | 547 | $smcFunc['db_insert']('replace', |
532 | 548 | '{db_prefix}settings', |
@@ -572,14 +588,17 @@ discard block |
||
572 | 588 | $start_invalid = $start < 0; |
573 | 589 | |
574 | 590 | // Make sure $start is a proper variable - not less than 0. |
575 | - if ($start_invalid) |
|
576 | - $start = 0; |
|
591 | + if ($start_invalid) { |
|
592 | + $start = 0; |
|
593 | + } |
|
577 | 594 | // Not greater than the upper bound. |
578 | - elseif ($start >= $max_value) |
|
579 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
595 | + elseif ($start >= $max_value) { |
|
596 | + $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 | + } |
|
580 | 598 | // And it has to be a multiple of $num_per_page! |
581 | - else |
|
582 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
599 | + else { |
|
600 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
601 | + } |
|
583 | 602 | |
584 | 603 | $context['current_page'] = $start / $num_per_page; |
585 | 604 | |
@@ -609,77 +628,87 @@ discard block |
||
609 | 628 | |
610 | 629 | // Show all the pages. |
611 | 630 | $display_page = 1; |
612 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
613 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
631 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
632 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
633 | + } |
|
614 | 634 | |
615 | 635 | // Show the right arrow. |
616 | 636 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
617 | - if ($start != $counter - $max_value && !$start_invalid) |
|
618 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
619 | - } |
|
620 | - else |
|
637 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
638 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
639 | + } |
|
640 | + } else |
|
621 | 641 | { |
622 | 642 | // If they didn't enter an odd value, pretend they did. |
623 | 643 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
624 | 644 | |
625 | 645 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
626 | - if (!empty($start) && $show_prevnext) |
|
627 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
628 | - else |
|
629 | - $pageindex .= ''; |
|
646 | + if (!empty($start) && $show_prevnext) { |
|
647 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
648 | + } else { |
|
649 | + $pageindex .= ''; |
|
650 | + } |
|
630 | 651 | |
631 | 652 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
632 | - if ($start > $num_per_page * $PageContiguous) |
|
633 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
653 | + if ($start > $num_per_page * $PageContiguous) { |
|
654 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
655 | + } |
|
634 | 656 | |
635 | 657 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
636 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
637 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
658 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
659 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
638 | 660 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
639 | 661 | '{FIRST_PAGE}' => $num_per_page, |
640 | 662 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
641 | 663 | '{PER_PAGE}' => $num_per_page, |
642 | 664 | )); |
665 | + } |
|
643 | 666 | |
644 | 667 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
645 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
646 | - if ($start >= $num_per_page * $nCont) |
|
668 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
669 | + if ($start >= $num_per_page * $nCont) |
|
647 | 670 | { |
648 | 671 | $tmpStart = $start - $num_per_page * $nCont; |
672 | + } |
|
649 | 673 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
650 | 674 | } |
651 | 675 | |
652 | 676 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
653 | - if (!$start_invalid) |
|
654 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
655 | - else |
|
656 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
677 | + if (!$start_invalid) { |
|
678 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
679 | + } else { |
|
680 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
681 | + } |
|
657 | 682 | |
658 | 683 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
659 | 684 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
660 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
661 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
685 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
686 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
662 | 687 | { |
663 | 688 | $tmpStart = $start + $num_per_page * $nCont; |
689 | + } |
|
664 | 690 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
665 | 691 | } |
666 | 692 | |
667 | 693 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
668 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
669 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
694 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
695 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
670 | 696 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
671 | 697 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
672 | 698 | '{LAST_PAGE}' => $tmpMaxPages, |
673 | 699 | '{PER_PAGE}' => $num_per_page, |
674 | 700 | )); |
701 | + } |
|
675 | 702 | |
676 | 703 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
677 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
678 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
704 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
705 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
706 | + } |
|
679 | 707 | |
680 | 708 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
681 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
682 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
709 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
710 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
711 | + } |
|
683 | 712 | } |
684 | 713 | $pageindex .= $settings['page_index']['extra_after']; |
685 | 714 | |
@@ -705,8 +734,9 @@ discard block |
||
705 | 734 | if ($decimal_separator === null) |
706 | 735 | { |
707 | 736 | // Not set for whatever reason? |
708 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
709 | - return $number; |
|
737 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
738 | + return $number; |
|
739 | + } |
|
710 | 740 | |
711 | 741 | // Cache these each load... |
712 | 742 | $thousands_separator = $matches[1]; |
@@ -740,17 +770,20 @@ discard block |
||
740 | 770 | static $unsupportedFormats, $finalizedFormats; |
741 | 771 | |
742 | 772 | // Offset the time. |
743 | - if (!$offset_type) |
|
744 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
773 | + if (!$offset_type) { |
|
774 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
775 | + } |
|
745 | 776 | // Just the forum offset? |
746 | - elseif ($offset_type == 'forum') |
|
747 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
748 | - else |
|
749 | - $time = $log_time; |
|
777 | + elseif ($offset_type == 'forum') { |
|
778 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
779 | + } else { |
|
780 | + $time = $log_time; |
|
781 | + } |
|
750 | 782 | |
751 | 783 | // We can't have a negative date (on Windows, at least.) |
752 | - if ($log_time < 0) |
|
753 | - $log_time = 0; |
|
784 | + if ($log_time < 0) { |
|
785 | + $log_time = 0; |
|
786 | + } |
|
754 | 787 | |
755 | 788 | // Today and Yesterday? |
756 | 789 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -767,24 +800,27 @@ discard block |
||
767 | 800 | { |
768 | 801 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
769 | 802 | $today_fmt = $h . ':%M' . $s . ' %p'; |
803 | + } else { |
|
804 | + $today_fmt = '%H:%M' . $s; |
|
770 | 805 | } |
771 | - else |
|
772 | - $today_fmt = '%H:%M' . $s; |
|
773 | 806 | |
774 | 807 | // Same day of the year, same year.... Today! |
775 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
776 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
808 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
809 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
810 | + } |
|
777 | 811 | |
778 | 812 | // 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... |
779 | - 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)) |
|
780 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
813 | + 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)) { |
|
814 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
815 | + } |
|
781 | 816 | } |
782 | 817 | |
783 | 818 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
784 | 819 | |
785 | 820 | // Use the cached formats if available |
786 | - if (is_null($finalizedFormats)) |
|
787 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
821 | + if (is_null($finalizedFormats)) { |
|
822 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
823 | + } |
|
788 | 824 | |
789 | 825 | // Make a supported version for this format if we don't already have one |
790 | 826 | if (empty($finalizedFormats[$str])) |
@@ -813,8 +849,9 @@ discard block |
||
813 | 849 | ); |
814 | 850 | |
815 | 851 | // No need to do this part again if we already did it once |
816 | - if (is_null($unsupportedFormats)) |
|
817 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
852 | + if (is_null($unsupportedFormats)) { |
|
853 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
854 | + } |
|
818 | 855 | if (empty($unsupportedFormats)) |
819 | 856 | { |
820 | 857 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -823,20 +860,23 @@ discard block |
||
823 | 860 | |
824 | 861 | // Windows will return false for unsupported formats |
825 | 862 | // Other operating systems return the format string as a literal |
826 | - if ($value === false || $value === $format) |
|
827 | - $unsupportedFormats[] = $format; |
|
863 | + if ($value === false || $value === $format) { |
|
864 | + $unsupportedFormats[] = $format; |
|
865 | + } |
|
828 | 866 | } |
829 | 867 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
830 | 868 | } |
831 | 869 | |
832 | 870 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
833 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
834 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
871 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
872 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
873 | + } |
|
835 | 874 | |
836 | 875 | // Substitute unsupported formats with supported ones |
837 | - if (!empty($unsupportedFormats)) |
|
838 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
876 | + if (!empty($unsupportedFormats)) { |
|
877 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
839 | 878 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
879 | + } |
|
840 | 880 | |
841 | 881 | // Remember this so we don't need to do it again |
842 | 882 | $finalizedFormats[$str] = $timeformat; |
@@ -845,33 +885,39 @@ discard block |
||
845 | 885 | |
846 | 886 | $str = $finalizedFormats[$str]; |
847 | 887 | |
848 | - if (!isset($locale_cache)) |
|
849 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
888 | + if (!isset($locale_cache)) { |
|
889 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
890 | + } |
|
850 | 891 | |
851 | 892 | if ($locale_cache !== false) |
852 | 893 | { |
853 | 894 | // Check if another process changed the locale |
854 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
855 | - setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
895 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
896 | + setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
897 | + } |
|
856 | 898 | |
857 | - if (!isset($non_twelve_hour)) |
|
858 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
859 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
860 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
899 | + if (!isset($non_twelve_hour)) { |
|
900 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
901 | + } |
|
902 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
904 | + } |
|
861 | 905 | |
862 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
863 | - if (strpos($str, $token) !== false) |
|
906 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
907 | + if (strpos($str, $token) !== false) |
|
864 | 908 | $str = str_replace($token, strftime($token, $time), $str); |
865 | - } |
|
866 | - else |
|
909 | + } |
|
910 | + } else |
|
867 | 911 | { |
868 | 912 | // Do-it-yourself time localization. Fun. |
869 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
870 | - if (strpos($str, $token) !== false) |
|
913 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
914 | + if (strpos($str, $token) !== false) |
|
871 | 915 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
916 | + } |
|
872 | 917 | |
873 | - if (strpos($str, '%p') !== false) |
|
874 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
918 | + if (strpos($str, '%p') !== false) { |
|
919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
920 | + } |
|
875 | 921 | } |
876 | 922 | |
877 | 923 | // Format the time and then restore any literal percent characters |
@@ -894,16 +940,19 @@ discard block |
||
894 | 940 | static $translation = array(); |
895 | 941 | |
896 | 942 | // Determine the character set... Default to UTF-8 |
897 | - if (empty($context['character_set'])) |
|
898 | - $charset = 'UTF-8'; |
|
943 | + if (empty($context['character_set'])) { |
|
944 | + $charset = 'UTF-8'; |
|
945 | + } |
|
899 | 946 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
900 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
901 | - $charset = 'ISO-8859-1'; |
|
902 | - else |
|
903 | - $charset = $context['character_set']; |
|
947 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
948 | + $charset = 'ISO-8859-1'; |
|
949 | + } else { |
|
950 | + $charset = $context['character_set']; |
|
951 | + } |
|
904 | 952 | |
905 | - if (empty($translation)) |
|
906 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
953 | + if (empty($translation)) { |
|
954 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
955 | + } |
|
907 | 956 | |
908 | 957 | return strtr($string, $translation); |
909 | 958 | } |
@@ -925,8 +974,9 @@ discard block |
||
925 | 974 | global $smcFunc; |
926 | 975 | |
927 | 976 | // It was already short enough! |
928 | - if ($smcFunc['strlen']($subject) <= $len) |
|
929 | - return $subject; |
|
977 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
978 | + return $subject; |
|
979 | + } |
|
930 | 980 | |
931 | 981 | // Shorten it by the length it was too long, and strip off junk from the end. |
932 | 982 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -945,10 +995,11 @@ discard block |
||
945 | 995 | { |
946 | 996 | global $user_info, $modSettings; |
947 | 997 | |
948 | - if ($timestamp === null) |
|
949 | - $timestamp = time(); |
|
950 | - elseif ($timestamp == 0) |
|
951 | - return 0; |
|
998 | + if ($timestamp === null) { |
|
999 | + $timestamp = time(); |
|
1000 | + } elseif ($timestamp == 0) { |
|
1001 | + return 0; |
|
1002 | + } |
|
952 | 1003 | |
953 | 1004 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
954 | 1005 | } |
@@ -977,8 +1028,9 @@ discard block |
||
977 | 1028 | $array[$i] = $array[$j]; |
978 | 1029 | $array[$j] = $temp; |
979 | 1030 | |
980 | - for ($i = 1; $p[$i] == 0; $i++) |
|
981 | - $p[$i] = 1; |
|
1031 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
1032 | + $p[$i] = 1; |
|
1033 | + } |
|
982 | 1034 | |
983 | 1035 | $orders[] = $array; |
984 | 1036 | } |
@@ -1010,12 +1062,14 @@ discard block |
||
1010 | 1062 | static $disabled; |
1011 | 1063 | |
1012 | 1064 | // Don't waste cycles |
1013 | - if ($message === '') |
|
1014 | - return ''; |
|
1065 | + if ($message === '') { |
|
1066 | + return ''; |
|
1067 | + } |
|
1015 | 1068 | |
1016 | 1069 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
1017 | - if (!isset($context['utf8'])) |
|
1018 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1070 | + if (!isset($context['utf8'])) { |
|
1071 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1072 | + } |
|
1019 | 1073 | |
1020 | 1074 | // Clean up any cut/paste issues we may have |
1021 | 1075 | $message = sanitizeMSCutPaste($message); |
@@ -1027,13 +1081,15 @@ discard block |
||
1027 | 1081 | return $message; |
1028 | 1082 | } |
1029 | 1083 | |
1030 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
1031 | - $smileys = (bool) $smileys; |
|
1084 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
1085 | + $smileys = (bool) $smileys; |
|
1086 | + } |
|
1032 | 1087 | |
1033 | 1088 | if (empty($modSettings['enableBBC']) && $message !== false) |
1034 | 1089 | { |
1035 | - if ($smileys === true) |
|
1036 | - parsesmileys($message); |
|
1090 | + if ($smileys === true) { |
|
1091 | + parsesmileys($message); |
|
1092 | + } |
|
1037 | 1093 | |
1038 | 1094 | return $message; |
1039 | 1095 | } |
@@ -1046,8 +1102,9 @@ discard block |
||
1046 | 1102 | } |
1047 | 1103 | |
1048 | 1104 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
1049 | - if (!empty($modSettings['autoLinkUrls'])) |
|
1050 | - set_tld_regex(); |
|
1105 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
1106 | + set_tld_regex(); |
|
1107 | + } |
|
1051 | 1108 | |
1052 | 1109 | // Allow mods access before entering the main parse_bbc loop |
1053 | 1110 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1061,12 +1118,14 @@ discard block |
||
1061 | 1118 | |
1062 | 1119 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
1063 | 1120 | |
1064 | - foreach ($temp as $tag) |
|
1065 | - $disabled[trim($tag)] = true; |
|
1121 | + foreach ($temp as $tag) { |
|
1122 | + $disabled[trim($tag)] = true; |
|
1123 | + } |
|
1066 | 1124 | } |
1067 | 1125 | |
1068 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1069 | - $disabled['flash'] = true; |
|
1126 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1127 | + $disabled['flash'] = true; |
|
1128 | + } |
|
1070 | 1129 | |
1071 | 1130 | /* The following bbc are formatted as an array, with keys as follows: |
1072 | 1131 | |
@@ -1187,8 +1246,9 @@ discard block |
||
1187 | 1246 | $returnContext = ''; |
1188 | 1247 | |
1189 | 1248 | // BBC or the entire attachments feature is disabled |
1190 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
1191 | - return $data; |
|
1249 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
1250 | + return $data; |
|
1251 | + } |
|
1192 | 1252 | |
1193 | 1253 | // Save the attach ID. |
1194 | 1254 | $attachID = $data; |
@@ -1199,8 +1259,9 @@ discard block |
||
1199 | 1259 | $currentAttachment = parseAttachBBC($attachID); |
1200 | 1260 | |
1201 | 1261 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
1202 | - if (is_string($currentAttachment)) |
|
1203 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1262 | + if (is_string($currentAttachment)) { |
|
1263 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1264 | + } |
|
1204 | 1265 | |
1205 | 1266 | if (!empty($currentAttachment['is_image'])) |
1206 | 1267 | { |
@@ -1216,15 +1277,17 @@ discard block |
||
1216 | 1277 | $height = ' height="' . $currentAttachment['height'] . '"'; |
1217 | 1278 | } |
1218 | 1279 | |
1219 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
1220 | - $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>'; |
|
1221 | - else |
|
1222 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1280 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
1281 | + $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>'; |
|
1282 | + } else { |
|
1283 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1284 | + } |
|
1223 | 1285 | } |
1224 | 1286 | |
1225 | 1287 | // No image. Show a link. |
1226 | - else |
|
1227 | - $returnContext .= $currentAttachment['link']; |
|
1288 | + else { |
|
1289 | + $returnContext .= $currentAttachment['link']; |
|
1290 | + } |
|
1228 | 1291 | |
1229 | 1292 | // Gotta append what we just did. |
1230 | 1293 | $data = $returnContext; |
@@ -1255,8 +1318,9 @@ discard block |
||
1255 | 1318 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1256 | 1319 | { |
1257 | 1320 | // Do PHP code coloring? |
1258 | - if ($php_parts[$php_i] != '<?php') |
|
1259 | - continue; |
|
1321 | + if ($php_parts[$php_i] != '<?php') { |
|
1322 | + continue; |
|
1323 | + } |
|
1260 | 1324 | |
1261 | 1325 | $php_string = ''; |
1262 | 1326 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1272,8 +1336,9 @@ discard block |
||
1272 | 1336 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
1273 | 1337 | |
1274 | 1338 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1275 | - if ($context['browser']['is_opera']) |
|
1276 | - $data .= ' '; |
|
1339 | + if ($context['browser']['is_opera']) { |
|
1340 | + $data .= ' '; |
|
1341 | + } |
|
1277 | 1342 | } |
1278 | 1343 | }, |
1279 | 1344 | 'block_level' => true, |
@@ -1292,8 +1357,9 @@ discard block |
||
1292 | 1357 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1293 | 1358 | { |
1294 | 1359 | // Do PHP code coloring? |
1295 | - if ($php_parts[$php_i] != '<?php') |
|
1296 | - continue; |
|
1360 | + if ($php_parts[$php_i] != '<?php') { |
|
1361 | + continue; |
|
1362 | + } |
|
1297 | 1363 | |
1298 | 1364 | $php_string = ''; |
1299 | 1365 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1309,8 +1375,9 @@ discard block |
||
1309 | 1375 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
1310 | 1376 | |
1311 | 1377 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1312 | - if ($context['browser']['is_opera']) |
|
1313 | - $data[0] .= ' '; |
|
1378 | + if ($context['browser']['is_opera']) { |
|
1379 | + $data[0] .= ' '; |
|
1380 | + } |
|
1314 | 1381 | } |
1315 | 1382 | }, |
1316 | 1383 | 'block_level' => true, |
@@ -1348,11 +1415,13 @@ discard block |
||
1348 | 1415 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1349 | 1416 | 'validate' => function (&$tag, &$data, $disabled) |
1350 | 1417 | { |
1351 | - if (isset($disabled['url'])) |
|
1352 | - $tag['content'] = '$1'; |
|
1418 | + if (isset($disabled['url'])) { |
|
1419 | + $tag['content'] = '$1'; |
|
1420 | + } |
|
1353 | 1421 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
1354 | - if (empty($scheme)) |
|
1355 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
1422 | + if (empty($scheme)) { |
|
1423 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
1424 | + } |
|
1356 | 1425 | }, |
1357 | 1426 | 'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', |
1358 | 1427 | ), |
@@ -1366,10 +1435,11 @@ discard block |
||
1366 | 1435 | { |
1367 | 1436 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1368 | 1437 | |
1369 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
1370 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1371 | - else |
|
1372 | - $css = ''; |
|
1438 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
1439 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1440 | + } else { |
|
1441 | + $css = ''; |
|
1442 | + } |
|
1373 | 1443 | |
1374 | 1444 | $data = $class . $css; |
1375 | 1445 | }, |
@@ -1419,17 +1489,20 @@ discard block |
||
1419 | 1489 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1420 | 1490 | if ($image_proxy_enabled) |
1421 | 1491 | { |
1422 | - if (!empty($user_info['possibly_robot'])) |
|
1423 | - return; |
|
1492 | + if (!empty($user_info['possibly_robot'])) { |
|
1493 | + return; |
|
1494 | + } |
|
1424 | 1495 | |
1425 | - if (empty($scheme)) |
|
1426 | - $data = 'http://' . ltrim($data, ':/'); |
|
1496 | + if (empty($scheme)) { |
|
1497 | + $data = 'http://' . ltrim($data, ':/'); |
|
1498 | + } |
|
1427 | 1499 | |
1428 | - if ($scheme != 'https') |
|
1429 | - $data = get_proxied_url($data); |
|
1500 | + if ($scheme != 'https') { |
|
1501 | + $data = get_proxied_url($data); |
|
1502 | + } |
|
1503 | + } elseif (empty($scheme)) { |
|
1504 | + $data = '//' . ltrim($data, ':/'); |
|
1430 | 1505 | } |
1431 | - elseif (empty($scheme)) |
|
1432 | - $data = '//' . ltrim($data, ':/'); |
|
1433 | 1506 | }, |
1434 | 1507 | 'disabled_content' => '($1)', |
1435 | 1508 | ), |
@@ -1445,17 +1518,20 @@ discard block |
||
1445 | 1518 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1446 | 1519 | if ($image_proxy_enabled) |
1447 | 1520 | { |
1448 | - if (!empty($user_info['possibly_robot'])) |
|
1449 | - return; |
|
1521 | + if (!empty($user_info['possibly_robot'])) { |
|
1522 | + return; |
|
1523 | + } |
|
1450 | 1524 | |
1451 | - if (empty($scheme)) |
|
1452 | - $data = 'http://' . ltrim($data, ':/'); |
|
1525 | + if (empty($scheme)) { |
|
1526 | + $data = 'http://' . ltrim($data, ':/'); |
|
1527 | + } |
|
1453 | 1528 | |
1454 | - if ($scheme != 'https') |
|
1455 | - $data = get_proxied_url($data); |
|
1529 | + if ($scheme != 'https') { |
|
1530 | + $data = get_proxied_url($data); |
|
1531 | + } |
|
1532 | + } elseif (empty($scheme)) { |
|
1533 | + $data = '//' . ltrim($data, ':/'); |
|
1456 | 1534 | } |
1457 | - elseif (empty($scheme)) |
|
1458 | - $data = '//' . ltrim($data, ':/'); |
|
1459 | 1535 | }, |
1460 | 1536 | 'disabled_content' => '($1)', |
1461 | 1537 | ), |
@@ -1467,8 +1543,9 @@ discard block |
||
1467 | 1543 | { |
1468 | 1544 | $data = strtr($data, array('<br>' => '')); |
1469 | 1545 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1470 | - if (empty($scheme)) |
|
1471 | - $data = '//' . ltrim($data, ':/'); |
|
1546 | + if (empty($scheme)) { |
|
1547 | + $data = '//' . ltrim($data, ':/'); |
|
1548 | + } |
|
1472 | 1549 | }, |
1473 | 1550 | ), |
1474 | 1551 | array( |
@@ -1479,13 +1556,14 @@ discard block |
||
1479 | 1556 | 'after' => '</a>', |
1480 | 1557 | 'validate' => function (&$tag, &$data, $disabled) |
1481 | 1558 | { |
1482 | - if (substr($data, 0, 1) == '#') |
|
1483 | - $data = '#post_' . substr($data, 1); |
|
1484 | - else |
|
1559 | + if (substr($data, 0, 1) == '#') { |
|
1560 | + $data = '#post_' . substr($data, 1); |
|
1561 | + } else |
|
1485 | 1562 | { |
1486 | 1563 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1487 | - if (empty($scheme)) |
|
1488 | - $data = '//' . ltrim($data, ':/'); |
|
1564 | + if (empty($scheme)) { |
|
1565 | + $data = '//' . ltrim($data, ':/'); |
|
1566 | + } |
|
1489 | 1567 | } |
1490 | 1568 | }, |
1491 | 1569 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1569,8 +1647,9 @@ discard block |
||
1569 | 1647 | { |
1570 | 1648 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1571 | 1649 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1572 | - if ($add_begin) |
|
1573 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1650 | + if ($add_begin) { |
|
1651 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1652 | + } |
|
1574 | 1653 | } |
1575 | 1654 | }, |
1576 | 1655 | 'block_level' => false, |
@@ -1701,10 +1780,11 @@ discard block |
||
1701 | 1780 | 'content' => '$1', |
1702 | 1781 | 'validate' => function (&$tag, &$data, $disabled) |
1703 | 1782 | { |
1704 | - if (is_numeric($data)) |
|
1705 | - $data = timeformat($data); |
|
1706 | - else |
|
1707 | - $tag['content'] = '[time]$1[/time]'; |
|
1783 | + if (is_numeric($data)) { |
|
1784 | + $data = timeformat($data); |
|
1785 | + } else { |
|
1786 | + $tag['content'] = '[time]$1[/time]'; |
|
1787 | + } |
|
1708 | 1788 | }, |
1709 | 1789 | ), |
1710 | 1790 | array( |
@@ -1731,8 +1811,9 @@ discard block |
||
1731 | 1811 | { |
1732 | 1812 | $data = strtr($data, array('<br>' => '')); |
1733 | 1813 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1734 | - if (empty($scheme)) |
|
1735 | - $data = '//' . ltrim($data, ':/'); |
|
1814 | + if (empty($scheme)) { |
|
1815 | + $data = '//' . ltrim($data, ':/'); |
|
1816 | + } |
|
1736 | 1817 | }, |
1737 | 1818 | ), |
1738 | 1819 | array( |
@@ -1744,8 +1825,9 @@ discard block |
||
1744 | 1825 | 'validate' => function (&$tag, &$data, $disabled) |
1745 | 1826 | { |
1746 | 1827 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1747 | - if (empty($scheme)) |
|
1748 | - $data = '//' . ltrim($data, ':/'); |
|
1828 | + if (empty($scheme)) { |
|
1829 | + $data = '//' . ltrim($data, ':/'); |
|
1830 | + } |
|
1749 | 1831 | }, |
1750 | 1832 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1751 | 1833 | 'disabled_after' => ' ($1)', |
@@ -1771,8 +1853,9 @@ discard block |
||
1771 | 1853 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1772 | 1854 | if ($message === false) |
1773 | 1855 | { |
1774 | - if (isset($temp_bbc)) |
|
1775 | - $bbc_codes = $temp_bbc; |
|
1856 | + if (isset($temp_bbc)) { |
|
1857 | + $bbc_codes = $temp_bbc; |
|
1858 | + } |
|
1776 | 1859 | usort($codes, function ($a, $b) { |
1777 | 1860 | return strcmp($a['tag'], $b['tag']); |
1778 | 1861 | }); |
@@ -1792,8 +1875,9 @@ discard block |
||
1792 | 1875 | ); |
1793 | 1876 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1794 | 1877 | { |
1795 | - foreach ($itemcodes as $c => $dummy) |
|
1796 | - $bbc_codes[$c] = array(); |
|
1878 | + foreach ($itemcodes as $c => $dummy) { |
|
1879 | + $bbc_codes[$c] = array(); |
|
1880 | + } |
|
1797 | 1881 | } |
1798 | 1882 | |
1799 | 1883 | // Shhhh! |
@@ -1814,12 +1898,14 @@ discard block |
||
1814 | 1898 | foreach ($codes as $code) |
1815 | 1899 | { |
1816 | 1900 | // Make it easier to process parameters later |
1817 | - if (!empty($code['parameters'])) |
|
1818 | - ksort($code['parameters'], SORT_STRING); |
|
1901 | + if (!empty($code['parameters'])) { |
|
1902 | + ksort($code['parameters'], SORT_STRING); |
|
1903 | + } |
|
1819 | 1904 | |
1820 | 1905 | // If we are not doing every tag only do ones we are interested in. |
1821 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1822 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1906 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1907 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1908 | + } |
|
1823 | 1909 | } |
1824 | 1910 | $codes = null; |
1825 | 1911 | } |
@@ -1830,8 +1916,9 @@ discard block |
||
1830 | 1916 | // It's likely this will change if the message is modified. |
1831 | 1917 | $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']); |
1832 | 1918 | |
1833 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1834 | - return $temp; |
|
1919 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1920 | + return $temp; |
|
1921 | + } |
|
1835 | 1922 | |
1836 | 1923 | $cache_t = microtime(); |
1837 | 1924 | } |
@@ -1863,8 +1950,9 @@ discard block |
||
1863 | 1950 | $disabled['flash'] = true; |
1864 | 1951 | |
1865 | 1952 | // @todo Change maybe? |
1866 | - if (!isset($_GET['images'])) |
|
1867 | - $disabled['img'] = true; |
|
1953 | + if (!isset($_GET['images'])) { |
|
1954 | + $disabled['img'] = true; |
|
1955 | + } |
|
1868 | 1956 | |
1869 | 1957 | // @todo Interface/setting to add more? |
1870 | 1958 | } |
@@ -1875,8 +1963,9 @@ discard block |
||
1875 | 1963 | $alltags = array(); |
1876 | 1964 | foreach ($bbc_codes as $section) |
1877 | 1965 | { |
1878 | - foreach ($section as $code) |
|
1879 | - $alltags[] = $code['tag']; |
|
1966 | + foreach ($section as $code) { |
|
1967 | + $alltags[] = $code['tag']; |
|
1968 | + } |
|
1880 | 1969 | } |
1881 | 1970 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
1882 | 1971 | |
@@ -1888,8 +1977,9 @@ discard block |
||
1888 | 1977 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1889 | 1978 | |
1890 | 1979 | // Failsafe. |
1891 | - if ($pos === false || $last_pos > $pos) |
|
1892 | - $pos = strlen($message) + 1; |
|
1980 | + if ($pos === false || $last_pos > $pos) { |
|
1981 | + $pos = strlen($message) + 1; |
|
1982 | + } |
|
1893 | 1983 | |
1894 | 1984 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1895 | 1985 | if ($last_pos < $pos - 1) |
@@ -1907,8 +1997,9 @@ discard block |
||
1907 | 1997 | |
1908 | 1998 | // <br> should be empty. |
1909 | 1999 | $empty_tags = array('br', 'hr'); |
1910 | - foreach ($empty_tags as $tag) |
|
1911 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
2000 | + foreach ($empty_tags as $tag) { |
|
2001 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
2002 | + } |
|
1912 | 2003 | |
1913 | 2004 | // b, u, i, s, pre... basic tags. |
1914 | 2005 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1917,8 +2008,9 @@ discard block |
||
1917 | 2008 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1918 | 2009 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1919 | 2010 | |
1920 | - if ($diff > 0) |
|
1921 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2011 | + if ($diff > 0) { |
|
2012 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2013 | + } |
|
1922 | 2014 | } |
1923 | 2015 | |
1924 | 2016 | // Do <img ...> - with security... action= -> action-. |
@@ -1931,8 +2023,9 @@ discard block |
||
1931 | 2023 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1932 | 2024 | |
1933 | 2025 | // Remove action= from the URL - no funny business, now. |
1934 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1935 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2026 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
2027 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2028 | + } |
|
1936 | 2029 | |
1937 | 2030 | $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
1938 | 2031 | } |
@@ -1947,16 +2040,18 @@ discard block |
||
1947 | 2040 | $no_autolink_area = false; |
1948 | 2041 | if (!empty($open_tags)) |
1949 | 2042 | { |
1950 | - foreach ($open_tags as $open_tag) |
|
1951 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2043 | + foreach ($open_tags as $open_tag) { |
|
2044 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1952 | 2045 | $no_autolink_area = true; |
2046 | + } |
|
1953 | 2047 | } |
1954 | 2048 | |
1955 | 2049 | // Don't go backwards. |
1956 | 2050 | // @todo Don't think is the real solution.... |
1957 | 2051 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1958 | - if ($pos < $lastAutoPos) |
|
1959 | - $no_autolink_area = true; |
|
2052 | + if ($pos < $lastAutoPos) { |
|
2053 | + $no_autolink_area = true; |
|
2054 | + } |
|
1960 | 2055 | $lastAutoPos = $pos; |
1961 | 2056 | |
1962 | 2057 | if (!$no_autolink_area) |
@@ -2061,29 +2156,33 @@ discard block |
||
2061 | 2156 | $url = array_shift($matches); |
2062 | 2157 | |
2063 | 2158 | // If this isn't a clean URL, bail out |
2064 | - if ($url != sanitize_iri($url)) |
|
2065 | - return $url; |
|
2159 | + if ($url != sanitize_iri($url)) { |
|
2160 | + return $url; |
|
2161 | + } |
|
2066 | 2162 | |
2067 | 2163 | $scheme = parse_url($url, PHP_URL_SCHEME); |
2068 | 2164 | |
2069 | 2165 | if ($scheme == 'mailto') |
2070 | 2166 | { |
2071 | 2167 | $email_address = str_replace('mailto:', '', $url); |
2072 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2073 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2074 | - else |
|
2075 | - return $url; |
|
2168 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2169 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2170 | + } else { |
|
2171 | + return $url; |
|
2172 | + } |
|
2076 | 2173 | } |
2077 | 2174 | |
2078 | 2175 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2079 | - if (empty($scheme)) |
|
2080 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2081 | - else |
|
2082 | - $fullUrl = $url; |
|
2176 | + if (empty($scheme)) { |
|
2177 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2178 | + } else { |
|
2179 | + $fullUrl = $url; |
|
2180 | + } |
|
2083 | 2181 | |
2084 | 2182 | // Make sure that $fullUrl really is valid |
2085 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
2086 | - return $url; |
|
2183 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) { |
|
2184 | + return $url; |
|
2185 | + } |
|
2087 | 2186 | |
2088 | 2187 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2089 | 2188 | }, $data); |
@@ -2132,22 +2231,25 @@ discard block |
||
2132 | 2231 | } |
2133 | 2232 | |
2134 | 2233 | // Are we there yet? Are we there yet? |
2135 | - if ($pos >= strlen($message) - 1) |
|
2136 | - break; |
|
2234 | + if ($pos >= strlen($message) - 1) { |
|
2235 | + break; |
|
2236 | + } |
|
2137 | 2237 | |
2138 | 2238 | $tags = strtolower($message[$pos + 1]); |
2139 | 2239 | |
2140 | 2240 | if ($tags == '/' && !empty($open_tags)) |
2141 | 2241 | { |
2142 | 2242 | $pos2 = strpos($message, ']', $pos + 1); |
2143 | - if ($pos2 == $pos + 2) |
|
2144 | - continue; |
|
2243 | + if ($pos2 == $pos + 2) { |
|
2244 | + continue; |
|
2245 | + } |
|
2145 | 2246 | |
2146 | 2247 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2147 | 2248 | |
2148 | 2249 | // A closing tag that doesn't match any open tags? Skip it. |
2149 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2150 | - continue; |
|
2250 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
2251 | + continue; |
|
2252 | + } |
|
2151 | 2253 | |
2152 | 2254 | $to_close = array(); |
2153 | 2255 | $block_level = null; |
@@ -2155,8 +2257,9 @@ discard block |
||
2155 | 2257 | do |
2156 | 2258 | { |
2157 | 2259 | $tag = array_pop($open_tags); |
2158 | - if (!$tag) |
|
2159 | - break; |
|
2260 | + if (!$tag) { |
|
2261 | + break; |
|
2262 | + } |
|
2160 | 2263 | |
2161 | 2264 | if (!empty($tag['block_level'])) |
2162 | 2265 | { |
@@ -2170,10 +2273,11 @@ discard block |
||
2170 | 2273 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2171 | 2274 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2172 | 2275 | { |
2173 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2174 | - if ($temp['tag'] == $look_for) |
|
2276 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2277 | + if ($temp['tag'] == $look_for) |
|
2175 | 2278 | { |
2176 | 2279 | $block_level = !empty($temp['block_level']); |
2280 | + } |
|
2177 | 2281 | break; |
2178 | 2282 | } |
2179 | 2283 | } |
@@ -2195,15 +2299,15 @@ discard block |
||
2195 | 2299 | { |
2196 | 2300 | $open_tags = $to_close; |
2197 | 2301 | continue; |
2198 | - } |
|
2199 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2302 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2200 | 2303 | { |
2201 | 2304 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2202 | 2305 | { |
2203 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2204 | - if ($temp['tag'] == $look_for) |
|
2306 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2307 | + if ($temp['tag'] == $look_for) |
|
2205 | 2308 | { |
2206 | 2309 | $block_level = !empty($temp['block_level']); |
2310 | + } |
|
2207 | 2311 | break; |
2208 | 2312 | } |
2209 | 2313 | } |
@@ -2211,8 +2315,9 @@ discard block |
||
2211 | 2315 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2212 | 2316 | if (!$block_level) |
2213 | 2317 | { |
2214 | - foreach ($to_close as $tag) |
|
2215 | - array_push($open_tags, $tag); |
|
2318 | + foreach ($to_close as $tag) { |
|
2319 | + array_push($open_tags, $tag); |
|
2320 | + } |
|
2216 | 2321 | continue; |
2217 | 2322 | } |
2218 | 2323 | } |
@@ -2225,14 +2330,17 @@ discard block |
||
2225 | 2330 | |
2226 | 2331 | // See the comment at the end of the big loop - just eating whitespace ;). |
2227 | 2332 | $whitespace_regex = ''; |
2228 | - if (!empty($tag['block_level'])) |
|
2229 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2333 | + if (!empty($tag['block_level'])) { |
|
2334 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2335 | + } |
|
2230 | 2336 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2231 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2232 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2337 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2338 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2339 | + } |
|
2233 | 2340 | |
2234 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2235 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2341 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2342 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2343 | + } |
|
2236 | 2344 | } |
2237 | 2345 | |
2238 | 2346 | if (!empty($to_close)) |
@@ -2245,8 +2353,9 @@ discard block |
||
2245 | 2353 | } |
2246 | 2354 | |
2247 | 2355 | // No tags for this character, so just keep going (fastest possible course.) |
2248 | - if (!isset($bbc_codes[$tags])) |
|
2249 | - continue; |
|
2356 | + if (!isset($bbc_codes[$tags])) { |
|
2357 | + continue; |
|
2358 | + } |
|
2250 | 2359 | |
2251 | 2360 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2252 | 2361 | $tag = null; |
@@ -2255,48 +2364,57 @@ discard block |
||
2255 | 2364 | $pt_strlen = strlen($possible['tag']); |
2256 | 2365 | |
2257 | 2366 | // Not a match? |
2258 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2259 | - continue; |
|
2367 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2368 | + continue; |
|
2369 | + } |
|
2260 | 2370 | |
2261 | 2371 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
2262 | 2372 | |
2263 | 2373 | // A tag is the last char maybe |
2264 | - if ($next_c == '') |
|
2265 | - break; |
|
2374 | + if ($next_c == '') { |
|
2375 | + break; |
|
2376 | + } |
|
2266 | 2377 | |
2267 | 2378 | // A test validation? |
2268 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2269 | - continue; |
|
2379 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2380 | + continue; |
|
2381 | + } |
|
2270 | 2382 | // Do we want parameters? |
2271 | 2383 | elseif (!empty($possible['parameters'])) |
2272 | 2384 | { |
2273 | - if ($next_c != ' ') |
|
2274 | - continue; |
|
2275 | - } |
|
2276 | - elseif (isset($possible['type'])) |
|
2385 | + if ($next_c != ' ') { |
|
2386 | + continue; |
|
2387 | + } |
|
2388 | + } elseif (isset($possible['type'])) |
|
2277 | 2389 | { |
2278 | 2390 | // Do we need an equal sign? |
2279 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2280 | - continue; |
|
2391 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2392 | + continue; |
|
2393 | + } |
|
2281 | 2394 | // Maybe we just want a /... |
2282 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2283 | - continue; |
|
2395 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2396 | + continue; |
|
2397 | + } |
|
2284 | 2398 | // An immediate ]? |
2285 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2286 | - continue; |
|
2399 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2400 | + continue; |
|
2401 | + } |
|
2287 | 2402 | } |
2288 | 2403 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2289 | - elseif ($next_c != ']') |
|
2290 | - continue; |
|
2404 | + elseif ($next_c != ']') { |
|
2405 | + continue; |
|
2406 | + } |
|
2291 | 2407 | |
2292 | 2408 | // Check allowed tree? |
2293 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2294 | - continue; |
|
2295 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2296 | - continue; |
|
2409 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2410 | + continue; |
|
2411 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2412 | + continue; |
|
2413 | + } |
|
2297 | 2414 | // If this is in the list of disallowed child tags, don't parse it. |
2298 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2299 | - continue; |
|
2415 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2416 | + continue; |
|
2417 | + } |
|
2300 | 2418 | |
2301 | 2419 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2302 | 2420 | |
@@ -2308,8 +2426,9 @@ discard block |
||
2308 | 2426 | foreach ($open_tags as $open_quote) |
2309 | 2427 | { |
2310 | 2428 | // Every parent quote this quote has flips the styling |
2311 | - if ($open_quote['tag'] == 'quote') |
|
2312 | - $quote_alt = !$quote_alt; |
|
2429 | + if ($open_quote['tag'] == 'quote') { |
|
2430 | + $quote_alt = !$quote_alt; |
|
2431 | + } |
|
2313 | 2432 | } |
2314 | 2433 | // Add a class to the quote to style alternating blockquotes |
2315 | 2434 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2320,8 +2439,9 @@ discard block |
||
2320 | 2439 | { |
2321 | 2440 | // Build a regular expression for each parameter for the current tag. |
2322 | 2441 | $preg = array(); |
2323 | - foreach ($possible['parameters'] as $p => $info) |
|
2324 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2442 | + foreach ($possible['parameters'] as $p => $info) { |
|
2443 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2444 | + } |
|
2325 | 2445 | |
2326 | 2446 | // Extract the string that potentially holds our parameters. |
2327 | 2447 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2340,24 +2460,27 @@ discard block |
||
2340 | 2460 | |
2341 | 2461 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2342 | 2462 | |
2343 | - if ($match) |
|
2344 | - $blob_counter = count($blobs) + 1; |
|
2463 | + if ($match) { |
|
2464 | + $blob_counter = count($blobs) + 1; |
|
2465 | + } |
|
2345 | 2466 | } |
2346 | 2467 | |
2347 | 2468 | // Didn't match our parameter list, try the next possible. |
2348 | - if (!$match) |
|
2349 | - continue; |
|
2469 | + if (!$match) { |
|
2470 | + continue; |
|
2471 | + } |
|
2350 | 2472 | |
2351 | 2473 | $params = array(); |
2352 | 2474 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2353 | 2475 | { |
2354 | 2476 | $key = strtok(ltrim($matches[$i]), '='); |
2355 | - if (isset($possible['parameters'][$key]['value'])) |
|
2356 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2357 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2358 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2359 | - else |
|
2360 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2477 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2478 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2479 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2480 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2481 | + } else { |
|
2482 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2483 | + } |
|
2361 | 2484 | |
2362 | 2485 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2363 | 2486 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2365,23 +2488,26 @@ discard block |
||
2365 | 2488 | |
2366 | 2489 | foreach ($possible['parameters'] as $p => $info) |
2367 | 2490 | { |
2368 | - if (!isset($params['{' . $p . '}'])) |
|
2369 | - $params['{' . $p . '}'] = ''; |
|
2491 | + if (!isset($params['{' . $p . '}'])) { |
|
2492 | + $params['{' . $p . '}'] = ''; |
|
2493 | + } |
|
2370 | 2494 | } |
2371 | 2495 | |
2372 | 2496 | $tag = $possible; |
2373 | 2497 | |
2374 | 2498 | // Put the parameters into the string. |
2375 | - if (isset($tag['before'])) |
|
2376 | - $tag['before'] = strtr($tag['before'], $params); |
|
2377 | - if (isset($tag['after'])) |
|
2378 | - $tag['after'] = strtr($tag['after'], $params); |
|
2379 | - if (isset($tag['content'])) |
|
2380 | - $tag['content'] = strtr($tag['content'], $params); |
|
2499 | + if (isset($tag['before'])) { |
|
2500 | + $tag['before'] = strtr($tag['before'], $params); |
|
2501 | + } |
|
2502 | + if (isset($tag['after'])) { |
|
2503 | + $tag['after'] = strtr($tag['after'], $params); |
|
2504 | + } |
|
2505 | + if (isset($tag['content'])) { |
|
2506 | + $tag['content'] = strtr($tag['content'], $params); |
|
2507 | + } |
|
2381 | 2508 | |
2382 | 2509 | $pos1 += strlen($given_param_string); |
2383 | - } |
|
2384 | - else |
|
2510 | + } else |
|
2385 | 2511 | { |
2386 | 2512 | $tag = $possible; |
2387 | 2513 | $params = array(); |
@@ -2392,8 +2518,9 @@ discard block |
||
2392 | 2518 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2393 | 2519 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2394 | 2520 | { |
2395 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2396 | - continue; |
|
2521 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2522 | + continue; |
|
2523 | + } |
|
2397 | 2524 | |
2398 | 2525 | $tag = $itemcodes[$message[$pos + 1]]; |
2399 | 2526 | |
@@ -2414,9 +2541,9 @@ discard block |
||
2414 | 2541 | { |
2415 | 2542 | array_pop($open_tags); |
2416 | 2543 | $code = '</li>'; |
2544 | + } else { |
|
2545 | + $code = ''; |
|
2417 | 2546 | } |
2418 | - else |
|
2419 | - $code = ''; |
|
2420 | 2547 | |
2421 | 2548 | // Now we open a new tag. |
2422 | 2549 | $open_tags[] = array( |
@@ -2463,12 +2590,14 @@ discard block |
||
2463 | 2590 | } |
2464 | 2591 | |
2465 | 2592 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2466 | - if ($tag === null) |
|
2467 | - continue; |
|
2593 | + if ($tag === null) { |
|
2594 | + continue; |
|
2595 | + } |
|
2468 | 2596 | |
2469 | 2597 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2470 | - if (isset($inside['disallow_children'])) |
|
2471 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2598 | + if (isset($inside['disallow_children'])) { |
|
2599 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2600 | + } |
|
2472 | 2601 | |
2473 | 2602 | // Is this tag disabled? |
2474 | 2603 | if (isset($disabled[$tag['tag']])) |
@@ -2478,14 +2607,13 @@ discard block |
||
2478 | 2607 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2479 | 2608 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2480 | 2609 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2481 | - } |
|
2482 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2610 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2483 | 2611 | { |
2484 | 2612 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2485 | 2613 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2614 | + } else { |
|
2615 | + $tag['content'] = $tag['disabled_content']; |
|
2486 | 2616 | } |
2487 | - else |
|
2488 | - $tag['content'] = $tag['disabled_content']; |
|
2489 | 2617 | } |
2490 | 2618 | |
2491 | 2619 | // we use this a lot |
@@ -2495,8 +2623,9 @@ discard block |
||
2495 | 2623 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2496 | 2624 | { |
2497 | 2625 | $n = count($open_tags) - 1; |
2498 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2499 | - $n--; |
|
2626 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2627 | + $n--; |
|
2628 | + } |
|
2500 | 2629 | |
2501 | 2630 | // Close all the non block level tags so this tag isn't surrounded by them. |
2502 | 2631 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2508,12 +2637,15 @@ discard block |
||
2508 | 2637 | |
2509 | 2638 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2510 | 2639 | $whitespace_regex = ''; |
2511 | - if (!empty($tag['block_level'])) |
|
2512 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2513 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2514 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2515 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2516 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2640 | + if (!empty($tag['block_level'])) { |
|
2641 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2642 | + } |
|
2643 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2644 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2645 | + } |
|
2646 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2647 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2648 | + } |
|
2517 | 2649 | |
2518 | 2650 | array_pop($open_tags); |
2519 | 2651 | } |
@@ -2534,16 +2666,19 @@ discard block |
||
2534 | 2666 | elseif ($tag['type'] == 'unparsed_content') |
2535 | 2667 | { |
2536 | 2668 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2537 | - if ($pos2 === false) |
|
2538 | - continue; |
|
2669 | + if ($pos2 === false) { |
|
2670 | + continue; |
|
2671 | + } |
|
2539 | 2672 | |
2540 | 2673 | $data = substr($message, $pos1, $pos2 - $pos1); |
2541 | 2674 | |
2542 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2543 | - $data = substr($data, 4); |
|
2675 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2676 | + $data = substr($data, 4); |
|
2677 | + } |
|
2544 | 2678 | |
2545 | - if (isset($tag['validate'])) |
|
2546 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2679 | + if (isset($tag['validate'])) { |
|
2680 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2681 | + } |
|
2547 | 2682 | |
2548 | 2683 | $code = strtr($tag['content'], array('$1' => $data)); |
2549 | 2684 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2558,34 +2693,40 @@ discard block |
||
2558 | 2693 | if (isset($tag['quoted'])) |
2559 | 2694 | { |
2560 | 2695 | $quoted = substr($message, $pos1, 6) == '"'; |
2561 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2562 | - continue; |
|
2696 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2697 | + continue; |
|
2698 | + } |
|
2563 | 2699 | |
2564 | - if ($quoted) |
|
2565 | - $pos1 += 6; |
|
2700 | + if ($quoted) { |
|
2701 | + $pos1 += 6; |
|
2702 | + } |
|
2703 | + } else { |
|
2704 | + $quoted = false; |
|
2566 | 2705 | } |
2567 | - else |
|
2568 | - $quoted = false; |
|
2569 | 2706 | |
2570 | 2707 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2571 | - if ($pos2 === false) |
|
2572 | - continue; |
|
2708 | + if ($pos2 === false) { |
|
2709 | + continue; |
|
2710 | + } |
|
2573 | 2711 | |
2574 | 2712 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2575 | - if ($pos3 === false) |
|
2576 | - continue; |
|
2713 | + if ($pos3 === false) { |
|
2714 | + continue; |
|
2715 | + } |
|
2577 | 2716 | |
2578 | 2717 | $data = array( |
2579 | 2718 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2580 | 2719 | substr($message, $pos1, $pos2 - $pos1) |
2581 | 2720 | ); |
2582 | 2721 | |
2583 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2584 | - $data[0] = substr($data[0], 4); |
|
2722 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2723 | + $data[0] = substr($data[0], 4); |
|
2724 | + } |
|
2585 | 2725 | |
2586 | 2726 | // Validation for my parking, please! |
2587 | - if (isset($tag['validate'])) |
|
2588 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2727 | + if (isset($tag['validate'])) { |
|
2728 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2729 | + } |
|
2589 | 2730 | |
2590 | 2731 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2591 | 2732 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2602,23 +2743,27 @@ discard block |
||
2602 | 2743 | elseif ($tag['type'] == 'unparsed_commas_content') |
2603 | 2744 | { |
2604 | 2745 | $pos2 = strpos($message, ']', $pos1); |
2605 | - if ($pos2 === false) |
|
2606 | - continue; |
|
2746 | + if ($pos2 === false) { |
|
2747 | + continue; |
|
2748 | + } |
|
2607 | 2749 | |
2608 | 2750 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2609 | - if ($pos3 === false) |
|
2610 | - continue; |
|
2751 | + if ($pos3 === false) { |
|
2752 | + continue; |
|
2753 | + } |
|
2611 | 2754 | |
2612 | 2755 | // We want $1 to be the content, and the rest to be csv. |
2613 | 2756 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2614 | 2757 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2615 | 2758 | |
2616 | - if (isset($tag['validate'])) |
|
2617 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2759 | + if (isset($tag['validate'])) { |
|
2760 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2761 | + } |
|
2618 | 2762 | |
2619 | 2763 | $code = $tag['content']; |
2620 | - foreach ($data as $k => $d) |
|
2621 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2764 | + foreach ($data as $k => $d) { |
|
2765 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2766 | + } |
|
2622 | 2767 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2623 | 2768 | $pos += strlen($code) - 1 + 2; |
2624 | 2769 | } |
@@ -2626,24 +2771,28 @@ discard block |
||
2626 | 2771 | elseif ($tag['type'] == 'unparsed_commas') |
2627 | 2772 | { |
2628 | 2773 | $pos2 = strpos($message, ']', $pos1); |
2629 | - if ($pos2 === false) |
|
2630 | - continue; |
|
2774 | + if ($pos2 === false) { |
|
2775 | + continue; |
|
2776 | + } |
|
2631 | 2777 | |
2632 | 2778 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2633 | 2779 | |
2634 | - if (isset($tag['validate'])) |
|
2635 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2780 | + if (isset($tag['validate'])) { |
|
2781 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2782 | + } |
|
2636 | 2783 | |
2637 | 2784 | // Fix after, for disabled code mainly. |
2638 | - foreach ($data as $k => $d) |
|
2639 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2785 | + foreach ($data as $k => $d) { |
|
2786 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2787 | + } |
|
2640 | 2788 | |
2641 | 2789 | $open_tags[] = $tag; |
2642 | 2790 | |
2643 | 2791 | // Replace them out, $1, $2, $3, $4, etc. |
2644 | 2792 | $code = $tag['before']; |
2645 | - foreach ($data as $k => $d) |
|
2646 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2793 | + foreach ($data as $k => $d) { |
|
2794 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2795 | + } |
|
2647 | 2796 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2648 | 2797 | $pos += strlen($code) - 1 + 2; |
2649 | 2798 | } |
@@ -2654,28 +2803,33 @@ discard block |
||
2654 | 2803 | if (isset($tag['quoted'])) |
2655 | 2804 | { |
2656 | 2805 | $quoted = substr($message, $pos1, 6) == '"'; |
2657 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2658 | - continue; |
|
2806 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2807 | + continue; |
|
2808 | + } |
|
2659 | 2809 | |
2660 | - if ($quoted) |
|
2661 | - $pos1 += 6; |
|
2810 | + if ($quoted) { |
|
2811 | + $pos1 += 6; |
|
2812 | + } |
|
2813 | + } else { |
|
2814 | + $quoted = false; |
|
2662 | 2815 | } |
2663 | - else |
|
2664 | - $quoted = false; |
|
2665 | 2816 | |
2666 | 2817 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2667 | - if ($pos2 === false) |
|
2668 | - continue; |
|
2818 | + if ($pos2 === false) { |
|
2819 | + continue; |
|
2820 | + } |
|
2669 | 2821 | |
2670 | 2822 | $data = substr($message, $pos1, $pos2 - $pos1); |
2671 | 2823 | |
2672 | 2824 | // Validation for my parking, please! |
2673 | - if (isset($tag['validate'])) |
|
2674 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2825 | + if (isset($tag['validate'])) { |
|
2826 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2827 | + } |
|
2675 | 2828 | |
2676 | 2829 | // For parsed content, we must recurse to avoid security problems. |
2677 | - if ($tag['type'] != 'unparsed_equals') |
|
2678 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2830 | + if ($tag['type'] != 'unparsed_equals') { |
|
2831 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2832 | + } |
|
2679 | 2833 | |
2680 | 2834 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2681 | 2835 | |
@@ -2687,34 +2841,40 @@ discard block |
||
2687 | 2841 | } |
2688 | 2842 | |
2689 | 2843 | // If this is block level, eat any breaks after it. |
2690 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2691 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2844 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2845 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2846 | + } |
|
2692 | 2847 | |
2693 | 2848 | // Are we trimming outside this tag? |
2694 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2695 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2849 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2850 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2851 | + } |
|
2696 | 2852 | } |
2697 | 2853 | |
2698 | 2854 | // Close any remaining tags. |
2699 | - while ($tag = array_pop($open_tags)) |
|
2700 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2855 | + while ($tag = array_pop($open_tags)) { |
|
2856 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2857 | + } |
|
2701 | 2858 | |
2702 | 2859 | // Parse the smileys within the parts where it can be done safely. |
2703 | 2860 | if ($smileys === true) |
2704 | 2861 | { |
2705 | 2862 | $message_parts = explode("\n", $message); |
2706 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2707 | - parsesmileys($message_parts[$i]); |
|
2863 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2864 | + parsesmileys($message_parts[$i]); |
|
2865 | + } |
|
2708 | 2866 | |
2709 | 2867 | $message = implode('', $message_parts); |
2710 | 2868 | } |
2711 | 2869 | |
2712 | 2870 | // No smileys, just get rid of the markers. |
2713 | - else |
|
2714 | - $message = strtr($message, array("\n" => '')); |
|
2871 | + else { |
|
2872 | + $message = strtr($message, array("\n" => '')); |
|
2873 | + } |
|
2715 | 2874 | |
2716 | - if ($message !== '' && $message[0] === ' ') |
|
2717 | - $message = ' ' . substr($message, 1); |
|
2875 | + if ($message !== '' && $message[0] === ' ') { |
|
2876 | + $message = ' ' . substr($message, 1); |
|
2877 | + } |
|
2718 | 2878 | |
2719 | 2879 | // Cleanup whitespace. |
2720 | 2880 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2723,15 +2883,16 @@ discard block |
||
2723 | 2883 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2724 | 2884 | |
2725 | 2885 | // Cache the output if it took some time... |
2726 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2727 | - cache_put_data($cache_key, $message, 240); |
|
2886 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2887 | + cache_put_data($cache_key, $message, 240); |
|
2888 | + } |
|
2728 | 2889 | |
2729 | 2890 | // If this was a force parse revert if needed. |
2730 | 2891 | if (!empty($parse_tags)) |
2731 | 2892 | { |
2732 | - if (empty($temp_bbc)) |
|
2733 | - $bbc_codes = array(); |
|
2734 | - else |
|
2893 | + if (empty($temp_bbc)) { |
|
2894 | + $bbc_codes = array(); |
|
2895 | + } else |
|
2735 | 2896 | { |
2736 | 2897 | $bbc_codes = $temp_bbc; |
2737 | 2898 | unset($temp_bbc); |
@@ -2758,8 +2919,9 @@ discard block |
||
2758 | 2919 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2759 | 2920 | |
2760 | 2921 | // No smiley set at all?! |
2761 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2762 | - return; |
|
2922 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2923 | + return; |
|
2924 | + } |
|
2763 | 2925 | |
2764 | 2926 | // If smileyPregSearch hasn't been set, do it now. |
2765 | 2927 | if (empty($smileyPregSearch)) |
@@ -2770,8 +2932,7 @@ discard block |
||
2770 | 2932 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2771 | 2933 | $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'); |
2772 | 2934 | $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'], '', '', '', ''); |
2773 | - } |
|
2774 | - else |
|
2935 | + } else |
|
2775 | 2936 | { |
2776 | 2937 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2777 | 2938 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2795,9 +2956,9 @@ discard block |
||
2795 | 2956 | $smcFunc['db_free_result']($result); |
2796 | 2957 | |
2797 | 2958 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2959 | + } else { |
|
2960 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2798 | 2961 | } |
2799 | - else |
|
2800 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2801 | 2962 | } |
2802 | 2963 | |
2803 | 2964 | // The non-breaking-space is a complex thing... |
@@ -2875,12 +3036,14 @@ discard block |
||
2875 | 3036 | global $boardurl, $image_proxy_enabled, $image_proxy_secret; |
2876 | 3037 | |
2877 | 3038 | // Only use the proxy if enabled and necessary |
2878 | - if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') |
|
2879 | - return $url; |
|
3039 | + if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') { |
|
3040 | + return $url; |
|
3041 | + } |
|
2880 | 3042 | |
2881 | 3043 | // We don't need to proxy our own resources |
2882 | - if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) |
|
2883 | - return strtr($url, array('http://' => 'https://')); |
|
3044 | + if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) { |
|
3045 | + return strtr($url, array('http://' => 'https://')); |
|
3046 | + } |
|
2884 | 3047 | |
2885 | 3048 | // By default, use SMF's own image proxy script |
2886 | 3049 | $proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret); |
@@ -2905,35 +3068,41 @@ discard block |
||
2905 | 3068 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2906 | 3069 | |
2907 | 3070 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2908 | - if (!empty($context['flush_mail'])) |
|
2909 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3071 | + if (!empty($context['flush_mail'])) { |
|
3072 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2910 | 3073 | AddMailQueue(true); |
3074 | + } |
|
2911 | 3075 | |
2912 | 3076 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2913 | 3077 | |
2914 | - if ($add) |
|
2915 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3078 | + if ($add) { |
|
3079 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3080 | + } |
|
2916 | 3081 | |
2917 | 3082 | // Put the session ID in. |
2918 | - if (defined('SID') && SID != '') |
|
2919 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3083 | + if (defined('SID') && SID != '') { |
|
3084 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3085 | + } |
|
2920 | 3086 | // Keep that debug in their for template debugging! |
2921 | - elseif (isset($_GET['debug'])) |
|
2922 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3087 | + elseif (isset($_GET['debug'])) { |
|
3088 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3089 | + } |
|
2923 | 3090 | |
2924 | 3091 | 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']))) |
2925 | 3092 | { |
2926 | - if (defined('SID') && SID != '') |
|
2927 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3093 | + if (defined('SID') && SID != '') { |
|
3094 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2928 | 3095 | function ($m) use ($scripturl) |
2929 | 3096 | { |
2930 | 3097 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3098 | + } |
|
2931 | 3099 | }, $setLocation); |
2932 | - else |
|
2933 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3100 | + else { |
|
3101 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2934 | 3102 | function ($m) use ($scripturl) |
2935 | 3103 | { |
2936 | 3104 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3105 | + } |
|
2937 | 3106 | }, $setLocation); |
2938 | 3107 | } |
2939 | 3108 | |
@@ -2944,8 +3113,9 @@ discard block |
||
2944 | 3113 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2945 | 3114 | |
2946 | 3115 | // Debugging. |
2947 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2948 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3116 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3117 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3118 | + } |
|
2949 | 3119 | |
2950 | 3120 | obExit(false); |
2951 | 3121 | } |
@@ -2964,51 +3134,60 @@ discard block |
||
2964 | 3134 | |
2965 | 3135 | // Attempt to prevent a recursive loop. |
2966 | 3136 | ++$level; |
2967 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2968 | - exit; |
|
2969 | - if ($from_fatal_error) |
|
2970 | - $has_fatal_error = true; |
|
3137 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3138 | + exit; |
|
3139 | + } |
|
3140 | + if ($from_fatal_error) { |
|
3141 | + $has_fatal_error = true; |
|
3142 | + } |
|
2971 | 3143 | |
2972 | 3144 | // Clear out the stat cache. |
2973 | 3145 | trackStats(); |
2974 | 3146 | |
2975 | 3147 | // If we have mail to send, send it. |
2976 | - if (!empty($context['flush_mail'])) |
|
2977 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3148 | + if (!empty($context['flush_mail'])) { |
|
3149 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2978 | 3150 | AddMailQueue(true); |
3151 | + } |
|
2979 | 3152 | |
2980 | 3153 | $do_header = $header === null ? !$header_done : $header; |
2981 | - if ($do_footer === null) |
|
2982 | - $do_footer = $do_header; |
|
3154 | + if ($do_footer === null) { |
|
3155 | + $do_footer = $do_header; |
|
3156 | + } |
|
2983 | 3157 | |
2984 | 3158 | // Has the template/header been done yet? |
2985 | 3159 | if ($do_header) |
2986 | 3160 | { |
2987 | 3161 | // Was the page title set last minute? Also update the HTML safe one. |
2988 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2989 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3162 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3163 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3164 | + } |
|
2990 | 3165 | |
2991 | 3166 | // Start up the session URL fixer. |
2992 | 3167 | ob_start('ob_sessrewrite'); |
2993 | 3168 | |
2994 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2995 | - $buffers = explode(',', $settings['output_buffers']); |
|
2996 | - elseif (!empty($settings['output_buffers'])) |
|
2997 | - $buffers = $settings['output_buffers']; |
|
2998 | - else |
|
2999 | - $buffers = array(); |
|
3169 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3170 | + $buffers = explode(',', $settings['output_buffers']); |
|
3171 | + } elseif (!empty($settings['output_buffers'])) { |
|
3172 | + $buffers = $settings['output_buffers']; |
|
3173 | + } else { |
|
3174 | + $buffers = array(); |
|
3175 | + } |
|
3000 | 3176 | |
3001 | - if (isset($modSettings['integrate_buffer'])) |
|
3002 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3177 | + if (isset($modSettings['integrate_buffer'])) { |
|
3178 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3179 | + } |
|
3003 | 3180 | |
3004 | - if (!empty($buffers)) |
|
3005 | - foreach ($buffers as $function) |
|
3181 | + if (!empty($buffers)) { |
|
3182 | + foreach ($buffers as $function) |
|
3006 | 3183 | { |
3007 | 3184 | $call = call_helper($function, true); |
3185 | + } |
|
3008 | 3186 | |
3009 | 3187 | // Is it valid? |
3010 | - if (!empty($call)) |
|
3011 | - ob_start($call); |
|
3188 | + if (!empty($call)) { |
|
3189 | + ob_start($call); |
|
3190 | + } |
|
3012 | 3191 | } |
3013 | 3192 | |
3014 | 3193 | // Display the screen in the logical order. |
@@ -3020,8 +3199,9 @@ discard block |
||
3020 | 3199 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
3021 | 3200 | |
3022 | 3201 | // Anything special to put out? |
3023 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
3024 | - echo $context['insert_after_template']; |
|
3202 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3203 | + echo $context['insert_after_template']; |
|
3204 | + } |
|
3025 | 3205 | |
3026 | 3206 | // Just so we don't get caught in an endless loop of errors from the footer... |
3027 | 3207 | if (!$footer_done) |
@@ -3030,14 +3210,16 @@ discard block |
||
3030 | 3210 | template_footer(); |
3031 | 3211 | |
3032 | 3212 | // (since this is just debugging... it's okay that it's after </html>.) |
3033 | - if (!isset($_REQUEST['xml'])) |
|
3034 | - displayDebug(); |
|
3213 | + if (!isset($_REQUEST['xml'])) { |
|
3214 | + displayDebug(); |
|
3215 | + } |
|
3035 | 3216 | } |
3036 | 3217 | } |
3037 | 3218 | |
3038 | 3219 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
3039 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
3040 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3220 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3221 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3222 | + } |
|
3041 | 3223 | |
3042 | 3224 | // For session check verification.... don't switch browsers... |
3043 | 3225 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3046,9 +3228,10 @@ discard block |
||
3046 | 3228 | call_integration_hook('integrate_exit', array($do_footer)); |
3047 | 3229 | |
3048 | 3230 | // Don't exit if we're coming from index.php; that will pass through normally. |
3049 | - if (!$from_index) |
|
3050 | - exit; |
|
3051 | -} |
|
3231 | + if (!$from_index) { |
|
3232 | + exit; |
|
3233 | + } |
|
3234 | + } |
|
3052 | 3235 | |
3053 | 3236 | /** |
3054 | 3237 | * Get the size of a specified image with better error handling. |
@@ -3067,8 +3250,9 @@ discard block |
||
3067 | 3250 | $url = str_replace(' ', '%20', $url); |
3068 | 3251 | |
3069 | 3252 | // Can we pull this from the cache... please please? |
3070 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3071 | - return $temp; |
|
3253 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3254 | + return $temp; |
|
3255 | + } |
|
3072 | 3256 | $t = microtime(); |
3073 | 3257 | |
3074 | 3258 | // Get the host to pester... |
@@ -3078,12 +3262,10 @@ discard block |
||
3078 | 3262 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3079 | 3263 | { |
3080 | 3264 | return false; |
3081 | - } |
|
3082 | - elseif (!isset($match[1])) |
|
3265 | + } elseif (!isset($match[1])) |
|
3083 | 3266 | { |
3084 | 3267 | $size = @getimagesize($url); |
3085 | - } |
|
3086 | - else |
|
3268 | + } else |
|
3087 | 3269 | { |
3088 | 3270 | // Try to connect to the server... give it half a second. |
3089 | 3271 | $temp = 0; |
@@ -3120,12 +3302,14 @@ discard block |
||
3120 | 3302 | } |
3121 | 3303 | |
3122 | 3304 | // If we didn't get it, we failed. |
3123 | - if (!isset($size)) |
|
3124 | - $size = false; |
|
3305 | + if (!isset($size)) { |
|
3306 | + $size = false; |
|
3307 | + } |
|
3125 | 3308 | |
3126 | 3309 | // If this took a long time, we may never have to do it again, but then again we might... |
3127 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3128 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3310 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3311 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3312 | + } |
|
3129 | 3313 | |
3130 | 3314 | // Didn't work. |
3131 | 3315 | return $size; |
@@ -3143,8 +3327,9 @@ discard block |
||
3143 | 3327 | |
3144 | 3328 | // Under SSI this function can be called more then once. That can cause some problems. |
3145 | 3329 | // So only run the function once unless we are forced to run it again. |
3146 | - if ($loaded && !$forceload) |
|
3147 | - return; |
|
3330 | + if ($loaded && !$forceload) { |
|
3331 | + return; |
|
3332 | + } |
|
3148 | 3333 | |
3149 | 3334 | $loaded = true; |
3150 | 3335 | |
@@ -3156,14 +3341,16 @@ discard block |
||
3156 | 3341 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3157 | 3342 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3158 | 3343 | { |
3159 | - if (trim($context['news_lines'][$i]) == '') |
|
3160 | - continue; |
|
3344 | + if (trim($context['news_lines'][$i]) == '') { |
|
3345 | + continue; |
|
3346 | + } |
|
3161 | 3347 | |
3162 | 3348 | // Clean it up for presentation ;). |
3163 | 3349 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3164 | 3350 | } |
3165 | - if (!empty($context['news_lines'])) |
|
3166 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3351 | + if (!empty($context['news_lines'])) { |
|
3352 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3353 | + } |
|
3167 | 3354 | |
3168 | 3355 | if (!$user_info['is_guest']) |
3169 | 3356 | { |
@@ -3172,40 +3359,48 @@ discard block |
||
3172 | 3359 | $context['user']['alerts'] = &$user_info['alerts']; |
3173 | 3360 | |
3174 | 3361 | // Personal message popup... |
3175 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3176 | - $context['user']['popup_messages'] = true; |
|
3177 | - else |
|
3178 | - $context['user']['popup_messages'] = false; |
|
3362 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3363 | + $context['user']['popup_messages'] = true; |
|
3364 | + } else { |
|
3365 | + $context['user']['popup_messages'] = false; |
|
3366 | + } |
|
3179 | 3367 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3180 | 3368 | |
3181 | - if (allowedTo('moderate_forum')) |
|
3182 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3369 | + if (allowedTo('moderate_forum')) { |
|
3370 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3371 | + } |
|
3183 | 3372 | |
3184 | 3373 | $context['user']['avatar'] = array(); |
3185 | 3374 | |
3186 | 3375 | // Check for gravatar first since we might be forcing them... |
3187 | 3376 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3188 | 3377 | { |
3189 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3190 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3191 | - else |
|
3192 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3378 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3379 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3380 | + } else { |
|
3381 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3382 | + } |
|
3193 | 3383 | } |
3194 | 3384 | // Uploaded? |
3195 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3196 | - $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'; |
|
3385 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3386 | + $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'; |
|
3387 | + } |
|
3197 | 3388 | // Full URL? |
3198 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3199 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3389 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3390 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3391 | + } |
|
3200 | 3392 | // Otherwise we assume it's server stored. |
3201 | - elseif ($user_info['avatar']['url'] != '') |
|
3202 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3393 | + elseif ($user_info['avatar']['url'] != '') { |
|
3394 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3395 | + } |
|
3203 | 3396 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3204 | - else |
|
3205 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3397 | + else { |
|
3398 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3399 | + } |
|
3206 | 3400 | |
3207 | - if (!empty($context['user']['avatar'])) |
|
3208 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3401 | + if (!empty($context['user']['avatar'])) { |
|
3402 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3403 | + } |
|
3209 | 3404 | |
3210 | 3405 | // Figure out how long they've been logged in. |
3211 | 3406 | $context['user']['total_time_logged_in'] = array( |
@@ -3213,8 +3408,7 @@ discard block |
||
3213 | 3408 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3214 | 3409 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3215 | 3410 | ); |
3216 | - } |
|
3217 | - else |
|
3411 | + } else |
|
3218 | 3412 | { |
3219 | 3413 | $context['user']['messages'] = 0; |
3220 | 3414 | $context['user']['unread_messages'] = 0; |
@@ -3222,12 +3416,14 @@ discard block |
||
3222 | 3416 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3223 | 3417 | $context['user']['popup_messages'] = false; |
3224 | 3418 | |
3225 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3226 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3419 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3420 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3421 | + } |
|
3227 | 3422 | |
3228 | 3423 | // If we've upgraded recently, go easy on the passwords. |
3229 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3230 | - $context['disable_login_hashing'] = true; |
|
3424 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3425 | + $context['disable_login_hashing'] = true; |
|
3426 | + } |
|
3231 | 3427 | } |
3232 | 3428 | |
3233 | 3429 | // Setup the main menu items. |
@@ -3240,8 +3436,8 @@ discard block |
||
3240 | 3436 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3241 | 3437 | |
3242 | 3438 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3243 | - if ($context['show_pm_popup']) |
|
3244 | - addInlineJavaScript(' |
|
3439 | + if ($context['show_pm_popup']) { |
|
3440 | + addInlineJavaScript(' |
|
3245 | 3441 | jQuery(document).ready(function($) { |
3246 | 3442 | new smc_Popup({ |
3247 | 3443 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3249,24 +3445,28 @@ discard block |
||
3249 | 3445 | icon_class: \'generic_icons mail_new\' |
3250 | 3446 | }); |
3251 | 3447 | });'); |
3448 | + } |
|
3252 | 3449 | |
3253 | 3450 | // Add a generic "Are you sure?" confirmation message. |
3254 | 3451 | addInlineJavaScript(' |
3255 | 3452 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3256 | 3453 | |
3257 | 3454 | // Now add the capping code for avatars. |
3258 | - 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') |
|
3259 | - addInlineCss(' |
|
3455 | + 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') { |
|
3456 | + addInlineCss(' |
|
3260 | 3457 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3458 | + } |
|
3261 | 3459 | |
3262 | 3460 | // Add max image limits |
3263 | - if (!empty($modSettings['max_image_width'])) |
|
3264 | - addInlineCss(' |
|
3461 | + if (!empty($modSettings['max_image_width'])) { |
|
3462 | + addInlineCss(' |
|
3265 | 3463 | .postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }'); |
3464 | + } |
|
3266 | 3465 | |
3267 | - if (!empty($modSettings['max_image_height'])) |
|
3268 | - addInlineCss(' |
|
3466 | + if (!empty($modSettings['max_image_height'])) { |
|
3467 | + addInlineCss(' |
|
3269 | 3468 | .postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }'); |
3469 | + } |
|
3270 | 3470 | |
3271 | 3471 | // This looks weird, but it's because BoardIndex.php references the variable. |
3272 | 3472 | $context['common_stats']['latest_member'] = array( |
@@ -3283,11 +3483,13 @@ discard block |
||
3283 | 3483 | ); |
3284 | 3484 | $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']); |
3285 | 3485 | |
3286 | - if (empty($settings['theme_version'])) |
|
3287 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3486 | + if (empty($settings['theme_version'])) { |
|
3487 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3488 | + } |
|
3288 | 3489 | |
3289 | - if (!isset($context['page_title'])) |
|
3290 | - $context['page_title'] = ''; |
|
3490 | + if (!isset($context['page_title'])) { |
|
3491 | + $context['page_title'] = ''; |
|
3492 | + } |
|
3291 | 3493 | |
3292 | 3494 | // Set some specific vars. |
3293 | 3495 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3297,21 +3499,23 @@ discard block |
||
3297 | 3499 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3298 | 3500 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3299 | 3501 | |
3300 | - if (!empty($context['meta_keywords'])) |
|
3301 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3502 | + if (!empty($context['meta_keywords'])) { |
|
3503 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3504 | + } |
|
3302 | 3505 | |
3303 | - if (!empty($context['canonical_url'])) |
|
3304 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3506 | + if (!empty($context['canonical_url'])) { |
|
3507 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3508 | + } |
|
3305 | 3509 | |
3306 | - if (!empty($settings['og_image'])) |
|
3307 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3510 | + if (!empty($settings['og_image'])) { |
|
3511 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3512 | + } |
|
3308 | 3513 | |
3309 | 3514 | if (!empty($context['meta_description'])) |
3310 | 3515 | { |
3311 | 3516 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3312 | 3517 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3313 | - } |
|
3314 | - else |
|
3518 | + } else |
|
3315 | 3519 | { |
3316 | 3520 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3317 | 3521 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3336,8 +3540,9 @@ discard block |
||
3336 | 3540 | $memory_needed = memoryReturnBytes($needed); |
3337 | 3541 | |
3338 | 3542 | // should we account for how much is currently being used? |
3339 | - if ($in_use) |
|
3340 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3543 | + if ($in_use) { |
|
3544 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3545 | + } |
|
3341 | 3546 | |
3342 | 3547 | // if more is needed, request it |
3343 | 3548 | if ($memory_current < $memory_needed) |
@@ -3360,8 +3565,9 @@ discard block |
||
3360 | 3565 | */ |
3361 | 3566 | function memoryReturnBytes($val) |
3362 | 3567 | { |
3363 | - if (is_integer($val)) |
|
3364 | - return $val; |
|
3568 | + if (is_integer($val)) { |
|
3569 | + return $val; |
|
3570 | + } |
|
3365 | 3571 | |
3366 | 3572 | // Separate the number from the designator |
3367 | 3573 | $val = trim($val); |
@@ -3397,10 +3603,11 @@ discard block |
||
3397 | 3603 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3398 | 3604 | |
3399 | 3605 | // Are we debugging the template/html content? |
3400 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3401 | - header('content-type: application/xhtml+xml'); |
|
3402 | - elseif (!isset($_REQUEST['xml'])) |
|
3403 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3606 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3607 | + header('content-type: application/xhtml+xml'); |
|
3608 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3609 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3610 | + } |
|
3404 | 3611 | } |
3405 | 3612 | |
3406 | 3613 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3409,8 +3616,9 @@ discard block |
||
3409 | 3616 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3410 | 3617 | { |
3411 | 3618 | $position = array_search('body', $context['template_layers']); |
3412 | - if ($position === false) |
|
3413 | - $position = array_search('main', $context['template_layers']); |
|
3619 | + if ($position === false) { |
|
3620 | + $position = array_search('main', $context['template_layers']); |
|
3621 | + } |
|
3414 | 3622 | |
3415 | 3623 | if ($position !== false) |
3416 | 3624 | { |
@@ -3438,23 +3646,25 @@ discard block |
||
3438 | 3646 | |
3439 | 3647 | foreach ($securityFiles as $i => $securityFile) |
3440 | 3648 | { |
3441 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3442 | - unset($securityFiles[$i]); |
|
3649 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3650 | + unset($securityFiles[$i]); |
|
3651 | + } |
|
3443 | 3652 | } |
3444 | 3653 | |
3445 | 3654 | // We are already checking so many files...just few more doesn't make any difference! :P |
3446 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3447 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3448 | - |
|
3449 | - else |
|
3450 | - $path = $modSettings['attachmentUploadDir']; |
|
3655 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3656 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3657 | + } else { |
|
3658 | + $path = $modSettings['attachmentUploadDir']; |
|
3659 | + } |
|
3451 | 3660 | |
3452 | 3661 | secureDirectory($path, true); |
3453 | 3662 | secureDirectory($cachedir); |
3454 | 3663 | |
3455 | 3664 | // If agreement is enabled, at least the english version shall exists |
3456 | - if ($modSettings['requireAgreement']) |
|
3457 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3665 | + if ($modSettings['requireAgreement']) { |
|
3666 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3667 | + } |
|
3458 | 3668 | |
3459 | 3669 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3460 | 3670 | { |
@@ -3469,18 +3679,21 @@ discard block |
||
3469 | 3679 | echo ' |
3470 | 3680 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3471 | 3681 | |
3472 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3473 | - echo ' |
|
3682 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3683 | + echo ' |
|
3474 | 3684 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3685 | + } |
|
3475 | 3686 | } |
3476 | 3687 | |
3477 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3478 | - echo ' |
|
3688 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3689 | + echo ' |
|
3479 | 3690 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3691 | + } |
|
3480 | 3692 | |
3481 | - if (!empty($agreement)) |
|
3482 | - echo ' |
|
3693 | + if (!empty($agreement)) { |
|
3694 | + echo ' |
|
3483 | 3695 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3696 | + } |
|
3484 | 3697 | |
3485 | 3698 | echo ' |
3486 | 3699 | </p> |
@@ -3495,16 +3708,18 @@ discard block |
||
3495 | 3708 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3496 | 3709 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3497 | 3710 | |
3498 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3499 | - echo ' |
|
3711 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3712 | + echo ' |
|
3500 | 3713 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3714 | + } |
|
3501 | 3715 | |
3502 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3503 | - echo ' |
|
3716 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3717 | + echo ' |
|
3504 | 3718 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3505 | - else |
|
3506 | - echo ' |
|
3719 | + } else { |
|
3720 | + echo ' |
|
3507 | 3721 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3722 | + } |
|
3508 | 3723 | |
3509 | 3724 | echo ' |
3510 | 3725 | </div>'; |
@@ -3520,8 +3735,9 @@ discard block |
||
3520 | 3735 | global $forum_copyright, $software_year, $forum_version; |
3521 | 3736 | |
3522 | 3737 | // Don't display copyright for things like SSI. |
3523 | - if (!isset($forum_version) || !isset($software_year)) |
|
3524 | - return; |
|
3738 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3739 | + return; |
|
3740 | + } |
|
3525 | 3741 | |
3526 | 3742 | // Put in the version... |
3527 | 3743 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3539,9 +3755,10 @@ discard block |
||
3539 | 3755 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
3540 | 3756 | $context['load_queries'] = $db_count; |
3541 | 3757 | |
3542 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3543 | - loadSubTemplate($layer . '_below', true); |
|
3544 | -} |
|
3758 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3759 | + loadSubTemplate($layer . '_below', true); |
|
3760 | + } |
|
3761 | + } |
|
3545 | 3762 | |
3546 | 3763 | /** |
3547 | 3764 | * Output the Javascript files |
@@ -3575,8 +3792,7 @@ discard block |
||
3575 | 3792 | { |
3576 | 3793 | echo ' |
3577 | 3794 | var ', $key, ';'; |
3578 | - } |
|
3579 | - else |
|
3795 | + } else |
|
3580 | 3796 | { |
3581 | 3797 | echo ' |
3582 | 3798 | var ', $key, ' = ', $value, ';'; |
@@ -3595,27 +3811,29 @@ discard block |
||
3595 | 3811 | foreach ($context['javascript_files'] as $id => $js_file) |
3596 | 3812 | { |
3597 | 3813 | // Last minute call! allow theme authors to disable single files. |
3598 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3599 | - continue; |
|
3814 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3815 | + continue; |
|
3816 | + } |
|
3600 | 3817 | |
3601 | 3818 | // By default files don't get minimized unless the file explicitly says so! |
3602 | 3819 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3603 | 3820 | { |
3604 | - if (!empty($js_file['options']['async'])) |
|
3605 | - $toMinify['async'][] = $js_file; |
|
3606 | - elseif (!empty($js_file['options']['defer'])) |
|
3607 | - $toMinify['defer'][] = $js_file; |
|
3608 | - else |
|
3609 | - $toMinify['standard'][] = $js_file; |
|
3821 | + if (!empty($js_file['options']['async'])) { |
|
3822 | + $toMinify['async'][] = $js_file; |
|
3823 | + } elseif (!empty($js_file['options']['defer'])) { |
|
3824 | + $toMinify['defer'][] = $js_file; |
|
3825 | + } else { |
|
3826 | + $toMinify['standard'][] = $js_file; |
|
3827 | + } |
|
3610 | 3828 | |
3611 | 3829 | // Grab a random seed. |
3612 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
3613 | - $minSeed = $js_file['options']['seed']; |
|
3614 | - } |
|
3615 | - |
|
3616 | - else |
|
3617 | - echo ' |
|
3830 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
3831 | + $minSeed = $js_file['options']['seed']; |
|
3832 | + } |
|
3833 | + } else { |
|
3834 | + echo ' |
|
3618 | 3835 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>'; |
3836 | + } |
|
3619 | 3837 | } |
3620 | 3838 | |
3621 | 3839 | foreach ($toMinify as $js_files) |
@@ -3626,9 +3844,10 @@ discard block |
||
3626 | 3844 | |
3627 | 3845 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3628 | 3846 | |
3629 | - foreach ($result as $minFile) |
|
3630 | - echo ' |
|
3847 | + foreach ($result as $minFile) { |
|
3848 | + echo ' |
|
3631 | 3849 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>'; |
3850 | + } |
|
3632 | 3851 | } |
3633 | 3852 | } |
3634 | 3853 | } |
@@ -3642,8 +3861,9 @@ discard block |
||
3642 | 3861 | <script> |
3643 | 3862 | window.addEventListener("DOMContentLoaded", function() {'; |
3644 | 3863 | |
3645 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3646 | - echo $js_code; |
|
3864 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3865 | + echo $js_code; |
|
3866 | + } |
|
3647 | 3867 | |
3648 | 3868 | echo ' |
3649 | 3869 | }); |
@@ -3655,8 +3875,9 @@ discard block |
||
3655 | 3875 | echo ' |
3656 | 3876 | <script>'; |
3657 | 3877 | |
3658 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3659 | - echo $js_code; |
|
3878 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3879 | + echo $js_code; |
|
3880 | + } |
|
3660 | 3881 | |
3661 | 3882 | echo ' |
3662 | 3883 | </script>'; |
@@ -3684,23 +3905,26 @@ discard block |
||
3684 | 3905 | foreach ($context['css_files'] as $id => $file) |
3685 | 3906 | { |
3686 | 3907 | // Last minute call! allow theme authors to disable single files. |
3687 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3688 | - continue; |
|
3908 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3909 | + continue; |
|
3910 | + } |
|
3689 | 3911 | |
3690 | 3912 | // Files are minimized unless they explicitly opt out. |
3691 | - if (!isset($file['options']['minimize'])) |
|
3692 | - $file['options']['minimize'] = true; |
|
3913 | + if (!isset($file['options']['minimize'])) { |
|
3914 | + $file['options']['minimize'] = true; |
|
3915 | + } |
|
3693 | 3916 | |
3694 | 3917 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3695 | 3918 | { |
3696 | 3919 | $toMinify[] = $file; |
3697 | 3920 | |
3698 | 3921 | // Grab a random seed. |
3699 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
3700 | - $minSeed = $file['options']['seed']; |
|
3922 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
3923 | + $minSeed = $file['options']['seed']; |
|
3924 | + } |
|
3925 | + } else { |
|
3926 | + $normal[] = $file['fileUrl']; |
|
3701 | 3927 | } |
3702 | - else |
|
3703 | - $normal[] = $file['fileUrl']; |
|
3704 | 3928 | } |
3705 | 3929 | |
3706 | 3930 | if (!empty($toMinify)) |
@@ -3709,23 +3933,26 @@ discard block |
||
3709 | 3933 | |
3710 | 3934 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3711 | 3935 | |
3712 | - foreach ($result as $minFile) |
|
3713 | - echo ' |
|
3936 | + foreach ($result as $minFile) { |
|
3937 | + echo ' |
|
3714 | 3938 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
3939 | + } |
|
3715 | 3940 | } |
3716 | 3941 | |
3717 | 3942 | // Print the rest after the minified files. |
3718 | - if (!empty($normal)) |
|
3719 | - foreach ($normal as $nf) |
|
3943 | + if (!empty($normal)) { |
|
3944 | + foreach ($normal as $nf) |
|
3720 | 3945 | echo ' |
3721 | 3946 | <link rel="stylesheet" href="', $nf ,'">'; |
3947 | + } |
|
3722 | 3948 | |
3723 | 3949 | if ($db_show_debug === true) |
3724 | 3950 | { |
3725 | 3951 | // Try to keep only what's useful. |
3726 | 3952 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3727 | - foreach ($context['css_files'] as $file) |
|
3728 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3953 | + foreach ($context['css_files'] as $file) { |
|
3954 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3955 | + } |
|
3729 | 3956 | } |
3730 | 3957 | |
3731 | 3958 | if (!empty($context['css_header'])) |
@@ -3733,9 +3960,10 @@ discard block |
||
3733 | 3960 | echo ' |
3734 | 3961 | <style>'; |
3735 | 3962 | |
3736 | - foreach ($context['css_header'] as $css) |
|
3737 | - echo $css .' |
|
3963 | + foreach ($context['css_header'] as $css) { |
|
3964 | + echo $css .' |
|
3738 | 3965 | '; |
3966 | + } |
|
3739 | 3967 | |
3740 | 3968 | echo' |
3741 | 3969 | </style>'; |
@@ -3758,8 +3986,9 @@ discard block |
||
3758 | 3986 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3759 | 3987 | $data = is_array($data) ? $data : array(); |
3760 | 3988 | |
3761 | - if (empty($type) || empty($data)) |
|
3762 | - return $data; |
|
3989 | + if (empty($type) || empty($data)) { |
|
3990 | + return $data; |
|
3991 | + } |
|
3763 | 3992 | |
3764 | 3993 | // Different pages include different files, so we use a hash to label the different combinations |
3765 | 3994 | $hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data))); |
@@ -3768,13 +3997,14 @@ discard block |
||
3768 | 3997 | list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null); |
3769 | 3998 | |
3770 | 3999 | // Already done? |
3771 | - if (!empty($toCache)) |
|
3772 | - return array('smf_minified' => array( |
|
4000 | + if (!empty($toCache)) { |
|
4001 | + return array('smf_minified' => array( |
|
3773 | 4002 | 'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache), |
3774 | 4003 | 'filePath' => $toCache, |
3775 | 4004 | 'fileName' => basename($toCache), |
3776 | 4005 | 'options' => array('async' => !empty($async), 'defer' => !empty($defer)), |
3777 | 4006 | )); |
4007 | + } |
|
3778 | 4008 | |
3779 | 4009 | |
3780 | 4010 | // No namespaces, sorry! |
@@ -3804,9 +4034,9 @@ discard block |
||
3804 | 4034 | |
3805 | 4035 | foreach ($data as $id => $file) |
3806 | 4036 | { |
3807 | - if (empty($file['filePath'])) |
|
3808 | - $toAdd = false; |
|
3809 | - else |
|
4037 | + if (empty($file['filePath'])) { |
|
4038 | + $toAdd = false; |
|
4039 | + } else |
|
3810 | 4040 | { |
3811 | 4041 | $seed = isset($file['options']['seed']) ? $file['options']['seed'] : ''; |
3812 | 4042 | $tempFile = str_replace($seed, '', $file['filePath']); |
@@ -3814,12 +4044,14 @@ discard block |
||
3814 | 4044 | } |
3815 | 4045 | |
3816 | 4046 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
3817 | - if (empty($file['options']['async'])) |
|
3818 | - $async = false; |
|
4047 | + if (empty($file['options']['async'])) { |
|
4048 | + $async = false; |
|
4049 | + } |
|
3819 | 4050 | |
3820 | 4051 | // A minified script should only be deferred if all its components wanted to be. |
3821 | - if (empty($file['options']['defer'])) |
|
3822 | - $defer = false; |
|
4052 | + if (empty($file['options']['defer'])) { |
|
4053 | + $defer = false; |
|
4054 | + } |
|
3823 | 4055 | |
3824 | 4056 | // The file couldn't be located so it won't be added. Log this error. |
3825 | 4057 | if (empty($toAdd)) |
@@ -3885,12 +4117,14 @@ discard block |
||
3885 | 4117 | foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename) |
3886 | 4118 | { |
3887 | 4119 | // Remove the cache entry |
3888 | - if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) |
|
3889 | - cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
4120 | + if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) { |
|
4121 | + cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
4122 | + } |
|
3890 | 4123 | |
3891 | 4124 | // Try to delete the file. Add it to our error list if it fails. |
3892 | - if (!@unlink($filename)) |
|
3893 | - $not_deleted[] = $filename; |
|
4125 | + if (!@unlink($filename)) { |
|
4126 | + $not_deleted[] = $filename; |
|
4127 | + } |
|
3894 | 4128 | } |
3895 | 4129 | } |
3896 | 4130 | } |
@@ -3922,8 +4156,9 @@ discard block |
||
3922 | 4156 | global $modSettings, $smcFunc; |
3923 | 4157 | |
3924 | 4158 | // Just make up a nice hash... |
3925 | - if ($new) |
|
3926 | - return sha1(md5($filename . time()) . mt_rand()); |
|
4159 | + if ($new) { |
|
4160 | + return sha1(md5($filename . time()) . mt_rand()); |
|
4161 | + } |
|
3927 | 4162 | |
3928 | 4163 | // Just make sure that attachment id is only a int |
3929 | 4164 | $attachment_id = (int) $attachment_id; |
@@ -3940,23 +4175,25 @@ discard block |
||
3940 | 4175 | 'id_attach' => $attachment_id, |
3941 | 4176 | )); |
3942 | 4177 | |
3943 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3944 | - return false; |
|
4178 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4179 | + return false; |
|
4180 | + } |
|
3945 | 4181 | |
3946 | 4182 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3947 | 4183 | $smcFunc['db_free_result']($request); |
3948 | 4184 | } |
3949 | 4185 | |
3950 | 4186 | // Still no hash? mmm... |
3951 | - if (empty($file_hash)) |
|
3952 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4187 | + if (empty($file_hash)) { |
|
4188 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4189 | + } |
|
3953 | 4190 | |
3954 | 4191 | // Are we using multiple directories? |
3955 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3956 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3957 | - |
|
3958 | - else |
|
3959 | - $path = $modSettings['attachmentUploadDir']; |
|
4192 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4193 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4194 | + } else { |
|
4195 | + $path = $modSettings['attachmentUploadDir']; |
|
4196 | + } |
|
3960 | 4197 | |
3961 | 4198 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3962 | 4199 | } |
@@ -3971,8 +4208,9 @@ discard block |
||
3971 | 4208 | function ip2range($fullip) |
3972 | 4209 | { |
3973 | 4210 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3974 | - if ($fullip == 'unknown') |
|
3975 | - $fullip = '255.255.255.255'; |
|
4211 | + if ($fullip == 'unknown') { |
|
4212 | + $fullip = '255.255.255.255'; |
|
4213 | + } |
|
3976 | 4214 | |
3977 | 4215 | $ip_parts = explode('-', $fullip); |
3978 | 4216 | $ip_array = array(); |
@@ -3996,10 +4234,11 @@ discard block |
||
3996 | 4234 | $ip_array['low'] = $ip_parts[0]; |
3997 | 4235 | $ip_array['high'] = $ip_parts[1]; |
3998 | 4236 | return $ip_array; |
3999 | - } |
|
4000 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4237 | + } elseif (count($ip_parts) == 2) { |
|
4238 | + // if ip 22.22.*-22.22.* |
|
4001 | 4239 | { |
4002 | 4240 | $valid_low = isValidIP($ip_parts[0]); |
4241 | + } |
|
4003 | 4242 | $valid_high = isValidIP($ip_parts[1]); |
4004 | 4243 | $count = 0; |
4005 | 4244 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -4014,7 +4253,9 @@ discard block |
||
4014 | 4253 | $ip_parts[0] .= $mode . $min; |
4015 | 4254 | $valid_low = isValidIP($ip_parts[0]); |
4016 | 4255 | $count++; |
4017 | - if ($count > 9) break; |
|
4256 | + if ($count > 9) { |
|
4257 | + break; |
|
4258 | + } |
|
4018 | 4259 | } |
4019 | 4260 | } |
4020 | 4261 | |
@@ -4028,7 +4269,9 @@ discard block |
||
4028 | 4269 | $ip_parts[1] .= $mode . $max; |
4029 | 4270 | $valid_high = isValidIP($ip_parts[1]); |
4030 | 4271 | $count++; |
4031 | - if ($count > 9) break; |
|
4272 | + if ($count > 9) { |
|
4273 | + break; |
|
4274 | + } |
|
4032 | 4275 | } |
4033 | 4276 | } |
4034 | 4277 | |
@@ -4052,46 +4295,54 @@ discard block |
||
4052 | 4295 | { |
4053 | 4296 | global $modSettings; |
4054 | 4297 | |
4055 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
4056 | - return $host; |
|
4298 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4299 | + return $host; |
|
4300 | + } |
|
4057 | 4301 | $t = microtime(); |
4058 | 4302 | |
4059 | 4303 | // Try the Linux host command, perhaps? |
4060 | 4304 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
4061 | 4305 | { |
4062 | - if (!isset($modSettings['host_to_dis'])) |
|
4063 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4064 | - else |
|
4065 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4306 | + if (!isset($modSettings['host_to_dis'])) { |
|
4307 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4308 | + } else { |
|
4309 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4310 | + } |
|
4066 | 4311 | |
4067 | 4312 | // Did host say it didn't find anything? |
4068 | - if (strpos($test, 'not found') !== false) |
|
4069 | - $host = ''; |
|
4313 | + if (strpos($test, 'not found') !== false) { |
|
4314 | + $host = ''; |
|
4315 | + } |
|
4070 | 4316 | // Invalid server option? |
4071 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
4072 | - updateSettings(array('host_to_dis' => 1)); |
|
4317 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4318 | + updateSettings(array('host_to_dis' => 1)); |
|
4319 | + } |
|
4073 | 4320 | // Maybe it found something, after all? |
4074 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
4075 | - $host = $match[1]; |
|
4321 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4322 | + $host = $match[1]; |
|
4323 | + } |
|
4076 | 4324 | } |
4077 | 4325 | |
4078 | 4326 | // This is nslookup; usually only Windows, but possibly some Unix? |
4079 | 4327 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
4080 | 4328 | { |
4081 | 4329 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
4082 | - if (strpos($test, 'Non-existent domain') !== false) |
|
4083 | - $host = ''; |
|
4084 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
4085 | - $host = $match[1]; |
|
4330 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4331 | + $host = ''; |
|
4332 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4333 | + $host = $match[1]; |
|
4334 | + } |
|
4086 | 4335 | } |
4087 | 4336 | |
4088 | 4337 | // This is the last try :/. |
4089 | - if (!isset($host) || $host === false) |
|
4090 | - $host = @gethostbyaddr($ip); |
|
4338 | + if (!isset($host) || $host === false) { |
|
4339 | + $host = @gethostbyaddr($ip); |
|
4340 | + } |
|
4091 | 4341 | |
4092 | 4342 | // It took a long time, so let's cache it! |
4093 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
4094 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4343 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4344 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4345 | + } |
|
4095 | 4346 | |
4096 | 4347 | return $host; |
4097 | 4348 | } |
@@ -4127,20 +4378,21 @@ discard block |
||
4127 | 4378 | { |
4128 | 4379 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
4129 | 4380 | $total = 0; |
4130 | - for ($i = 0; $i < $max_chars; $i++) |
|
4131 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4381 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4382 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4383 | + } |
|
4132 | 4384 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
4133 | 4385 | } |
4134 | 4386 | } |
4135 | 4387 | return array_unique($returned_ints); |
4136 | - } |
|
4137 | - else |
|
4388 | + } else |
|
4138 | 4389 | { |
4139 | 4390 | // Trim characters before and after and add slashes for database insertion. |
4140 | 4391 | $returned_words = array(); |
4141 | - foreach ($words as $word) |
|
4142 | - if (($word = trim($word, '-_\'')) !== '') |
|
4392 | + foreach ($words as $word) { |
|
4393 | + if (($word = trim($word, '-_\'')) !== '') |
|
4143 | 4394 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4395 | + } |
|
4144 | 4396 | |
4145 | 4397 | // Filter out all words that occur more than once. |
4146 | 4398 | return array_unique($returned_words); |
@@ -4162,16 +4414,18 @@ discard block |
||
4162 | 4414 | global $settings, $txt; |
4163 | 4415 | |
4164 | 4416 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4165 | - if (function_exists('template_create_button') && !$force_use) |
|
4166 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4417 | + if (function_exists('template_create_button') && !$force_use) { |
|
4418 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4419 | + } |
|
4167 | 4420 | |
4168 | - if (!$settings['use_image_buttons']) |
|
4169 | - return $txt[$alt]; |
|
4170 | - elseif (!empty($settings['use_buttons'])) |
|
4171 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4172 | - else |
|
4173 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4174 | -} |
|
4421 | + if (!$settings['use_image_buttons']) { |
|
4422 | + return $txt[$alt]; |
|
4423 | + } elseif (!empty($settings['use_buttons'])) { |
|
4424 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4425 | + } else { |
|
4426 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4427 | + } |
|
4428 | + } |
|
4175 | 4429 | |
4176 | 4430 | /** |
4177 | 4431 | * Sets up all of the top menu buttons |
@@ -4214,9 +4468,10 @@ discard block |
||
4214 | 4468 | var user_menus = new smc_PopupMenu(); |
4215 | 4469 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4216 | 4470 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4217 | - if ($context['allow_pm']) |
|
4218 | - addInlineJavaScript(' |
|
4471 | + if ($context['allow_pm']) { |
|
4472 | + addInlineJavaScript(' |
|
4219 | 4473 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4474 | + } |
|
4220 | 4475 | |
4221 | 4476 | if (!empty($modSettings['enable_ajax_alerts'])) |
4222 | 4477 | { |
@@ -4376,88 +4631,96 @@ discard block |
||
4376 | 4631 | |
4377 | 4632 | // Now we put the buttons in the context so the theme can use them. |
4378 | 4633 | $menu_buttons = array(); |
4379 | - foreach ($buttons as $act => $button) |
|
4380 | - if (!empty($button['show'])) |
|
4634 | + foreach ($buttons as $act => $button) { |
|
4635 | + if (!empty($button['show'])) |
|
4381 | 4636 | { |
4382 | 4637 | $button['active_button'] = false; |
4638 | + } |
|
4383 | 4639 | |
4384 | 4640 | // This button needs some action. |
4385 | - if (isset($button['action_hook'])) |
|
4386 | - $needs_action_hook = true; |
|
4641 | + if (isset($button['action_hook'])) { |
|
4642 | + $needs_action_hook = true; |
|
4643 | + } |
|
4387 | 4644 | |
4388 | 4645 | // Make sure the last button truly is the last button. |
4389 | 4646 | if (!empty($button['is_last'])) |
4390 | 4647 | { |
4391 | - if (isset($last_button)) |
|
4392 | - unset($menu_buttons[$last_button]['is_last']); |
|
4648 | + if (isset($last_button)) { |
|
4649 | + unset($menu_buttons[$last_button]['is_last']); |
|
4650 | + } |
|
4393 | 4651 | $last_button = $act; |
4394 | 4652 | } |
4395 | 4653 | |
4396 | 4654 | // Go through the sub buttons if there are any. |
4397 | - if (!empty($button['sub_buttons'])) |
|
4398 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4655 | + if (!empty($button['sub_buttons'])) { |
|
4656 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4399 | 4657 | { |
4400 | 4658 | if (empty($subbutton['show'])) |
4401 | 4659 | unset($button['sub_buttons'][$key]); |
4660 | + } |
|
4402 | 4661 | |
4403 | 4662 | // 2nd level sub buttons next... |
4404 | 4663 | if (!empty($subbutton['sub_buttons'])) |
4405 | 4664 | { |
4406 | 4665 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4407 | 4666 | { |
4408 | - if (empty($sub_button2['show'])) |
|
4409 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4667 | + if (empty($sub_button2['show'])) { |
|
4668 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4669 | + } |
|
4410 | 4670 | } |
4411 | 4671 | } |
4412 | 4672 | } |
4413 | 4673 | |
4414 | 4674 | // Does this button have its own icon? |
4415 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4416 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4417 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4418 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4419 | - elseif (isset($button['icon'])) |
|
4420 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4421 | - else |
|
4422 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4675 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4676 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4677 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4678 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4679 | + } elseif (isset($button['icon'])) { |
|
4680 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4681 | + } else { |
|
4682 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4683 | + } |
|
4423 | 4684 | |
4424 | 4685 | $menu_buttons[$act] = $button; |
4425 | 4686 | } |
4426 | 4687 | |
4427 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4428 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4688 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4689 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4690 | + } |
|
4429 | 4691 | } |
4430 | 4692 | |
4431 | 4693 | $context['menu_buttons'] = $menu_buttons; |
4432 | 4694 | |
4433 | 4695 | // Logging out requires the session id in the url. |
4434 | - if (isset($context['menu_buttons']['logout'])) |
|
4435 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4696 | + if (isset($context['menu_buttons']['logout'])) { |
|
4697 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4698 | + } |
|
4436 | 4699 | |
4437 | 4700 | // Figure out which action we are doing so we can set the active tab. |
4438 | 4701 | // Default to home. |
4439 | 4702 | $current_action = 'home'; |
4440 | 4703 | |
4441 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4442 | - $current_action = $context['current_action']; |
|
4443 | - elseif ($context['current_action'] == 'search2') |
|
4444 | - $current_action = 'search'; |
|
4445 | - elseif ($context['current_action'] == 'theme') |
|
4446 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4447 | - elseif ($context['current_action'] == 'register2') |
|
4448 | - $current_action = 'register'; |
|
4449 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4450 | - $current_action = 'login'; |
|
4451 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4452 | - $current_action = 'moderate'; |
|
4704 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4705 | + $current_action = $context['current_action']; |
|
4706 | + } elseif ($context['current_action'] == 'search2') { |
|
4707 | + $current_action = 'search'; |
|
4708 | + } elseif ($context['current_action'] == 'theme') { |
|
4709 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4710 | + } elseif ($context['current_action'] == 'register2') { |
|
4711 | + $current_action = 'register'; |
|
4712 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4713 | + $current_action = 'login'; |
|
4714 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4715 | + $current_action = 'moderate'; |
|
4716 | + } |
|
4453 | 4717 | |
4454 | 4718 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4455 | 4719 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4456 | 4720 | { |
4457 | 4721 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4458 | 4722 | $context[$current_action] = true; |
4459 | - } |
|
4460 | - elseif ($context['current_action'] == 'pm') |
|
4723 | + } elseif ($context['current_action'] == 'pm') |
|
4461 | 4724 | { |
4462 | 4725 | $current_action = 'self_pm'; |
4463 | 4726 | $context['self_pm'] = true; |
@@ -4514,12 +4777,14 @@ discard block |
||
4514 | 4777 | } |
4515 | 4778 | |
4516 | 4779 | // Not all actions are simple. |
4517 | - if (!empty($needs_action_hook)) |
|
4518 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4780 | + if (!empty($needs_action_hook)) { |
|
4781 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4782 | + } |
|
4519 | 4783 | |
4520 | - if (isset($context['menu_buttons'][$current_action])) |
|
4521 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4522 | -} |
|
4784 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4785 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4786 | + } |
|
4787 | + } |
|
4523 | 4788 | |
4524 | 4789 | /** |
4525 | 4790 | * Generate a random seed and ensure it's stored in settings. |
@@ -4543,30 +4808,35 @@ discard block |
||
4543 | 4808 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4544 | 4809 | global $context, $txt; |
4545 | 4810 | |
4546 | - if ($db_show_debug === true) |
|
4547 | - $context['debug']['hooks'][] = $hook; |
|
4811 | + if ($db_show_debug === true) { |
|
4812 | + $context['debug']['hooks'][] = $hook; |
|
4813 | + } |
|
4548 | 4814 | |
4549 | 4815 | // Need to have some control. |
4550 | - if (!isset($context['instances'])) |
|
4551 | - $context['instances'] = array(); |
|
4816 | + if (!isset($context['instances'])) { |
|
4817 | + $context['instances'] = array(); |
|
4818 | + } |
|
4552 | 4819 | |
4553 | 4820 | $results = array(); |
4554 | - if (empty($modSettings[$hook])) |
|
4555 | - return $results; |
|
4821 | + if (empty($modSettings[$hook])) { |
|
4822 | + return $results; |
|
4823 | + } |
|
4556 | 4824 | |
4557 | 4825 | $functions = explode(',', $modSettings[$hook]); |
4558 | 4826 | // Loop through each function. |
4559 | 4827 | foreach ($functions as $function) |
4560 | 4828 | { |
4561 | 4829 | // Hook has been marked as "disabled". Skip it! |
4562 | - if (strpos($function, '!') !== false) |
|
4563 | - continue; |
|
4830 | + if (strpos($function, '!') !== false) { |
|
4831 | + continue; |
|
4832 | + } |
|
4564 | 4833 | |
4565 | 4834 | $call = call_helper($function, true); |
4566 | 4835 | |
4567 | 4836 | // Is it valid? |
4568 | - if (!empty($call)) |
|
4569 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4837 | + if (!empty($call)) { |
|
4838 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4839 | + } |
|
4570 | 4840 | |
4571 | 4841 | // Whatever it was suppose to call, it failed :( |
4572 | 4842 | elseif (!empty($function)) |
@@ -4582,8 +4852,9 @@ discard block |
||
4582 | 4852 | } |
4583 | 4853 | |
4584 | 4854 | // "Assume" the file resides on $boarddir somewhere... |
4585 | - else |
|
4586 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4855 | + else { |
|
4856 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4857 | + } |
|
4587 | 4858 | } |
4588 | 4859 | } |
4589 | 4860 | |
@@ -4605,12 +4876,14 @@ discard block |
||
4605 | 4876 | global $smcFunc, $modSettings; |
4606 | 4877 | |
4607 | 4878 | // Any objects? |
4608 | - if ($object) |
|
4609 | - $function = $function . '#'; |
|
4879 | + if ($object) { |
|
4880 | + $function = $function . '#'; |
|
4881 | + } |
|
4610 | 4882 | |
4611 | 4883 | // Any files to load? |
4612 | - if (!empty($file) && is_string($file)) |
|
4613 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4884 | + if (!empty($file) && is_string($file)) { |
|
4885 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4886 | + } |
|
4614 | 4887 | |
4615 | 4888 | // Get the correct string. |
4616 | 4889 | $integration_call = $function; |
@@ -4632,13 +4905,14 @@ discard block |
||
4632 | 4905 | if (!empty($current_functions)) |
4633 | 4906 | { |
4634 | 4907 | $current_functions = explode(',', $current_functions); |
4635 | - if (in_array($integration_call, $current_functions)) |
|
4636 | - return; |
|
4908 | + if (in_array($integration_call, $current_functions)) { |
|
4909 | + return; |
|
4910 | + } |
|
4637 | 4911 | |
4638 | 4912 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4913 | + } else { |
|
4914 | + $permanent_functions = array($integration_call); |
|
4639 | 4915 | } |
4640 | - else |
|
4641 | - $permanent_functions = array($integration_call); |
|
4642 | 4916 | |
4643 | 4917 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4644 | 4918 | } |
@@ -4647,8 +4921,9 @@ discard block |
||
4647 | 4921 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4648 | 4922 | |
4649 | 4923 | // Do nothing, if it's already there. |
4650 | - if (in_array($integration_call, $functions)) |
|
4651 | - return; |
|
4924 | + if (in_array($integration_call, $functions)) { |
|
4925 | + return; |
|
4926 | + } |
|
4652 | 4927 | |
4653 | 4928 | $functions[] = $integration_call; |
4654 | 4929 | $modSettings[$hook] = implode(',', $functions); |
@@ -4671,12 +4946,14 @@ discard block |
||
4671 | 4946 | global $smcFunc, $modSettings; |
4672 | 4947 | |
4673 | 4948 | // Any objects? |
4674 | - if ($object) |
|
4675 | - $function = $function . '#'; |
|
4949 | + if ($object) { |
|
4950 | + $function = $function . '#'; |
|
4951 | + } |
|
4676 | 4952 | |
4677 | 4953 | // Any files to load? |
4678 | - if (!empty($file) && is_string($file)) |
|
4679 | - $function = $file . '|' . $function; |
|
4954 | + if (!empty($file) && is_string($file)) { |
|
4955 | + $function = $file . '|' . $function; |
|
4956 | + } |
|
4680 | 4957 | |
4681 | 4958 | // Get the correct string. |
4682 | 4959 | $integration_call = $function; |
@@ -4697,16 +4974,18 @@ discard block |
||
4697 | 4974 | { |
4698 | 4975 | $current_functions = explode(',', $current_functions); |
4699 | 4976 | |
4700 | - if (in_array($integration_call, $current_functions)) |
|
4701 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4977 | + if (in_array($integration_call, $current_functions)) { |
|
4978 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4979 | + } |
|
4702 | 4980 | } |
4703 | 4981 | |
4704 | 4982 | // Turn the function list into something usable. |
4705 | 4983 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4706 | 4984 | |
4707 | 4985 | // You can only remove it if it's available. |
4708 | - if (!in_array($integration_call, $functions)) |
|
4709 | - return; |
|
4986 | + if (!in_array($integration_call, $functions)) { |
|
4987 | + return; |
|
4988 | + } |
|
4710 | 4989 | |
4711 | 4990 | $functions = array_diff($functions, array($integration_call)); |
4712 | 4991 | $modSettings[$hook] = implode(',', $functions); |
@@ -4727,17 +5006,20 @@ discard block |
||
4727 | 5006 | global $context, $smcFunc, $txt, $db_show_debug; |
4728 | 5007 | |
4729 | 5008 | // Really? |
4730 | - if (empty($string)) |
|
4731 | - return false; |
|
5009 | + if (empty($string)) { |
|
5010 | + return false; |
|
5011 | + } |
|
4732 | 5012 | |
4733 | 5013 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4734 | 5014 | // A closure? should be a callable one. |
4735 | - if (is_array($string) || $string instanceof Closure) |
|
4736 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
5015 | + if (is_array($string) || $string instanceof Closure) { |
|
5016 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
5017 | + } |
|
4737 | 5018 | |
4738 | 5019 | // No full objects, sorry! pass a method or a property instead! |
4739 | - if (is_object($string)) |
|
4740 | - return false; |
|
5020 | + if (is_object($string)) { |
|
5021 | + return false; |
|
5022 | + } |
|
4741 | 5023 | |
4742 | 5024 | // Stay vitaminized my friends... |
4743 | 5025 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4746,8 +5028,9 @@ discard block |
||
4746 | 5028 | $string = load_file($string); |
4747 | 5029 | |
4748 | 5030 | // Loaded file failed |
4749 | - if (empty($string)) |
|
4750 | - return false; |
|
5031 | + if (empty($string)) { |
|
5032 | + return false; |
|
5033 | + } |
|
4751 | 5034 | |
4752 | 5035 | // Found a method. |
4753 | 5036 | if (strpos($string, '::') !== false) |
@@ -4768,8 +5051,9 @@ discard block |
||
4768 | 5051 | // Add another one to the list. |
4769 | 5052 | if ($db_show_debug === true) |
4770 | 5053 | { |
4771 | - if (!isset($context['debug']['instances'])) |
|
4772 | - $context['debug']['instances'] = array(); |
|
5054 | + if (!isset($context['debug']['instances'])) { |
|
5055 | + $context['debug']['instances'] = array(); |
|
5056 | + } |
|
4773 | 5057 | |
4774 | 5058 | $context['debug']['instances'][$class] = $class; |
4775 | 5059 | } |
@@ -4779,13 +5063,15 @@ discard block |
||
4779 | 5063 | } |
4780 | 5064 | |
4781 | 5065 | // Right then. This is a call to a static method. |
4782 | - else |
|
4783 | - $func = array($class, $method); |
|
5066 | + else { |
|
5067 | + $func = array($class, $method); |
|
5068 | + } |
|
4784 | 5069 | } |
4785 | 5070 | |
4786 | 5071 | // Nope! just a plain regular function. |
4787 | - else |
|
4788 | - $func = $string; |
|
5072 | + else { |
|
5073 | + $func = $string; |
|
5074 | + } |
|
4789 | 5075 | |
4790 | 5076 | // Right, we got what we need, time to do some checks. |
4791 | 5077 | if (!is_callable($func, false, $callable_name)) |
@@ -4801,17 +5087,18 @@ discard block |
||
4801 | 5087 | else |
4802 | 5088 | { |
4803 | 5089 | // What are we gonna do about it? |
4804 | - if ($return) |
|
4805 | - return $func; |
|
5090 | + if ($return) { |
|
5091 | + return $func; |
|
5092 | + } |
|
4806 | 5093 | |
4807 | 5094 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4808 | 5095 | else |
4809 | 5096 | { |
4810 | - if (is_array($func)) |
|
4811 | - call_user_func($func); |
|
4812 | - |
|
4813 | - else |
|
4814 | - $func(); |
|
5097 | + if (is_array($func)) { |
|
5098 | + call_user_func($func); |
|
5099 | + } else { |
|
5100 | + $func(); |
|
5101 | + } |
|
4815 | 5102 | } |
4816 | 5103 | } |
4817 | 5104 | } |
@@ -4828,31 +5115,34 @@ discard block |
||
4828 | 5115 | { |
4829 | 5116 | global $sourcedir, $txt, $boarddir, $settings; |
4830 | 5117 | |
4831 | - if (empty($string)) |
|
4832 | - return false; |
|
5118 | + if (empty($string)) { |
|
5119 | + return false; |
|
5120 | + } |
|
4833 | 5121 | |
4834 | 5122 | if (strpos($string, '|') !== false) |
4835 | 5123 | { |
4836 | 5124 | list ($file, $string) = explode('|', $string); |
4837 | 5125 | |
4838 | 5126 | // Match the wildcards to their regular vars. |
4839 | - if (empty($settings['theme_dir'])) |
|
4840 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4841 | - |
|
4842 | - else |
|
4843 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5127 | + if (empty($settings['theme_dir'])) { |
|
5128 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
5129 | + } else { |
|
5130 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5131 | + } |
|
4844 | 5132 | |
4845 | 5133 | // Load the file if it can be loaded. |
4846 | - if (file_exists($absPath)) |
|
4847 | - require_once($absPath); |
|
5134 | + if (file_exists($absPath)) { |
|
5135 | + require_once($absPath); |
|
5136 | + } |
|
4848 | 5137 | |
4849 | 5138 | // No? try a fallback to $sourcedir |
4850 | 5139 | else |
4851 | 5140 | { |
4852 | 5141 | $absPath = $sourcedir .'/'. $file; |
4853 | 5142 | |
4854 | - if (file_exists($absPath)) |
|
4855 | - require_once($absPath); |
|
5143 | + if (file_exists($absPath)) { |
|
5144 | + require_once($absPath); |
|
5145 | + } |
|
4856 | 5146 | |
4857 | 5147 | // Sorry, can't do much for you at this point. |
4858 | 5148 | else |
@@ -4891,8 +5181,9 @@ discard block |
||
4891 | 5181 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
4892 | 5182 | |
4893 | 5183 | // No scheme? No data for you! |
4894 | - if (empty($match[1])) |
|
4895 | - return false; |
|
5184 | + if (empty($match[1])) { |
|
5185 | + return false; |
|
5186 | + } |
|
4896 | 5187 | |
4897 | 5188 | // An FTP url. We should try connecting and RETRieving it... |
4898 | 5189 | elseif ($match[1] == 'ftp') |
@@ -4902,23 +5193,26 @@ discard block |
||
4902 | 5193 | |
4903 | 5194 | // Establish a connection and attempt to enable passive mode. |
4904 | 5195 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
4905 | - if ($ftp->error !== false || !$ftp->passive()) |
|
4906 | - return false; |
|
5196 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
5197 | + return false; |
|
5198 | + } |
|
4907 | 5199 | |
4908 | 5200 | // I want that one *points*! |
4909 | 5201 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
4910 | 5202 | |
4911 | 5203 | // Since passive mode worked (or we would have returned already!) open the connection. |
4912 | 5204 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
4913 | - if (!$fp) |
|
4914 | - return false; |
|
5205 | + if (!$fp) { |
|
5206 | + return false; |
|
5207 | + } |
|
4915 | 5208 | |
4916 | 5209 | // The server should now say something in acknowledgement. |
4917 | 5210 | $ftp->check_response(150); |
4918 | 5211 | |
4919 | 5212 | $data = ''; |
4920 | - while (!feof($fp)) |
|
4921 | - $data .= fread($fp, 4096); |
|
5213 | + while (!feof($fp)) { |
|
5214 | + $data .= fread($fp, 4096); |
|
5215 | + } |
|
4922 | 5216 | fclose($fp); |
4923 | 5217 | |
4924 | 5218 | // All done, right? Good. |
@@ -4930,8 +5224,9 @@ discard block |
||
4930 | 5224 | elseif (isset($match[1]) && $match[1] == 'http') |
4931 | 5225 | { |
4932 | 5226 | // First try to use fsockopen, because it is fastest. |
4933 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
4934 | - $fp = $keep_alive_fp; |
|
5227 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
5228 | + $fp = $keep_alive_fp; |
|
5229 | + } |
|
4935 | 5230 | if (empty($fp)) |
4936 | 5231 | { |
4937 | 5232 | // Open the socket on the port we want... |
@@ -4951,20 +5246,21 @@ discard block |
||
4951 | 5246 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
4952 | 5247 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
4953 | 5248 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
4954 | - if ($keep_alive) |
|
4955 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
4956 | - else |
|
4957 | - fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
4958 | - } |
|
4959 | - else |
|
5249 | + if ($keep_alive) { |
|
5250 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
5251 | + } else { |
|
5252 | + fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
5253 | + } |
|
5254 | + } else |
|
4960 | 5255 | { |
4961 | 5256 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
4962 | 5257 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
4963 | 5258 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
4964 | - if ($keep_alive) |
|
4965 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
4966 | - else |
|
4967 | - fwrite($fp, 'connection: close' . "\r\n"); |
|
5259 | + if ($keep_alive) { |
|
5260 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
5261 | + } else { |
|
5262 | + fwrite($fp, 'connection: close' . "\r\n"); |
|
5263 | + } |
|
4968 | 5264 | fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n"); |
4969 | 5265 | fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n"); |
4970 | 5266 | fwrite($fp, $post_data); |
@@ -4977,30 +5273,33 @@ discard block |
||
4977 | 5273 | { |
4978 | 5274 | $header = ''; |
4979 | 5275 | $location = ''; |
4980 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
4981 | - if (strpos($header, 'location:') !== false) |
|
5276 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
5277 | + if (strpos($header, 'location:') !== false) |
|
4982 | 5278 | $location = trim(substr($header, strpos($header, ':') + 1)); |
5279 | + } |
|
4983 | 5280 | |
4984 | - if (empty($location)) |
|
4985 | - return false; |
|
4986 | - else |
|
5281 | + if (empty($location)) { |
|
5282 | + return false; |
|
5283 | + } else |
|
4987 | 5284 | { |
4988 | - if (!$keep_alive) |
|
4989 | - fclose($fp); |
|
5285 | + if (!$keep_alive) { |
|
5286 | + fclose($fp); |
|
5287 | + } |
|
4990 | 5288 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
4991 | 5289 | } |
4992 | 5290 | } |
4993 | 5291 | |
4994 | 5292 | // Make sure we get a 200 OK. |
4995 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
4996 | - return false; |
|
5293 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
5294 | + return false; |
|
5295 | + } |
|
4997 | 5296 | |
4998 | 5297 | // Skip the headers... |
4999 | 5298 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
5000 | 5299 | { |
5001 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
5002 | - $content_length = $match[1]; |
|
5003 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
5300 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
5301 | + $content_length = $match[1]; |
|
5302 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
5004 | 5303 | { |
5005 | 5304 | $keep_alive_dom = null; |
5006 | 5305 | $keep_alive = false; |
@@ -5012,17 +5311,19 @@ discard block |
||
5012 | 5311 | $data = ''; |
5013 | 5312 | if (isset($content_length)) |
5014 | 5313 | { |
5015 | - while (!feof($fp) && strlen($data) < $content_length) |
|
5016 | - $data .= fread($fp, $content_length - strlen($data)); |
|
5017 | - } |
|
5018 | - else |
|
5314 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
5315 | + $data .= fread($fp, $content_length - strlen($data)); |
|
5316 | + } |
|
5317 | + } else |
|
5019 | 5318 | { |
5020 | - while (!feof($fp)) |
|
5021 | - $data .= fread($fp, 4096); |
|
5319 | + while (!feof($fp)) { |
|
5320 | + $data .= fread($fp, 4096); |
|
5321 | + } |
|
5022 | 5322 | } |
5023 | 5323 | |
5024 | - if (!$keep_alive) |
|
5025 | - fclose($fp); |
|
5324 | + if (!$keep_alive) { |
|
5325 | + fclose($fp); |
|
5326 | + } |
|
5026 | 5327 | } |
5027 | 5328 | |
5028 | 5329 | // If using fsockopen didn't work, try to use cURL if available. |
@@ -5035,17 +5336,18 @@ discard block |
||
5035 | 5336 | $fetch_data->get_url_data($url, $post_data); |
5036 | 5337 | |
5037 | 5338 | // no errors and a 200 result, then we have a good dataset, well we at least have data. ;) |
5038 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
5039 | - $data = $fetch_data->result('body'); |
|
5040 | - else |
|
5041 | - return false; |
|
5339 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
5340 | + $data = $fetch_data->result('body'); |
|
5341 | + } else { |
|
5342 | + return false; |
|
5343 | + } |
|
5042 | 5344 | } |
5043 | 5345 | |
5044 | 5346 | // Neither fsockopen nor curl are available. Well, phooey. |
5045 | - else |
|
5046 | - return false; |
|
5047 | - } |
|
5048 | - else |
|
5347 | + else { |
|
5348 | + return false; |
|
5349 | + } |
|
5350 | + } else |
|
5049 | 5351 | { |
5050 | 5352 | // Umm, this shouldn't happen? |
5051 | 5353 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -5065,8 +5367,9 @@ discard block |
||
5065 | 5367 | global $user_info, $smcFunc; |
5066 | 5368 | |
5067 | 5369 | // Make sure we have something to work with. |
5068 | - if (empty($topic)) |
|
5069 | - return array(); |
|
5370 | + if (empty($topic)) { |
|
5371 | + return array(); |
|
5372 | + } |
|
5070 | 5373 | |
5071 | 5374 | |
5072 | 5375 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -5089,8 +5392,9 @@ discard block |
||
5089 | 5392 | 'topic' => $topic, |
5090 | 5393 | ) |
5091 | 5394 | ); |
5092 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
5093 | - $temp[] = (int) $row['content_id']; |
|
5395 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5396 | + $temp[] = (int) $row['content_id']; |
|
5397 | + } |
|
5094 | 5398 | |
5095 | 5399 | cache_put_data($cache_key, $temp, $ttl); |
5096 | 5400 | } |
@@ -5111,8 +5415,9 @@ discard block |
||
5111 | 5415 | { |
5112 | 5416 | global $context; |
5113 | 5417 | |
5114 | - if (empty($string)) |
|
5115 | - return $string; |
|
5418 | + if (empty($string)) { |
|
5419 | + return $string; |
|
5420 | + } |
|
5116 | 5421 | |
5117 | 5422 | // UTF-8 occurences of MS special characters |
5118 | 5423 | $findchars_utf8 = array( |
@@ -5153,10 +5458,11 @@ discard block |
||
5153 | 5458 | '--', // — |
5154 | 5459 | ); |
5155 | 5460 | |
5156 | - if ($context['utf8']) |
|
5157 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5158 | - else |
|
5159 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5461 | + if ($context['utf8']) { |
|
5462 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5463 | + } else { |
|
5464 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5465 | + } |
|
5160 | 5466 | |
5161 | 5467 | return $string; |
5162 | 5468 | } |
@@ -5175,49 +5481,59 @@ discard block |
||
5175 | 5481 | { |
5176 | 5482 | global $context; |
5177 | 5483 | |
5178 | - if (!isset($matches[2])) |
|
5179 | - return ''; |
|
5484 | + if (!isset($matches[2])) { |
|
5485 | + return ''; |
|
5486 | + } |
|
5180 | 5487 | |
5181 | 5488 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
5182 | 5489 | |
5183 | 5490 | // remove left to right / right to left overrides |
5184 | - if ($num === 0x202D || $num === 0x202E) |
|
5185 | - return ''; |
|
5491 | + if ($num === 0x202D || $num === 0x202E) { |
|
5492 | + return ''; |
|
5493 | + } |
|
5186 | 5494 | |
5187 | 5495 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
5188 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
5189 | - return '&#' . $num . ';'; |
|
5496 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5497 | + return '&#' . $num . ';'; |
|
5498 | + } |
|
5190 | 5499 | |
5191 | 5500 | if (empty($context['utf8'])) |
5192 | 5501 | { |
5193 | 5502 | // no control characters |
5194 | - if ($num < 0x20) |
|
5195 | - return ''; |
|
5503 | + if ($num < 0x20) { |
|
5504 | + return ''; |
|
5505 | + } |
|
5196 | 5506 | // text is text |
5197 | - elseif ($num < 0x80) |
|
5198 | - return chr($num); |
|
5507 | + elseif ($num < 0x80) { |
|
5508 | + return chr($num); |
|
5509 | + } |
|
5199 | 5510 | // all others get html-ised |
5200 | - else |
|
5201 | - return '&#' . $matches[2] . ';'; |
|
5202 | - } |
|
5203 | - else |
|
5511 | + else { |
|
5512 | + return '&#' . $matches[2] . ';'; |
|
5513 | + } |
|
5514 | + } else |
|
5204 | 5515 | { |
5205 | 5516 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
5206 | 5517 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
5207 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
5208 | - return ''; |
|
5518 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5519 | + return ''; |
|
5520 | + } |
|
5209 | 5521 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
5210 | - elseif ($num < 0x80) |
|
5211 | - return chr($num); |
|
5522 | + elseif ($num < 0x80) { |
|
5523 | + return chr($num); |
|
5524 | + } |
|
5212 | 5525 | // <0x800 (2048) |
5213 | - elseif ($num < 0x800) |
|
5214 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5526 | + elseif ($num < 0x800) { |
|
5527 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5528 | + } |
|
5215 | 5529 | // < 0x10000 (65536) |
5216 | - elseif ($num < 0x10000) |
|
5217 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5530 | + elseif ($num < 0x10000) { |
|
5531 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5532 | + } |
|
5218 | 5533 | // <= 0x10FFFF (1114111) |
5219 | - else |
|
5220 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5534 | + else { |
|
5535 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5536 | + } |
|
5221 | 5537 | } |
5222 | 5538 | } |
5223 | 5539 | |
@@ -5233,28 +5549,34 @@ discard block |
||
5233 | 5549 | */ |
5234 | 5550 | function fixchar__callback($matches) |
5235 | 5551 | { |
5236 | - if (!isset($matches[1])) |
|
5237 | - return ''; |
|
5552 | + if (!isset($matches[1])) { |
|
5553 | + return ''; |
|
5554 | + } |
|
5238 | 5555 | |
5239 | 5556 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
5240 | 5557 | |
5241 | 5558 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
5242 | 5559 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
5243 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
5244 | - return ''; |
|
5560 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5561 | + return ''; |
|
5562 | + } |
|
5245 | 5563 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
5246 | - elseif ($num < 0x80) |
|
5247 | - return chr($num); |
|
5564 | + elseif ($num < 0x80) { |
|
5565 | + return chr($num); |
|
5566 | + } |
|
5248 | 5567 | // <0x800 (2048) |
5249 | - elseif ($num < 0x800) |
|
5250 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5568 | + elseif ($num < 0x800) { |
|
5569 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5570 | + } |
|
5251 | 5571 | // < 0x10000 (65536) |
5252 | - elseif ($num < 0x10000) |
|
5253 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5572 | + elseif ($num < 0x10000) { |
|
5573 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5574 | + } |
|
5254 | 5575 | // <= 0x10FFFF (1114111) |
5255 | - else |
|
5256 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5257 | -} |
|
5576 | + else { |
|
5577 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5578 | + } |
|
5579 | + } |
|
5258 | 5580 | |
5259 | 5581 | /** |
5260 | 5582 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -5267,17 +5589,19 @@ discard block |
||
5267 | 5589 | */ |
5268 | 5590 | function entity_fix__callback($matches) |
5269 | 5591 | { |
5270 | - if (!isset($matches[2])) |
|
5271 | - return ''; |
|
5592 | + if (!isset($matches[2])) { |
|
5593 | + return ''; |
|
5594 | + } |
|
5272 | 5595 | |
5273 | 5596 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
5274 | 5597 | |
5275 | 5598 | // we don't allow control characters, characters out of range, byte markers, etc |
5276 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
5277 | - return ''; |
|
5278 | - else |
|
5279 | - return '&#' . $num . ';'; |
|
5280 | -} |
|
5599 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5600 | + return ''; |
|
5601 | + } else { |
|
5602 | + return '&#' . $num . ';'; |
|
5603 | + } |
|
5604 | + } |
|
5281 | 5605 | |
5282 | 5606 | /** |
5283 | 5607 | * Return a Gravatar URL based on |
@@ -5301,18 +5625,23 @@ discard block |
||
5301 | 5625 | $ratings = array('G', 'PG', 'R', 'X'); |
5302 | 5626 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
5303 | 5627 | $url_params = array(); |
5304 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
5305 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5306 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
5307 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5308 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
5309 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5310 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
5311 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5628 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5629 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5630 | + } |
|
5631 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5632 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5633 | + } |
|
5634 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5635 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5636 | + } |
|
5637 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5638 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5312 | 5639 | $size_string = $modSettings['avatar_max_height_external']; |
5640 | + } |
|
5313 | 5641 | |
5314 | - if (!empty($size_string)) |
|
5315 | - $url_params[] = 's=' . $size_string; |
|
5642 | + if (!empty($size_string)) { |
|
5643 | + $url_params[] = 's=' . $size_string; |
|
5644 | + } |
|
5316 | 5645 | } |
5317 | 5646 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
5318 | 5647 | |
@@ -5331,22 +5660,26 @@ discard block |
||
5331 | 5660 | static $timezones = null, $lastwhen = null; |
5332 | 5661 | |
5333 | 5662 | // No point doing this over if we already did it once |
5334 | - if (!empty($timezones) && $when == $lastwhen) |
|
5335 | - return $timezones; |
|
5336 | - else |
|
5337 | - $lastwhen = $when; |
|
5663 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5664 | + return $timezones; |
|
5665 | + } else { |
|
5666 | + $lastwhen = $when; |
|
5667 | + } |
|
5338 | 5668 | |
5339 | 5669 | // Parseable datetime string? |
5340 | - if (is_int($timestamp = strtotime($when))) |
|
5341 | - $when = $timestamp; |
|
5670 | + if (is_int($timestamp = strtotime($when))) { |
|
5671 | + $when = $timestamp; |
|
5672 | + } |
|
5342 | 5673 | |
5343 | 5674 | // A Unix timestamp? |
5344 | - elseif (is_numeric($when)) |
|
5345 | - $when = intval($when); |
|
5675 | + elseif (is_numeric($when)) { |
|
5676 | + $when = intval($when); |
|
5677 | + } |
|
5346 | 5678 | |
5347 | 5679 | // Invalid value? Just get current Unix timestamp. |
5348 | - else |
|
5349 | - $when = time(); |
|
5680 | + else { |
|
5681 | + $when = time(); |
|
5682 | + } |
|
5350 | 5683 | |
5351 | 5684 | // We'll need these too |
5352 | 5685 | $date_when = date_create('@' . $when); |
@@ -5361,8 +5694,9 @@ discard block |
||
5361 | 5694 | foreach ($priority_countries as $country) |
5362 | 5695 | { |
5363 | 5696 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5364 | - if (!empty($country_tzids)) |
|
5365 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5697 | + if (!empty($country_tzids)) { |
|
5698 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5699 | + } |
|
5366 | 5700 | } |
5367 | 5701 | |
5368 | 5702 | // Antarctic research stations should be listed last, unless you're running a penguin forum |
@@ -5376,8 +5710,9 @@ discard block |
||
5376 | 5710 | foreach ($tzids as $tzid) |
5377 | 5711 | { |
5378 | 5712 | // We don't want UTC right now |
5379 | - if ($tzid == 'UTC') |
|
5380 | - continue; |
|
5713 | + if ($tzid == 'UTC') { |
|
5714 | + continue; |
|
5715 | + } |
|
5381 | 5716 | |
5382 | 5717 | $tz = timezone_open($tzid); |
5383 | 5718 | |
@@ -5398,13 +5733,14 @@ discard block |
||
5398 | 5733 | } |
5399 | 5734 | |
5400 | 5735 | // A time zone from a prioritized country? |
5401 | - if (in_array($tzid, $priority_tzids)) |
|
5402 | - $priority_zones[$tzkey] = true; |
|
5736 | + if (in_array($tzid, $priority_tzids)) { |
|
5737 | + $priority_zones[$tzkey] = true; |
|
5738 | + } |
|
5403 | 5739 | |
5404 | 5740 | // Keep track of the location and offset for this tzid |
5405 | - if (!empty($txt[$tzid])) |
|
5406 | - $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
5407 | - else |
|
5741 | + if (!empty($txt[$tzid])) { |
|
5742 | + $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
5743 | + } else |
|
5408 | 5744 | { |
5409 | 5745 | $tzid_parts = explode('/', $tzid); |
5410 | 5746 | $zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop($tzid_parts)); |
@@ -5424,23 +5760,27 @@ discard block |
||
5424 | 5760 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5425 | 5761 | |
5426 | 5762 | // Use the custom description, if there is one |
5427 | - if (!empty($tztxt[$tzvalue['tzid']])) |
|
5428 | - $desc = $tztxt[$tzvalue['tzid']]; |
|
5763 | + if (!empty($tztxt[$tzvalue['tzid']])) { |
|
5764 | + $desc = $tztxt[$tzvalue['tzid']]; |
|
5765 | + } |
|
5429 | 5766 | // Otherwise, use the list of locations (max 5, so things don't get silly) |
5430 | - else |
|
5431 | - $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
5767 | + else { |
|
5768 | + $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
5769 | + } |
|
5432 | 5770 | |
5433 | 5771 | // Show the UTC offset and the abbreviation, if it's something like 'MST' and not '-06' |
5434 | 5772 | $desc = '[UTC' . date_format($date_when, 'P') . '] - ' . (!strspn($tzvalue['abbr'], '+-') ? $tzvalue['abbr'] . ' - ' : '') . $desc; |
5435 | 5773 | |
5436 | - if (isset($priority_zones[$tzkey])) |
|
5437 | - $priority_timezones[$tzvalue['tzid']] = $desc; |
|
5438 | - else |
|
5439 | - $timezones[$tzvalue['tzid']] = $desc; |
|
5774 | + if (isset($priority_zones[$tzkey])) { |
|
5775 | + $priority_timezones[$tzvalue['tzid']] = $desc; |
|
5776 | + } else { |
|
5777 | + $timezones[$tzvalue['tzid']] = $desc; |
|
5778 | + } |
|
5440 | 5779 | } |
5441 | 5780 | |
5442 | - if (!empty($priority_timezones)) |
|
5443 | - $priority_timezones[] = '-----'; |
|
5781 | + if (!empty($priority_timezones)) { |
|
5782 | + $priority_timezones[] = '-----'; |
|
5783 | + } |
|
5444 | 5784 | |
5445 | 5785 | $timezones = array_merge( |
5446 | 5786 | $priority_timezones, |
@@ -5457,8 +5797,9 @@ discard block |
||
5457 | 5797 | */ |
5458 | 5798 | function inet_ptod($ip_address) |
5459 | 5799 | { |
5460 | - if (!isValidIP($ip_address)) |
|
5461 | - return $ip_address; |
|
5800 | + if (!isValidIP($ip_address)) { |
|
5801 | + return $ip_address; |
|
5802 | + } |
|
5462 | 5803 | |
5463 | 5804 | $bin = inet_pton($ip_address); |
5464 | 5805 | return $bin; |
@@ -5470,13 +5811,15 @@ discard block |
||
5470 | 5811 | */ |
5471 | 5812 | function inet_dtop($bin) |
5472 | 5813 | { |
5473 | - if(empty($bin)) |
|
5474 | - return ''; |
|
5814 | + if(empty($bin)) { |
|
5815 | + return ''; |
|
5816 | + } |
|
5475 | 5817 | |
5476 | 5818 | global $db_type; |
5477 | 5819 | |
5478 | - if ($db_type == 'postgresql') |
|
5479 | - return $bin; |
|
5820 | + if ($db_type == 'postgresql') { |
|
5821 | + return $bin; |
|
5822 | + } |
|
5480 | 5823 | |
5481 | 5824 | $ip_address = inet_ntop($bin); |
5482 | 5825 | |
@@ -5501,26 +5844,32 @@ discard block |
||
5501 | 5844 | */ |
5502 | 5845 | function _safe_serialize($value) |
5503 | 5846 | { |
5504 | - if(is_null($value)) |
|
5505 | - return 'N;'; |
|
5847 | + if(is_null($value)) { |
|
5848 | + return 'N;'; |
|
5849 | + } |
|
5506 | 5850 | |
5507 | - if(is_bool($value)) |
|
5508 | - return 'b:'. (int) $value .';'; |
|
5851 | + if(is_bool($value)) { |
|
5852 | + return 'b:'. (int) $value .';'; |
|
5853 | + } |
|
5509 | 5854 | |
5510 | - if(is_int($value)) |
|
5511 | - return 'i:'. $value .';'; |
|
5855 | + if(is_int($value)) { |
|
5856 | + return 'i:'. $value .';'; |
|
5857 | + } |
|
5512 | 5858 | |
5513 | - if(is_float($value)) |
|
5514 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5859 | + if(is_float($value)) { |
|
5860 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5861 | + } |
|
5515 | 5862 | |
5516 | - if(is_string($value)) |
|
5517 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5863 | + if(is_string($value)) { |
|
5864 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5865 | + } |
|
5518 | 5866 | |
5519 | 5867 | if(is_array($value)) |
5520 | 5868 | { |
5521 | 5869 | $out = ''; |
5522 | - foreach($value as $k => $v) |
|
5523 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5870 | + foreach($value as $k => $v) { |
|
5871 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5872 | + } |
|
5524 | 5873 | |
5525 | 5874 | return 'a:'. count($value) .':{'. $out .'}'; |
5526 | 5875 | } |
@@ -5546,8 +5895,9 @@ discard block |
||
5546 | 5895 | |
5547 | 5896 | $out = _safe_serialize($value); |
5548 | 5897 | |
5549 | - if (isset($mbIntEnc)) |
|
5550 | - mb_internal_encoding($mbIntEnc); |
|
5898 | + if (isset($mbIntEnc)) { |
|
5899 | + mb_internal_encoding($mbIntEnc); |
|
5900 | + } |
|
5551 | 5901 | |
5552 | 5902 | return $out; |
5553 | 5903 | } |
@@ -5564,8 +5914,9 @@ discard block |
||
5564 | 5914 | function _safe_unserialize($str) |
5565 | 5915 | { |
5566 | 5916 | // Input is not a string. |
5567 | - if(empty($str) || !is_string($str)) |
|
5568 | - return false; |
|
5917 | + if(empty($str) || !is_string($str)) { |
|
5918 | + return false; |
|
5919 | + } |
|
5569 | 5920 | |
5570 | 5921 | $stack = array(); |
5571 | 5922 | $expected = array(); |
@@ -5581,43 +5932,38 @@ discard block |
||
5581 | 5932 | while($state != 1) |
5582 | 5933 | { |
5583 | 5934 | $type = isset($str[0]) ? $str[0] : ''; |
5584 | - if($type == '}') |
|
5585 | - $str = substr($str, 1); |
|
5586 | - |
|
5587 | - else if($type == 'N' && $str[1] == ';') |
|
5935 | + if($type == '}') { |
|
5936 | + $str = substr($str, 1); |
|
5937 | + } else if($type == 'N' && $str[1] == ';') |
|
5588 | 5938 | { |
5589 | 5939 | $value = null; |
5590 | 5940 | $str = substr($str, 2); |
5591 | - } |
|
5592 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5941 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5593 | 5942 | { |
5594 | 5943 | $value = $matches[1] == '1' ? true : false; |
5595 | 5944 | $str = substr($str, 4); |
5596 | - } |
|
5597 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5945 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5598 | 5946 | { |
5599 | 5947 | $value = (int)$matches[1]; |
5600 | 5948 | $str = $matches[2]; |
5601 | - } |
|
5602 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5949 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5603 | 5950 | { |
5604 | 5951 | $value = (float)$matches[1]; |
5605 | 5952 | $str = $matches[3]; |
5606 | - } |
|
5607 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5953 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5608 | 5954 | { |
5609 | 5955 | $value = substr($matches[2], 0, (int)$matches[1]); |
5610 | 5956 | $str = substr($matches[2], (int)$matches[1] + 2); |
5611 | - } |
|
5612 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5957 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5613 | 5958 | { |
5614 | 5959 | $expectedLength = (int)$matches[1]; |
5615 | 5960 | $str = $matches[2]; |
5616 | 5961 | } |
5617 | 5962 | |
5618 | 5963 | // Object or unknown/malformed type. |
5619 | - else |
|
5620 | - return false; |
|
5964 | + else { |
|
5965 | + return false; |
|
5966 | + } |
|
5621 | 5967 | |
5622 | 5968 | switch($state) |
5623 | 5969 | { |
@@ -5645,8 +5991,9 @@ discard block |
||
5645 | 5991 | if($type == '}') |
5646 | 5992 | { |
5647 | 5993 | // Array size is less than expected. |
5648 | - if(count($list) < end($expected)) |
|
5649 | - return false; |
|
5994 | + if(count($list) < end($expected)) { |
|
5995 | + return false; |
|
5996 | + } |
|
5650 | 5997 | |
5651 | 5998 | unset($list); |
5652 | 5999 | $list = &$stack[count($stack)-1]; |
@@ -5655,8 +6002,9 @@ discard block |
||
5655 | 6002 | // Go to terminal state if we're at the end of the root array. |
5656 | 6003 | array_pop($expected); |
5657 | 6004 | |
5658 | - if(count($expected) == 0) |
|
5659 | - $state = 1; |
|
6005 | + if(count($expected) == 0) { |
|
6006 | + $state = 1; |
|
6007 | + } |
|
5660 | 6008 | |
5661 | 6009 | break; |
5662 | 6010 | } |
@@ -5664,8 +6012,9 @@ discard block |
||
5664 | 6012 | if($type == 'i' || $type == 's') |
5665 | 6013 | { |
5666 | 6014 | // Array size exceeds expected length. |
5667 | - if(count($list) >= end($expected)) |
|
5668 | - return false; |
|
6015 | + if(count($list) >= end($expected)) { |
|
6016 | + return false; |
|
6017 | + } |
|
5669 | 6018 | |
5670 | 6019 | $key = $value; |
5671 | 6020 | $state = 3; |
@@ -5699,8 +6048,9 @@ discard block |
||
5699 | 6048 | } |
5700 | 6049 | |
5701 | 6050 | // Trailing data in input. |
5702 | - if(!empty($str)) |
|
5703 | - return false; |
|
6051 | + if(!empty($str)) { |
|
6052 | + return false; |
|
6053 | + } |
|
5704 | 6054 | |
5705 | 6055 | return $data; |
5706 | 6056 | } |
@@ -5723,8 +6073,9 @@ discard block |
||
5723 | 6073 | |
5724 | 6074 | $out = _safe_unserialize($str); |
5725 | 6075 | |
5726 | - if (isset($mbIntEnc)) |
|
5727 | - mb_internal_encoding($mbIntEnc); |
|
6076 | + if (isset($mbIntEnc)) { |
|
6077 | + mb_internal_encoding($mbIntEnc); |
|
6078 | + } |
|
5728 | 6079 | |
5729 | 6080 | return $out; |
5730 | 6081 | } |
@@ -5739,12 +6090,14 @@ discard block |
||
5739 | 6090 | function smf_chmod($file, $value = 0) |
5740 | 6091 | { |
5741 | 6092 | // No file? no checks! |
5742 | - if (empty($file)) |
|
5743 | - return false; |
|
6093 | + if (empty($file)) { |
|
6094 | + return false; |
|
6095 | + } |
|
5744 | 6096 | |
5745 | 6097 | // Already writable? |
5746 | - if (is_writable($file)) |
|
5747 | - return true; |
|
6098 | + if (is_writable($file)) { |
|
6099 | + return true; |
|
6100 | + } |
|
5748 | 6101 | |
5749 | 6102 | // Do we have a file or a dir? |
5750 | 6103 | $isDir = is_dir($file); |
@@ -5760,10 +6113,9 @@ discard block |
||
5760 | 6113 | { |
5761 | 6114 | $isWritable = true; |
5762 | 6115 | break; |
6116 | + } else { |
|
6117 | + @chmod($file, $val); |
|
5763 | 6118 | } |
5764 | - |
|
5765 | - else |
|
5766 | - @chmod($file, $val); |
|
5767 | 6119 | } |
5768 | 6120 | |
5769 | 6121 | return $isWritable; |
@@ -5782,8 +6134,9 @@ discard block |
||
5782 | 6134 | global $txt; |
5783 | 6135 | |
5784 | 6136 | // Come on... |
5785 | - if (empty($json) || !is_string($json)) |
|
5786 | - return array(); |
|
6137 | + if (empty($json) || !is_string($json)) { |
|
6138 | + return array(); |
|
6139 | + } |
|
5787 | 6140 | |
5788 | 6141 | $returnArray = @json_decode($json, $returnAsArray); |
5789 | 6142 | |
@@ -5821,11 +6174,11 @@ discard block |
||
5821 | 6174 | $jsonDebug = $jsonDebug[0]; |
5822 | 6175 | loadLanguage('Errors'); |
5823 | 6176 | |
5824 | - if (!empty($jsonDebug)) |
|
5825 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5826 | - |
|
5827 | - else |
|
5828 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
6177 | + if (!empty($jsonDebug)) { |
|
6178 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
6179 | + } else { |
|
6180 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
6181 | + } |
|
5829 | 6182 | |
5830 | 6183 | // Everyone expects an array. |
5831 | 6184 | return array(); |
@@ -5859,8 +6212,9 @@ discard block |
||
5859 | 6212 | global $db_show_debug, $modSettings; |
5860 | 6213 | |
5861 | 6214 | // Defensive programming anyone? |
5862 | - if (empty($data)) |
|
5863 | - return false; |
|
6215 | + if (empty($data)) { |
|
6216 | + return false; |
|
6217 | + } |
|
5864 | 6218 | |
5865 | 6219 | // Don't need extra stuff... |
5866 | 6220 | $db_show_debug = false; |
@@ -5868,11 +6222,11 @@ discard block |
||
5868 | 6222 | // Kill anything else. |
5869 | 6223 | ob_end_clean(); |
5870 | 6224 | |
5871 | - if (!empty($modSettings['CompressedOutput'])) |
|
5872 | - @ob_start('ob_gzhandler'); |
|
5873 | - |
|
5874 | - else |
|
5875 | - ob_start(); |
|
6225 | + if (!empty($modSettings['CompressedOutput'])) { |
|
6226 | + @ob_start('ob_gzhandler'); |
|
6227 | + } else { |
|
6228 | + ob_start(); |
|
6229 | + } |
|
5876 | 6230 | |
5877 | 6231 | // Set the header. |
5878 | 6232 | header($type); |
@@ -5904,8 +6258,9 @@ discard block |
||
5904 | 6258 | static $done = false; |
5905 | 6259 | |
5906 | 6260 | // If we don't need to do anything, don't |
5907 | - if (!$update && $done) |
|
5908 | - return; |
|
6261 | + if (!$update && $done) { |
|
6262 | + return; |
|
6263 | + } |
|
5909 | 6264 | |
5910 | 6265 | // Should we get a new copy of the official list of TLDs? |
5911 | 6266 | if ($update) |
@@ -5917,8 +6272,9 @@ discard block |
||
5917 | 6272 | // marauding bandits roaming on the surface. We don't want to waste precious electricity on |
5918 | 6273 | // pointlessly repeating background tasks, so we'll wait until the next regularly scheduled |
5919 | 6274 | // update to see if civilization has been restored. |
5920 | - if ($tlds === false) |
|
5921 | - $postapocalypticNightmare = true; |
|
6275 | + if ($tlds === false) { |
|
6276 | + $postapocalypticNightmare = true; |
|
6277 | + } |
|
5922 | 6278 | } |
5923 | 6279 | // If we aren't updating and the regex is valid, we're done |
5924 | 6280 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5933,10 +6289,11 @@ discard block |
||
5933 | 6289 | // Clean $tlds and convert it to an array |
5934 | 6290 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5935 | 6291 | $line = trim($line); |
5936 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5937 | - return false; |
|
5938 | - else |
|
5939 | - return true; |
|
6292 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6293 | + return false; |
|
6294 | + } else { |
|
6295 | + return true; |
|
6296 | + } |
|
5940 | 6297 | }); |
5941 | 6298 | |
5942 | 6299 | // Convert Punycode to Unicode |
@@ -6028,8 +6385,7 @@ discard block |
||
6028 | 6385 | |
6029 | 6386 | $strlen = 'mb_strlen'; |
6030 | 6387 | $substr = 'mb_substr'; |
6031 | - } |
|
6032 | - else |
|
6388 | + } else |
|
6033 | 6389 | { |
6034 | 6390 | $strlen = $smcFunc['strlen']; |
6035 | 6391 | $substr = $smcFunc['substr']; |
@@ -6043,20 +6399,21 @@ discard block |
||
6043 | 6399 | |
6044 | 6400 | $first = $substr($string, 0, 1); |
6045 | 6401 | |
6046 | - if (empty($index[$first])) |
|
6047 | - $index[$first] = array(); |
|
6402 | + if (empty($index[$first])) { |
|
6403 | + $index[$first] = array(); |
|
6404 | + } |
|
6048 | 6405 | |
6049 | 6406 | if ($strlen($string) > 1) |
6050 | 6407 | { |
6051 | 6408 | // Sanity check on recursion |
6052 | - if ($depth > 99) |
|
6053 | - $index[$first][$substr($string, 1)] = ''; |
|
6054 | - |
|
6055 | - else |
|
6056 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6409 | + if ($depth > 99) { |
|
6410 | + $index[$first][$substr($string, 1)] = ''; |
|
6411 | + } else { |
|
6412 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6413 | + } |
|
6414 | + } else { |
|
6415 | + $index[$first][''] = ''; |
|
6057 | 6416 | } |
6058 | - else |
|
6059 | - $index[$first][''] = ''; |
|
6060 | 6417 | |
6061 | 6418 | $depth--; |
6062 | 6419 | return $index; |
@@ -6079,9 +6436,9 @@ discard block |
||
6079 | 6436 | $key_regex = preg_quote($key, $delim); |
6080 | 6437 | $new_key = $key; |
6081 | 6438 | |
6082 | - if (empty($value)) |
|
6083 | - $sub_regex = ''; |
|
6084 | - else |
|
6439 | + if (empty($value)) { |
|
6440 | + $sub_regex = ''; |
|
6441 | + } else |
|
6085 | 6442 | { |
6086 | 6443 | $sub_regex = $index_to_regex($value, $delim); |
6087 | 6444 | |
@@ -6089,22 +6446,22 @@ discard block |
||
6089 | 6446 | { |
6090 | 6447 | $new_key_array = explode('(?'.'>', $sub_regex); |
6091 | 6448 | $new_key .= $new_key_array[0]; |
6449 | + } else { |
|
6450 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6092 | 6451 | } |
6093 | - else |
|
6094 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6095 | 6452 | } |
6096 | 6453 | |
6097 | - if ($depth > 1) |
|
6098 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
6099 | - else |
|
6454 | + if ($depth > 1) { |
|
6455 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6456 | + } else |
|
6100 | 6457 | { |
6101 | 6458 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
6102 | 6459 | { |
6103 | 6460 | $regex[$new_key] = $key_regex . $sub_regex; |
6104 | 6461 | unset($index[$key]); |
6462 | + } else { |
|
6463 | + break; |
|
6105 | 6464 | } |
6106 | - else |
|
6107 | - break; |
|
6108 | 6465 | } |
6109 | 6466 | } |
6110 | 6467 | |
@@ -6113,10 +6470,11 @@ discard block |
||
6113 | 6470 | $l1 = $strlen($k1); |
6114 | 6471 | $l2 = $strlen($k2); |
6115 | 6472 | |
6116 | - if ($l1 == $l2) |
|
6117 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6118 | - else |
|
6119 | - return $l1 > $l2 ? -1 : 1; |
|
6473 | + if ($l1 == $l2) { |
|
6474 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6475 | + } else { |
|
6476 | + return $l1 > $l2 ? -1 : 1; |
|
6477 | + } |
|
6120 | 6478 | }); |
6121 | 6479 | |
6122 | 6480 | $depth--; |
@@ -6127,21 +6485,24 @@ discard block |
||
6127 | 6485 | $index = array(); |
6128 | 6486 | $regex = ''; |
6129 | 6487 | |
6130 | - foreach ($strings as $string) |
|
6131 | - $index = $add_string_to_index($string, $index); |
|
6488 | + foreach ($strings as $string) { |
|
6489 | + $index = $add_string_to_index($string, $index); |
|
6490 | + } |
|
6132 | 6491 | |
6133 | 6492 | if ($returnArray === true) |
6134 | 6493 | { |
6135 | 6494 | $regex = array(); |
6136 | - while (!empty($index)) |
|
6137 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6495 | + while (!empty($index)) { |
|
6496 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6497 | + } |
|
6498 | + } else { |
|
6499 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6138 | 6500 | } |
6139 | - else |
|
6140 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6141 | 6501 | |
6142 | 6502 | // Restore PHP's internal character encoding to whatever it was originally |
6143 | - if (!empty($current_encoding)) |
|
6144 | - mb_internal_encoding($current_encoding); |
|
6503 | + if (!empty($current_encoding)) { |
|
6504 | + mb_internal_encoding($current_encoding); |
|
6505 | + } |
|
6145 | 6506 | |
6146 | 6507 | return $regex; |
6147 | 6508 | } |
@@ -6184,13 +6545,15 @@ discard block |
||
6184 | 6545 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
6185 | 6546 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
6186 | 6547 | $headers = @get_headers($url); |
6187 | - if ($headers === false) |
|
6188 | - return false; |
|
6548 | + if ($headers === false) { |
|
6549 | + return false; |
|
6550 | + } |
|
6189 | 6551 | |
6190 | 6552 | // Now to see if it came back https... |
6191 | 6553 | // First check for a redirect status code in first row (301, 302, 307) |
6192 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
6193 | - return false; |
|
6554 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
6555 | + return false; |
|
6556 | + } |
|
6194 | 6557 | |
6195 | 6558 | // Search for the location entry to confirm https |
6196 | 6559 | $result = false; |
@@ -6228,8 +6591,7 @@ discard block |
||
6228 | 6591 | $is_admin = $user_info['is_admin']; |
6229 | 6592 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
6230 | 6593 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
6231 | - } |
|
6232 | - else |
|
6594 | + } else |
|
6233 | 6595 | { |
6234 | 6596 | $request = $smcFunc['db_query']('', ' |
6235 | 6597 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6243,17 +6605,19 @@ discard block |
||
6243 | 6605 | |
6244 | 6606 | $row = $smcFunc['db_fetch_assoc']($request); |
6245 | 6607 | |
6246 | - if (empty($row['additional_groups'])) |
|
6247 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
6248 | - else |
|
6249 | - $groups = array_merge( |
|
6608 | + if (empty($row['additional_groups'])) { |
|
6609 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
6610 | + } else { |
|
6611 | + $groups = array_merge( |
|
6250 | 6612 | array($row['id_group'], $row['id_post_group']), |
6251 | 6613 | explode(',', $row['additional_groups']) |
6252 | 6614 | ); |
6615 | + } |
|
6253 | 6616 | |
6254 | 6617 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
6255 | - foreach ($groups as $k => $v) |
|
6256 | - $groups[$k] = (int) $v; |
|
6618 | + foreach ($groups as $k => $v) { |
|
6619 | + $groups[$k] = (int) $v; |
|
6620 | + } |
|
6257 | 6621 | |
6258 | 6622 | $is_admin = in_array(1, $groups); |
6259 | 6623 | |
@@ -6270,8 +6634,9 @@ discard block |
||
6270 | 6634 | 'current_member' => $userid, |
6271 | 6635 | ) |
6272 | 6636 | ); |
6273 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6274 | - $boards_mod[] = $row['id_board']; |
|
6637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6638 | + $boards_mod[] = $row['id_board']; |
|
6639 | + } |
|
6275 | 6640 | $smcFunc['db_free_result']($request); |
6276 | 6641 | |
6277 | 6642 | // Can any of the groups they're in moderate any of the boards? |
@@ -6283,8 +6648,9 @@ discard block |
||
6283 | 6648 | 'groups' => $groups, |
6284 | 6649 | ) |
6285 | 6650 | ); |
6286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6287 | - $boards_mod[] = $row['id_board']; |
|
6651 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6652 | + $boards_mod[] = $row['id_board']; |
|
6653 | + } |
|
6288 | 6654 | $smcFunc['db_free_result']($request); |
6289 | 6655 | |
6290 | 6656 | // Just in case we've got duplicates here... |
@@ -6294,21 +6660,25 @@ discard block |
||
6294 | 6660 | } |
6295 | 6661 | |
6296 | 6662 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
6297 | - if ($is_admin) |
|
6298 | - $query_part['query_see_board'] = '1=1'; |
|
6663 | + if ($is_admin) { |
|
6664 | + $query_part['query_see_board'] = '1=1'; |
|
6665 | + } |
|
6299 | 6666 | // Otherwise just the groups in $user_info['groups']. |
6300 | - else |
|
6301 | - $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'] : '') . ')'; |
|
6667 | + else { |
|
6668 | + $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'] : '') . ')'; |
|
6669 | + } |
|
6302 | 6670 | |
6303 | 6671 | // Build the list of boards they WANT to see. |
6304 | 6672 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
6305 | 6673 | |
6306 | 6674 | // If they aren't ignoring any boards then they want to see all the boards they can see |
6307 | - if (empty($ignoreboards)) |
|
6308 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6675 | + if (empty($ignoreboards)) { |
|
6676 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6677 | + } |
|
6309 | 6678 | // Ok I guess they don't want to see all the boards |
6310 | - else |
|
6311 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6679 | + else { |
|
6680 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6681 | + } |
|
6312 | 6682 | |
6313 | 6683 | return $query_part; |
6314 | 6684 | } |
@@ -6322,10 +6692,11 @@ discard block |
||
6322 | 6692 | { |
6323 | 6693 | $secure = false; |
6324 | 6694 | |
6325 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
6326 | - $secure = true; |
|
6327 | - 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') |
|
6328 | - $secure = true; |
|
6695 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
6696 | + $secure = true; |
|
6697 | + } 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') { |
|
6698 | + $secure = true; |
|
6699 | + } |
|
6329 | 6700 | |
6330 | 6701 | return $secure; |
6331 | 6702 | } |
@@ -6342,11 +6713,12 @@ discard block |
||
6342 | 6713 | { |
6343 | 6714 | $url = iri_to_url($iri); |
6344 | 6715 | |
6345 | - if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) |
|
6346 | - return $iri; |
|
6347 | - else |
|
6348 | - return false; |
|
6349 | -} |
|
6716 | + if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) { |
|
6717 | + return $iri; |
|
6718 | + } else { |
|
6719 | + return false; |
|
6720 | + } |
|
6721 | + } |
|
6350 | 6722 | |
6351 | 6723 | /** |
6352 | 6724 | * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs |
@@ -6389,8 +6761,9 @@ discard block |
||
6389 | 6761 | |
6390 | 6762 | $host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST); |
6391 | 6763 | |
6392 | - if (empty($host)) |
|
6393 | - return $iri; |
|
6764 | + if (empty($host)) { |
|
6765 | + return $iri; |
|
6766 | + } |
|
6394 | 6767 | |
6395 | 6768 | // Convert the domain using the Punycode algorithm |
6396 | 6769 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6426,8 +6799,9 @@ discard block |
||
6426 | 6799 | |
6427 | 6800 | $host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST); |
6428 | 6801 | |
6429 | - if (empty($host)) |
|
6430 | - return $url; |
|
6802 | + if (empty($host)) { |
|
6803 | + return $url; |
|
6804 | + } |
|
6431 | 6805 | |
6432 | 6806 | // Decode the domain from Punycode |
6433 | 6807 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6453,8 +6827,9 @@ discard block |
||
6453 | 6827 | { |
6454 | 6828 | global $user_info, $modSettings, $smcFunc, $txt; |
6455 | 6829 | |
6456 | - if (empty($modSettings['cron_last_checked'])) |
|
6457 | - $modSettings['cron_last_checked'] = 0; |
|
6830 | + if (empty($modSettings['cron_last_checked'])) { |
|
6831 | + $modSettings['cron_last_checked'] = 0; |
|
6832 | + } |
|
6458 | 6833 | |
6459 | 6834 | if (!empty($modSettings['cron_is_real_cron']) && time() - $modSettings['cron_last_checked'] > 84600) |
6460 | 6835 | { |
@@ -6474,9 +6849,9 @@ discard block |
||
6474 | 6849 | loadLanguage('ManageScheduledTasks'); |
6475 | 6850 | log_error($txt['cron_not_working']); |
6476 | 6851 | updateSettings(array('cron_is_real_cron' => 0)); |
6852 | + } else { |
|
6853 | + updateSettings(array('cron_last_checked' => time())); |
|
6477 | 6854 | } |
6478 | - else |
|
6479 | - updateSettings(array('cron_last_checked' => time())); |
|
6480 | 6855 | } |
6481 | 6856 | } |
6482 | 6857 |