@@ -116,9 +116,10 @@ discard block |
||
116 | 116 | </div><!-- .windowbg --> |
117 | 117 | </div><!-- #manage_attachments -->'; |
118 | 118 | |
119 | - if (!empty($context['results'])) |
|
120 | - echo ' |
|
119 | + if (!empty($context['results'])) { |
|
120 | + echo ' |
|
121 | 121 | <div class="noticebox">', $context['results'], '</div>'; |
122 | + } |
|
122 | 123 | |
123 | 124 | echo ' |
124 | 125 | <div id="transfer" class="cat_bar"> |
@@ -133,9 +134,10 @@ discard block |
||
133 | 134 | <select name="from"> |
134 | 135 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
135 | 136 | |
136 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
137 | - echo ' |
|
137 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
138 | + echo ' |
|
138 | 139 | <option value="', $id, '">', $dir, '</option>'; |
140 | + } |
|
139 | 141 | |
140 | 142 | echo ' |
141 | 143 | </select> |
@@ -146,13 +148,14 @@ discard block |
||
146 | 148 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
147 | 149 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
148 | 150 | |
149 | - if (!empty($context['base_dirs'])) |
|
150 | - foreach ($context['base_dirs'] as $id => $dir) |
|
151 | + if (!empty($context['base_dirs'])) { |
|
152 | + foreach ($context['base_dirs'] as $id => $dir) |
|
151 | 153 | echo ' |
152 | 154 | <option value="', $id, '">', $dir, '</option>'; |
153 | - else |
|
154 | - echo ' |
|
155 | + } else { |
|
156 | + echo ' |
|
155 | 157 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
158 | + } |
|
156 | 159 | |
157 | 160 | echo ' |
158 | 161 | </select> |
@@ -162,18 +165,20 @@ discard block |
||
162 | 165 | <select name="to"> |
163 | 166 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
164 | 167 | |
165 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
166 | - echo ' |
|
168 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
169 | + echo ' |
|
167 | 170 | <option value="', $id, '">', $dir, '</option>'; |
171 | + } |
|
168 | 172 | |
169 | 173 | echo ' |
170 | 174 | </select> |
171 | 175 | </dd>'; |
172 | 176 | |
173 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
174 | - echo ' |
|
177 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
178 | + echo ' |
|
175 | 179 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
176 | 180 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
181 | + } |
|
177 | 182 | |
178 | 183 | echo ' |
179 | 184 | </dl> |
@@ -209,8 +214,8 @@ discard block |
||
209 | 214 | global $context, $txt, $scripturl; |
210 | 215 | |
211 | 216 | // If we've completed just let them know! |
212 | - if ($context['completed']) |
|
213 | - echo ' |
|
217 | + if ($context['completed']) { |
|
218 | + echo ' |
|
214 | 219 | <div id="manage_attachments"> |
215 | 220 | <div class="cat_bar"> |
216 | 221 | <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3> |
@@ -219,10 +224,11 @@ discard block |
||
219 | 224 | ', $txt['repair_attachments_complete_desc'], ' |
220 | 225 | </div> |
221 | 226 | </div>'; |
227 | + } |
|
222 | 228 | |
223 | 229 | // What about if no errors were even found? |
224 | - elseif (!$context['errors_found']) |
|
225 | - echo ' |
|
230 | + elseif (!$context['errors_found']) { |
|
231 | + echo ' |
|
226 | 232 | <div id="manage_attachments"> |
227 | 233 | <div class="cat_bar"> |
228 | 234 | <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3> |
@@ -231,6 +237,7 @@ discard block |
||
231 | 237 | ', $txt['repair_attachments_no_errors'], ' |
232 | 238 | </div> |
233 | 239 | </div>'; |
240 | + } |
|
234 | 241 | |
235 | 242 | // Otherwise, I'm sad to say, we have a problem! |
236 | 243 | else |
@@ -245,11 +252,12 @@ discard block |
||
245 | 252 | <p>', $txt['repair_attachments_error_desc'], '</p>'; |
246 | 253 | |
247 | 254 | // Loop through each error reporting the status |
248 | - foreach ($context['repair_errors'] as $error => $number) |
|
249 | - if (!empty($number)) |
|
255 | + foreach ($context['repair_errors'] as $error => $number) { |
|
256 | + if (!empty($number)) |
|
250 | 257 | echo ' |
251 | 258 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
252 | 259 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
260 | + } |
|
253 | 261 | |
254 | 262 | echo ' |
255 | 263 | <br> |
@@ -268,8 +276,9 @@ discard block |
||
268 | 276 | { |
269 | 277 | global $modSettings; |
270 | 278 | |
271 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
272 | - template_show_list('base_paths'); |
|
279 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
280 | + template_show_list('base_paths'); |
|
281 | + } |
|
273 | 282 | |
274 | 283 | template_show_list('attach_paths'); |
275 | 284 | } |
@@ -31,9 +31,10 @@ discard block |
||
31 | 31 | ', $txt['who_show1'], ' |
32 | 32 | <select name="show_top" onchange="document.forms.whoFilter.show.value = this.value; document.forms.whoFilter.submit();">'; |
33 | 33 | |
34 | - foreach ($context['show_methods'] as $value => $label) |
|
35 | - echo ' |
|
34 | + foreach ($context['show_methods'] as $value => $label) { |
|
35 | + echo ' |
|
36 | 36 | <option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>'; |
37 | + } |
|
37 | 38 | echo ' |
38 | 39 | </select> |
39 | 40 | <noscript> |
@@ -58,20 +59,22 @@ discard block |
||
58 | 59 | <td>'; |
59 | 60 | |
60 | 61 | // Guests can't be messaged. |
61 | - if (!$member['is_guest']) |
|
62 | - echo ' |
|
62 | + if (!$member['is_guest']) { |
|
63 | + echo ' |
|
63 | 64 | <span class="contact_info floatright"> |
64 | 65 | ', $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['text'] . '">' : '', $settings['use_image_buttons'] ? '<span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span>' : $member['online']['label'], $context['can_send_pm'] ? '</a>' : '', ' |
65 | 66 | </span>'; |
67 | + } |
|
66 | 68 | |
67 | 69 | echo ' |
68 | 70 | <span class="member', $member['is_hidden'] ? ' hidden' : '', '"> |
69 | 71 | ', $member['is_guest'] ? $member['name'] : '<a href="' . $member['href'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '"' . (empty($member['color']) ? '' : ' style="color: ' . $member['color'] . '"') . '>' . $member['name'] . '</a>', ' |
70 | 72 | </span>'; |
71 | 73 | |
72 | - if (!empty($member['ip'])) |
|
73 | - echo ' |
|
74 | + if (!empty($member['ip'])) { |
|
75 | + echo ' |
|
74 | 76 | (<a href="' . $scripturl . '?action=', ($member['is_guest'] ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $member['id']), ';searchip=' . $member['ip'] . '">' . $member['ip'] . '</a>)'; |
77 | + } |
|
75 | 78 | |
76 | 79 | echo ' |
77 | 80 | </td> |
@@ -81,13 +84,14 @@ discard block |
||
81 | 84 | } |
82 | 85 | |
83 | 86 | // No members? |
84 | - if (empty($context['members'])) |
|
85 | - echo ' |
|
87 | + if (empty($context['members'])) { |
|
88 | + echo ' |
|
86 | 89 | <tr class="windowbg"> |
87 | 90 | <td colspan="3"> |
88 | 91 | ', $txt['who_no_online_' . ($context['show_by'] == 'guests' || $context['show_by'] == 'spiders' ? $context['show_by'] : 'members')], ' |
89 | 92 | </td> |
90 | 93 | </tr>'; |
94 | + } |
|
91 | 95 | |
92 | 96 | echo ' |
93 | 97 | </tbody> |
@@ -98,9 +102,10 @@ discard block |
||
98 | 102 | ', $txt['who_show1'], ' |
99 | 103 | <select name="show" onchange="document.forms.whoFilter.submit();">'; |
100 | 104 | |
101 | - foreach ($context['show_methods'] as $value => $label) |
|
102 | - echo ' |
|
105 | + foreach ($context['show_methods'] as $value => $label) { |
|
106 | + echo ' |
|
103 | 107 | <option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>'; |
108 | + } |
|
104 | 109 | echo ' |
105 | 110 | </select> |
106 | 111 | <noscript> |
@@ -129,17 +134,19 @@ discard block |
||
129 | 134 | |
130 | 135 | foreach ($context['credits'] as $section) |
131 | 136 | { |
132 | - if (isset($section['pretext'])) |
|
133 | - echo ' |
|
137 | + if (isset($section['pretext'])) { |
|
138 | + echo ' |
|
134 | 139 | <div class="windowbg"> |
135 | 140 | <p>', $section['pretext'], '</p> |
136 | 141 | </div>'; |
142 | + } |
|
137 | 143 | |
138 | - if (isset($section['title'])) |
|
139 | - echo ' |
|
144 | + if (isset($section['title'])) { |
|
145 | + echo ' |
|
140 | 146 | <div class="cat_bar"> |
141 | 147 | <h3 class="catbg">', $section['title'], '</h3> |
142 | 148 | </div>'; |
149 | + } |
|
143 | 150 | |
144 | 151 | echo ' |
145 | 152 | <div class="windowbg"> |
@@ -147,17 +154,18 @@ discard block |
||
147 | 154 | |
148 | 155 | foreach ($section['groups'] as $group) |
149 | 156 | { |
150 | - if (isset($group['title'])) |
|
151 | - echo ' |
|
157 | + if (isset($group['title'])) { |
|
158 | + echo ' |
|
152 | 159 | <dt> |
153 | 160 | <strong>', $group['title'], '</strong> |
154 | 161 | </dt> |
155 | 162 | <dd>'; |
163 | + } |
|
156 | 164 | |
157 | 165 | // Try to make this read nicely. |
158 | - if (count($group['members']) <= 2) |
|
159 | - echo implode(' ' . $txt['credits_and'] . ' ', $group['members']); |
|
160 | - else |
|
166 | + if (count($group['members']) <= 2) { |
|
167 | + echo implode(' ' . $txt['credits_and'] . ' ', $group['members']); |
|
168 | + } else |
|
161 | 169 | { |
162 | 170 | $last_peep = array_pop($group['members']); |
163 | 171 | echo implode(', ', $group['members']), ' ', $txt['credits_and'], ' ', $last_peep; |
@@ -170,9 +178,10 @@ discard block |
||
170 | 178 | echo ' |
171 | 179 | </dl>'; |
172 | 180 | |
173 | - if (isset($section['posttext'])) |
|
174 | - echo ' |
|
181 | + if (isset($section['posttext'])) { |
|
182 | + echo ' |
|
175 | 183 | <p class="posttext">', $section['posttext'], '</p>'; |
184 | + } |
|
176 | 185 | |
177 | 186 | echo ' |
178 | 187 | </div>'; |
@@ -187,26 +196,29 @@ discard block |
||
187 | 196 | </div> |
188 | 197 | <div class="windowbg">'; |
189 | 198 | |
190 | - if (!empty($context['credits_software_graphics']['graphics'])) |
|
191 | - echo ' |
|
199 | + if (!empty($context['credits_software_graphics']['graphics'])) { |
|
200 | + echo ' |
|
192 | 201 | <dl> |
193 | 202 | <dt><strong>', $txt['credits_graphics'], '</strong></dt> |
194 | 203 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['graphics']), '</dd> |
195 | 204 | </dl>'; |
205 | + } |
|
196 | 206 | |
197 | - if (!empty($context['credits_software_graphics']['software'])) |
|
198 | - echo ' |
|
207 | + if (!empty($context['credits_software_graphics']['software'])) { |
|
208 | + echo ' |
|
199 | 209 | <dl> |
200 | 210 | <dt><strong>', $txt['credits_software'], '</strong></dt> |
201 | 211 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['software']), '</dd> |
202 | 212 | </dl>'; |
213 | + } |
|
203 | 214 | |
204 | - if (!empty($context['credits_software_graphics']['fonts'])) |
|
205 | - echo ' |
|
215 | + if (!empty($context['credits_software_graphics']['fonts'])) { |
|
216 | + echo ' |
|
206 | 217 | <dl> |
207 | 218 | <dt><strong>', $txt['credits_fonts'], '</strong></dt> |
208 | 219 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['fonts']), '</dd> |
209 | 220 | </dl>'; |
221 | + } |
|
210 | 222 | echo ' |
211 | 223 | </div>'; |
212 | 224 | } |
@@ -222,14 +234,16 @@ discard block |
||
222 | 234 | <ul>'; |
223 | 235 | |
224 | 236 | // Display the credits. |
225 | - if (!empty($context['credits_modifications'])) |
|
226 | - echo ' |
|
237 | + if (!empty($context['credits_modifications'])) { |
|
238 | + echo ' |
|
227 | 239 | <li>', implode('</li><li>', $context['credits_modifications']), '</li>'; |
240 | + } |
|
228 | 241 | |
229 | 242 | // Legacy. |
230 | - if (!empty($context['copyrights']['mods'])) |
|
231 | - echo ' |
|
243 | + if (!empty($context['copyrights']['mods'])) { |
|
244 | + echo ' |
|
232 | 245 | <li>', implode('</li><li>', $context['copyrights']['mods']), '</li>'; |
246 | + } |
|
233 | 247 | |
234 | 248 | echo ' |
235 | 249 | </ul> |
@@ -54,18 +54,20 @@ discard block |
||
54 | 54 | <div class="windowbg" id="group_requests_panel"> |
55 | 55 | <ul>'; |
56 | 56 | |
57 | - foreach ($context['group_requests'] as $request) |
|
58 | - echo ' |
|
57 | + foreach ($context['group_requests'] as $request) { |
|
58 | + echo ' |
|
59 | 59 | <li class="smalltext"> |
60 | 60 | <a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], ' |
61 | 61 | </li>'; |
62 | + } |
|
62 | 63 | |
63 | 64 | // Don't have any watched users right now? |
64 | - if (empty($context['group_requests'])) |
|
65 | - echo ' |
|
65 | + if (empty($context['group_requests'])) { |
|
66 | + echo ' |
|
66 | 67 | <li> |
67 | 68 | <strong class="smalltext">', $txt['mc_group_requests_none'], '</strong> |
68 | 69 | </li>'; |
70 | + } |
|
69 | 71 | |
70 | 72 | echo ' |
71 | 73 | </ul> |
@@ -121,18 +123,20 @@ discard block |
||
121 | 123 | <div class="windowbg" id="watched_users_panel"> |
122 | 124 | <ul>'; |
123 | 125 | |
124 | - foreach ($context['watched_users'] as $user) |
|
125 | - echo ' |
|
126 | + foreach ($context['watched_users'] as $user) { |
|
127 | + echo ' |
|
126 | 128 | <li> |
127 | 129 | <span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span> |
128 | 130 | </li>'; |
131 | + } |
|
129 | 132 | |
130 | 133 | // Don't have any watched users right now? |
131 | - if (empty($context['watched_users'])) |
|
132 | - echo ' |
|
134 | + if (empty($context['watched_users'])) { |
|
135 | + echo ' |
|
133 | 136 | <li> |
134 | 137 | <strong class="smalltext">', $txt['mc_watched_users_none'], '</strong> |
135 | 138 | </li>'; |
139 | + } |
|
136 | 140 | |
137 | 141 | echo ' |
138 | 142 | </ul> |
@@ -188,18 +192,20 @@ discard block |
||
188 | 192 | <div class="windowbg" id="reported_posts_panel"> |
189 | 193 | <ul>'; |
190 | 194 | |
191 | - foreach ($context['reported_posts'] as $post) |
|
192 | - echo ' |
|
195 | + foreach ($context['reported_posts'] as $post) { |
|
196 | + echo ' |
|
193 | 197 | <li> |
194 | 198 | <span class="smalltext">', sprintf($txt['mc_post_report'], $post['report_link'], $post['author']['link']), '</span> |
195 | 199 | </li>'; |
200 | + } |
|
196 | 201 | |
197 | 202 | // Don't have any watched users right now? |
198 | - if (empty($context['reported_posts'])) |
|
199 | - echo ' |
|
203 | + if (empty($context['reported_posts'])) { |
|
204 | + echo ' |
|
200 | 205 | <li> |
201 | 206 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
202 | 207 | </li>'; |
208 | + } |
|
203 | 209 | |
204 | 210 | echo ' |
205 | 211 | </ul> |
@@ -255,18 +261,20 @@ discard block |
||
255 | 261 | <div class="windowbg" id="reported_users_panel"> |
256 | 262 | <ul>'; |
257 | 263 | |
258 | - foreach ($context['reported_users'] as $user) |
|
259 | - echo ' |
|
264 | + foreach ($context['reported_users'] as $user) { |
|
265 | + echo ' |
|
260 | 266 | <li> |
261 | 267 | <span class="smalltext">', $user['user']['link'], '</span> |
262 | 268 | </li>'; |
269 | + } |
|
263 | 270 | |
264 | 271 | // Don't have any watched users right now? |
265 | - if (empty($context['reported_users'])) |
|
266 | - echo ' |
|
272 | + if (empty($context['reported_users'])) { |
|
273 | + echo ' |
|
267 | 274 | <li> |
268 | 275 | <strong class="smalltext">', $txt['mc_reported_users_none'], '</strong> |
269 | 276 | </li>'; |
277 | + } |
|
270 | 278 | |
271 | 279 | echo ' |
272 | 280 | </ul> |
@@ -313,11 +321,12 @@ discard block |
||
313 | 321 | global $context, $txt, $scripturl; |
314 | 322 | |
315 | 323 | // Let them know the action was a success. |
316 | - if (!empty($context['report_post_action'])) |
|
317 | - echo ' |
|
324 | + if (!empty($context['report_post_action'])) { |
|
325 | + echo ' |
|
318 | 326 | <div class="infobox"> |
319 | 327 | ', $txt['report_action_' . $context['report_post_action']], ' |
320 | 328 | </div>'; |
329 | + } |
|
321 | 330 | |
322 | 331 | echo ' |
323 | 332 | <div id="modnotes"> |
@@ -333,11 +342,12 @@ discard block |
||
333 | 342 | <ul class="moderation_notes">'; |
334 | 343 | |
335 | 344 | // Cycle through the notes. |
336 | - foreach ($context['notes'] as $note) |
|
337 | - echo ' |
|
345 | + foreach ($context['notes'] as $note) { |
|
346 | + echo ' |
|
338 | 347 | <li class="smalltext"> |
339 | 348 | ', ($note['can_delete'] ? '<a href="' . $note['delete_href'] . ';' . $context['mod-modnote-del_token_var'] . '=' . $context['mod-modnote-del_token'] . '" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '" class="you_sure"><span class="generic_icons delete"></span></a>' : ''), $note['time'], ' <strong>', $note['author']['link'], ':</strong> ', $note['text'], ' |
340 | 349 | </li>'; |
350 | + } |
|
341 | 351 | |
342 | 352 | echo ' |
343 | 353 | </ul> |
@@ -378,18 +388,19 @@ discard block |
||
378 | 388 | $remove_button = create_button('delete', 'remove_message', 'remove'); |
379 | 389 | |
380 | 390 | // No posts? |
381 | - if (empty($context['unapproved_items'])) |
|
382 | - echo ' |
|
391 | + if (empty($context['unapproved_items'])) { |
|
392 | + echo ' |
|
383 | 393 | <div class="windowbg"> |
384 | 394 | <p class="centertext"> |
385 | 395 | ', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], ' |
386 | 396 | </p> |
387 | 397 | </div>'; |
388 | - else |
|
389 | - echo ' |
|
398 | + } else { |
|
399 | + echo ' |
|
390 | 400 | <div class="pagesection floatleft"> |
391 | 401 | ', $context['page_index'], ' |
392 | 402 | </div>'; |
403 | + } |
|
393 | 404 | |
394 | 405 | foreach ($context['unapproved_items'] as $item) |
395 | 406 | { |
@@ -408,14 +419,16 @@ discard block |
||
408 | 419 | <span class="floatright"> |
409 | 420 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>'; |
410 | 421 | |
411 | - if ($item['can_delete']) |
|
412 | - echo ' |
|
422 | + if ($item['can_delete']) { |
|
423 | + echo ' |
|
413 | 424 | ', $context['menu_separator'], ' |
414 | 425 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>'; |
426 | + } |
|
415 | 427 | |
416 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
417 | - echo ' |
|
428 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
429 | + echo ' |
|
418 | 430 | <input type="checkbox" name="item[]" value="', $item['id'], '" checked> '; |
431 | + } |
|
419 | 432 | |
420 | 433 | echo ' |
421 | 434 | </span> |
@@ -425,8 +438,8 @@ discard block |
||
425 | 438 | echo ' |
426 | 439 | <div class="pagesection">'; |
427 | 440 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
429 | - echo ' |
|
441 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
442 | + echo ' |
|
430 | 443 | <div class="floatright"> |
431 | 444 | <select name="do" onchange="if (this.value != 0 && confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();"> |
432 | 445 | <option value="0">', $txt['with_selected'], ':</option> |
@@ -438,12 +451,14 @@ discard block |
||
438 | 451 | <input type="submit" name="mc_go" value="', $txt['go'], '" class="button"> |
439 | 452 | </noscript> |
440 | 453 | </div>'; |
454 | + } |
|
441 | 455 | |
442 | - if (!empty($context['unapproved_items'])) |
|
443 | - echo ' |
|
456 | + if (!empty($context['unapproved_items'])) { |
|
457 | + echo ' |
|
444 | 458 | <div class="floatleft"> |
445 | 459 | <div class="pagelinks">', $context['page_index'], '</div> |
446 | 460 | </div>'; |
461 | + } |
|
447 | 462 | |
448 | 463 | echo ' |
449 | 464 | </div><!-- .pagesection --> |
@@ -464,8 +479,9 @@ discard block |
||
464 | 479 | |
465 | 480 | // We'll have a delete please bob. |
466 | 481 | // @todo Discuss this with the team and rewrite if required. |
467 | - if (empty($delete_button)) |
|
468 | - $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
482 | + if (empty($delete_button)) { |
|
483 | + $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
484 | + } |
|
469 | 485 | |
470 | 486 | $output_html = ' |
471 | 487 | <div> |
@@ -474,10 +490,11 @@ discard block |
||
474 | 490 | </div> |
475 | 491 | <div class="floatright">'; |
476 | 492 | |
477 | - if ($post['can_delete']) |
|
478 | - $output_html .= ' |
|
493 | + if ($post['can_delete']) { |
|
494 | + $output_html .= ' |
|
479 | 495 | <a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['mc_watched_users_delete_post'] . '" class="you_sure">' . $delete_button . '</a> |
480 | 496 | <input type="checkbox" name="delete[]" value="' . $post['id'] . '">'; |
497 | + } |
|
481 | 498 | |
482 | 499 | $output_html .= ' |
483 | 500 | </div> |
@@ -521,12 +538,12 @@ discard block |
||
521 | 538 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
522 | 539 | </div> |
523 | 540 | </form>'; |
524 | - } |
|
525 | - else |
|
526 | - echo ' |
|
541 | + } else { |
|
542 | + echo ' |
|
527 | 543 | <div class="windowbg"> |
528 | 544 | <div class="centertext">', $txt['mc_no_settings'], '</div> |
529 | 545 | </div>'; |
546 | + } |
|
530 | 547 | |
531 | 548 | echo ' |
532 | 549 | </div><!-- #modcenter -->'; |
@@ -622,13 +639,14 @@ discard block |
||
622 | 639 | </dd> |
623 | 640 | </dl>'; |
624 | 641 | |
625 | - if ($context['template_data']['can_edit_personal']) |
|
626 | - echo ' |
|
642 | + if ($context['template_data']['can_edit_personal']) { |
|
643 | + echo ' |
|
627 | 644 | <input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', '> |
628 | 645 | <label for="make_personal"> |
629 | 646 | <strong>', $txt['mc_warning_template_personal'], '</strong> |
630 | 647 | </label> |
631 | 648 | <p class="smalltext">', $txt['mc_warning_template_personal_desc'], '</p>'; |
649 | + } |
|
632 | 650 | |
633 | 651 | echo ' |
634 | 652 | <input type="submit" name="preview" id="preview_button" value="', $txt['preview'], '" class="button"> |
@@ -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 | * Locks a topic... either by way of a moderator or the topic starter. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $topic, $user_info, $sourcedir, $board, $smcFunc; |
33 | 34 | |
34 | 35 | // Just quit if there's no topic to lock. |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('not_a_topic', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('not_a_topic', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | checkSession('get'); |
39 | 41 | |
@@ -55,29 +57,35 @@ discard block |
||
55 | 57 | |
56 | 58 | // Can you lock topics here, mister? |
57 | 59 | $user_lock = !allowedTo('lock_any'); |
58 | - if ($user_lock && $starter == $user_info['id']) |
|
59 | - isAllowedTo('lock_own'); |
|
60 | - else |
|
61 | - isAllowedTo('lock_any'); |
|
60 | + if ($user_lock && $starter == $user_info['id']) { |
|
61 | + isAllowedTo('lock_own'); |
|
62 | + } else { |
|
63 | + isAllowedTo('lock_any'); |
|
64 | + } |
|
62 | 65 | |
63 | 66 | // Another moderator got the job done first? |
64 | - if (isset($_GET['sa']) && $_GET['sa'] == 'unlock' && $locked == '0') |
|
65 | - fatal_lang_error('error_topic_locked_already', false); |
|
66 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'lock' && ($locked == '1' || $locked == '2')) |
|
67 | - fatal_lang_error('error_topic_unlocked_already', false); |
|
67 | + if (isset($_GET['sa']) && $_GET['sa'] == 'unlock' && $locked == '0') { |
|
68 | + fatal_lang_error('error_topic_locked_already', false); |
|
69 | + } elseif (isset($_GET['sa']) && $_GET['sa'] == 'lock' && ($locked == '1' || $locked == '2')) { |
|
70 | + fatal_lang_error('error_topic_unlocked_already', false); |
|
71 | + } |
|
68 | 72 | |
69 | 73 | // Locking with high privileges. |
70 | - if ($locked == '0' && !$user_lock) |
|
71 | - $locked = '1'; |
|
74 | + if ($locked == '0' && !$user_lock) { |
|
75 | + $locked = '1'; |
|
76 | + } |
|
72 | 77 | // Locking with low privileges. |
73 | - elseif ($locked == '0') |
|
74 | - $locked = '2'; |
|
78 | + elseif ($locked == '0') { |
|
79 | + $locked = '2'; |
|
80 | + } |
|
75 | 81 | // Unlocking - make sure you don't unlock what you can't. |
76 | - elseif ($locked == '2' || ($locked == '1' && !$user_lock)) |
|
77 | - $locked = '0'; |
|
82 | + elseif ($locked == '2' || ($locked == '1' && !$user_lock)) { |
|
83 | + $locked = '0'; |
|
84 | + } |
|
78 | 85 | // You cannot unlock this! |
79 | - else |
|
80 | - fatal_lang_error('locked_by_admin', 'user'); |
|
86 | + else { |
|
87 | + fatal_lang_error('locked_by_admin', 'user'); |
|
88 | + } |
|
81 | 89 | |
82 | 90 | // Actually lock the topic in the database with the new value. |
83 | 91 | $smcFunc['db_query']('', ' |
@@ -91,8 +99,9 @@ discard block |
||
91 | 99 | ); |
92 | 100 | |
93 | 101 | // If they are allowed a "moderator" permission, log it in the moderator log. |
94 | - if (!$user_lock) |
|
95 | - logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
102 | + if (!$user_lock) { |
|
103 | + logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
104 | + } |
|
96 | 105 | // Notify people that this topic has been locked? |
97 | 106 | sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); |
98 | 107 | |
@@ -118,8 +127,9 @@ discard block |
||
118 | 127 | isAllowedTo('make_sticky'); |
119 | 128 | |
120 | 129 | // You can't sticky a board or something! |
121 | - if (empty($topic)) |
|
122 | - fatal_lang_error('not_a_topic', false); |
|
130 | + if (empty($topic)) { |
|
131 | + fatal_lang_error('not_a_topic', false); |
|
132 | + } |
|
123 | 133 | |
124 | 134 | checkSession('get'); |
125 | 135 | |
@@ -140,10 +150,11 @@ discard block |
||
140 | 150 | $smcFunc['db_free_result']($request); |
141 | 151 | |
142 | 152 | // Another moderator got the job done first? |
143 | - if (isset($_GET['sa']) && $_GET['sa'] == 'nonsticky' && $is_sticky == '0') |
|
144 | - fatal_lang_error('error_topic_nonsticky_already', false); |
|
145 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'sticky' && $is_sticky == '1') |
|
146 | - fatal_lang_error('error_topic_sticky_already', false); |
|
153 | + if (isset($_GET['sa']) && $_GET['sa'] == 'nonsticky' && $is_sticky == '0') { |
|
154 | + fatal_lang_error('error_topic_nonsticky_already', false); |
|
155 | + } elseif (isset($_GET['sa']) && $_GET['sa'] == 'sticky' && $is_sticky == '1') { |
|
156 | + fatal_lang_error('error_topic_sticky_already', false); |
|
157 | + } |
|
147 | 158 | |
148 | 159 | // Toggle the sticky value.... pretty simple ;). |
149 | 160 | $smcFunc['db_query']('', ' |
@@ -159,8 +170,9 @@ discard block |
||
159 | 170 | // Log this sticky action - always a moderator thing. |
160 | 171 | logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); |
161 | 172 | // Notify people that this topic has been stickied? |
162 | - if (empty($is_sticky)) |
|
163 | - sendNotifications($topic, 'sticky'); |
|
173 | + if (empty($is_sticky)) { |
|
174 | + sendNotifications($topic, 'sticky'); |
|
175 | + } |
|
164 | 176 | |
165 | 177 | // Take them back to the now stickied topic. |
166 | 178 | redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); |
@@ -28,15 +28,17 @@ discard block |
||
28 | 28 | <form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">'; |
29 | 29 | |
30 | 30 | // Did they make a mistake last time? |
31 | - if (!empty($context['login_errors'])) |
|
32 | - echo ' |
|
31 | + if (!empty($context['login_errors'])) { |
|
32 | + echo ' |
|
33 | 33 | <div class="errorbox">', implode('<br>', $context['login_errors']), '</div> |
34 | 34 | <br>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | // Or perhaps there's some special description for this time? |
37 | - if (isset($context['description'])) |
|
38 | - echo ' |
|
38 | + if (isset($context['description'])) { |
|
39 | + echo ' |
|
39 | 40 | <div class="information">', $context['description'], '</div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Now just get the basic information - username, password, etc. |
42 | 44 | echo ' |
@@ -55,19 +57,21 @@ discard block |
||
55 | 57 | <dd> |
56 | 58 | <select name="cookielength" id="cookielength">'; |
57 | 59 | |
58 | - foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) |
|
59 | - echo ' |
|
60 | + foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) { |
|
61 | + echo ' |
|
60 | 62 | <option value="', $cookie_time, '"', $modSettings['cookieTime'] == $cookie_time ? ' selected' : '', '>', $txt[$cookie_txt], '</option>'; |
63 | + } |
|
61 | 64 | |
62 | 65 | echo ' |
63 | 66 | </select> |
64 | 67 | </dd>'; |
65 | 68 | |
66 | 69 | // If they have deleted their account, give them a chance to change their mind. |
67 | - if (isset($context['login_show_undelete'])) |
|
68 | - echo ' |
|
70 | + if (isset($context['login_show_undelete'])) { |
|
71 | + echo ' |
|
69 | 72 | <dt class="alert">', $txt['undelete_account'], ':</dt> |
70 | 73 | <dd><input type="checkbox" name="undelete"></dd>'; |
74 | + } |
|
71 | 75 | |
72 | 76 | echo ' |
73 | 77 | </dl> |
@@ -85,8 +89,8 @@ discard block |
||
85 | 89 | document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus(); |
86 | 90 | }, 150);'; |
87 | 91 | |
88 | - if (!empty($context['from_ajax'])) |
|
89 | - echo ' |
|
92 | + if (!empty($context['from_ajax'])) { |
|
93 | + echo ' |
|
90 | 94 | form = $("#frmLogin"); |
91 | 95 | form.submit(function(e) { |
92 | 96 | e.preventDefault(); |
@@ -119,16 +123,18 @@ discard block |
||
119 | 123 | |
120 | 124 | return false; |
121 | 125 | });'; |
126 | + } |
|
122 | 127 | |
123 | 128 | echo ' |
124 | 129 | </script> |
125 | 130 | </form>'; |
126 | 131 | |
127 | 132 | // It is a long story as to why we have this when we're clearly not going to use it. |
128 | - if (!empty($context['from_ajax'])) |
|
129 | - echo ' |
|
133 | + if (!empty($context['from_ajax'])) { |
|
134 | + echo ' |
|
130 | 135 | <br> |
131 | 136 | <a href="javascript:self.close();"></a>'; |
137 | + } |
|
132 | 138 | |
133 | 139 | echo ' |
134 | 140 | </div><!-- .roundframe --> |
@@ -151,11 +157,12 @@ discard block |
||
151 | 157 | </div> |
152 | 158 | <div class="roundframe">'; |
153 | 159 | |
154 | - if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) |
|
155 | - echo ' |
|
160 | + if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) { |
|
161 | + echo ' |
|
156 | 162 | <div class="error"> |
157 | 163 | ', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], ' |
158 | 164 | </div>'; |
165 | + } |
|
159 | 166 | |
160 | 167 | echo ' |
161 | 168 | <form action="', $context['tfa_url'], '" method="post" id="frmTfa"> |
@@ -183,8 +190,8 @@ discard block |
||
183 | 190 | <script> |
184 | 191 | form = $("#frmTfa");'; |
185 | 192 | |
186 | - if (!empty($context['from_ajax'])) |
|
187 | - echo ' |
|
193 | + if (!empty($context['from_ajax'])) { |
|
194 | + echo ' |
|
188 | 195 | form.submit(function(e) { |
189 | 196 | // If we are submitting backup code, let normal workflow follow since it redirects a couple times into a different page |
190 | 197 | if (form.find("input[name=tfa_backup]:first").val().length > 0) |
@@ -203,6 +210,7 @@ discard block |
||
203 | 210 | |
204 | 211 | return false; |
205 | 212 | });'; |
213 | + } |
|
206 | 214 | |
207 | 215 | echo ' |
208 | 216 | form.find("input[name=backup]").click(function(e) { |
@@ -234,10 +242,11 @@ discard block |
||
234 | 242 | <p class="information centertext"> |
235 | 243 | ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>'; |
236 | 244 | |
237 | - if ($context['can_register']) |
|
238 | - echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
239 | - else |
|
240 | - echo $txt['login_below']; |
|
245 | + if ($context['can_register']) { |
|
246 | + echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
247 | + } else { |
|
248 | + echo $txt['login_below']; |
|
249 | + } |
|
241 | 250 | |
242 | 251 | // And now the login information. |
243 | 252 | echo ' |
@@ -256,9 +265,10 @@ discard block |
||
256 | 265 | <dd> |
257 | 266 | <select name="cookielength" id="cookielength">'; |
258 | 267 | |
259 | - foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) |
|
260 | - echo ' |
|
268 | + foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) { |
|
269 | + echo ' |
|
261 | 270 | <option value="', $cookie_time, '"', $modSettings['cookieTime'] == $cookie_time ? ' selected' : '', '>', $txt[$cookie_txt], '</option>'; |
271 | + } |
|
262 | 272 | |
263 | 273 | echo ' |
264 | 274 | </select> |
@@ -315,9 +325,10 @@ discard block |
||
315 | 325 | <dd> |
316 | 326 | <select name="cookielength" id="cookielength">'; |
317 | 327 | |
318 | - foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) |
|
319 | - echo ' |
|
328 | + foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) { |
|
329 | + echo ' |
|
320 | 330 | <option value="', $cookie_time, '"', $modSettings['cookieTime'] == $cookie_time ? ' selected' : '', '>', $txt[$cookie_txt], '</option>'; |
331 | + } |
|
321 | 332 | |
322 | 333 | echo ' |
323 | 334 | </select> |
@@ -351,9 +362,10 @@ discard block |
||
351 | 362 | </div> |
352 | 363 | <div class="roundframe centertext">'; |
353 | 364 | |
354 | - if (!empty($context['incorrect_password'])) |
|
355 | - echo ' |
|
365 | + if (!empty($context['incorrect_password'])) { |
|
366 | + echo ' |
|
356 | 367 | <div class="error">', $txt['admin_incorrect_password'], '</div>'; |
368 | + } |
|
357 | 369 | |
358 | 370 | echo ' |
359 | 371 | <strong>', $txt['password'], ':</strong> |
@@ -394,10 +406,11 @@ discard block |
||
394 | 406 | <dl>'; |
395 | 407 | |
396 | 408 | // You didn't even have an ID? |
397 | - if (empty($context['member_id'])) |
|
398 | - echo ' |
|
409 | + if (empty($context['member_id'])) { |
|
410 | + echo ' |
|
399 | 411 | <dt>', $txt['invalid_activation_username'], ':</dt> |
400 | 412 | <dd><input type="text" name="user" size="30"></dd>'; |
413 | + } |
|
401 | 414 | |
402 | 415 | echo ' |
403 | 416 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
@@ -434,13 +447,14 @@ discard block |
||
434 | 447 | <dd><input type="password" name="passwd" size="30"></dd> |
435 | 448 | </dl>'; |
436 | 449 | |
437 | - if ($context['can_activate']) |
|
438 | - echo ' |
|
450 | + if ($context['can_activate']) { |
|
451 | + echo ' |
|
439 | 452 | <p>', $txt['invalid_activation_known'], '</p> |
440 | 453 | <dl> |
441 | 454 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
442 | 455 | <dd><input type="text" name="code" size="30"></dd> |
443 | 456 | </dl>'; |
457 | + } |
|
444 | 458 | |
445 | 459 | echo ' |
446 | 460 | <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button"></p> |
@@ -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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
93 | 96 | |
94 | 97 | // Check to ensure we're forcing SSL for authentication |
95 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
96 | - fatal_lang_error('login_ssl_required'); |
|
98 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
99 | + fatal_lang_error('login_ssl_required'); |
|
100 | + } |
|
97 | 101 | |
98 | 102 | // Load cookie authentication stuff. |
99 | 103 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -107,23 +111,26 @@ discard block |
||
107 | 111 | if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest']) |
108 | 112 | { |
109 | 113 | // First check for 2.1 json-format cookie in $_COOKIE |
110 | - if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) |
|
111 | - list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
114 | + if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) { |
|
115 | + list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
116 | + } |
|
112 | 117 | |
113 | 118 | // Try checking for 2.1 json-format cookie in $_SESSION |
114 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) |
|
115 | - list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
119 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) { |
|
120 | + list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
121 | + } |
|
116 | 122 | |
117 | 123 | // Next, try checking for 2.0 serialized string cookie in $_COOKIE |
118 | - elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) |
|
119 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
124 | + elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) { |
|
125 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
126 | + } |
|
120 | 127 | |
121 | 128 | // Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION |
122 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) |
|
123 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
124 | - |
|
125 | - else |
|
126 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
129 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) { |
|
130 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
131 | + } else { |
|
132 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
133 | + } |
|
127 | 134 | |
128 | 135 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
129 | 136 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -143,24 +150,23 @@ discard block |
||
143 | 150 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
144 | 151 | { |
145 | 152 | // Strike! You're outta there! |
146 | - if ($_GET['member'] != $user_info['id']) |
|
147 | - fatal_lang_error('login_cookie_error', false); |
|
153 | + if ($_GET['member'] != $user_info['id']) { |
|
154 | + fatal_lang_error('login_cookie_error', false); |
|
155 | + } |
|
148 | 156 | |
149 | 157 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
150 | 158 | |
151 | 159 | // Some whitelisting for login_url... |
152 | - if (empty($_SESSION['login_url'])) |
|
153 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
154 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
160 | + if (empty($_SESSION['login_url'])) { |
|
161 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
162 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
155 | 163 | { |
156 | 164 | unset ($_SESSION['login_url']); |
157 | 165 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
158 | - } |
|
159 | - elseif (!empty($user_settings['tfa_secret'])) |
|
166 | + } elseif (!empty($user_settings['tfa_secret'])) |
|
160 | 167 | { |
161 | 168 | redirectexit('action=logintfa'); |
162 | - } |
|
163 | - else |
|
169 | + } else |
|
164 | 170 | { |
165 | 171 | // Best not to clutter the session data too much... |
166 | 172 | $temp = $_SESSION['login_url']; |
@@ -171,8 +177,9 @@ discard block |
||
171 | 177 | } |
172 | 178 | |
173 | 179 | // Beyond this point you are assumed to be a guest trying to login. |
174 | - if (!$user_info['is_guest']) |
|
175 | - redirectexit(); |
|
180 | + if (!$user_info['is_guest']) { |
|
181 | + redirectexit(); |
|
182 | + } |
|
176 | 183 | |
177 | 184 | // Are you guessing with a script? |
178 | 185 | checkSession(); |
@@ -180,18 +187,21 @@ discard block |
||
180 | 187 | spamProtection('login'); |
181 | 188 | |
182 | 189 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
183 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
184 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
190 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
191 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
192 | + } |
|
185 | 193 | |
186 | 194 | // Been guessing a lot, haven't we? |
187 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
188 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
195 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
196 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
197 | + } |
|
189 | 198 | |
190 | 199 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
191 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
192 | - $modSettings['cookieTime'] = 3153600; |
|
193 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) |
|
194 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
200 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
201 | + $modSettings['cookieTime'] = 3153600; |
|
202 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) { |
|
203 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
204 | + } |
|
195 | 205 | |
196 | 206 | // Login Cookie times. Format: time => txt |
197 | 207 | $context['login_cookie_times'] = array( |
@@ -320,8 +330,9 @@ discard block |
||
320 | 330 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
321 | 331 | |
322 | 332 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
323 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
324 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
333 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
334 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
335 | + } |
|
325 | 336 | |
326 | 337 | // phpBB3 users new hashing. We now support it as well ;). |
327 | 338 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -341,27 +352,29 @@ discard block |
||
341 | 352 | // Some common md5 ones. |
342 | 353 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
343 | 354 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
344 | - } |
|
345 | - elseif (strlen($user_settings['passwd']) == 40) |
|
355 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
346 | 356 | { |
347 | 357 | // Maybe they are using a hash from before the password fix. |
348 | 358 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
349 | 359 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
350 | 360 | |
351 | 361 | // BurningBoard3 style of hashing. |
352 | - if (!empty($modSettings['enable_password_conversion'])) |
|
353 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
362 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
363 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
364 | + } |
|
354 | 365 | |
355 | 366 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
356 | 367 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
357 | 368 | { |
358 | 369 | // Try iconv first, for no particular reason. |
359 | - if (function_exists('iconv')) |
|
360 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
370 | + if (function_exists('iconv')) { |
|
371 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
372 | + } |
|
361 | 373 | |
362 | 374 | // Say it aint so, iconv failed! |
363 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
364 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
375 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
376 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
377 | + } |
|
365 | 378 | } |
366 | 379 | } |
367 | 380 | |
@@ -391,8 +404,9 @@ discard block |
||
391 | 404 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
392 | 405 | |
393 | 406 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
394 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
395 | - redirectexit('action=reminder'); |
|
407 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
408 | + redirectexit('action=reminder'); |
|
409 | + } |
|
396 | 410 | // We'll give you another chance... |
397 | 411 | else |
398 | 412 | { |
@@ -403,8 +417,7 @@ discard block |
||
403 | 417 | return; |
404 | 418 | } |
405 | 419 | } |
406 | - } |
|
407 | - elseif (!empty($user_settings['passwd_flood'])) |
|
420 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
408 | 421 | { |
409 | 422 | // Let's be sure they weren't a little hacker. |
410 | 423 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -421,8 +434,9 @@ discard block |
||
421 | 434 | } |
422 | 435 | |
423 | 436 | // Check their activation status. |
424 | - if (!checkActivation()) |
|
425 | - return; |
|
437 | + if (!checkActivation()) { |
|
438 | + return; |
|
439 | + } |
|
426 | 440 | |
427 | 441 | DoLogin(); |
428 | 442 | } |
@@ -434,8 +448,9 @@ discard block |
||
434 | 448 | { |
435 | 449 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
436 | 450 | |
437 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
438 | - fatal_lang_error('no_access', false); |
|
451 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
452 | + fatal_lang_error('no_access', false); |
|
453 | + } |
|
439 | 454 | |
440 | 455 | loadLanguage('Profile'); |
441 | 456 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -443,8 +458,9 @@ discard block |
||
443 | 458 | $member = $context['tfa_member']; |
444 | 459 | |
445 | 460 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
446 | - if (time() - $member['last_login'] < 120) |
|
447 | - fatal_lang_error('tfa_wait', false); |
|
461 | + if (time() - $member['last_login'] < 120) { |
|
462 | + fatal_lang_error('tfa_wait', false); |
|
463 | + } |
|
448 | 464 | |
449 | 465 | $totp = new \TOTP\Auth($member['tfa_secret']); |
450 | 466 | $totp->setRange(1); |
@@ -458,8 +474,9 @@ discard block |
||
458 | 474 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
459 | 475 | { |
460 | 476 | // Check to ensure we're forcing SSL for authentication |
461 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
462 | - fatal_lang_error('login_ssl_required'); |
|
477 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
478 | + fatal_lang_error('login_ssl_required'); |
|
479 | + } |
|
463 | 480 | |
464 | 481 | $code = $_POST['tfa_code']; |
465 | 482 | |
@@ -469,20 +486,19 @@ discard block |
||
469 | 486 | |
470 | 487 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
471 | 488 | redirectexit(); |
472 | - } |
|
473 | - else |
|
489 | + } else |
|
474 | 490 | { |
475 | 491 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
476 | 492 | |
477 | 493 | $context['tfa_error'] = true; |
478 | 494 | $context['tfa_value'] = $_POST['tfa_code']; |
479 | 495 | } |
480 | - } |
|
481 | - elseif (!empty($_POST['tfa_backup'])) |
|
496 | + } elseif (!empty($_POST['tfa_backup'])) |
|
482 | 497 | { |
483 | 498 | // Check to ensure we're forcing SSL for authentication |
484 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
485 | - fatal_lang_error('login_ssl_required'); |
|
499 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
500 | + fatal_lang_error('login_ssl_required'); |
|
501 | + } |
|
486 | 502 | |
487 | 503 | $backup = $_POST['tfa_backup']; |
488 | 504 | |
@@ -496,8 +512,7 @@ discard block |
||
496 | 512 | )); |
497 | 513 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
498 | 514 | redirectexit('action=profile;area=tfasetup;backup'); |
499 | - } |
|
500 | - else |
|
515 | + } else |
|
501 | 516 | { |
502 | 517 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
503 | 518 | |
@@ -520,8 +535,9 @@ discard block |
||
520 | 535 | { |
521 | 536 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
522 | 537 | |
523 | - if (!isset($context['login_errors'])) |
|
524 | - $context['login_errors'] = array(); |
|
538 | + if (!isset($context['login_errors'])) { |
|
539 | + $context['login_errors'] = array(); |
|
540 | + } |
|
525 | 541 | |
526 | 542 | // What is the true activation status of this account? |
527 | 543 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -533,8 +549,9 @@ discard block |
||
533 | 549 | return false; |
534 | 550 | } |
535 | 551 | // Awaiting approval still? |
536 | - elseif ($activation_status == 3) |
|
537 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
552 | + elseif ($activation_status == 3) { |
|
553 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
554 | + } |
|
538 | 555 | // Awaiting deletion, changed their mind? |
539 | 556 | elseif ($activation_status == 4) |
540 | 557 | { |
@@ -542,8 +559,7 @@ discard block |
||
542 | 559 | { |
543 | 560 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
544 | 561 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
545 | - } |
|
546 | - else |
|
562 | + } else |
|
547 | 563 | { |
548 | 564 | $context['disable_login_hashing'] = true; |
549 | 565 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -583,8 +599,9 @@ discard block |
||
583 | 599 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
584 | 600 | |
585 | 601 | // Reset the login threshold. |
586 | - if (isset($_SESSION['failed_login'])) |
|
587 | - unset($_SESSION['failed_login']); |
|
602 | + if (isset($_SESSION['failed_login'])) { |
|
603 | + unset($_SESSION['failed_login']); |
|
604 | + } |
|
588 | 605 | |
589 | 606 | $user_info['is_guest'] = false; |
590 | 607 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -606,16 +623,18 @@ discard block |
||
606 | 623 | 'id_member' => $user_info['id'], |
607 | 624 | ) |
608 | 625 | ); |
609 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
610 | - $_SESSION['first_login'] = true; |
|
611 | - else |
|
612 | - unset($_SESSION['first_login']); |
|
626 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
627 | + $_SESSION['first_login'] = true; |
|
628 | + } else { |
|
629 | + unset($_SESSION['first_login']); |
|
630 | + } |
|
613 | 631 | $smcFunc['db_free_result']($request); |
614 | 632 | |
615 | 633 | // You've logged in, haven't you? |
616 | 634 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
617 | - if (empty($user_settings['tfa_secret'])) |
|
618 | - $update['last_login'] = time(); |
|
635 | + if (empty($user_settings['tfa_secret'])) { |
|
636 | + $update['last_login'] = time(); |
|
637 | + } |
|
619 | 638 | updateMemberData($user_info['id'], $update); |
620 | 639 | |
621 | 640 | // Get rid of the online entry for that old guest.... |
@@ -629,8 +648,8 @@ discard block |
||
629 | 648 | $_SESSION['log_time'] = 0; |
630 | 649 | |
631 | 650 | // Log this entry, only if we have it enabled. |
632 | - if (!empty($modSettings['loginHistoryDays'])) |
|
633 | - $smcFunc['db_insert']('insert', |
|
651 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
652 | + $smcFunc['db_insert']('insert', |
|
634 | 653 | '{db_prefix}member_logins', |
635 | 654 | array( |
636 | 655 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -642,13 +661,15 @@ discard block |
||
642 | 661 | 'id_member', 'time' |
643 | 662 | ) |
644 | 663 | ); |
664 | + } |
|
645 | 665 | |
646 | 666 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
647 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
648 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
649 | - else |
|
650 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
651 | -} |
|
667 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
668 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
669 | + } else { |
|
670 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
671 | + } |
|
672 | + } |
|
652 | 673 | |
653 | 674 | /** |
654 | 675 | * Logs the current user out of their account. |
@@ -664,13 +685,15 @@ discard block |
||
664 | 685 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
665 | 686 | |
666 | 687 | // Make sure they aren't being auto-logged out. |
667 | - if (!$internal) |
|
668 | - checkSession('get'); |
|
688 | + if (!$internal) { |
|
689 | + checkSession('get'); |
|
690 | + } |
|
669 | 691 | |
670 | 692 | require_once($sourcedir . '/Subs-Auth.php'); |
671 | 693 | |
672 | - if (isset($_SESSION['pack_ftp'])) |
|
673 | - $_SESSION['pack_ftp'] = null; |
|
694 | + if (isset($_SESSION['pack_ftp'])) { |
|
695 | + $_SESSION['pack_ftp'] = null; |
|
696 | + } |
|
674 | 697 | |
675 | 698 | // It won't be first login anymore. |
676 | 699 | unset($_SESSION['first_login']); |
@@ -698,8 +721,9 @@ discard block |
||
698 | 721 | |
699 | 722 | // And some other housekeeping while we're at it. |
700 | 723 | $salt = substr(md5(mt_rand()), 0, 4); |
701 | - if (!empty($user_info['id'])) |
|
702 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
724 | + if (!empty($user_info['id'])) { |
|
725 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
726 | + } |
|
703 | 727 | |
704 | 728 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
705 | 729 | { |
@@ -712,14 +736,13 @@ discard block |
||
712 | 736 | // Off to the merry board index we go! |
713 | 737 | if ($redirect) |
714 | 738 | { |
715 | - if (empty($_SESSION['logout_url'])) |
|
716 | - redirectexit('', $context['server']['needs_login_fix']); |
|
717 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
739 | + if (empty($_SESSION['logout_url'])) { |
|
740 | + redirectexit('', $context['server']['needs_login_fix']); |
|
741 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
718 | 742 | { |
719 | 743 | unset ($_SESSION['logout_url']); |
720 | 744 | redirectexit(); |
721 | - } |
|
722 | - else |
|
745 | + } else |
|
723 | 746 | { |
724 | 747 | $temp = $_SESSION['logout_url']; |
725 | 748 | unset($_SESSION['logout_url']); |
@@ -752,8 +775,9 @@ discard block |
||
752 | 775 | function phpBB3_password_check($passwd, $passwd_hash) |
753 | 776 | { |
754 | 777 | // Too long or too short? |
755 | - if (strlen($passwd_hash) != 34) |
|
756 | - return; |
|
778 | + if (strlen($passwd_hash) != 34) { |
|
779 | + return; |
|
780 | + } |
|
757 | 781 | |
758 | 782 | // Range of characters allowed. |
759 | 783 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -764,8 +788,9 @@ discard block |
||
764 | 788 | $salt = substr($passwd_hash, 4, 8); |
765 | 789 | |
766 | 790 | $hash = md5($salt . $passwd, true); |
767 | - for (; $count != 0; --$count) |
|
768 | - $hash = md5($hash . $passwd, true); |
|
791 | + for (; $count != 0; --$count) { |
|
792 | + $hash = md5($hash . $passwd, true); |
|
793 | + } |
|
769 | 794 | |
770 | 795 | $output = substr($passwd_hash, 0, 12); |
771 | 796 | $i = 0; |
@@ -774,21 +799,25 @@ discard block |
||
774 | 799 | $value = ord($hash[$i++]); |
775 | 800 | $output .= $range[$value & 0x3f]; |
776 | 801 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 8; |
|
802 | + if ($i < 16) { |
|
803 | + $value |= ord($hash[$i]) << 8; |
|
804 | + } |
|
779 | 805 | |
780 | 806 | $output .= $range[($value >> 6) & 0x3f]; |
781 | 807 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
808 | + if ($i++ >= 16) { |
|
809 | + break; |
|
810 | + } |
|
784 | 811 | |
785 | - if ($i < 16) |
|
786 | - $value |= ord($hash[$i]) << 16; |
|
812 | + if ($i < 16) { |
|
813 | + $value |= ord($hash[$i]) << 16; |
|
814 | + } |
|
787 | 815 | |
788 | 816 | $output .= $range[($value >> 12) & 0x3f]; |
789 | 817 | |
790 | - if ($i++ >= 16) |
|
791 | - break; |
|
818 | + if ($i++ >= 16) { |
|
819 | + break; |
|
820 | + } |
|
792 | 821 | |
793 | 822 | $output .= $range[($value >> 18) & 0x3f]; |
794 | 823 | } |
@@ -820,8 +849,9 @@ discard block |
||
820 | 849 | require_once($sourcedir . '/Subs-Auth.php'); |
821 | 850 | setLoginCookie(-3600, 0); |
822 | 851 | |
823 | - if (isset($_SESSION['login_' . $cookiename])) |
|
824 | - unset($_SESSION['login_' . $cookiename]); |
|
852 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
853 | + unset($_SESSION['login_' . $cookiename]); |
|
854 | + } |
|
825 | 855 | } |
826 | 856 | |
827 | 857 | // We need a member! |
@@ -835,8 +865,9 @@ discard block |
||
835 | 865 | } |
836 | 866 | |
837 | 867 | // Right, have we got a flood value? |
838 | - if ($password_flood_value !== false) |
|
839 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
868 | + if ($password_flood_value !== false) { |
|
869 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
870 | + } |
|
840 | 871 | |
841 | 872 | // Timestamp or number of tries invalid? |
842 | 873 | if (empty($number_tries) || empty($time_stamp)) |
@@ -852,15 +883,17 @@ discard block |
||
852 | 883 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
853 | 884 | |
854 | 885 | // They are trying too fast, make them wait longer |
855 | - if ($time_stamp < time() - 10) |
|
856 | - $time_stamp = time(); |
|
886 | + if ($time_stamp < time() - 10) { |
|
887 | + $time_stamp = time(); |
|
888 | + } |
|
857 | 889 | } |
858 | 890 | |
859 | 891 | $number_tries++; |
860 | 892 | |
861 | 893 | // Broken the law? |
862 | - if ($number_tries > 5) |
|
863 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
894 | + if ($number_tries > 5) { |
|
895 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
896 | + } |
|
864 | 897 | |
865 | 898 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
866 | 899 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting for fatal errors. |
154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
230 | 239 | // Now just redirect to a blank.png... |
231 | 240 | $secure = false; |
232 | 241 | |
233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
234 | - $secure = true; |
|
235 | - 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') |
|
236 | - $secure = true; |
|
242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
243 | + $secure = true; |
|
244 | + } 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') { |
|
245 | + $secure = true; |
|
246 | + } |
|
237 | 247 | |
238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | { |
245 | 255 | // Get PHP's default timezone, if set |
246 | 256 | $ini_tz = ini_get('date.timezone'); |
247 | - if (!empty($ini_tz)) |
|
248 | - $timezone_id = $ini_tz; |
|
249 | - else |
|
250 | - $timezone_id = ''; |
|
257 | + if (!empty($ini_tz)) { |
|
258 | + $timezone_id = $ini_tz; |
|
259 | + } else { |
|
260 | + $timezone_id = ''; |
|
261 | + } |
|
251 | 262 | |
252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
278 | 289 | while ($entry = $dir->read()) |
279 | 290 | { |
280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
293 | + } |
|
282 | 294 | } |
283 | 295 | $dir->close(); |
284 | 296 | } |
@@ -325,10 +337,11 @@ discard block |
||
325 | 337 | } |
326 | 338 | |
327 | 339 | // Override the language file? |
328 | - if (isset($_GET['lang_file'])) |
|
329 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
330 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
331 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
340 | + if (isset($_GET['lang_file'])) { |
|
341 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
342 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
343 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
344 | + } |
|
332 | 345 | |
333 | 346 | // Make sure it exists, if it doesn't reset it. |
334 | 347 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -337,8 +350,9 @@ discard block |
||
337 | 350 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
338 | 351 | |
339 | 352 | // If we have english and some other language, use the other language. We Americans hate english :P. |
340 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
341 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
353 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
354 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
355 | + } |
|
342 | 356 | } |
343 | 357 | |
344 | 358 | // And now include the actual language file itself. |
@@ -355,15 +369,18 @@ discard block |
||
355 | 369 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
356 | 370 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
357 | 371 | |
358 | - if (empty($sourcedir)) |
|
359 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
372 | + if (empty($sourcedir)) { |
|
373 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
374 | + } |
|
360 | 375 | |
361 | 376 | // Need this to check whether we need the database password. |
362 | 377 | require(dirname(__FILE__) . '/Settings.php'); |
363 | - if (!defined('SMF')) |
|
364 | - define('SMF', 1); |
|
365 | - if (empty($smcFunc)) |
|
366 | - $smcFunc = array(); |
|
378 | + if (!defined('SMF')) { |
|
379 | + define('SMF', 1); |
|
380 | + } |
|
381 | + if (empty($smcFunc)) { |
|
382 | + $smcFunc = array(); |
|
383 | + } |
|
367 | 384 | |
368 | 385 | $modSettings['disableQueryCheck'] = true; |
369 | 386 | |
@@ -371,8 +388,9 @@ discard block |
||
371 | 388 | if (!$db_connection) |
372 | 389 | { |
373 | 390 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
374 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
375 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
391 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
392 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
393 | + } |
|
376 | 394 | |
377 | 395 | $db_options = array('persist' => $db_persist); |
378 | 396 | $port = ''; |
@@ -383,19 +401,20 @@ discard block |
||
383 | 401 | if ($db_type == 'mysql') |
384 | 402 | { |
385 | 403 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
386 | - } |
|
387 | - elseif ($db_type == 'postgresql') |
|
404 | + } elseif ($db_type == 'postgresql') |
|
388 | 405 | { |
389 | 406 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
390 | 407 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
391 | 408 | } |
392 | 409 | } |
393 | 410 | |
394 | - if (!empty($port)) |
|
395 | - $db_options['port'] = $port; |
|
411 | + if (!empty($port)) { |
|
412 | + $db_options['port'] = $port; |
|
413 | + } |
|
396 | 414 | |
397 | - if (!$db_connection) |
|
398 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
415 | + if (!$db_connection) { |
|
416 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
417 | + } |
|
399 | 418 | } |
400 | 419 | } |
401 | 420 | |
@@ -423,8 +442,9 @@ discard block |
||
423 | 442 | // @todo REMOVE THIS!! |
424 | 443 | else |
425 | 444 | { |
426 | - if (function_exists('doStep' . $_GET['step'])) |
|
427 | - call_user_func('doStep' . $_GET['step']); |
|
445 | + if (function_exists('doStep' . $_GET['step'])) { |
|
446 | + call_user_func('doStep' . $_GET['step']); |
|
447 | + } |
|
428 | 448 | } |
429 | 449 | // Show the footer. |
430 | 450 | template_install_below(); |
@@ -442,8 +462,9 @@ discard block |
||
442 | 462 | $incontext['sub_template'] = 'welcome_message'; |
443 | 463 | |
444 | 464 | // Done the submission? |
445 | - if (isset($_POST['contbutt'])) |
|
446 | - return true; |
|
465 | + if (isset($_POST['contbutt'])) { |
|
466 | + return true; |
|
467 | + } |
|
447 | 468 | |
448 | 469 | // See if we think they have already installed it? |
449 | 470 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -451,14 +472,17 @@ discard block |
||
451 | 472 | $probably_installed = 0; |
452 | 473 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
453 | 474 | { |
454 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
455 | - $probably_installed++; |
|
456 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
457 | - $probably_installed++; |
|
475 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
476 | + $probably_installed++; |
|
477 | + } |
|
478 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
479 | + $probably_installed++; |
|
480 | + } |
|
458 | 481 | } |
459 | 482 | |
460 | - if ($probably_installed == 2) |
|
461 | - $incontext['warning'] = $txt['error_already_installed']; |
|
483 | + if ($probably_installed == 2) { |
|
484 | + $incontext['warning'] = $txt['error_already_installed']; |
|
485 | + } |
|
462 | 486 | } |
463 | 487 | |
464 | 488 | // Is some database support even compiled in? |
@@ -473,45 +497,54 @@ discard block |
||
473 | 497 | $databases[$key]['supported'] = false; |
474 | 498 | $notFoundSQLFile = true; |
475 | 499 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
500 | + } else { |
|
501 | + $incontext['supported_databases'][] = $db; |
|
476 | 502 | } |
477 | - else |
|
478 | - $incontext['supported_databases'][] = $db; |
|
479 | 503 | } |
480 | 504 | } |
481 | 505 | |
482 | 506 | // Check the PHP version. |
483 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
484 | - $error = 'error_php_too_low'; |
|
507 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
508 | + $error = 'error_php_too_low'; |
|
509 | + } |
|
485 | 510 | // Make sure we have a supported database |
486 | - elseif (empty($incontext['supported_databases'])) |
|
487 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
511 | + elseif (empty($incontext['supported_databases'])) { |
|
512 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
513 | + } |
|
488 | 514 | // How about session support? Some crazy sysadmin remove it? |
489 | - elseif (!function_exists('session_start')) |
|
490 | - $error = 'error_session_missing'; |
|
515 | + elseif (!function_exists('session_start')) { |
|
516 | + $error = 'error_session_missing'; |
|
517 | + } |
|
491 | 518 | // Make sure they uploaded all the files. |
492 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
493 | - $error = 'error_missing_files'; |
|
519 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
520 | + $error = 'error_missing_files'; |
|
521 | + } |
|
494 | 522 | // Very simple check on the session.save_path for Windows. |
495 | 523 | // @todo Move this down later if they don't use database-driven sessions? |
496 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
497 | - $error = 'error_session_save_path'; |
|
524 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
525 | + $error = 'error_session_save_path'; |
|
526 | + } |
|
498 | 527 | |
499 | 528 | // Since each of the three messages would look the same, anyway... |
500 | - if (isset($error)) |
|
501 | - $incontext['error'] = $txt[$error]; |
|
529 | + if (isset($error)) { |
|
530 | + $incontext['error'] = $txt[$error]; |
|
531 | + } |
|
502 | 532 | |
503 | 533 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
504 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
505 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
534 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
535 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
536 | + } |
|
506 | 537 | |
507 | 538 | // Confirm mbstring is loaded... |
508 | - if (!extension_loaded('mbstring')) |
|
509 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
539 | + if (!extension_loaded('mbstring')) { |
|
540 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
541 | + } |
|
510 | 542 | |
511 | 543 | // Check for https stream support. |
512 | 544 | $supported_streams = stream_get_wrappers(); |
513 | - if (!in_array('https', $supported_streams)) |
|
514 | - $incontext['warning'] = $txt['install_no_https']; |
|
545 | + if (!in_array('https', $supported_streams)) { |
|
546 | + $incontext['warning'] = $txt['install_no_https']; |
|
547 | + } |
|
515 | 548 | |
516 | 549 | return false; |
517 | 550 | } |
@@ -536,12 +569,14 @@ discard block |
||
536 | 569 | 'Settings_bak.php', |
537 | 570 | ); |
538 | 571 | |
539 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
540 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
572 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
573 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
574 | + } |
|
541 | 575 | |
542 | 576 | // With mod_security installed, we could attempt to fix it with .htaccess. |
543 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
544 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
577 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
578 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
579 | + } |
|
545 | 580 | |
546 | 581 | $failed_files = array(); |
547 | 582 | |
@@ -553,20 +588,23 @@ discard block |
||
553 | 588 | foreach ($writable_files as $file) |
554 | 589 | { |
555 | 590 | // Some files won't exist, try to address up front |
556 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
557 | - @touch(dirname(__FILE__) . '/' . $file); |
|
591 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
592 | + @touch(dirname(__FILE__) . '/' . $file); |
|
593 | + } |
|
558 | 594 | // NOW do the writable check... |
559 | 595 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
560 | 596 | { |
561 | 597 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
562 | 598 | |
563 | 599 | // Well, 755 hopefully worked... if not, try 777. |
564 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
565 | - $failed_files[] = $file; |
|
600 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
601 | + $failed_files[] = $file; |
|
602 | + } |
|
566 | 603 | } |
567 | 604 | } |
568 | - foreach ($extra_files as $file) |
|
569 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
605 | + foreach ($extra_files as $file) { |
|
606 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
607 | + } |
|
570 | 608 | } |
571 | 609 | // Windows is trickier. Let's try opening for r+... |
572 | 610 | else |
@@ -576,30 +614,35 @@ discard block |
||
576 | 614 | foreach ($writable_files as $file) |
577 | 615 | { |
578 | 616 | // Folders can't be opened for write... but the index.php in them can ;) |
579 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
580 | - $file .= '/index.php'; |
|
617 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
618 | + $file .= '/index.php'; |
|
619 | + } |
|
581 | 620 | |
582 | 621 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
583 | 622 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
584 | 623 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
585 | 624 | |
586 | 625 | // Hmm, okay, try just for write in that case... |
587 | - if (!is_resource($fp)) |
|
588 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
626 | + if (!is_resource($fp)) { |
|
627 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
628 | + } |
|
589 | 629 | |
590 | - if (!is_resource($fp)) |
|
591 | - $failed_files[] = $file; |
|
630 | + if (!is_resource($fp)) { |
|
631 | + $failed_files[] = $file; |
|
632 | + } |
|
592 | 633 | |
593 | 634 | @fclose($fp); |
594 | 635 | } |
595 | - foreach ($extra_files as $file) |
|
596 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
636 | + foreach ($extra_files as $file) { |
|
637 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
638 | + } |
|
597 | 639 | } |
598 | 640 | |
599 | 641 | $failure = count($failed_files) >= 1; |
600 | 642 | |
601 | - if (!isset($_SERVER)) |
|
602 | - return !$failure; |
|
643 | + if (!isset($_SERVER)) { |
|
644 | + return !$failure; |
|
645 | + } |
|
603 | 646 | |
604 | 647 | // Put the list into context. |
605 | 648 | $incontext['failed_files'] = $failed_files; |
@@ -647,19 +690,23 @@ discard block |
||
647 | 690 | |
648 | 691 | if (!isset($ftp) || $ftp->error !== false) |
649 | 692 | { |
650 | - if (!isset($ftp)) |
|
651 | - $ftp = new ftp_connection(null); |
|
693 | + if (!isset($ftp)) { |
|
694 | + $ftp = new ftp_connection(null); |
|
695 | + } |
|
652 | 696 | // Save the error so we can mess with listing... |
653 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
654 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
697 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
698 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
699 | + } |
|
655 | 700 | |
656 | 701 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
657 | 702 | |
658 | - if (empty($_POST['ftp_path']) && $found_path) |
|
659 | - $_POST['ftp_path'] = $detect_path; |
|
703 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
704 | + $_POST['ftp_path'] = $detect_path; |
|
705 | + } |
|
660 | 706 | |
661 | - if (!isset($_POST['ftp_username'])) |
|
662 | - $_POST['ftp_username'] = $username; |
|
707 | + if (!isset($_POST['ftp_username'])) { |
|
708 | + $_POST['ftp_username'] = $username; |
|
709 | + } |
|
663 | 710 | |
664 | 711 | // Set the username etc, into context. |
665 | 712 | $incontext['ftp'] = array( |
@@ -671,8 +718,7 @@ discard block |
||
671 | 718 | ); |
672 | 719 | |
673 | 720 | return false; |
674 | - } |
|
675 | - else |
|
721 | + } else |
|
676 | 722 | { |
677 | 723 | $_SESSION['installer_temp_ftp'] = array( |
678 | 724 | 'server' => $_POST['ftp_server'], |
@@ -686,10 +732,12 @@ discard block |
||
686 | 732 | |
687 | 733 | foreach ($failed_files as $file) |
688 | 734 | { |
689 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
690 | - $ftp->chmod($file, 0755); |
|
691 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
692 | - $ftp->chmod($file, 0777); |
|
735 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
736 | + $ftp->chmod($file, 0755); |
|
737 | + } |
|
738 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
739 | + $ftp->chmod($file, 0777); |
|
740 | + } |
|
693 | 741 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
694 | 742 | { |
695 | 743 | $failed_files_updated[] = $file; |
@@ -745,15 +793,17 @@ discard block |
||
745 | 793 | |
746 | 794 | if (!$foundOne) |
747 | 795 | { |
748 | - if (isset($db['default_host'])) |
|
749 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
796 | + if (isset($db['default_host'])) { |
|
797 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
798 | + } |
|
750 | 799 | if (isset($db['default_user'])) |
751 | 800 | { |
752 | 801 | $incontext['db']['user'] = ini_get($db['default_user']); |
753 | 802 | $incontext['db']['name'] = ini_get($db['default_user']); |
754 | 803 | } |
755 | - if (isset($db['default_password'])) |
|
756 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
804 | + if (isset($db['default_password'])) { |
|
805 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
806 | + } |
|
757 | 807 | |
758 | 808 | // For simplicity and less confusion, leave the port blank by default |
759 | 809 | $incontext['db']['port'] = ''; |
@@ -772,10 +822,10 @@ discard block |
||
772 | 822 | $incontext['db']['server'] = $_POST['db_server']; |
773 | 823 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
774 | 824 | |
775 | - if (!empty($_POST['db_port'])) |
|
776 | - $incontext['db']['port'] = $_POST['db_port']; |
|
777 | - } |
|
778 | - else |
|
825 | + if (!empty($_POST['db_port'])) { |
|
826 | + $incontext['db']['port'] = $_POST['db_port']; |
|
827 | + } |
|
828 | + } else |
|
779 | 829 | { |
780 | 830 | $incontext['db']['prefix'] = 'smf_'; |
781 | 831 | } |
@@ -811,10 +861,11 @@ discard block |
||
811 | 861 | if (!empty($_POST['db_port'])) |
812 | 862 | { |
813 | 863 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
814 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
815 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
816 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
817 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
864 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
865 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
866 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
867 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
868 | + } |
|
818 | 869 | } |
819 | 870 | |
820 | 871 | // God I hope it saved! |
@@ -827,8 +878,9 @@ discard block |
||
827 | 878 | // Make sure it works. |
828 | 879 | require(dirname(__FILE__) . '/Settings.php'); |
829 | 880 | |
830 | - if (empty($sourcedir)) |
|
831 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
881 | + if (empty($sourcedir)) { |
|
882 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
883 | + } |
|
832 | 884 | |
833 | 885 | // Better find the database file! |
834 | 886 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -838,18 +890,21 @@ discard block |
||
838 | 890 | } |
839 | 891 | |
840 | 892 | // Now include it for database functions! |
841 | - if (!defined('SMF')) |
|
842 | - define('SMF', 1); |
|
893 | + if (!defined('SMF')) { |
|
894 | + define('SMF', 1); |
|
895 | + } |
|
843 | 896 | |
844 | 897 | $modSettings['disableQueryCheck'] = true; |
845 | - if (empty($smcFunc)) |
|
846 | - $smcFunc = array(); |
|
898 | + if (empty($smcFunc)) { |
|
899 | + $smcFunc = array(); |
|
900 | + } |
|
847 | 901 | |
848 | 902 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
849 | 903 | |
850 | 904 | // What - running PHP4? The shame! |
851 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
852 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
905 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
906 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
907 | + } |
|
853 | 908 | |
854 | 909 | // Attempt a connection. |
855 | 910 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -937,12 +992,14 @@ discard block |
||
937 | 992 | $incontext['page_title'] = $txt['install_settings']; |
938 | 993 | |
939 | 994 | // Let's see if we got the database type correct. |
940 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
941 | - $db_type = $_POST['db_type']; |
|
995 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
996 | + $db_type = $_POST['db_type']; |
|
997 | + } |
|
942 | 998 | |
943 | 999 | // Else we'd better be able to get the connection. |
944 | - else |
|
945 | - load_database(); |
|
1000 | + else { |
|
1001 | + load_database(); |
|
1002 | + } |
|
946 | 1003 | |
947 | 1004 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
948 | 1005 | |
@@ -951,10 +1008,11 @@ discard block |
||
951 | 1008 | |
952 | 1009 | $secure = false; |
953 | 1010 | |
954 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
955 | - $secure = true; |
|
956 | - 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') |
|
957 | - $secure = true; |
|
1011 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
1012 | + $secure = true; |
|
1013 | + } 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') { |
|
1014 | + $secure = true; |
|
1015 | + } |
|
958 | 1016 | |
959 | 1017 | // Now, to put what we've learned together... and add a path. |
960 | 1018 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -986,18 +1044,21 @@ discard block |
||
986 | 1044 | // Submitting? |
987 | 1045 | if (isset($_POST['boardurl'])) |
988 | 1046 | { |
989 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
990 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
991 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
992 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
993 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
994 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1047 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1048 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1049 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1050 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1051 | + } |
|
1052 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1053 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1054 | + } |
|
995 | 1055 | |
996 | 1056 | //Make sure boardurl is aligned with ssl setting |
997 | - if (empty($_POST['force_ssl'])) |
|
998 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
999 | - else |
|
1000 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1057 | + if (empty($_POST['force_ssl'])) { |
|
1058 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1059 | + } else { |
|
1060 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1061 | + } |
|
1001 | 1062 | |
1002 | 1063 | // Save these variables. |
1003 | 1064 | $vars = array( |
@@ -1036,10 +1097,10 @@ discard block |
||
1036 | 1097 | { |
1037 | 1098 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1038 | 1099 | return false; |
1039 | - } |
|
1040 | - else |
|
1041 | - // Set the character set here. |
|
1100 | + } else { |
|
1101 | + // Set the character set here. |
|
1042 | 1102 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1103 | + } |
|
1043 | 1104 | } |
1044 | 1105 | |
1045 | 1106 | // Good, skip on. |
@@ -1059,8 +1120,9 @@ discard block |
||
1059 | 1120 | $incontext['continue'] = 1; |
1060 | 1121 | |
1061 | 1122 | // Already done? |
1062 | - if (isset($_POST['pop_done'])) |
|
1063 | - return true; |
|
1123 | + if (isset($_POST['pop_done'])) { |
|
1124 | + return true; |
|
1125 | + } |
|
1064 | 1126 | |
1065 | 1127 | // Reload settings. |
1066 | 1128 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1078,8 +1140,9 @@ discard block |
||
1078 | 1140 | $modSettings = array(); |
1079 | 1141 | if ($result !== false) |
1080 | 1142 | { |
1081 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1082 | - $modSettings[$row['variable']] = $row['value']; |
|
1143 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1144 | + $modSettings[$row['variable']] = $row['value']; |
|
1145 | + } |
|
1083 | 1146 | $smcFunc['db_free_result']($result); |
1084 | 1147 | |
1085 | 1148 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1092,20 +1155,22 @@ discard block |
||
1092 | 1155 | $modSettings['disableQueryCheck'] = true; |
1093 | 1156 | |
1094 | 1157 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1095 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1096 | - $smcFunc['db_query']('', ' |
|
1158 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1159 | + $smcFunc['db_query']('', ' |
|
1097 | 1160 | SET NAMES {string:utf8}', |
1098 | 1161 | array( |
1099 | 1162 | 'db_error_skip' => true, |
1100 | 1163 | 'utf8' => 'utf8', |
1101 | 1164 | ) |
1102 | 1165 | ); |
1166 | + } |
|
1103 | 1167 | |
1104 | 1168 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1105 | - if (substr(__DIR__, -1) == '\\') |
|
1106 | - $attachdir = __DIR__ . 'attachments'; |
|
1107 | - else |
|
1108 | - $attachdir = __DIR__ . '/attachments'; |
|
1169 | + if (substr(__DIR__, -1) == '\\') { |
|
1170 | + $attachdir = __DIR__ . 'attachments'; |
|
1171 | + } else { |
|
1172 | + $attachdir = __DIR__ . '/attachments'; |
|
1173 | + } |
|
1109 | 1174 | |
1110 | 1175 | $replaces = array( |
1111 | 1176 | '{$db_prefix}' => $db_prefix, |
@@ -1122,8 +1187,9 @@ discard block |
||
1122 | 1187 | |
1123 | 1188 | foreach ($txt as $key => $value) |
1124 | 1189 | { |
1125 | - if (substr($key, 0, 8) == 'default_') |
|
1126 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1190 | + if (substr($key, 0, 8) == 'default_') { |
|
1191 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1192 | + } |
|
1127 | 1193 | } |
1128 | 1194 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1129 | 1195 | |
@@ -1138,8 +1204,9 @@ discard block |
||
1138 | 1204 | |
1139 | 1205 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1140 | 1206 | { |
1141 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1142 | - $engines[] = $row['Engine']; |
|
1207 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1208 | + $engines[] = $row['Engine']; |
|
1209 | + } |
|
1143 | 1210 | } |
1144 | 1211 | |
1145 | 1212 | // Done with this now |
@@ -1163,8 +1230,7 @@ discard block |
||
1163 | 1230 | $replaces['START TRANSACTION;'] = ''; |
1164 | 1231 | $replaces['COMMIT;'] = ''; |
1165 | 1232 | } |
1166 | - } |
|
1167 | - else |
|
1233 | + } else |
|
1168 | 1234 | { |
1169 | 1235 | $has_innodb = false; |
1170 | 1236 | } |
@@ -1186,21 +1252,24 @@ discard block |
||
1186 | 1252 | foreach ($sql_lines as $count => $line) |
1187 | 1253 | { |
1188 | 1254 | // No comments allowed! |
1189 | - if (substr(trim($line), 0, 1) != '#') |
|
1190 | - $current_statement .= "\n" . rtrim($line); |
|
1255 | + if (substr(trim($line), 0, 1) != '#') { |
|
1256 | + $current_statement .= "\n" . rtrim($line); |
|
1257 | + } |
|
1191 | 1258 | |
1192 | 1259 | // Is this the end of the query string? |
1193 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1194 | - continue; |
|
1260 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1261 | + continue; |
|
1262 | + } |
|
1195 | 1263 | |
1196 | 1264 | // Does this table already exist? If so, don't insert more data into it! |
1197 | 1265 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1198 | 1266 | { |
1199 | 1267 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1200 | - if (!empty($matches[0])) |
|
1201 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1202 | - else |
|
1203 | - $incontext['sql_results']['insert_dups']++; |
|
1268 | + if (!empty($matches[0])) { |
|
1269 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1270 | + } else { |
|
1271 | + $incontext['sql_results']['insert_dups']++; |
|
1272 | + } |
|
1204 | 1273 | |
1205 | 1274 | $current_statement = ''; |
1206 | 1275 | continue; |
@@ -1209,8 +1278,9 @@ discard block |
||
1209 | 1278 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1210 | 1279 | { |
1211 | 1280 | // Use the appropriate function based on the DB type |
1212 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1213 | - $db_errorno = $db_type . '_errno'; |
|
1281 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1282 | + $db_errorno = $db_type . '_errno'; |
|
1283 | + } |
|
1214 | 1284 | |
1215 | 1285 | // Error 1050: Table already exists! |
1216 | 1286 | // @todo Needs to be made better! |
@@ -1225,18 +1295,18 @@ discard block |
||
1225 | 1295 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1226 | 1296 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1227 | 1297 | } |
1228 | - } |
|
1229 | - else |
|
1298 | + } else |
|
1230 | 1299 | { |
1231 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1232 | - $incontext['sql_results']['tables']++; |
|
1233 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1300 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1301 | + $incontext['sql_results']['tables']++; |
|
1302 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1234 | 1303 | { |
1235 | 1304 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1236 | - if (!empty($matches[0])) |
|
1237 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1238 | - else |
|
1239 | - $incontext['sql_results']['inserts']++; |
|
1305 | + if (!empty($matches[0])) { |
|
1306 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1307 | + } else { |
|
1308 | + $incontext['sql_results']['inserts']++; |
|
1309 | + } |
|
1240 | 1310 | } |
1241 | 1311 | } |
1242 | 1312 | |
@@ -1249,15 +1319,17 @@ discard block |
||
1249 | 1319 | // Sort out the context for the SQL. |
1250 | 1320 | foreach ($incontext['sql_results'] as $key => $number) |
1251 | 1321 | { |
1252 | - if ($number == 0) |
|
1253 | - unset($incontext['sql_results'][$key]); |
|
1254 | - else |
|
1255 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1322 | + if ($number == 0) { |
|
1323 | + unset($incontext['sql_results'][$key]); |
|
1324 | + } else { |
|
1325 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1326 | + } |
|
1256 | 1327 | } |
1257 | 1328 | |
1258 | 1329 | // Make sure UTF will be used globally. |
1259 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1260 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1330 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1331 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1332 | + } |
|
1261 | 1333 | |
1262 | 1334 | // Auto-detect local & global cookie settings |
1263 | 1335 | $url_parts = parse_url($boardurl); |
@@ -1286,15 +1358,19 @@ discard block |
||
1286 | 1358 | |
1287 | 1359 | // Look for subfolder, if found, set localCookie |
1288 | 1360 | // Checking for len > 1 ensures you don't have just a slash... |
1289 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
1290 | - $localCookies = '1'; |
|
1361 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
1362 | + $localCookies = '1'; |
|
1363 | + } |
|
1291 | 1364 | |
1292 | - if (isset($globalCookies)) |
|
1293 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
1294 | - if (isset($globalCookiesDomain)) |
|
1295 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1296 | - if (isset($localCookies)) |
|
1297 | - $newSettings[] = array('localCookies', $localCookies); |
|
1365 | + if (isset($globalCookies)) { |
|
1366 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
1367 | + } |
|
1368 | + if (isset($globalCookiesDomain)) { |
|
1369 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1370 | + } |
|
1371 | + if (isset($localCookies)) { |
|
1372 | + $newSettings[] = array('localCookies', $localCookies); |
|
1373 | + } |
|
1298 | 1374 | } |
1299 | 1375 | |
1300 | 1376 | // Are we allowing stat collection? |
@@ -1312,16 +1388,17 @@ discard block |
||
1312 | 1388 | fwrite($fp, $out); |
1313 | 1389 | |
1314 | 1390 | $return_data = ''; |
1315 | - while (!feof($fp)) |
|
1316 | - $return_data .= fgets($fp, 128); |
|
1391 | + while (!feof($fp)) { |
|
1392 | + $return_data .= fgets($fp, 128); |
|
1393 | + } |
|
1317 | 1394 | |
1318 | 1395 | fclose($fp); |
1319 | 1396 | |
1320 | 1397 | // Get the unique site ID. |
1321 | 1398 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1322 | 1399 | |
1323 | - if (!empty($ID[1])) |
|
1324 | - $smcFunc['db_insert']('replace', |
|
1400 | + if (!empty($ID[1])) { |
|
1401 | + $smcFunc['db_insert']('replace', |
|
1325 | 1402 | $db_prefix . 'settings', |
1326 | 1403 | array('variable' => 'string', 'value' => 'string'), |
1327 | 1404 | array( |
@@ -1330,11 +1407,12 @@ discard block |
||
1330 | 1407 | ), |
1331 | 1408 | array('variable') |
1332 | 1409 | ); |
1410 | + } |
|
1333 | 1411 | } |
1334 | 1412 | } |
1335 | 1413 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1336 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1337 | - $smcFunc['db_query']('', ' |
|
1414 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1415 | + $smcFunc['db_query']('', ' |
|
1338 | 1416 | DELETE FROM {db_prefix}settings |
1339 | 1417 | WHERE variable = {string:enable_sm_stats}', |
1340 | 1418 | array( |
@@ -1342,20 +1420,23 @@ discard block |
||
1342 | 1420 | 'db_error_skip' => true, |
1343 | 1421 | ) |
1344 | 1422 | ); |
1423 | + } |
|
1345 | 1424 | |
1346 | 1425 | // Are we enabling SSL? |
1347 | - if (!empty($_POST['force_ssl'])) |
|
1348 | - $newSettings[] = array('force_ssl', 1); |
|
1426 | + if (!empty($_POST['force_ssl'])) { |
|
1427 | + $newSettings[] = array('force_ssl', 1); |
|
1428 | + } |
|
1349 | 1429 | |
1350 | 1430 | // Setting a timezone is required. |
1351 | 1431 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1352 | 1432 | { |
1353 | 1433 | // Get PHP's default timezone, if set |
1354 | 1434 | $ini_tz = ini_get('date.timezone'); |
1355 | - if (!empty($ini_tz)) |
|
1356 | - $timezone_id = $ini_tz; |
|
1357 | - else |
|
1358 | - $timezone_id = ''; |
|
1435 | + if (!empty($ini_tz)) { |
|
1436 | + $timezone_id = $ini_tz; |
|
1437 | + } else { |
|
1438 | + $timezone_id = ''; |
|
1439 | + } |
|
1359 | 1440 | |
1360 | 1441 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1361 | 1442 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1364,8 +1445,9 @@ discard block |
||
1364 | 1445 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1365 | 1446 | } |
1366 | 1447 | |
1367 | - if (date_default_timezone_set($timezone_id)) |
|
1368 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1448 | + if (date_default_timezone_set($timezone_id)) { |
|
1449 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1450 | + } |
|
1369 | 1451 | } |
1370 | 1452 | |
1371 | 1453 | if (!empty($newSettings)) |
@@ -1396,16 +1478,18 @@ discard block |
||
1396 | 1478 | } |
1397 | 1479 | |
1398 | 1480 | // MySQL specific stuff |
1399 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1400 | - return false; |
|
1481 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1482 | + return false; |
|
1483 | + } |
|
1401 | 1484 | |
1402 | 1485 | // Find database user privileges. |
1403 | 1486 | $privs = array(); |
1404 | 1487 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1405 | 1488 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1406 | 1489 | { |
1407 | - if ($row['Privilege'] == 'Alter') |
|
1408 | - $privs[] = $row['Privilege']; |
|
1490 | + if ($row['Privilege'] == 'Alter') { |
|
1491 | + $privs[] = $row['Privilege']; |
|
1492 | + } |
|
1409 | 1493 | } |
1410 | 1494 | $smcFunc['db_free_result']($get_privs); |
1411 | 1495 | |
@@ -1435,8 +1519,9 @@ discard block |
||
1435 | 1519 | $incontext['continue'] = 1; |
1436 | 1520 | |
1437 | 1521 | // Skipping? |
1438 | - if (!empty($_POST['skip'])) |
|
1439 | - return true; |
|
1522 | + if (!empty($_POST['skip'])) { |
|
1523 | + return true; |
|
1524 | + } |
|
1440 | 1525 | |
1441 | 1526 | // Need this to check whether we need the database password. |
1442 | 1527 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1453,18 +1538,22 @@ discard block |
||
1453 | 1538 | // We need this to properly hash the password for Admin |
1454 | 1539 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1455 | 1540 | global $sourcedir; |
1456 | - if (function_exists('mb_strtolower')) |
|
1457 | - return mb_strtolower($string, 'UTF-8'); |
|
1541 | + if (function_exists('mb_strtolower')) { |
|
1542 | + return mb_strtolower($string, 'UTF-8'); |
|
1543 | + } |
|
1458 | 1544 | require_once($sourcedir . '/Subs-Charset.php'); |
1459 | 1545 | return utf8_strtolower($string); |
1460 | 1546 | }; |
1461 | 1547 | |
1462 | - if (!isset($_POST['username'])) |
|
1463 | - $_POST['username'] = ''; |
|
1464 | - if (!isset($_POST['email'])) |
|
1465 | - $_POST['email'] = ''; |
|
1466 | - if (!isset($_POST['server_email'])) |
|
1467 | - $_POST['server_email'] = ''; |
|
1548 | + if (!isset($_POST['username'])) { |
|
1549 | + $_POST['username'] = ''; |
|
1550 | + } |
|
1551 | + if (!isset($_POST['email'])) { |
|
1552 | + $_POST['email'] = ''; |
|
1553 | + } |
|
1554 | + if (!isset($_POST['server_email'])) { |
|
1555 | + $_POST['server_email'] = ''; |
|
1556 | + } |
|
1468 | 1557 | |
1469 | 1558 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1470 | 1559 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1483,8 +1572,9 @@ discard block |
||
1483 | 1572 | 'admin_group' => 1, |
1484 | 1573 | ) |
1485 | 1574 | ); |
1486 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1487 | - $incontext['skip'] = 1; |
|
1575 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1576 | + $incontext['skip'] = 1; |
|
1577 | + } |
|
1488 | 1578 | $smcFunc['db_free_result']($request); |
1489 | 1579 | |
1490 | 1580 | // Trying to create an account? |
@@ -1515,8 +1605,9 @@ discard block |
||
1515 | 1605 | } |
1516 | 1606 | |
1517 | 1607 | // Update the webmaster's email? |
1518 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1519 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1608 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1609 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1610 | + } |
|
1520 | 1611 | |
1521 | 1612 | // Work out whether we're going to have dodgy characters and remove them. |
1522 | 1613 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1539,32 +1630,27 @@ discard block |
||
1539 | 1630 | $smcFunc['db_free_result']($result); |
1540 | 1631 | |
1541 | 1632 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1542 | - } |
|
1543 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1633 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1544 | 1634 | { |
1545 | 1635 | // Try the previous step again. |
1546 | 1636 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1547 | 1637 | return false; |
1548 | - } |
|
1549 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1638 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1550 | 1639 | { |
1551 | 1640 | // Try the previous step again. |
1552 | 1641 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1553 | 1642 | return false; |
1554 | - } |
|
1555 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1643 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1556 | 1644 | { |
1557 | 1645 | // One step back, this time fill out a proper admin email address. |
1558 | 1646 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1559 | 1647 | return false; |
1560 | - } |
|
1561 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1648 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1562 | 1649 | { |
1563 | 1650 | // One step back, this time fill out a proper admin email address. |
1564 | 1651 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1565 | 1652 | return false; |
1566 | - } |
|
1567 | - elseif ($_POST['username'] != '') |
|
1653 | + } elseif ($_POST['username'] != '') |
|
1568 | 1654 | { |
1569 | 1655 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1570 | 1656 | |
@@ -1632,17 +1718,19 @@ discard block |
||
1632 | 1718 | reloadSettings(); |
1633 | 1719 | |
1634 | 1720 | // Bring a warning over. |
1635 | - if (!empty($incontext['account_existed'])) |
|
1636 | - $incontext['warning'] = $incontext['account_existed']; |
|
1721 | + if (!empty($incontext['account_existed'])) { |
|
1722 | + $incontext['warning'] = $incontext['account_existed']; |
|
1723 | + } |
|
1637 | 1724 | |
1638 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1639 | - $smcFunc['db_query']('', ' |
|
1725 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1726 | + $smcFunc['db_query']('', ' |
|
1640 | 1727 | SET NAMES {string:db_character_set}', |
1641 | 1728 | array( |
1642 | 1729 | 'db_character_set' => $db_character_set, |
1643 | 1730 | 'db_error_skip' => true, |
1644 | 1731 | ) |
1645 | 1732 | ); |
1733 | + } |
|
1646 | 1734 | |
1647 | 1735 | // As track stats is by default enabled let's add some activity. |
1648 | 1736 | $smcFunc['db_insert']('ignore', |
@@ -1663,14 +1751,16 @@ discard block |
||
1663 | 1751 | // Only proceed if we can load the data. |
1664 | 1752 | if ($request) |
1665 | 1753 | { |
1666 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1667 | - $modSettings[$row[0]] = $row[1]; |
|
1754 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1755 | + $modSettings[$row[0]] = $row[1]; |
|
1756 | + } |
|
1668 | 1757 | $smcFunc['db_free_result']($request); |
1669 | 1758 | } |
1670 | 1759 | |
1671 | 1760 | // Automatically log them in ;) |
1672 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1673 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1761 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1762 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1763 | + } |
|
1674 | 1764 | |
1675 | 1765 | $result = $smcFunc['db_query']('', ' |
1676 | 1766 | SELECT value |
@@ -1681,13 +1771,14 @@ discard block |
||
1681 | 1771 | 'db_error_skip' => true, |
1682 | 1772 | ) |
1683 | 1773 | ); |
1684 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1685 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1774 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1775 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1776 | + } |
|
1686 | 1777 | $smcFunc['db_free_result']($result); |
1687 | 1778 | |
1688 | - if (empty($db_sessions)) |
|
1689 | - $_SESSION['admin_time'] = time(); |
|
1690 | - else |
|
1779 | + if (empty($db_sessions)) { |
|
1780 | + $_SESSION['admin_time'] = time(); |
|
1781 | + } else |
|
1691 | 1782 | { |
1692 | 1783 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1693 | 1784 | |
@@ -1711,8 +1802,9 @@ discard block |
||
1711 | 1802 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1712 | 1803 | function($string){ |
1713 | 1804 | global $sourcedir; |
1714 | - if (function_exists('mb_strtolower')) |
|
1715 | - return mb_strtolower($string, 'UTF-8'); |
|
1805 | + if (function_exists('mb_strtolower')) { |
|
1806 | + return mb_strtolower($string, 'UTF-8'); |
|
1807 | + } |
|
1716 | 1808 | require_once($sourcedir . '/Subs-Charset.php'); |
1717 | 1809 | return utf8_strtolower($string); |
1718 | 1810 | }; |
@@ -1728,8 +1820,9 @@ discard block |
||
1728 | 1820 | ) |
1729 | 1821 | ); |
1730 | 1822 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1731 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1732 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1823 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1824 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1825 | + } |
|
1733 | 1826 | $smcFunc['db_free_result']($request); |
1734 | 1827 | |
1735 | 1828 | // Now is the perfect time to fetch the SM files. |
@@ -1748,8 +1841,9 @@ discard block |
||
1748 | 1841 | |
1749 | 1842 | // Check if we need some stupid MySQL fix. |
1750 | 1843 | $server_version = $smcFunc['db_server_info'](); |
1751 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1752 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1844 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1845 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1846 | + } |
|
1753 | 1847 | |
1754 | 1848 | // Some final context for the template. |
1755 | 1849 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1769,8 +1863,9 @@ discard block |
||
1769 | 1863 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1770 | 1864 | |
1771 | 1865 | // @todo Do we just want to read the file in clean, and split it this way always? |
1772 | - if (count($settingsArray) == 1) |
|
1773 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1866 | + if (count($settingsArray) == 1) { |
|
1867 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1868 | + } |
|
1774 | 1869 | |
1775 | 1870 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1776 | 1871 | { |
@@ -1778,25 +1873,29 @@ discard block |
||
1778 | 1873 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
1779 | 1874 | { |
1780 | 1875 | // Set the ten lines to nothing. |
1781 | - for ($j=0; $j < 10; $j++) |
|
1782 | - $settingsArray[$i++] = ''; |
|
1876 | + for ($j=0; $j < 10; $j++) { |
|
1877 | + $settingsArray[$i++] = ''; |
|
1878 | + } |
|
1783 | 1879 | |
1784 | 1880 | continue; |
1785 | 1881 | } |
1786 | 1882 | |
1787 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1788 | - $settingsArray[$i] = ''; |
|
1883 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1884 | + $settingsArray[$i] = ''; |
|
1885 | + } |
|
1789 | 1886 | |
1790 | 1887 | // Don't trim or bother with it if it's not a variable. |
1791 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1792 | - continue; |
|
1888 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1889 | + continue; |
|
1890 | + } |
|
1793 | 1891 | |
1794 | 1892 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1795 | 1893 | |
1796 | - foreach ($vars as $var => $val) |
|
1797 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1894 | + foreach ($vars as $var => $val) { |
|
1895 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1798 | 1896 | { |
1799 | 1897 | $comment = strstr($settingsArray[$i], '#'); |
1898 | + } |
|
1800 | 1899 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1801 | 1900 | unset($vars[$var]); |
1802 | 1901 | } |
@@ -1806,36 +1905,41 @@ discard block |
||
1806 | 1905 | if (!empty($vars)) |
1807 | 1906 | { |
1808 | 1907 | $settingsArray[$i++] = ''; |
1809 | - foreach ($vars as $var => $val) |
|
1810 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1908 | + foreach ($vars as $var => $val) { |
|
1909 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1910 | + } |
|
1811 | 1911 | } |
1812 | 1912 | |
1813 | 1913 | // Blank out the file - done to fix a oddity with some servers. |
1814 | 1914 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1815 | - if (!$fp) |
|
1816 | - return false; |
|
1915 | + if (!$fp) { |
|
1916 | + return false; |
|
1917 | + } |
|
1817 | 1918 | fclose($fp); |
1818 | 1919 | |
1819 | 1920 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1820 | 1921 | |
1821 | 1922 | // Gotta have one of these ;) |
1822 | - if (trim($settingsArray[0]) != '<?php') |
|
1823 | - fwrite($fp, "<?php\n"); |
|
1923 | + if (trim($settingsArray[0]) != '<?php') { |
|
1924 | + fwrite($fp, "<?php\n"); |
|
1925 | + } |
|
1824 | 1926 | |
1825 | 1927 | $lines = count($settingsArray); |
1826 | 1928 | for ($i = 0; $i < $lines - 1; $i++) |
1827 | 1929 | { |
1828 | 1930 | // Don't just write a bunch of blank lines. |
1829 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1830 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1931 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1932 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1933 | + } |
|
1831 | 1934 | } |
1832 | 1935 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1833 | 1936 | fclose($fp); |
1834 | 1937 | |
1835 | 1938 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1836 | 1939 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1837 | - if (function_exists('opcache_invalidate')) |
|
1838 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1940 | + if (function_exists('opcache_invalidate')) { |
|
1941 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1942 | + } |
|
1839 | 1943 | |
1840 | 1944 | return true; |
1841 | 1945 | } |
@@ -1845,10 +1949,11 @@ discard block |
||
1845 | 1949 | global $cachedir; |
1846 | 1950 | |
1847 | 1951 | // Write out the db_last_error file with the error timestamp |
1848 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
1849 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1850 | - else |
|
1851 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1952 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
1953 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1954 | + } else { |
|
1955 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1956 | + } |
|
1852 | 1957 | |
1853 | 1958 | return true; |
1854 | 1959 | } |
@@ -1865,9 +1970,9 @@ discard block |
||
1865 | 1970 | SecFilterScanPOST Off |
1866 | 1971 | </IfModule>'; |
1867 | 1972 | |
1868 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1869 | - return true; |
|
1870 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1973 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1974 | + return true; |
|
1975 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1871 | 1976 | { |
1872 | 1977 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1873 | 1978 | |
@@ -1879,29 +1984,28 @@ discard block |
||
1879 | 1984 | fwrite($ht_handle, $htaccess_addition); |
1880 | 1985 | fclose($ht_handle); |
1881 | 1986 | return true; |
1987 | + } else { |
|
1988 | + return false; |
|
1882 | 1989 | } |
1883 | - else |
|
1884 | - return false; |
|
1990 | + } else { |
|
1991 | + return true; |
|
1885 | 1992 | } |
1886 | - else |
|
1887 | - return true; |
|
1888 | - } |
|
1889 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1890 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1891 | - elseif (is_writable(dirname(__FILE__))) |
|
1993 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1994 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1995 | + } elseif (is_writable(dirname(__FILE__))) |
|
1892 | 1996 | { |
1893 | 1997 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1894 | 1998 | { |
1895 | 1999 | fwrite($ht_handle, $htaccess_addition); |
1896 | 2000 | fclose($ht_handle); |
1897 | 2001 | return true; |
2002 | + } else { |
|
2003 | + return false; |
|
1898 | 2004 | } |
1899 | - else |
|
2005 | + } else { |
|
1900 | 2006 | return false; |
1901 | 2007 | } |
1902 | - else |
|
1903 | - return false; |
|
1904 | -} |
|
2008 | + } |
|
1905 | 2009 | |
1906 | 2010 | function template_install_above() |
1907 | 2011 | { |
@@ -1940,9 +2044,10 @@ discard block |
||
1940 | 2044 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1941 | 2045 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1942 | 2046 | |
1943 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1944 | - echo ' |
|
2047 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2048 | + echo ' |
|
1945 | 2049 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
2050 | + } |
|
1946 | 2051 | |
1947 | 2052 | echo ' |
1948 | 2053 | </select> |
@@ -1962,9 +2067,10 @@ discard block |
||
1962 | 2067 | <h2>', $txt['upgrade_progress'], '</h2> |
1963 | 2068 | <ul>'; |
1964 | 2069 | |
1965 | - foreach ($incontext['steps'] as $num => $step) |
|
1966 | - echo ' |
|
2070 | + foreach ($incontext['steps'] as $num => $step) { |
|
2071 | + echo ' |
|
1967 | 2072 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2073 | + } |
|
1968 | 2074 | |
1969 | 2075 | echo ' |
1970 | 2076 | </ul> |
@@ -1990,20 +2096,23 @@ discard block |
||
1990 | 2096 | echo ' |
1991 | 2097 | <div class="floatright">'; |
1992 | 2098 | |
1993 | - if (!empty($incontext['continue'])) |
|
1994 | - echo ' |
|
2099 | + if (!empty($incontext['continue'])) { |
|
2100 | + echo ' |
|
1995 | 2101 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">'; |
1996 | - if (!empty($incontext['skip'])) |
|
1997 | - echo ' |
|
2102 | + } |
|
2103 | + if (!empty($incontext['skip'])) { |
|
2104 | + echo ' |
|
1998 | 2105 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">'; |
2106 | + } |
|
1999 | 2107 | echo ' |
2000 | 2108 | </div>'; |
2001 | 2109 | } |
2002 | 2110 | |
2003 | 2111 | // Show the closing form tag and other data only if not in the last step |
2004 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
2005 | - echo ' |
|
2112 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2113 | + echo ' |
|
2006 | 2114 | </form>'; |
2115 | + } |
|
2007 | 2116 | |
2008 | 2117 | echo ' |
2009 | 2118 | </div><!-- .panel --> |
@@ -2036,13 +2145,15 @@ discard block |
||
2036 | 2145 | </div>'; |
2037 | 2146 | |
2038 | 2147 | // Show the warnings, or not. |
2039 | - if (template_warning_divs()) |
|
2040 | - echo ' |
|
2148 | + if (template_warning_divs()) { |
|
2149 | + echo ' |
|
2041 | 2150 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2151 | + } |
|
2042 | 2152 | |
2043 | 2153 | // Say we want the continue button! |
2044 | - if (empty($incontext['error'])) |
|
2045 | - $incontext['continue'] = 1; |
|
2154 | + if (empty($incontext['error'])) { |
|
2155 | + $incontext['continue'] = 1; |
|
2156 | + } |
|
2046 | 2157 | |
2047 | 2158 | // For the latest version stuff. |
2048 | 2159 | echo ' |
@@ -2076,19 +2187,21 @@ discard block |
||
2076 | 2187 | global $txt, $incontext; |
2077 | 2188 | |
2078 | 2189 | // Errors are very serious.. |
2079 | - if (!empty($incontext['error'])) |
|
2080 | - echo ' |
|
2190 | + if (!empty($incontext['error'])) { |
|
2191 | + echo ' |
|
2081 | 2192 | <div class="errorbox"> |
2082 | 2193 | <h3>', $txt['upgrade_critical_error'], '</h3> |
2083 | 2194 | ', $incontext['error'], ' |
2084 | 2195 | </div>'; |
2196 | + } |
|
2085 | 2197 | // A warning message? |
2086 | - elseif (!empty($incontext['warning'])) |
|
2087 | - echo ' |
|
2198 | + elseif (!empty($incontext['warning'])) { |
|
2199 | + echo ' |
|
2088 | 2200 | <div class="errorbox"> |
2089 | 2201 | <h3>', $txt['upgrade_warning'], '</h3> |
2090 | 2202 | ', $incontext['warning'], ' |
2091 | 2203 | </div>'; |
2204 | + } |
|
2092 | 2205 | |
2093 | 2206 | return empty($incontext['error']) && empty($incontext['warning']); |
2094 | 2207 | } |
@@ -2104,26 +2217,29 @@ discard block |
||
2104 | 2217 | <li>', $incontext['failed_files']), '</li> |
2105 | 2218 | </ul>'; |
2106 | 2219 | |
2107 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2108 | - echo ' |
|
2220 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2221 | + echo ' |
|
2109 | 2222 | <hr> |
2110 | 2223 | <p>', $txt['chmod_linux_info'], '</p> |
2111 | 2224 | <samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>'; |
2225 | + } |
|
2112 | 2226 | |
2113 | 2227 | // This is serious! |
2114 | - if (!template_warning_divs()) |
|
2115 | - return; |
|
2228 | + if (!template_warning_divs()) { |
|
2229 | + return; |
|
2230 | + } |
|
2116 | 2231 | |
2117 | 2232 | echo ' |
2118 | 2233 | <hr> |
2119 | 2234 | <p>', $txt['ftp_setup_info'], '</p>'; |
2120 | 2235 | |
2121 | - if (!empty($incontext['ftp_errors'])) |
|
2122 | - echo ' |
|
2236 | + if (!empty($incontext['ftp_errors'])) { |
|
2237 | + echo ' |
|
2123 | 2238 | <div class="error_message"> |
2124 | 2239 | ', $txt['error_ftp_no_connect'], '<br><br> |
2125 | 2240 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2126 | 2241 | </div>'; |
2242 | + } |
|
2127 | 2243 | |
2128 | 2244 | echo ' |
2129 | 2245 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2192,16 +2308,16 @@ discard block |
||
2192 | 2308 | <dd> |
2193 | 2309 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2194 | 2310 | |
2195 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2196 | - echo ' |
|
2311 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2312 | + echo ' |
|
2197 | 2313 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2314 | + } |
|
2198 | 2315 | |
2199 | 2316 | echo ' |
2200 | 2317 | </select> |
2201 | 2318 | <div class="smalltext">', $txt['db_settings_type_info'], '</div> |
2202 | 2319 | </dd>'; |
2203 | - } |
|
2204 | - else |
|
2320 | + } else |
|
2205 | 2321 | { |
2206 | 2322 | echo ' |
2207 | 2323 | <dd> |
@@ -2376,9 +2492,10 @@ discard block |
||
2376 | 2492 | <div class="red">', $txt['error_db_queries'], '</div> |
2377 | 2493 | <ul>'; |
2378 | 2494 | |
2379 | - foreach ($incontext['failures'] as $line => $fail) |
|
2380 | - echo ' |
|
2495 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2496 | + echo ' |
|
2381 | 2497 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2498 | + } |
|
2382 | 2499 | |
2383 | 2500 | echo ' |
2384 | 2501 | </ul>'; |
@@ -2443,15 +2560,16 @@ discard block |
||
2443 | 2560 | </dd> |
2444 | 2561 | </dl>'; |
2445 | 2562 | |
2446 | - if ($incontext['require_db_confirm']) |
|
2447 | - echo ' |
|
2563 | + if ($incontext['require_db_confirm']) { |
|
2564 | + echo ' |
|
2448 | 2565 | <h2>', $txt['user_settings_database'], '</h2> |
2449 | 2566 | <p>', $txt['user_settings_database_info'], '</p> |
2450 | 2567 | |
2451 | 2568 | <div class="lefttext"> |
2452 | 2569 | <input type="password" name="password3" size="30"> |
2453 | 2570 | </div>'; |
2454 | -} |
|
2571 | + } |
|
2572 | + } |
|
2455 | 2573 | |
2456 | 2574 | // Tell them it's done, and to delete. |
2457 | 2575 | function template_delete_install() |
@@ -2464,13 +2582,14 @@ discard block |
||
2464 | 2582 | template_warning_divs(); |
2465 | 2583 | |
2466 | 2584 | // Install directory still writable? |
2467 | - if ($incontext['dir_still_writable']) |
|
2468 | - echo ' |
|
2585 | + if ($incontext['dir_still_writable']) { |
|
2586 | + echo ' |
|
2469 | 2587 | <p><em>', $txt['still_writable'], '</em></p>'; |
2588 | + } |
|
2470 | 2589 | |
2471 | 2590 | // Don't show the box if it's like 99% sure it won't work :P. |
2472 | - if ($incontext['probably_delete_install']) |
|
2473 | - echo ' |
|
2591 | + if ($incontext['probably_delete_install']) { |
|
2592 | + echo ' |
|
2474 | 2593 | <label> |
2475 | 2594 | <input type="checkbox" id="delete_self" onclick="doTheDelete();"> |
2476 | 2595 | <strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong> |
@@ -2486,6 +2605,7 @@ discard block |
||
2486 | 2605 | theCheck.disabled = true; |
2487 | 2606 | } |
2488 | 2607 | </script>'; |
2608 | + } |
|
2489 | 2609 | |
2490 | 2610 | echo ' |
2491 | 2611 | <p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p> |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function shows the board index. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | $context['canonical_url'] = $scripturl; |
35 | 36 | |
36 | 37 | // Do not let search engines index anything if there is a random thing in $_GET. |
37 | - if (!empty($_GET)) |
|
38 | - $context['robot_no_index'] = true; |
|
38 | + if (!empty($_GET)) { |
|
39 | + $context['robot_no_index'] = true; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Retrieve the categories and boards. |
41 | 43 | require_once($sourcedir . '/Subs-BoardIndex.php'); |
@@ -62,11 +64,12 @@ discard block |
||
62 | 64 | $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); |
63 | 65 | } |
64 | 66 | |
65 | - if (!empty($context['latest_posts']) || !empty($context['latest_post'])) |
|
66 | - $context['info_center'][] = array( |
|
67 | + if (!empty($context['latest_posts']) || !empty($context['latest_post'])) { |
|
68 | + $context['info_center'][] = array( |
|
67 | 69 | 'tpl' => 'recent', |
68 | 70 | 'txt' => 'recent_posts', |
69 | 71 | ); |
72 | + } |
|
70 | 73 | } |
71 | 74 | |
72 | 75 | // Load the calendar? |
@@ -87,20 +90,22 @@ discard block |
||
87 | 90 | // This is used to show the "how-do-I-edit" help. |
88 | 91 | $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); |
89 | 92 | |
90 | - if (!empty($context['show_calendar'])) |
|
91 | - $context['info_center'][] = array( |
|
93 | + if (!empty($context['show_calendar'])) { |
|
94 | + $context['info_center'][] = array( |
|
92 | 95 | 'tpl' => 'calendar', |
93 | 96 | 'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming', |
94 | 97 | ); |
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | // And stats. |
98 | 102 | $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); |
99 | - if ($settings['show_stats_index']) |
|
100 | - $context['info_center'][] = array( |
|
103 | + if ($settings['show_stats_index']) { |
|
104 | + $context['info_center'][] = array( |
|
101 | 105 | 'tpl' => 'stats', |
102 | 106 | 'txt' => 'forum_stats', |
103 | 107 | ); |
108 | + } |
|
104 | 109 | |
105 | 110 | // Now the online stuff |
106 | 111 | require_once($sourcedir . '/Subs-MembersOnline.php'); |
@@ -118,12 +123,14 @@ discard block |
||
118 | 123 | ); |
119 | 124 | |
120 | 125 | // Track most online statistics? (Subs-MembersOnline.php) |
121 | - if (!empty($modSettings['trackStats'])) |
|
122 | - trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
126 | + if (!empty($modSettings['trackStats'])) { |
|
127 | + trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
128 | + } |
|
123 | 129 | |
124 | 130 | // Are we showing all membergroups on the board index? |
125 | - if (!empty($settings['show_group_key'])) |
|
126 | - $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
131 | + if (!empty($settings['show_group_key'])) { |
|
132 | + $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
133 | + } |
|
127 | 134 | |
128 | 135 | // And back to normality. |
129 | 136 | $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); |
@@ -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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -60,12 +63,14 @@ discard block |
||
60 | 63 | { |
61 | 64 | // Get ids of all the boards they can post in. |
62 | 65 | $post_permissions = array('post_new'); |
63 | - if ($modSettings['postmod_active']) |
|
64 | - $post_permissions[] = 'post_unapproved_topics'; |
|
66 | + if ($modSettings['postmod_active']) { |
|
67 | + $post_permissions[] = 'post_unapproved_topics'; |
|
68 | + } |
|
65 | 69 | |
66 | 70 | $boards = boardsAllowedTo($post_permissions); |
67 | - if (empty($boards)) |
|
68 | - fatal_lang_error('cannot_post_new', false); |
|
71 | + if (empty($boards)) { |
|
72 | + fatal_lang_error('cannot_post_new', false); |
|
73 | + } |
|
69 | 74 | |
70 | 75 | // Get a list of boards for the select menu |
71 | 76 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -78,8 +83,9 @@ discard block |
||
78 | 83 | $board_list = getBoardList($boardListOptions); |
79 | 84 | } |
80 | 85 | // Let's keep things simple for ourselves below |
81 | - else |
|
82 | - $boards = array($board); |
|
86 | + else { |
|
87 | + $boards = array($board); |
|
88 | + } |
|
83 | 89 | |
84 | 90 | require_once($sourcedir . '/Subs-Post.php'); |
85 | 91 | |
@@ -102,10 +108,11 @@ discard block |
||
102 | 108 | array( |
103 | 109 | 'msg' => (int) $_REQUEST['msg'], |
104 | 110 | )); |
105 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
106 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
107 | - else |
|
108 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
111 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
112 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
113 | + } else { |
|
114 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
115 | + } |
|
109 | 116 | $smcFunc['db_free_result']($request); |
110 | 117 | } |
111 | 118 | |
@@ -132,33 +139,36 @@ discard block |
||
132 | 139 | $smcFunc['db_free_result']($request); |
133 | 140 | |
134 | 141 | // If this topic already has a poll, they sure can't add another. |
135 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
136 | - unset($_REQUEST['poll']); |
|
142 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
143 | + unset($_REQUEST['poll']); |
|
144 | + } |
|
137 | 145 | |
138 | 146 | if (empty($_REQUEST['msg'])) |
139 | 147 | { |
140 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
141 | - is_not_guest(); |
|
148 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
149 | + is_not_guest(); |
|
150 | + } |
|
142 | 151 | |
143 | 152 | // By default the reply will be approved... |
144 | 153 | $context['becomes_approved'] = true; |
145 | 154 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
146 | 155 | { |
147 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
148 | - $context['becomes_approved'] = false; |
|
149 | - else |
|
150 | - isAllowedTo('post_reply_any'); |
|
151 | - } |
|
152 | - elseif (!allowedTo('post_reply_any')) |
|
156 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
157 | + $context['becomes_approved'] = false; |
|
158 | + } else { |
|
159 | + isAllowedTo('post_reply_any'); |
|
160 | + } |
|
161 | + } elseif (!allowedTo('post_reply_any')) |
|
153 | 162 | { |
154 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
155 | - $context['becomes_approved'] = false; |
|
156 | - else |
|
157 | - isAllowedTo('post_reply_own'); |
|
163 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
164 | + $context['becomes_approved'] = false; |
|
165 | + } else { |
|
166 | + isAllowedTo('post_reply_own'); |
|
167 | + } |
|
158 | 168 | } |
169 | + } else { |
|
170 | + $context['becomes_approved'] = true; |
|
159 | 171 | } |
160 | - else |
|
161 | - $context['becomes_approved'] = true; |
|
162 | 172 | |
163 | 173 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
164 | 174 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -173,17 +183,18 @@ discard block |
||
173 | 183 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
174 | 184 | |
175 | 185 | // Check whether this is a really old post being bumped... |
176 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
177 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
178 | - } |
|
179 | - else |
|
186 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
187 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
188 | + } |
|
189 | + } else |
|
180 | 190 | { |
181 | 191 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
182 | 192 | $context['becomes_approved'] = true; |
183 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
184 | - $context['becomes_approved'] = false; |
|
185 | - else |
|
186 | - isAllowedTo('post_new', $boards, true); |
|
193 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
194 | + $context['becomes_approved'] = false; |
|
195 | + } else { |
|
196 | + isAllowedTo('post_new', $boards, true); |
|
197 | + } |
|
187 | 198 | |
188 | 199 | $locked = 0; |
189 | 200 | $context['already_locked'] = 0; |
@@ -213,27 +224,32 @@ discard block |
||
213 | 224 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
214 | 225 | { |
215 | 226 | require_once($sourcedir . '/ManageAttachments.php'); |
216 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
217 | - removeAttachments(array('id_attach' => $attachID)); |
|
227 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
228 | + removeAttachments(array('id_attach' => $attachID)); |
|
229 | + } |
|
218 | 230 | |
219 | 231 | unset($_SESSION['already_attached']); |
220 | 232 | } |
221 | 233 | |
222 | 234 | // Don't allow a post if it's locked and you aren't all powerful. |
223 | - if ($locked && !allowedTo('moderate_board')) |
|
224 | - fatal_lang_error('topic_locked', false); |
|
235 | + if ($locked && !allowedTo('moderate_board')) { |
|
236 | + fatal_lang_error('topic_locked', false); |
|
237 | + } |
|
225 | 238 | // Check the users permissions - is the user allowed to add or post a poll? |
226 | 239 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
227 | 240 | { |
228 | 241 | // New topic, new poll. |
229 | - if (empty($topic)) |
|
230 | - isAllowedTo('poll_post'); |
|
242 | + if (empty($topic)) { |
|
243 | + isAllowedTo('poll_post'); |
|
244 | + } |
|
231 | 245 | // This is an old topic - but it is yours! Can you add to it? |
232 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
233 | - isAllowedTo('poll_add_own'); |
|
246 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
247 | + isAllowedTo('poll_add_own'); |
|
248 | + } |
|
234 | 249 | // If you're not the owner, can you add to any poll? |
235 | - else |
|
236 | - isAllowedTo('poll_add_any'); |
|
250 | + else { |
|
251 | + isAllowedTo('poll_add_any'); |
|
252 | + } |
|
237 | 253 | |
238 | 254 | if (!empty($board)) |
239 | 255 | { |
@@ -242,8 +258,9 @@ discard block |
||
242 | 258 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
243 | 259 | } |
244 | 260 | // No board, so we'll have to check this again in Post2 |
245 | - else |
|
246 | - $guest_vote_enabled = true; |
|
261 | + else { |
|
262 | + $guest_vote_enabled = true; |
|
263 | + } |
|
247 | 264 | |
248 | 265 | // Set up the poll options. |
249 | 266 | $context['poll_options'] = array( |
@@ -269,8 +286,9 @@ discard block |
||
269 | 286 | if ($context['make_event']) |
270 | 287 | { |
271 | 288 | // They might want to pick a board. |
272 | - if (!isset($context['current_board'])) |
|
273 | - $context['current_board'] = 0; |
|
289 | + if (!isset($context['current_board'])) { |
|
290 | + $context['current_board'] = 0; |
|
291 | + } |
|
274 | 292 | |
275 | 293 | // Start loading up the event info. |
276 | 294 | $context['event'] = array(); |
@@ -284,10 +302,11 @@ discard block |
||
284 | 302 | isAllowedTo('calendar_post'); |
285 | 303 | |
286 | 304 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
287 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
288 | - $time_string = '%k:%M'; |
|
289 | - else |
|
290 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
305 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
306 | + $time_string = '%k:%M'; |
|
307 | + } else { |
|
308 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
309 | + } |
|
291 | 310 | |
292 | 311 | $js_time_string = str_replace( |
293 | 312 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -309,8 +328,7 @@ discard block |
||
309 | 328 | require_once($sourcedir . '/Subs-Calendar.php'); |
310 | 329 | $eventProperties = getEventProperties($context['event']['id']); |
311 | 330 | $context['event'] = array_merge($context['event'], $eventProperties); |
312 | - } |
|
313 | - else |
|
331 | + } else |
|
314 | 332 | { |
315 | 333 | // Get the current event information. |
316 | 334 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -318,10 +336,12 @@ discard block |
||
318 | 336 | $context['event'] = array_merge($context['event'], $eventProperties); |
319 | 337 | |
320 | 338 | // Make sure the year and month are in the valid range. |
321 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
322 | - fatal_lang_error('invalid_month', false); |
|
323 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
324 | - fatal_lang_error('invalid_year', false); |
|
339 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
340 | + fatal_lang_error('invalid_month', false); |
|
341 | + } |
|
342 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
343 | + fatal_lang_error('invalid_year', false); |
|
344 | + } |
|
325 | 345 | |
326 | 346 | $context['event']['categories'] = $board_list; |
327 | 347 | } |
@@ -432,10 +452,11 @@ discard block |
||
432 | 452 | |
433 | 453 | if (!empty($context['new_replies'])) |
434 | 454 | { |
435 | - if ($context['new_replies'] == 1) |
|
436 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
437 | - else |
|
438 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
455 | + if ($context['new_replies'] == 1) { |
|
456 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
457 | + } else { |
|
458 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
459 | + } |
|
439 | 460 | |
440 | 461 | $post_errors[] = 'new_replies'; |
441 | 462 | |
@@ -447,9 +468,9 @@ discard block |
||
447 | 468 | // Get a response prefix (like 'Re:') in the default forum language. |
448 | 469 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
449 | 470 | { |
450 | - if ($language === $user_info['language']) |
|
451 | - $context['response_prefix'] = $txt['response_prefix']; |
|
452 | - else |
|
471 | + if ($language === $user_info['language']) { |
|
472 | + $context['response_prefix'] = $txt['response_prefix']; |
|
473 | + } else |
|
453 | 474 | { |
454 | 475 | loadLanguage('index', $language, false); |
455 | 476 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -462,23 +483,26 @@ discard block |
||
462 | 483 | // Do we have a body, but an error happened. |
463 | 484 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
464 | 485 | { |
465 | - if (isset($_REQUEST['quickReply'])) |
|
466 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
486 | + if (isset($_REQUEST['quickReply'])) { |
|
487 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
488 | + } |
|
467 | 489 | |
468 | 490 | // Validate inputs. |
469 | 491 | if (empty($context['post_error'])) |
470 | 492 | { |
471 | 493 | // This means they didn't click Post and get an error. |
472 | 494 | $really_previewing = true; |
473 | - } |
|
474 | - else |
|
495 | + } else |
|
475 | 496 | { |
476 | - if (!isset($_REQUEST['subject'])) |
|
477 | - $_REQUEST['subject'] = ''; |
|
478 | - if (!isset($_REQUEST['message'])) |
|
479 | - $_REQUEST['message'] = ''; |
|
480 | - if (!isset($_REQUEST['icon'])) |
|
481 | - $_REQUEST['icon'] = 'xx'; |
|
497 | + if (!isset($_REQUEST['subject'])) { |
|
498 | + $_REQUEST['subject'] = ''; |
|
499 | + } |
|
500 | + if (!isset($_REQUEST['message'])) { |
|
501 | + $_REQUEST['message'] = ''; |
|
502 | + } |
|
503 | + if (!isset($_REQUEST['icon'])) { |
|
504 | + $_REQUEST['icon'] = 'xx'; |
|
505 | + } |
|
482 | 506 | |
483 | 507 | // They are previewing if they asked to preview (i.e. came from quick reply). |
484 | 508 | $really_previewing = !empty($_POST['preview']); |
@@ -494,8 +518,9 @@ discard block |
||
494 | 518 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
495 | 519 | |
496 | 520 | // Make sure the subject isn't too long - taking into account special characters. |
497 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
498 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
521 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
522 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
523 | + } |
|
499 | 524 | |
500 | 525 | if (isset($_REQUEST['poll'])) |
501 | 526 | { |
@@ -507,8 +532,9 @@ discard block |
||
507 | 532 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
508 | 533 | foreach ($_POST['options'] as $option) |
509 | 534 | { |
510 | - if (trim($option) == '') |
|
511 | - continue; |
|
535 | + if (trim($option) == '') { |
|
536 | + continue; |
|
537 | + } |
|
512 | 538 | |
513 | 539 | $context['choices'][] = array( |
514 | 540 | 'id' => $choice_id++, |
@@ -570,13 +596,14 @@ discard block |
||
570 | 596 | $context['preview_subject'] = $form_subject; |
571 | 597 | |
572 | 598 | censorText($context['preview_subject']); |
599 | + } else { |
|
600 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
573 | 601 | } |
574 | - else |
|
575 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
576 | 602 | |
577 | 603 | // Protect any CDATA blocks. |
578 | - if (isset($_REQUEST['xml'])) |
|
579 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
604 | + if (isset($_REQUEST['xml'])) { |
|
605 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
619 | - fatal_lang_error('no_board', false); |
|
645 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
646 | + fatal_lang_error('no_board', false); |
|
647 | + } |
|
620 | 648 | $row = $smcFunc['db_fetch_assoc']($request); |
621 | 649 | |
622 | 650 | $attachment_stuff = array($row); |
623 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
624 | - $attachment_stuff[] = $row2; |
|
651 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
652 | + $attachment_stuff[] = $row2; |
|
653 | + } |
|
625 | 654 | $smcFunc['db_free_result']($request); |
626 | 655 | |
627 | 656 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
628 | 657 | { |
629 | 658 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
630 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
631 | - fatal_lang_error('modify_post_time_passed', false); |
|
632 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
633 | - isAllowedTo('modify_replies'); |
|
634 | - else |
|
635 | - isAllowedTo('modify_own'); |
|
659 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
660 | + fatal_lang_error('modify_post_time_passed', false); |
|
661 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
662 | + isAllowedTo('modify_replies'); |
|
663 | + } else { |
|
664 | + isAllowedTo('modify_own'); |
|
665 | + } |
|
666 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
667 | + isAllowedTo('modify_replies'); |
|
668 | + } else { |
|
669 | + isAllowedTo('modify_any'); |
|
636 | 670 | } |
637 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
638 | - isAllowedTo('modify_replies'); |
|
639 | - else |
|
640 | - isAllowedTo('modify_any'); |
|
641 | 671 | |
642 | 672 | if ($context['can_announce'] && !empty($row['id_action'])) |
643 | 673 | { |
@@ -661,8 +691,9 @@ discard block |
||
661 | 691 | |
662 | 692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
663 | 693 | { |
664 | - if ($row['filesize'] <= 0) |
|
665 | - continue; |
|
694 | + if ($row['filesize'] <= 0) { |
|
695 | + continue; |
|
696 | + } |
|
666 | 697 | $context['current_attachments'][$row['id_attach']] = array( |
667 | 698 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
668 | 699 | 'size' => $row['filesize'], |
@@ -732,29 +763,32 @@ discard block |
||
732 | 763 | ) |
733 | 764 | ); |
734 | 765 | // The message they were trying to edit was most likely deleted. |
735 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
736 | - fatal_lang_error('no_message', false); |
|
766 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
767 | + fatal_lang_error('no_message', false); |
|
768 | + } |
|
737 | 769 | $row = $smcFunc['db_fetch_assoc']($request); |
738 | 770 | |
739 | 771 | $attachment_stuff = array($row); |
740 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
741 | - $attachment_stuff[] = $row2; |
|
772 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
773 | + $attachment_stuff[] = $row2; |
|
774 | + } |
|
742 | 775 | $smcFunc['db_free_result']($request); |
743 | 776 | |
744 | 777 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
745 | 778 | { |
746 | 779 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
747 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
748 | - fatal_lang_error('modify_post_time_passed', false); |
|
749 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
750 | - isAllowedTo('modify_replies'); |
|
751 | - else |
|
752 | - isAllowedTo('modify_own'); |
|
780 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
781 | + fatal_lang_error('modify_post_time_passed', false); |
|
782 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
783 | + isAllowedTo('modify_replies'); |
|
784 | + } else { |
|
785 | + isAllowedTo('modify_own'); |
|
786 | + } |
|
787 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
788 | + isAllowedTo('modify_replies'); |
|
789 | + } else { |
|
790 | + isAllowedTo('modify_any'); |
|
753 | 791 | } |
754 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
755 | - isAllowedTo('modify_replies'); |
|
756 | - else |
|
757 | - isAllowedTo('modify_any'); |
|
758 | 792 | |
759 | 793 | if ($context['can_announce'] && !empty($row['id_action'])) |
760 | 794 | { |
@@ -781,15 +815,17 @@ discard block |
||
781 | 815 | $context['icon'] = $row['icon']; |
782 | 816 | |
783 | 817 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
784 | - if (!$row['approved'] && !$context['show_approval']) |
|
785 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
818 | + if (!$row['approved'] && !$context['show_approval']) { |
|
819 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // Sort the attachments so they are in the order saved |
788 | 823 | $temp = array(); |
789 | 824 | foreach ($attachment_stuff as $attachment) |
790 | 825 | { |
791 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
792 | - $temp[$attachment['id_attach']] = $attachment; |
|
826 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
827 | + $temp[$attachment['id_attach']] = $attachment; |
|
828 | + } |
|
793 | 829 | } |
794 | 830 | ksort($temp); |
795 | 831 | |
@@ -850,14 +886,16 @@ discard block |
||
850 | 886 | 'is_approved' => 1, |
851 | 887 | ) |
852 | 888 | ); |
853 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
854 | - fatal_lang_error('quoted_post_deleted', false); |
|
889 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
890 | + fatal_lang_error('quoted_post_deleted', false); |
|
891 | + } |
|
855 | 892 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
856 | 893 | $smcFunc['db_free_result']($request); |
857 | 894 | |
858 | 895 | // Add 'Re: ' to the front of the quoted subject. |
859 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
860 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
896 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
897 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
898 | + } |
|
861 | 899 | |
862 | 900 | // Censor the message and subject. |
863 | 901 | censorText($form_message); |
@@ -870,10 +908,11 @@ discard block |
||
870 | 908 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
871 | 909 | { |
872 | 910 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
873 | - if ($i % 4 == 0) |
|
874 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
911 | + if ($i % 4 == 0) { |
|
912 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
875 | 913 | { |
876 | 914 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
915 | + } |
|
877 | 916 | }, $parts[$i]); |
878 | 917 | } |
879 | 918 | $form_message = implode('', $parts); |
@@ -882,8 +921,9 @@ discard block |
||
882 | 921 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
883 | 922 | |
884 | 923 | // Remove any nested quotes, if necessary. |
885 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
886 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
924 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
925 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
926 | + } |
|
887 | 927 | |
888 | 928 | // Add a quote string on the front and end. |
889 | 929 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -895,15 +935,15 @@ discard block |
||
895 | 935 | $form_subject = $first_subject; |
896 | 936 | |
897 | 937 | // Add 'Re: ' to the front of the subject. |
898 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
899 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
938 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
939 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
940 | + } |
|
900 | 941 | |
901 | 942 | // Censor the subject. |
902 | 943 | censorText($form_subject); |
903 | 944 | |
904 | 945 | $form_message = ''; |
905 | - } |
|
906 | - else |
|
946 | + } else |
|
907 | 947 | { |
908 | 948 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
909 | 949 | $form_message = ''; |
@@ -922,13 +962,15 @@ discard block |
||
922 | 962 | if (isset($_REQUEST['msg'])) |
923 | 963 | { |
924 | 964 | $context['attachments']['quantity'] = count($context['current_attachments']); |
925 | - foreach ($context['current_attachments'] as $attachment) |
|
926 | - $context['attachments']['total_size'] += $attachment['size']; |
|
965 | + foreach ($context['current_attachments'] as $attachment) { |
|
966 | + $context['attachments']['total_size'] += $attachment['size']; |
|
967 | + } |
|
927 | 968 | } |
928 | 969 | |
929 | 970 | // A bit of house keeping first. |
930 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
931 | - unset($_SESSION['temp_attachments']); |
|
971 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
972 | + unset($_SESSION['temp_attachments']); |
|
973 | + } |
|
932 | 974 | |
933 | 975 | if (!empty($_SESSION['temp_attachments'])) |
934 | 976 | { |
@@ -937,9 +979,10 @@ discard block |
||
937 | 979 | { |
938 | 980 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
939 | 981 | { |
940 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
941 | - if (file_exists($attachment['tmp_name'])) |
|
982 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
983 | + if (file_exists($attachment['tmp_name'])) |
|
942 | 984 | unlink($attachment['tmp_name']); |
985 | + } |
|
943 | 986 | } |
944 | 987 | $post_errors[] = 'temp_attachments_gone'; |
945 | 988 | $_SESSION['temp_attachments'] = array(); |
@@ -953,8 +996,9 @@ discard block |
||
953 | 996 | // See if any files still exist before showing the warning message and the files attached. |
954 | 997 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
955 | 998 | { |
956 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
957 | - continue; |
|
999 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1000 | + continue; |
|
1001 | + } |
|
958 | 1002 | |
959 | 1003 | if (file_exists($attachment['tmp_name'])) |
960 | 1004 | { |
@@ -964,20 +1008,21 @@ discard block |
||
964 | 1008 | break; |
965 | 1009 | } |
966 | 1010 | } |
967 | - } |
|
968 | - else |
|
1011 | + } else |
|
969 | 1012 | { |
970 | 1013 | // Since, they don't belong here. Let's inform the user that they exist.. |
971 | - if (!empty($topic)) |
|
972 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
973 | - else |
|
974 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
1014 | + if (!empty($topic)) { |
|
1015 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
1016 | + } else { |
|
1017 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
1018 | + } |
|
975 | 1019 | |
976 | 1020 | // Compile a list of the files to show the user. |
977 | 1021 | $file_list = array(); |
978 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
979 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
1022 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1023 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
980 | 1024 | $file_list[] = $attachment['name']; |
1025 | + } |
|
981 | 1026 | |
982 | 1027 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
983 | 1028 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -989,8 +1034,7 @@ discard block |
||
989 | 1034 | |
990 | 1035 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
991 | 1036 | $context['ignore_temp_attachments'] = true; |
992 | - } |
|
993 | - else |
|
1037 | + } else |
|
994 | 1038 | { |
995 | 1039 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
996 | 1040 | $context['ignore_temp_attachments'] = true; |
@@ -998,16 +1042,19 @@ discard block |
||
998 | 1042 | } |
999 | 1043 | } |
1000 | 1044 | |
1001 | - if (!empty($context['we_are_history'])) |
|
1002 | - $post_errors[] = $context['we_are_history']; |
|
1045 | + if (!empty($context['we_are_history'])) { |
|
1046 | + $post_errors[] = $context['we_are_history']; |
|
1047 | + } |
|
1003 | 1048 | |
1004 | 1049 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1005 | 1050 | { |
1006 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
1007 | - break; |
|
1051 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1052 | + break; |
|
1053 | + } |
|
1008 | 1054 | |
1009 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1010 | - continue; |
|
1055 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1056 | + continue; |
|
1057 | + } |
|
1011 | 1058 | |
1012 | 1059 | if ($attachID == 'initial_error') |
1013 | 1060 | { |
@@ -1022,15 +1069,17 @@ discard block |
||
1022 | 1069 | { |
1023 | 1070 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1024 | 1071 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1025 | - foreach ($attachment['errors'] as $error) |
|
1026 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1072 | + foreach ($attachment['errors'] as $error) { |
|
1073 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1074 | + } |
|
1027 | 1075 | $txt['error_attach_errors'] .= '</div>'; |
1028 | 1076 | $post_errors[] = 'attach_errors'; |
1029 | 1077 | |
1030 | 1078 | // Take out the trash. |
1031 | 1079 | unset($_SESSION['temp_attachments'][$attachID]); |
1032 | - if (file_exists($attachment['tmp_name'])) |
|
1033 | - unlink($attachment['tmp_name']); |
|
1080 | + if (file_exists($attachment['tmp_name'])) { |
|
1081 | + unlink($attachment['tmp_name']); |
|
1082 | + } |
|
1034 | 1083 | continue; |
1035 | 1084 | } |
1036 | 1085 | |
@@ -1043,8 +1092,9 @@ discard block |
||
1043 | 1092 | |
1044 | 1093 | $context['attachments']['quantity']++; |
1045 | 1094 | $context['attachments']['total_size'] += $attachment['size']; |
1046 | - if (!isset($context['files_in_session_warning'])) |
|
1047 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1095 | + if (!isset($context['files_in_session_warning'])) { |
|
1096 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1097 | + } |
|
1048 | 1098 | |
1049 | 1099 | $context['current_attachments'][$attachID] = array( |
1050 | 1100 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1072,8 +1122,9 @@ discard block |
||
1072 | 1122 | } |
1073 | 1123 | |
1074 | 1124 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1075 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1076 | - $post_errors[] = 'need_qr_verification'; |
|
1125 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1126 | + $post_errors[] = 'need_qr_verification'; |
|
1127 | + } |
|
1077 | 1128 | |
1078 | 1129 | /* |
1079 | 1130 | * There are two error types: serious and minor. Serious errors |
@@ -1090,52 +1141,56 @@ discard block |
||
1090 | 1141 | { |
1091 | 1142 | loadLanguage('Errors'); |
1092 | 1143 | $context['error_type'] = 'minor'; |
1093 | - foreach ($post_errors as $post_error) |
|
1094 | - if (is_array($post_error)) |
|
1144 | + foreach ($post_errors as $post_error) { |
|
1145 | + if (is_array($post_error)) |
|
1095 | 1146 | { |
1096 | 1147 | $post_error_id = $post_error[0]; |
1148 | + } |
|
1097 | 1149 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1098 | 1150 | |
1099 | 1151 | // If it's not a minor error flag it as such. |
1100 | - if (!in_array($post_error_id, $minor_errors)) |
|
1101 | - $context['error_type'] = 'serious'; |
|
1102 | - } |
|
1103 | - else |
|
1152 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1153 | + $context['error_type'] = 'serious'; |
|
1154 | + } |
|
1155 | + } else |
|
1104 | 1156 | { |
1105 | 1157 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1106 | 1158 | |
1107 | 1159 | // If it's not a minor error flag it as such. |
1108 | - if (!in_array($post_error, $minor_errors)) |
|
1109 | - $context['error_type'] = 'serious'; |
|
1160 | + if (!in_array($post_error, $minor_errors)) { |
|
1161 | + $context['error_type'] = 'serious'; |
|
1162 | + } |
|
1110 | 1163 | } |
1111 | 1164 | } |
1112 | 1165 | |
1113 | 1166 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1114 | - if (isset($_REQUEST['poll'])) |
|
1115 | - $context['page_title'] = $txt['new_poll']; |
|
1116 | - elseif ($context['make_event']) |
|
1117 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1118 | - elseif (isset($_REQUEST['msg'])) |
|
1119 | - $context['page_title'] = $txt['modify_msg']; |
|
1120 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1121 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1122 | - elseif (empty($topic)) |
|
1123 | - $context['page_title'] = $txt['start_new_topic']; |
|
1124 | - else |
|
1125 | - $context['page_title'] = $txt['post_reply']; |
|
1167 | + if (isset($_REQUEST['poll'])) { |
|
1168 | + $context['page_title'] = $txt['new_poll']; |
|
1169 | + } elseif ($context['make_event']) { |
|
1170 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1171 | + } elseif (isset($_REQUEST['msg'])) { |
|
1172 | + $context['page_title'] = $txt['modify_msg']; |
|
1173 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1174 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1175 | + } elseif (empty($topic)) { |
|
1176 | + $context['page_title'] = $txt['start_new_topic']; |
|
1177 | + } else { |
|
1178 | + $context['page_title'] = $txt['post_reply']; |
|
1179 | + } |
|
1126 | 1180 | |
1127 | 1181 | // Build the link tree. |
1128 | - if (empty($topic)) |
|
1129 | - $context['linktree'][] = array( |
|
1182 | + if (empty($topic)) { |
|
1183 | + $context['linktree'][] = array( |
|
1130 | 1184 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1131 | 1185 | ); |
1132 | - else |
|
1133 | - $context['linktree'][] = array( |
|
1186 | + } else { |
|
1187 | + $context['linktree'][] = array( |
|
1134 | 1188 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1135 | 1189 | 'name' => $form_subject, |
1136 | 1190 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1137 | 1191 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1138 | 1192 | ); |
1193 | + } |
|
1139 | 1194 | |
1140 | 1195 | $context['subject'] = addcslashes($form_subject, '"'); |
1141 | 1196 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1179,8 +1234,9 @@ discard block |
||
1179 | 1234 | // Message icons - customized icons are off? |
1180 | 1235 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
1181 | 1236 | |
1182 | - if (!empty($context['icons'])) |
|
1183 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1237 | + if (!empty($context['icons'])) { |
|
1238 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1239 | + } |
|
1184 | 1240 | |
1185 | 1241 | // Are we starting a poll? if set the poll icon as selected if its available |
1186 | 1242 | if (isset($_REQUEST['poll'])) |
@@ -1200,8 +1256,9 @@ discard block |
||
1200 | 1256 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1201 | 1257 | { |
1202 | 1258 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1203 | - if ($context['icons'][$i]['selected']) |
|
1204 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1259 | + if ($context['icons'][$i]['selected']) { |
|
1260 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1261 | + } |
|
1205 | 1262 | } |
1206 | 1263 | if (empty($context['icon_url'])) |
1207 | 1264 | { |
@@ -1215,8 +1272,9 @@ discard block |
||
1215 | 1272 | )); |
1216 | 1273 | } |
1217 | 1274 | |
1218 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1219 | - getTopic(); |
|
1275 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1276 | + getTopic(); |
|
1277 | + } |
|
1220 | 1278 | |
1221 | 1279 | // If the user can post attachments prepare the warning labels. |
1222 | 1280 | if ($context['can_post_attachment']) |
@@ -1227,12 +1285,13 @@ discard block |
||
1227 | 1285 | $context['attachment_restrictions'] = array(); |
1228 | 1286 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1229 | 1287 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1230 | - foreach ($attachmentRestrictionTypes as $type) |
|
1231 | - if (!empty($modSettings[$type])) |
|
1288 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1289 | + if (!empty($modSettings[$type])) |
|
1232 | 1290 | { |
1233 | 1291 | // Show the max number of attachments if not 0. |
1234 | 1292 | if ($type == 'attachmentNumPerPostLimit') |
1235 | 1293 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1294 | + } |
|
1236 | 1295 | } |
1237 | 1296 | } |
1238 | 1297 | |
@@ -1266,8 +1325,8 @@ discard block |
||
1266 | 1325 | |
1267 | 1326 | if (!empty($context['current_attachments'])) |
1268 | 1327 | { |
1269 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1270 | - addInlineJavaScript(' |
|
1328 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1329 | + addInlineJavaScript(' |
|
1271 | 1330 | current_attachments.push({ |
1272 | 1331 | name: '. JavaScriptEscape($mock['name']) . ', |
1273 | 1332 | size: '. $mock['size'] . ', |
@@ -1276,6 +1335,7 @@ discard block |
||
1276 | 1335 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1277 | 1336 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1278 | 1337 | });'); |
1338 | + } |
|
1279 | 1339 | } |
1280 | 1340 | |
1281 | 1341 | // File Upload. |
@@ -1350,9 +1410,10 @@ discard block |
||
1350 | 1410 | $context['posting_fields']['board']['dd'] .= ' |
1351 | 1411 | <optgroup label="' . $category['name'] . '">'; |
1352 | 1412 | |
1353 | - foreach ($category['boards'] as $brd) |
|
1354 | - $context['posting_fields']['board']['dd'] .= ' |
|
1413 | + foreach ($category['boards'] as $brd) { |
|
1414 | + $context['posting_fields']['board']['dd'] .= ' |
|
1355 | 1415 | <option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'] . '</option>'; |
1416 | + } |
|
1356 | 1417 | |
1357 | 1418 | $context['posting_fields']['board']['dd'] .= ' |
1358 | 1419 | </optgroup>'; |
@@ -1383,8 +1444,9 @@ discard block |
||
1383 | 1444 | |
1384 | 1445 | |
1385 | 1446 | // Finally, load the template. |
1386 | - if (!isset($_REQUEST['xml'])) |
|
1387 | - loadTemplate('Post'); |
|
1447 | + if (!isset($_REQUEST['xml'])) { |
|
1448 | + loadTemplate('Post'); |
|
1449 | + } |
|
1388 | 1450 | |
1389 | 1451 | call_integration_hook('integrate_post_end'); |
1390 | 1452 | } |
@@ -1405,13 +1467,14 @@ discard block |
||
1405 | 1467 | // Sneaking off, are we? |
1406 | 1468 | if (empty($_POST) && empty($topic)) |
1407 | 1469 | { |
1408 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1409 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1410 | - else |
|
1411 | - fatal_lang_error('post_upload_error', false); |
|
1470 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1471 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1472 | + } else { |
|
1473 | + fatal_lang_error('post_upload_error', false); |
|
1474 | + } |
|
1475 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1476 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1412 | 1477 | } |
1413 | - elseif (empty($_POST) && !empty($topic)) |
|
1414 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1415 | 1478 | |
1416 | 1479 | // No need! |
1417 | 1480 | $context['robot_no_index'] = true; |
@@ -1423,8 +1486,9 @@ discard block |
||
1423 | 1486 | $post_errors = array(); |
1424 | 1487 | |
1425 | 1488 | // If the session has timed out, let the user re-submit their form. |
1426 | - if (checkSession('post', '', false) != '') |
|
1427 | - $post_errors[] = 'session_timeout'; |
|
1489 | + if (checkSession('post', '', false) != '') { |
|
1490 | + $post_errors[] = 'session_timeout'; |
|
1491 | + } |
|
1428 | 1492 | |
1429 | 1493 | // Wrong verification code? |
1430 | 1494 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1434,8 +1498,9 @@ discard block |
||
1434 | 1498 | 'id' => 'post', |
1435 | 1499 | ); |
1436 | 1500 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1437 | - if (is_array($context['require_verification'])) |
|
1438 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1501 | + if (is_array($context['require_verification'])) { |
|
1502 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1503 | + } |
|
1439 | 1504 | } |
1440 | 1505 | |
1441 | 1506 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -1444,25 +1509,29 @@ discard block |
||
1444 | 1509 | call_integration_hook('integrate_post2_start'); |
1445 | 1510 | |
1446 | 1511 | // Drafts enabled and needed? |
1447 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1448 | - require_once($sourcedir . '/Drafts.php'); |
|
1512 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1513 | + require_once($sourcedir . '/Drafts.php'); |
|
1514 | + } |
|
1449 | 1515 | |
1450 | 1516 | // First check to see if they are trying to delete any current attachments. |
1451 | 1517 | if (isset($_POST['attach_del'])) |
1452 | 1518 | { |
1453 | 1519 | $keep_temp = array(); |
1454 | 1520 | $keep_ids = array(); |
1455 | - foreach ($_POST['attach_del'] as $dummy) |
|
1456 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1521 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1522 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1457 | 1523 | $keep_temp[] = $dummy; |
1458 | - else |
|
1459 | - $keep_ids[] = (int) $dummy; |
|
1524 | + } |
|
1525 | + else { |
|
1526 | + $keep_ids[] = (int) $dummy; |
|
1527 | + } |
|
1460 | 1528 | |
1461 | - if (isset($_SESSION['temp_attachments'])) |
|
1462 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1529 | + if (isset($_SESSION['temp_attachments'])) { |
|
1530 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1463 | 1531 | { |
1464 | 1532 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1465 | 1533 | continue; |
1534 | + } |
|
1466 | 1535 | |
1467 | 1536 | unset($_SESSION['temp_attachments'][$attachID]); |
1468 | 1537 | unlink($attachment['tmp_name']); |
@@ -1494,8 +1563,9 @@ discard block |
||
1494 | 1563 | { |
1495 | 1564 | require_once($sourcedir . '/ManageAttachments.php'); |
1496 | 1565 | |
1497 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
1498 | - removeAttachments(array('id_attach' => $attachID)); |
|
1566 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
1567 | + removeAttachments(array('id_attach' => $attachID)); |
|
1568 | + } |
|
1499 | 1569 | |
1500 | 1570 | unset($_SESSION['already_attached']); |
1501 | 1571 | |
@@ -1518,12 +1588,14 @@ discard block |
||
1518 | 1588 | $smcFunc['db_free_result']($request); |
1519 | 1589 | |
1520 | 1590 | // Though the topic should be there, it might have vanished. |
1521 | - if (!is_array($topic_info)) |
|
1522 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1591 | + if (!is_array($topic_info)) { |
|
1592 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1593 | + } |
|
1523 | 1594 | |
1524 | 1595 | // Did this topic suddenly move? Just checking... |
1525 | - if ($topic_info['id_board'] != $board) |
|
1526 | - fatal_lang_error('not_a_topic'); |
|
1596 | + if ($topic_info['id_board'] != $board) { |
|
1597 | + fatal_lang_error('not_a_topic'); |
|
1598 | + } |
|
1527 | 1599 | |
1528 | 1600 | // Do the permissions and approval stuff... |
1529 | 1601 | $becomesApproved = true; |
@@ -1546,49 +1618,50 @@ discard block |
||
1546 | 1618 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1547 | 1619 | { |
1548 | 1620 | // Don't allow a post if it's locked. |
1549 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1550 | - fatal_lang_error('topic_locked', false); |
|
1621 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1622 | + fatal_lang_error('topic_locked', false); |
|
1623 | + } |
|
1551 | 1624 | |
1552 | 1625 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1553 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1554 | - unset($_REQUEST['poll']); |
|
1555 | - |
|
1556 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1557 | - { |
|
1558 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1559 | - $becomesApproved = false; |
|
1560 | - |
|
1561 | - else |
|
1562 | - isAllowedTo('post_reply_any'); |
|
1563 | - } |
|
1564 | - elseif (!allowedTo('post_reply_any')) |
|
1626 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1627 | + unset($_REQUEST['poll']); |
|
1628 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1629 | + { |
|
1630 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1631 | + $becomesApproved = false; |
|
1632 | + } else { |
|
1633 | + isAllowedTo('post_reply_any'); |
|
1634 | + } |
|
1635 | + } elseif (!allowedTo('post_reply_any')) |
|
1565 | 1636 | { |
1566 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1567 | - $becomesApproved = false; |
|
1568 | - |
|
1569 | - else |
|
1570 | - isAllowedTo('post_reply_own'); |
|
1637 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1638 | + $becomesApproved = false; |
|
1639 | + } else { |
|
1640 | + isAllowedTo('post_reply_own'); |
|
1641 | + } |
|
1571 | 1642 | } |
1572 | 1643 | |
1573 | 1644 | if (isset($_POST['lock'])) |
1574 | 1645 | { |
1575 | 1646 | // Nothing is changed to the lock. |
1576 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
1577 | - unset($_POST['lock']); |
|
1647 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
1648 | + unset($_POST['lock']); |
|
1649 | + } |
|
1578 | 1650 | |
1579 | 1651 | // You're have no permission to lock this topic. |
1580 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1581 | - unset($_POST['lock']); |
|
1652 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1653 | + unset($_POST['lock']); |
|
1654 | + } |
|
1582 | 1655 | |
1583 | 1656 | // You are allowed to (un)lock your own topic only. |
1584 | 1657 | elseif (!allowedTo('lock_any')) |
1585 | 1658 | { |
1586 | 1659 | // You cannot override a moderator lock. |
1587 | - if ($topic_info['locked'] == 1) |
|
1588 | - unset($_POST['lock']); |
|
1589 | - |
|
1590 | - else |
|
1591 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1660 | + if ($topic_info['locked'] == 1) { |
|
1661 | + unset($_POST['lock']); |
|
1662 | + } else { |
|
1663 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1664 | + } |
|
1592 | 1665 | } |
1593 | 1666 | // Hail mighty moderator, (un)lock this topic immediately. |
1594 | 1667 | else |
@@ -1596,19 +1669,21 @@ discard block |
||
1596 | 1669 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1597 | 1670 | |
1598 | 1671 | // Did someone (un)lock this while you were posting? |
1599 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1600 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1672 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1673 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1674 | + } |
|
1601 | 1675 | } |
1602 | 1676 | } |
1603 | 1677 | |
1604 | 1678 | // So you wanna (un)sticky this...let's see. |
1605 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1606 | - unset($_POST['sticky']); |
|
1607 | - elseif (isset($_POST['sticky'])) |
|
1679 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1680 | + unset($_POST['sticky']); |
|
1681 | + } elseif (isset($_POST['sticky'])) |
|
1608 | 1682 | { |
1609 | 1683 | // Did someone (un)sticky this while you were posting? |
1610 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1611 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1684 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1685 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1686 | + } |
|
1612 | 1687 | } |
1613 | 1688 | |
1614 | 1689 | // If drafts are enabled, then pass this off |
@@ -1635,26 +1710,31 @@ discard block |
||
1635 | 1710 | |
1636 | 1711 | // Do like, the permissions, for safety and stuff... |
1637 | 1712 | $becomesApproved = true; |
1638 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1639 | - $becomesApproved = false; |
|
1640 | - else |
|
1641 | - isAllowedTo('post_new'); |
|
1713 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1714 | + $becomesApproved = false; |
|
1715 | + } else { |
|
1716 | + isAllowedTo('post_new'); |
|
1717 | + } |
|
1642 | 1718 | |
1643 | 1719 | if (isset($_POST['lock'])) |
1644 | 1720 | { |
1645 | 1721 | // New topics are by default not locked. |
1646 | - if (empty($_POST['lock'])) |
|
1647 | - unset($_POST['lock']); |
|
1722 | + if (empty($_POST['lock'])) { |
|
1723 | + unset($_POST['lock']); |
|
1724 | + } |
|
1648 | 1725 | // Besides, you need permission. |
1649 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1650 | - unset($_POST['lock']); |
|
1726 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1727 | + unset($_POST['lock']); |
|
1728 | + } |
|
1651 | 1729 | // A moderator-lock (1) can override a user-lock (2). |
1652 | - else |
|
1653 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1730 | + else { |
|
1731 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1732 | + } |
|
1654 | 1733 | } |
1655 | 1734 | |
1656 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1657 | - unset($_POST['sticky']); |
|
1735 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1736 | + unset($_POST['sticky']); |
|
1737 | + } |
|
1658 | 1738 | |
1659 | 1739 | // Saving your new topic as a draft first? |
1660 | 1740 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1679,31 +1759,37 @@ discard block |
||
1679 | 1759 | 'id_msg' => $_REQUEST['msg'], |
1680 | 1760 | ) |
1681 | 1761 | ); |
1682 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1683 | - fatal_lang_error('cant_find_messages', false); |
|
1762 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1763 | + fatal_lang_error('cant_find_messages', false); |
|
1764 | + } |
|
1684 | 1765 | $row = $smcFunc['db_fetch_assoc']($request); |
1685 | 1766 | $smcFunc['db_free_result']($request); |
1686 | 1767 | |
1687 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1688 | - fatal_lang_error('topic_locked', false); |
|
1768 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1769 | + fatal_lang_error('topic_locked', false); |
|
1770 | + } |
|
1689 | 1771 | |
1690 | 1772 | if (isset($_POST['lock'])) |
1691 | 1773 | { |
1692 | 1774 | // Nothing changes to the lock status. |
1693 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1694 | - unset($_POST['lock']); |
|
1775 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1776 | + unset($_POST['lock']); |
|
1777 | + } |
|
1695 | 1778 | // You're simply not allowed to (un)lock this. |
1696 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1697 | - unset($_POST['lock']); |
|
1779 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1780 | + unset($_POST['lock']); |
|
1781 | + } |
|
1698 | 1782 | // You're only allowed to lock your own topics. |
1699 | 1783 | elseif (!allowedTo('lock_any')) |
1700 | 1784 | { |
1701 | 1785 | // You're not allowed to break a moderator's lock. |
1702 | - if ($topic_info['locked'] == 1) |
|
1703 | - unset($_POST['lock']); |
|
1786 | + if ($topic_info['locked'] == 1) { |
|
1787 | + unset($_POST['lock']); |
|
1788 | + } |
|
1704 | 1789 | // Lock it with a soft lock or unlock it. |
1705 | - else |
|
1706 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1790 | + else { |
|
1791 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1792 | + } |
|
1707 | 1793 | } |
1708 | 1794 | // You must be the moderator. |
1709 | 1795 | else |
@@ -1711,44 +1797,46 @@ discard block |
||
1711 | 1797 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1712 | 1798 | |
1713 | 1799 | // Did someone (un)lock this while you were posting? |
1714 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1715 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1800 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1801 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1802 | + } |
|
1716 | 1803 | } |
1717 | 1804 | } |
1718 | 1805 | |
1719 | 1806 | // Change the sticky status of this topic? |
1720 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1721 | - unset($_POST['sticky']); |
|
1722 | - elseif (isset($_POST['sticky'])) |
|
1807 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1808 | + unset($_POST['sticky']); |
|
1809 | + } elseif (isset($_POST['sticky'])) |
|
1723 | 1810 | { |
1724 | 1811 | // Did someone (un)sticky this while you were posting? |
1725 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1726 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1812 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1813 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1814 | + } |
|
1727 | 1815 | } |
1728 | 1816 | |
1729 | 1817 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1730 | 1818 | { |
1731 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1732 | - fatal_lang_error('modify_post_time_passed', false); |
|
1733 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1734 | - isAllowedTo('modify_replies'); |
|
1735 | - else |
|
1736 | - isAllowedTo('modify_own'); |
|
1737 | - } |
|
1738 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1819 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1820 | + fatal_lang_error('modify_post_time_passed', false); |
|
1821 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1822 | + isAllowedTo('modify_replies'); |
|
1823 | + } else { |
|
1824 | + isAllowedTo('modify_own'); |
|
1825 | + } |
|
1826 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1739 | 1827 | { |
1740 | 1828 | isAllowedTo('modify_replies'); |
1741 | 1829 | |
1742 | 1830 | // If you're modifying a reply, I say it better be logged... |
1743 | 1831 | $moderationAction = true; |
1744 | - } |
|
1745 | - else |
|
1832 | + } else |
|
1746 | 1833 | { |
1747 | 1834 | isAllowedTo('modify_any'); |
1748 | 1835 | |
1749 | 1836 | // Log it, assuming you're not modifying your own post. |
1750 | - if ($row['id_member'] != $user_info['id']) |
|
1751 | - $moderationAction = true; |
|
1837 | + if ($row['id_member'] != $user_info['id']) { |
|
1838 | + $moderationAction = true; |
|
1839 | + } |
|
1752 | 1840 | } |
1753 | 1841 | |
1754 | 1842 | // If drafts are enabled, then lets send this off to save |
@@ -1775,8 +1863,9 @@ discard block |
||
1775 | 1863 | // Update search api |
1776 | 1864 | require_once($sourcedir . '/Search.php'); |
1777 | 1865 | $searchAPI = findSearchAPI(); |
1778 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
1779 | - $searchAPI->postRemoved($_REQUEST['msg']); |
|
1866 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
1867 | + $searchAPI->postRemoved($_REQUEST['msg']); |
|
1868 | + } |
|
1780 | 1869 | |
1781 | 1870 | } |
1782 | 1871 | |
@@ -1794,20 +1883,24 @@ discard block |
||
1794 | 1883 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1795 | 1884 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1796 | 1885 | |
1797 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1798 | - $post_errors[] = 'no_name'; |
|
1799 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1800 | - $post_errors[] = 'long_name'; |
|
1886 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1887 | + $post_errors[] = 'no_name'; |
|
1888 | + } |
|
1889 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1890 | + $post_errors[] = 'long_name'; |
|
1891 | + } |
|
1801 | 1892 | |
1802 | 1893 | if (empty($modSettings['guest_post_no_email'])) |
1803 | 1894 | { |
1804 | 1895 | // Only check if they changed it! |
1805 | 1896 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1806 | 1897 | { |
1807 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1808 | - $post_errors[] = 'no_email'; |
|
1809 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1810 | - $post_errors[] = 'bad_email'; |
|
1898 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1899 | + $post_errors[] = 'no_email'; |
|
1900 | + } |
|
1901 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1902 | + $post_errors[] = 'bad_email'; |
|
1903 | + } |
|
1811 | 1904 | } |
1812 | 1905 | |
1813 | 1906 | // Now make sure this email address is not banned from posting. |
@@ -1823,76 +1916,90 @@ discard block |
||
1823 | 1916 | } |
1824 | 1917 | |
1825 | 1918 | // Coming from the quickReply? |
1826 | - if (isset($_POST['quickReply'])) |
|
1827 | - $_POST['message'] = $_POST['quickReply']; |
|
1919 | + if (isset($_POST['quickReply'])) { |
|
1920 | + $_POST['message'] = $_POST['quickReply']; |
|
1921 | + } |
|
1828 | 1922 | |
1829 | 1923 | // Check the subject and message. |
1830 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1831 | - $post_errors[] = 'no_subject'; |
|
1832 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1833 | - $post_errors[] = 'no_message'; |
|
1834 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1835 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1836 | - else |
|
1924 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1925 | + $post_errors[] = 'no_subject'; |
|
1926 | + } |
|
1927 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1928 | + $post_errors[] = 'no_message'; |
|
1929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1930 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1931 | + } else |
|
1837 | 1932 | { |
1838 | 1933 | // Prepare the message a bit for some additional testing. |
1839 | 1934 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1840 | 1935 | |
1841 | 1936 | // Preparse code. (Zef) |
1842 | - if ($user_info['is_guest']) |
|
1843 | - $user_info['name'] = $_POST['guestname']; |
|
1937 | + if ($user_info['is_guest']) { |
|
1938 | + $user_info['name'] = $_POST['guestname']; |
|
1939 | + } |
|
1844 | 1940 | preparsecode($_POST['message']); |
1845 | 1941 | |
1846 | 1942 | // Let's see if there's still some content left without the tags. |
1847 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1848 | - $post_errors[] = 'no_message'; |
|
1943 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1944 | + $post_errors[] = 'no_message'; |
|
1945 | + } |
|
1849 | 1946 | |
1850 | 1947 | } |
1851 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1852 | - $post_errors[] = 'no_event'; |
|
1948 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1949 | + $post_errors[] = 'no_event'; |
|
1950 | + } |
|
1853 | 1951 | // You are not! |
1854 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1855 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1952 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1953 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1954 | + } |
|
1856 | 1955 | |
1857 | 1956 | // Validate the poll... |
1858 | 1957 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1859 | 1958 | { |
1860 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1861 | - fatal_lang_error('no_access', false); |
|
1959 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1960 | + fatal_lang_error('no_access', false); |
|
1961 | + } |
|
1862 | 1962 | |
1863 | 1963 | // This is a new topic... so it's a new poll. |
1864 | - if (empty($topic)) |
|
1865 | - isAllowedTo('poll_post'); |
|
1964 | + if (empty($topic)) { |
|
1965 | + isAllowedTo('poll_post'); |
|
1966 | + } |
|
1866 | 1967 | // Can you add to your own topics? |
1867 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1868 | - isAllowedTo('poll_add_own'); |
|
1968 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1969 | + isAllowedTo('poll_add_own'); |
|
1970 | + } |
|
1869 | 1971 | // Can you add polls to any topic, then? |
1870 | - else |
|
1871 | - isAllowedTo('poll_add_any'); |
|
1972 | + else { |
|
1973 | + isAllowedTo('poll_add_any'); |
|
1974 | + } |
|
1872 | 1975 | |
1873 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1874 | - $post_errors[] = 'no_question'; |
|
1976 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1977 | + $post_errors[] = 'no_question'; |
|
1978 | + } |
|
1875 | 1979 | |
1876 | 1980 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1877 | 1981 | |
1878 | 1982 | // Get rid of empty ones. |
1879 | - foreach ($_POST['options'] as $k => $option) |
|
1880 | - if ($option == '') |
|
1983 | + foreach ($_POST['options'] as $k => $option) { |
|
1984 | + if ($option == '') |
|
1881 | 1985 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1986 | + } |
|
1882 | 1987 | |
1883 | 1988 | // What are you going to vote between with one choice?!? |
1884 | - if (count($_POST['options']) < 2) |
|
1885 | - $post_errors[] = 'poll_few'; |
|
1886 | - elseif (count($_POST['options']) > 256) |
|
1887 | - $post_errors[] = 'poll_many'; |
|
1989 | + if (count($_POST['options']) < 2) { |
|
1990 | + $post_errors[] = 'poll_few'; |
|
1991 | + } elseif (count($_POST['options']) > 256) { |
|
1992 | + $post_errors[] = 'poll_many'; |
|
1993 | + } |
|
1888 | 1994 | } |
1889 | 1995 | |
1890 | 1996 | if ($posterIsGuest) |
1891 | 1997 | { |
1892 | 1998 | // If user is a guest, make sure the chosen name isn't taken. |
1893 | 1999 | require_once($sourcedir . '/Subs-Members.php'); |
1894 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1895 | - $post_errors[] = 'bad_name'; |
|
2000 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
2001 | + $post_errors[] = 'bad_name'; |
|
2002 | + } |
|
1896 | 2003 | } |
1897 | 2004 | // If the user isn't a guest, get his or her name and email. |
1898 | 2005 | elseif (!isset($_REQUEST['msg'])) |
@@ -1923,8 +2030,9 @@ discard block |
||
1923 | 2030 | } |
1924 | 2031 | |
1925 | 2032 | // Make sure the user isn't spamming the board. |
1926 | - if (!isset($_REQUEST['msg'])) |
|
1927 | - spamProtection('post'); |
|
2033 | + if (!isset($_REQUEST['msg'])) { |
|
2034 | + spamProtection('post'); |
|
2035 | + } |
|
1928 | 2036 | |
1929 | 2037 | // At about this point, we're posting and that's that. |
1930 | 2038 | ignore_user_abort(true); |
@@ -1937,32 +2045,36 @@ discard block |
||
1937 | 2045 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1938 | 2046 | |
1939 | 2047 | // At this point, we want to make sure the subject isn't too long. |
1940 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1941 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2048 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2049 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2050 | + } |
|
1942 | 2051 | |
1943 | 2052 | // Same with the "why did you edit this" text. |
1944 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1945 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2053 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2054 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2055 | + } |
|
1946 | 2056 | |
1947 | 2057 | // Make the poll... |
1948 | 2058 | if (isset($_REQUEST['poll'])) |
1949 | 2059 | { |
1950 | 2060 | // Make sure that the user has not entered a ridiculous number of options.. |
1951 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1952 | - $_POST['poll_max_votes'] = 1; |
|
1953 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1954 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1955 | - else |
|
1956 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
2061 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
2062 | + $_POST['poll_max_votes'] = 1; |
|
2063 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
2064 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
2065 | + } else { |
|
2066 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
2067 | + } |
|
1957 | 2068 | |
1958 | 2069 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1959 | 2070 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1960 | 2071 | |
1961 | 2072 | // Just set it to zero if it's not there.. |
1962 | - if (!isset($_POST['poll_hide'])) |
|
1963 | - $_POST['poll_hide'] = 0; |
|
1964 | - else |
|
1965 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2073 | + if (!isset($_POST['poll_hide'])) { |
|
2074 | + $_POST['poll_hide'] = 0; |
|
2075 | + } else { |
|
2076 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2077 | + } |
|
1966 | 2078 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1967 | 2079 | |
1968 | 2080 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1971,16 +2083,19 @@ discard block |
||
1971 | 2083 | { |
1972 | 2084 | require_once($sourcedir . '/Subs-Members.php'); |
1973 | 2085 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1974 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1975 | - $_POST['poll_guest_vote'] = 0; |
|
2086 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2087 | + $_POST['poll_guest_vote'] = 0; |
|
2088 | + } |
|
1976 | 2089 | } |
1977 | 2090 | |
1978 | 2091 | // If the user tries to set the poll too far in advance, don't let them. |
1979 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1980 | - fatal_lang_error('poll_range_error', false); |
|
2092 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2093 | + fatal_lang_error('poll_range_error', false); |
|
2094 | + } |
|
1981 | 2095 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1982 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1983 | - $_POST['poll_hide'] = 1; |
|
2096 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2097 | + $_POST['poll_hide'] = 1; |
|
2098 | + } |
|
1984 | 2099 | |
1985 | 2100 | // Clean up the question and answers. |
1986 | 2101 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1994,13 +2109,15 @@ discard block |
||
1994 | 2109 | { |
1995 | 2110 | $attachIDs = array(); |
1996 | 2111 | $attach_errors = array(); |
1997 | - if (!empty($context['we_are_history'])) |
|
1998 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2112 | + if (!empty($context['we_are_history'])) { |
|
2113 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2114 | + } |
|
1999 | 2115 | |
2000 | 2116 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
2001 | 2117 | { |
2002 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
2003 | - continue; |
|
2118 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2119 | + continue; |
|
2120 | + } |
|
2004 | 2121 | |
2005 | 2122 | // If there was an initial error just show that message. |
2006 | 2123 | if ($attachID == 'initial_error') |
@@ -2029,12 +2146,13 @@ discard block |
||
2029 | 2146 | if (createAttachment($attachmentOptions)) |
2030 | 2147 | { |
2031 | 2148 | $attachIDs[] = $attachmentOptions['id']; |
2032 | - if (!empty($attachmentOptions['thumb'])) |
|
2033 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2149 | + if (!empty($attachmentOptions['thumb'])) { |
|
2150 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2151 | + } |
|
2034 | 2152 | } |
2153 | + } else { |
|
2154 | + $attach_errors[] = '<dt> </dt>'; |
|
2035 | 2155 | } |
2036 | - else |
|
2037 | - $attach_errors[] = '<dt> </dt>'; |
|
2038 | 2156 | |
2039 | 2157 | if (!empty($attachmentOptions['errors'])) |
2040 | 2158 | { |
@@ -2046,14 +2164,16 @@ discard block |
||
2046 | 2164 | if (!is_array($error)) |
2047 | 2165 | { |
2048 | 2166 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
2049 | - if (in_array($error, $log_these)) |
|
2050 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2167 | + if (in_array($error, $log_these)) { |
|
2168 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2169 | + } |
|
2170 | + } else { |
|
2171 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
2051 | 2172 | } |
2052 | - else |
|
2053 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
2054 | 2173 | } |
2055 | - if (file_exists($attachment['tmp_name'])) |
|
2056 | - unlink($attachment['tmp_name']); |
|
2174 | + if (file_exists($attachment['tmp_name'])) { |
|
2175 | + unlink($attachment['tmp_name']); |
|
2176 | + } |
|
2057 | 2177 | } |
2058 | 2178 | } |
2059 | 2179 | unset($_SESSION['temp_attachments']); |
@@ -2094,24 +2214,24 @@ discard block |
||
2094 | 2214 | ); |
2095 | 2215 | |
2096 | 2216 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2217 | + } else { |
|
2218 | + $id_poll = 0; |
|
2097 | 2219 | } |
2098 | - else |
|
2099 | - $id_poll = 0; |
|
2100 | 2220 | |
2101 | 2221 | // Creating a new topic? |
2102 | 2222 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2103 | 2223 | |
2104 | 2224 | // Check the icon. |
2105 | - if (!isset($_POST['icon'])) |
|
2106 | - $_POST['icon'] = 'xx'; |
|
2107 | - |
|
2108 | - else |
|
2225 | + if (!isset($_POST['icon'])) { |
|
2226 | + $_POST['icon'] = 'xx'; |
|
2227 | + } else |
|
2109 | 2228 | { |
2110 | 2229 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2111 | 2230 | |
2112 | 2231 | // Need to figure it out if this is a valid icon name. |
2113 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2114 | - $_POST['icon'] = 'xx'; |
|
2232 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2233 | + $_POST['icon'] = 'xx'; |
|
2234 | + } |
|
2115 | 2235 | } |
2116 | 2236 | |
2117 | 2237 | // Collect all parameters for the creation or modification of a post. |
@@ -2152,8 +2272,9 @@ discard block |
||
2152 | 2272 | } |
2153 | 2273 | |
2154 | 2274 | // This will save some time... |
2155 | - if (empty($approve_has_changed)) |
|
2156 | - unset($msgOptions['approved']); |
|
2275 | + if (empty($approve_has_changed)) { |
|
2276 | + unset($msgOptions['approved']); |
|
2277 | + } |
|
2157 | 2278 | |
2158 | 2279 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2159 | 2280 | } |
@@ -2162,8 +2283,9 @@ discard block |
||
2162 | 2283 | { |
2163 | 2284 | createPost($msgOptions, $topicOptions, $posterOptions); |
2164 | 2285 | |
2165 | - if (isset($topicOptions['id'])) |
|
2166 | - $topic = $topicOptions['id']; |
|
2286 | + if (isset($topicOptions['id'])) { |
|
2287 | + $topic = $topicOptions['id']; |
|
2288 | + } |
|
2167 | 2289 | } |
2168 | 2290 | |
2169 | 2291 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2175,8 +2297,9 @@ discard block |
||
2175 | 2297 | } |
2176 | 2298 | |
2177 | 2299 | // If we had a draft for this, its time to remove it since it was just posted |
2178 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2179 | - DeleteDraft($_POST['id_draft']); |
|
2300 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2301 | + DeleteDraft($_POST['id_draft']); |
|
2302 | + } |
|
2180 | 2303 | |
2181 | 2304 | // Editing or posting an event? |
2182 | 2305 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2195,8 +2318,7 @@ discard block |
||
2195 | 2318 | 'member' => $user_info['id'], |
2196 | 2319 | ); |
2197 | 2320 | insertEvent($eventOptions); |
2198 | - } |
|
2199 | - elseif (isset($_POST['calendar'])) |
|
2321 | + } elseif (isset($_POST['calendar'])) |
|
2200 | 2322 | { |
2201 | 2323 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2202 | 2324 | |
@@ -2224,14 +2346,15 @@ discard block |
||
2224 | 2346 | } |
2225 | 2347 | |
2226 | 2348 | // Delete it? |
2227 | - if (isset($_REQUEST['deleteevent'])) |
|
2228 | - $smcFunc['db_query']('', ' |
|
2349 | + if (isset($_REQUEST['deleteevent'])) { |
|
2350 | + $smcFunc['db_query']('', ' |
|
2229 | 2351 | DELETE FROM {db_prefix}calendar |
2230 | 2352 | WHERE id_event = {int:id_event}', |
2231 | 2353 | array( |
2232 | 2354 | 'id_event' => $_REQUEST['eventid'], |
2233 | 2355 | ) |
2234 | 2356 | ); |
2357 | + } |
|
2235 | 2358 | // ... or just update it? |
2236 | 2359 | else |
2237 | 2360 | { |
@@ -2273,9 +2396,8 @@ discard block |
||
2273 | 2396 | array($user_info['id'], $topic, 0), |
2274 | 2397 | array('id_member', 'id_topic', 'id_board') |
2275 | 2398 | ); |
2276 | - } |
|
2277 | - elseif (!$newTopic) |
|
2278 | - $smcFunc['db_query']('', ' |
|
2399 | + } elseif (!$newTopic) { |
|
2400 | + $smcFunc['db_query']('', ' |
|
2279 | 2401 | DELETE FROM {db_prefix}log_notify |
2280 | 2402 | WHERE id_member = {int:current_member} |
2281 | 2403 | AND id_topic = {int:current_topic}', |
@@ -2284,16 +2406,20 @@ discard block |
||
2284 | 2406 | 'current_topic' => $topic, |
2285 | 2407 | ) |
2286 | 2408 | ); |
2409 | + } |
|
2287 | 2410 | |
2288 | 2411 | // Log an act of moderation - modifying. |
2289 | - if (!empty($moderationAction)) |
|
2290 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2412 | + if (!empty($moderationAction)) { |
|
2413 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2414 | + } |
|
2291 | 2415 | |
2292 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2293 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2416 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2417 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2418 | + } |
|
2294 | 2419 | |
2295 | - if (isset($_POST['sticky'])) |
|
2296 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2420 | + if (isset($_POST['sticky'])) { |
|
2421 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2422 | + } |
|
2297 | 2423 | |
2298 | 2424 | // Returning to the topic? |
2299 | 2425 | if (!empty($_REQUEST['goback'])) |
@@ -2312,26 +2438,31 @@ discard block |
||
2312 | 2438 | ); |
2313 | 2439 | } |
2314 | 2440 | |
2315 | - if ($board_info['num_topics'] == 0) |
|
2316 | - cache_put_data('board-' . $board, null, 120); |
|
2441 | + if ($board_info['num_topics'] == 0) { |
|
2442 | + cache_put_data('board-' . $board, null, 120); |
|
2443 | + } |
|
2317 | 2444 | |
2318 | 2445 | call_integration_hook('integrate_post2_end'); |
2319 | 2446 | |
2320 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
2321 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2447 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
2448 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2449 | + } |
|
2322 | 2450 | |
2323 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2324 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2451 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2452 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2453 | + } |
|
2325 | 2454 | |
2326 | 2455 | // Return to post if the mod is on. |
2327 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2328 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2329 | - elseif (!empty($_REQUEST['goback'])) |
|
2330 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2456 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2457 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2458 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2459 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2460 | + } |
|
2331 | 2461 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2332 | - else |
|
2333 | - redirectexit('board=' . $board . '.0'); |
|
2334 | -} |
|
2462 | + else { |
|
2463 | + redirectexit('board=' . $board . '.0'); |
|
2464 | + } |
|
2465 | + } |
|
2335 | 2466 | |
2336 | 2467 | /** |
2337 | 2468 | * Handle the announce topic function (action=announce). |
@@ -2349,8 +2480,9 @@ discard block |
||
2349 | 2480 | |
2350 | 2481 | validateSession(); |
2351 | 2482 | |
2352 | - if (empty($topic)) |
|
2353 | - fatal_lang_error('topic_gone', false); |
|
2483 | + if (empty($topic)) { |
|
2484 | + fatal_lang_error('topic_gone', false); |
|
2485 | + } |
|
2354 | 2486 | |
2355 | 2487 | loadLanguage('Post'); |
2356 | 2488 | loadTemplate('Post'); |
@@ -2377,8 +2509,9 @@ discard block |
||
2377 | 2509 | global $txt, $context, $topic, $board_info, $smcFunc; |
2378 | 2510 | |
2379 | 2511 | $groups = array_merge($board_info['groups'], array(1)); |
2380 | - foreach ($groups as $id => $group) |
|
2381 | - $groups[$id] = (int) $group; |
|
2512 | + foreach ($groups as $id => $group) { |
|
2513 | + $groups[$id] = (int) $group; |
|
2514 | + } |
|
2382 | 2515 | |
2383 | 2516 | $context['groups'] = array(); |
2384 | 2517 | if (in_array(0, $groups)) |
@@ -2421,8 +2554,9 @@ discard block |
||
2421 | 2554 | 'group_list' => $groups, |
2422 | 2555 | ) |
2423 | 2556 | ); |
2424 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2425 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2557 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2558 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2559 | + } |
|
2426 | 2560 | $smcFunc['db_free_result']($request); |
2427 | 2561 | |
2428 | 2562 | // Get the subject of the topic we're about to announce. |
@@ -2464,16 +2598,19 @@ discard block |
||
2464 | 2598 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2465 | 2599 | $groups = array_merge($board_info['groups'], array(1)); |
2466 | 2600 | |
2467 | - if (isset($_POST['membergroups'])) |
|
2468 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2601 | + if (isset($_POST['membergroups'])) { |
|
2602 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2603 | + } |
|
2469 | 2604 | |
2470 | 2605 | // Check whether at least one membergroup was selected. |
2471 | - if (empty($_POST['who'])) |
|
2472 | - fatal_lang_error('no_membergroup_selected'); |
|
2606 | + if (empty($_POST['who'])) { |
|
2607 | + fatal_lang_error('no_membergroup_selected'); |
|
2608 | + } |
|
2473 | 2609 | |
2474 | 2610 | // Make sure all membergroups are integers and can access the board of the announcement. |
2475 | - foreach ($_POST['who'] as $id => $mg) |
|
2476 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2611 | + foreach ($_POST['who'] as $id => $mg) { |
|
2612 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2613 | + } |
|
2477 | 2614 | |
2478 | 2615 | // Get the topic subject and censor it. |
2479 | 2616 | $request = $smcFunc['db_query']('', ' |
@@ -2519,12 +2656,13 @@ discard block |
||
2519 | 2656 | if ($smcFunc['db_num_rows']($request) == 0) |
2520 | 2657 | { |
2521 | 2658 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2522 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2523 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2524 | - elseif (!empty($_REQUEST['goback'])) |
|
2525 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2526 | - else |
|
2527 | - redirectexit('board=' . $board . '.0'); |
|
2659 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2660 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2661 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2662 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2663 | + } else { |
|
2664 | + redirectexit('board=' . $board . '.0'); |
|
2665 | + } |
|
2528 | 2666 | } |
2529 | 2667 | |
2530 | 2668 | $announcements = array(); |
@@ -2543,8 +2681,9 @@ discard block |
||
2543 | 2681 | foreach ($rows as $row) |
2544 | 2682 | { |
2545 | 2683 | // Force them to have it? |
2546 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2547 | - continue; |
|
2684 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2685 | + continue; |
|
2686 | + } |
|
2548 | 2687 | |
2549 | 2688 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2550 | 2689 | |
@@ -2572,8 +2711,9 @@ discard block |
||
2572 | 2711 | } |
2573 | 2712 | |
2574 | 2713 | // For each language send a different mail - low priority... |
2575 | - foreach ($announcements as $lang => $mail) |
|
2576 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2714 | + foreach ($announcements as $lang => $mail) { |
|
2715 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2716 | + } |
|
2577 | 2717 | |
2578 | 2718 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2579 | 2719 | |
@@ -2583,9 +2723,10 @@ discard block |
||
2583 | 2723 | $context['sub_template'] = 'announcement_send'; |
2584 | 2724 | |
2585 | 2725 | // Go back to the correct language for the user ;). |
2586 | - if (!empty($modSettings['userLanguage'])) |
|
2587 | - loadLanguage('Post'); |
|
2588 | -} |
|
2726 | + if (!empty($modSettings['userLanguage'])) { |
|
2727 | + loadLanguage('Post'); |
|
2728 | + } |
|
2729 | + } |
|
2589 | 2730 | |
2590 | 2731 | /** |
2591 | 2732 | * Get the topic for display purposes. |
@@ -2598,12 +2739,13 @@ discard block |
||
2598 | 2739 | { |
2599 | 2740 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2600 | 2741 | |
2601 | - if (isset($_REQUEST['xml'])) |
|
2602 | - $limit = ' |
|
2742 | + if (isset($_REQUEST['xml'])) { |
|
2743 | + $limit = ' |
|
2603 | 2744 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2604 | - else |
|
2605 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2745 | + } else { |
|
2746 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2606 | 2747 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2748 | + } |
|
2607 | 2749 | |
2608 | 2750 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2609 | 2751 | $request = $smcFunc['db_query']('', ' |
@@ -2641,8 +2783,9 @@ discard block |
||
2641 | 2783 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2642 | 2784 | ); |
2643 | 2785 | |
2644 | - if (!empty($context['new_replies'])) |
|
2645 | - $context['new_replies']--; |
|
2786 | + if (!empty($context['new_replies'])) { |
|
2787 | + $context['new_replies']--; |
|
2788 | + } |
|
2646 | 2789 | } |
2647 | 2790 | $smcFunc['db_free_result']($request); |
2648 | 2791 | } |
@@ -2659,8 +2802,9 @@ discard block |
||
2659 | 2802 | global $sourcedir, $smcFunc; |
2660 | 2803 | |
2661 | 2804 | loadLanguage('Post'); |
2662 | - if (!isset($_REQUEST['xml'])) |
|
2663 | - loadTemplate('Post'); |
|
2805 | + if (!isset($_REQUEST['xml'])) { |
|
2806 | + loadTemplate('Post'); |
|
2807 | + } |
|
2664 | 2808 | |
2665 | 2809 | include_once($sourcedir . '/Subs-Post.php'); |
2666 | 2810 | |
@@ -2691,8 +2835,9 @@ discard block |
||
2691 | 2835 | $smcFunc['db_free_result']($request); |
2692 | 2836 | |
2693 | 2837 | $context['sub_template'] = 'quotefast'; |
2694 | - if (!empty($row)) |
|
2695 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2838 | + if (!empty($row)) { |
|
2839 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2840 | + } |
|
2696 | 2841 | |
2697 | 2842 | if (!empty($can_view_post)) |
2698 | 2843 | { |
@@ -2725,8 +2870,9 @@ discard block |
||
2725 | 2870 | } |
2726 | 2871 | |
2727 | 2872 | // Remove any nested quotes. |
2728 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2729 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2873 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2874 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2875 | + } |
|
2730 | 2876 | |
2731 | 2877 | $lb = "\n"; |
2732 | 2878 | |
@@ -2752,14 +2898,14 @@ discard block |
||
2752 | 2898 | 'time' => '', |
2753 | 2899 | ), |
2754 | 2900 | ); |
2755 | - } |
|
2756 | - else |
|
2757 | - $context['quote'] = array( |
|
2901 | + } else { |
|
2902 | + $context['quote'] = array( |
|
2758 | 2903 | 'xml' => '', |
2759 | 2904 | 'mozilla' => '', |
2760 | 2905 | 'text' => '', |
2761 | 2906 | ); |
2762 | -} |
|
2907 | + } |
|
2908 | + } |
|
2763 | 2909 | |
2764 | 2910 | /** |
2765 | 2911 | * Used to edit the body or subject of a message inline |
@@ -2771,8 +2917,9 @@ discard block |
||
2771 | 2917 | global $user_info, $context, $smcFunc, $language, $board_info; |
2772 | 2918 | |
2773 | 2919 | // We have to have a topic! |
2774 | - if (empty($topic)) |
|
2775 | - obExit(false); |
|
2920 | + if (empty($topic)) { |
|
2921 | + obExit(false); |
|
2922 | + } |
|
2776 | 2923 | |
2777 | 2924 | checkSession('get'); |
2778 | 2925 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2798,31 +2945,35 @@ discard block |
||
2798 | 2945 | 'guest_id' => 0, |
2799 | 2946 | ) |
2800 | 2947 | ); |
2801 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2802 | - fatal_lang_error('no_board', false); |
|
2948 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2949 | + fatal_lang_error('no_board', false); |
|
2950 | + } |
|
2803 | 2951 | $row = $smcFunc['db_fetch_assoc']($request); |
2804 | 2952 | $smcFunc['db_free_result']($request); |
2805 | 2953 | |
2806 | 2954 | // Change either body or subject requires permissions to modify messages. |
2807 | 2955 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2808 | 2956 | { |
2809 | - if (!empty($row['locked'])) |
|
2810 | - isAllowedTo('moderate_board'); |
|
2957 | + if (!empty($row['locked'])) { |
|
2958 | + isAllowedTo('moderate_board'); |
|
2959 | + } |
|
2811 | 2960 | |
2812 | 2961 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2813 | 2962 | { |
2814 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2815 | - fatal_lang_error('modify_post_time_passed', false); |
|
2816 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2817 | - isAllowedTo('modify_replies'); |
|
2818 | - else |
|
2819 | - isAllowedTo('modify_own'); |
|
2963 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2964 | + fatal_lang_error('modify_post_time_passed', false); |
|
2965 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2966 | + isAllowedTo('modify_replies'); |
|
2967 | + } else { |
|
2968 | + isAllowedTo('modify_own'); |
|
2969 | + } |
|
2820 | 2970 | } |
2821 | 2971 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2822 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2823 | - isAllowedTo('modify_replies'); |
|
2824 | - else |
|
2825 | - isAllowedTo('modify_any'); |
|
2972 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2973 | + isAllowedTo('modify_replies'); |
|
2974 | + } else { |
|
2975 | + isAllowedTo('modify_any'); |
|
2976 | + } |
|
2826 | 2977 | |
2827 | 2978 | // Only log this action if it wasn't your message. |
2828 | 2979 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2834,10 +2985,10 @@ discard block |
||
2834 | 2985 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2835 | 2986 | |
2836 | 2987 | // Maximum number of characters. |
2837 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2838 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2839 | - } |
|
2840 | - elseif (isset($_POST['subject'])) |
|
2988 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2989 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2990 | + } |
|
2991 | + } elseif (isset($_POST['subject'])) |
|
2841 | 2992 | { |
2842 | 2993 | $post_errors[] = 'no_subject'; |
2843 | 2994 | unset($_POST['subject']); |
@@ -2849,13 +3000,11 @@ discard block |
||
2849 | 3000 | { |
2850 | 3001 | $post_errors[] = 'no_message'; |
2851 | 3002 | unset($_POST['message']); |
2852 | - } |
|
2853 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
3003 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2854 | 3004 | { |
2855 | 3005 | $post_errors[] = 'long_message'; |
2856 | 3006 | unset($_POST['message']); |
2857 | - } |
|
2858 | - else |
|
3007 | + } else |
|
2859 | 3008 | { |
2860 | 3009 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2861 | 3010 | |
@@ -2871,31 +3020,34 @@ discard block |
||
2871 | 3020 | |
2872 | 3021 | if (isset($_POST['lock'])) |
2873 | 3022 | { |
2874 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2875 | - unset($_POST['lock']); |
|
2876 | - elseif (!allowedTo('lock_any')) |
|
3023 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
3024 | + unset($_POST['lock']); |
|
3025 | + } elseif (!allowedTo('lock_any')) |
|
2877 | 3026 | { |
2878 | - if ($row['locked'] == 1) |
|
2879 | - unset($_POST['lock']); |
|
2880 | - else |
|
2881 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
3027 | + if ($row['locked'] == 1) { |
|
3028 | + unset($_POST['lock']); |
|
3029 | + } else { |
|
3030 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
3031 | + } |
|
3032 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
3033 | + unset($_POST['lock']); |
|
3034 | + } else { |
|
3035 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2882 | 3036 | } |
2883 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2884 | - unset($_POST['lock']); |
|
2885 | - else |
|
2886 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2887 | 3037 | } |
2888 | 3038 | |
2889 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2890 | - unset($_POST['sticky']); |
|
3039 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
3040 | + unset($_POST['sticky']); |
|
3041 | + } |
|
2891 | 3042 | |
2892 | 3043 | if (isset($_POST['modify_reason'])) |
2893 | 3044 | { |
2894 | 3045 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2895 | 3046 | |
2896 | 3047 | // Maximum number of characters. |
2897 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2898 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
3048 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
3049 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
3050 | + } |
|
2899 | 3051 | } |
2900 | 3052 | |
2901 | 3053 | if (empty($post_errors)) |
@@ -2932,8 +3084,9 @@ discard block |
||
2932 | 3084 | } |
2933 | 3085 | } |
2934 | 3086 | // If nothing was changed there's no need to add an entry to the moderation log. |
2935 | - else |
|
2936 | - $moderationAction = false; |
|
3087 | + else { |
|
3088 | + $moderationAction = false; |
|
3089 | + } |
|
2937 | 3090 | |
2938 | 3091 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2939 | 3092 | |
@@ -2951,9 +3104,9 @@ discard block |
||
2951 | 3104 | // Get the proper (default language) response prefix first. |
2952 | 3105 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2953 | 3106 | { |
2954 | - if ($language === $user_info['language']) |
|
2955 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2956 | - else |
|
3107 | + if ($language === $user_info['language']) { |
|
3108 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3109 | + } else |
|
2957 | 3110 | { |
2958 | 3111 | loadLanguage('index', $language, false); |
2959 | 3112 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2975,8 +3128,9 @@ discard block |
||
2975 | 3128 | ); |
2976 | 3129 | } |
2977 | 3130 | |
2978 | - if (!empty($moderationAction)) |
|
2979 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3131 | + if (!empty($moderationAction)) { |
|
3132 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3133 | + } |
|
2980 | 3134 | } |
2981 | 3135 | |
2982 | 3136 | if (isset($_REQUEST['xml'])) |
@@ -3017,8 +3171,7 @@ discard block |
||
3017 | 3171 | ); |
3018 | 3172 | |
3019 | 3173 | censorText($context['message']['subject']); |
3020 | - } |
|
3021 | - else |
|
3174 | + } else |
|
3022 | 3175 | { |
3023 | 3176 | $context['message'] = array( |
3024 | 3177 | 'id' => $row['id_msg'], |
@@ -3030,15 +3183,16 @@ discard block |
||
3030 | 3183 | loadLanguage('Errors'); |
3031 | 3184 | foreach ($post_errors as $post_error) |
3032 | 3185 | { |
3033 | - if ($post_error == 'long_message') |
|
3034 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3035 | - else |
|
3036 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3186 | + if ($post_error == 'long_message') { |
|
3187 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3188 | + } else { |
|
3189 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3190 | + } |
|
3037 | 3191 | } |
3038 | 3192 | } |
3193 | + } else { |
|
3194 | + obExit(false); |
|
3195 | + } |
|
3039 | 3196 | } |
3040 | - else |
|
3041 | - obExit(false); |
|
3042 | -} |
|
3043 | 3197 | |
3044 | 3198 | ?> |
3045 | 3199 | \ No newline at end of file |