@@ -20,17 +20,19 @@ discard block |
||
20 | 20 | echo ' |
21 | 21 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">'; |
22 | 22 | |
23 | - if (!empty($context['search_errors'])) |
|
24 | - echo ' |
|
23 | + if (!empty($context['search_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="errorbox"> |
26 | 26 | ', implode('<br>', $context['search_errors']['messages']), ' |
27 | 27 | </div>'; |
28 | + } |
|
28 | 29 | |
29 | - if (!empty($context['search_ignored'])) |
|
30 | - echo ' |
|
30 | + if (!empty($context['search_ignored'])) { |
|
31 | + echo ' |
|
31 | 32 | <div class="noticebox"> |
32 | 33 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
33 | 34 | </div>'; |
35 | + } |
|
34 | 36 | |
35 | 37 | echo ' |
36 | 38 | <div class="cat_bar"> |
@@ -48,9 +50,10 @@ discard block |
||
48 | 50 | <dd> |
49 | 51 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
50 | 52 | |
51 | - if (empty($modSettings['search_simple_fulltext'])) |
|
52 | - echo ' |
|
53 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
54 | + echo ' |
|
53 | 55 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
56 | + } |
|
54 | 57 | |
55 | 58 | echo ' |
56 | 59 | </dd> |
@@ -114,21 +117,23 @@ discard block |
||
114 | 117 | <input type="hidden" name="advanced" value="1">'; |
115 | 118 | |
116 | 119 | // Require an image to be typed to save spamming? |
117 | - if ($context['require_verification']) |
|
118 | - echo ' |
|
120 | + if ($context['require_verification']) { |
|
121 | + echo ' |
|
119 | 122 | <p> |
120 | 123 | <strong>', $txt['verification'], ':</strong> |
121 | 124 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
122 | 125 | </p>'; |
126 | + } |
|
123 | 127 | |
124 | 128 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
125 | - if (!empty($context['search_params']['topic'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['search_params']['topic'])) { |
|
130 | + echo ' |
|
127 | 131 | <p> |
128 | 132 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
129 | 133 | </p> |
130 | 134 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
131 | 135 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
136 | + } |
|
132 | 137 | |
133 | 138 | echo ' |
134 | 139 | </div>'; |
@@ -158,14 +163,15 @@ discard block |
||
158 | 163 | |
159 | 164 | foreach ($category['boards'] as $board) |
160 | 165 | { |
161 | - if ($i == $limit) |
|
162 | - echo ' |
|
166 | + if ($i == $limit) { |
|
167 | + echo ' |
|
163 | 168 | </ul> |
164 | 169 | </li> |
165 | 170 | </ul> |
166 | 171 | <ul class="ignoreboards floatright"> |
167 | 172 | <li class="category"> |
168 | 173 | <ul>'; |
174 | + } |
|
169 | 175 | |
170 | 176 | echo ' |
171 | 177 | <li class="board"> |
@@ -253,17 +259,19 @@ discard block |
||
253 | 259 | <div class="roundframe noup">'; |
254 | 260 | |
255 | 261 | // Did they make any typos or mistakes, perhaps? |
256 | - if (isset($context['did_you_mean'])) |
|
257 | - echo ' |
|
262 | + if (isset($context['did_you_mean'])) { |
|
263 | + echo ' |
|
258 | 264 | <p> |
259 | 265 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
260 | 266 | </p>'; |
267 | + } |
|
261 | 268 | |
262 | - if (!empty($context['search_ignored'])) |
|
263 | - echo ' |
|
269 | + if (!empty($context['search_ignored'])) { |
|
270 | + echo ' |
|
264 | 271 | <p> |
265 | 272 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
266 | 273 | </p>'; |
274 | + } |
|
267 | 275 | |
268 | 276 | echo ' |
269 | 277 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -286,10 +294,11 @@ discard block |
||
286 | 294 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
287 | 295 | </div>'; |
288 | 296 | |
289 | - if (!empty($context['search_params']['brd'])) |
|
290 | - foreach ($context['search_params']['brd'] as $board_id) |
|
297 | + if (!empty($context['search_params']['brd'])) { |
|
298 | + foreach ($context['search_params']['brd'] as $board_id) |
|
291 | 299 | echo ' |
292 | 300 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
301 | + } |
|
293 | 302 | |
294 | 303 | echo ' |
295 | 304 | </form> |
@@ -300,18 +309,20 @@ discard block |
||
300 | 309 | if ($context['compact']) |
301 | 310 | { |
302 | 311 | // Quick moderation set to checkboxes? Oh, how fun :/ |
303 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
304 | - echo ' |
|
312 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
313 | + echo ' |
|
305 | 314 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
315 | + } |
|
306 | 316 | |
307 | 317 | echo ' |
308 | 318 | <div class="cat_bar"> |
309 | 319 | <h3 class="catbg"> |
310 | 320 | <span class="floatright">'; |
311 | 321 | |
312 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
313 | - echo ' |
|
322 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
323 | + echo ' |
|
314 | 324 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
325 | + } |
|
315 | 326 | echo ' |
316 | 327 | </span> |
317 | 328 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -319,15 +330,15 @@ discard block |
||
319 | 330 | </div>'; |
320 | 331 | |
321 | 332 | // Was anything even found? |
322 | - if (!empty($context['topics'])) |
|
323 | - echo ' |
|
333 | + if (!empty($context['topics'])) { |
|
334 | + echo ' |
|
324 | 335 | <div class="pagesection"> |
325 | 336 | <span>', $context['page_index'], '</span> |
326 | 337 | </div>'; |
327 | - |
|
328 | - else |
|
329 | - echo ' |
|
338 | + } else { |
|
339 | + echo ' |
|
330 | 340 | <div class="roundframe noup">', $txt['find_no_results'], '</div>'; |
341 | + } |
|
331 | 342 | |
332 | 343 | // While we have results to show ... |
333 | 344 | while ($topic = $context['get_topics']()) |
@@ -350,31 +361,35 @@ discard block |
||
350 | 361 | echo ' |
351 | 362 | <span class="floatright">'; |
352 | 363 | |
353 | - if ($options['display_quick_mod'] == 1) |
|
354 | - echo ' |
|
364 | + if ($options['display_quick_mod'] == 1) { |
|
365 | + echo ' |
|
355 | 366 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
356 | - |
|
357 | - else |
|
367 | + } else |
|
358 | 368 | { |
359 | - if ($topic['quick_mod']['remove']) |
|
360 | - echo ' |
|
369 | + if ($topic['quick_mod']['remove']) { |
|
370 | + echo ' |
|
361 | 371 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
372 | + } |
|
362 | 373 | |
363 | - if ($topic['quick_mod']['lock']) |
|
364 | - echo ' |
|
374 | + if ($topic['quick_mod']['lock']) { |
|
375 | + echo ' |
|
365 | 376 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
377 | + } |
|
366 | 378 | |
367 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
368 | - echo ' |
|
379 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
380 | + echo ' |
|
369 | 381 | <br>'; |
382 | + } |
|
370 | 383 | |
371 | - if ($topic['quick_mod']['sticky']) |
|
372 | - echo ' |
|
384 | + if ($topic['quick_mod']['sticky']) { |
|
385 | + echo ' |
|
373 | 386 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
387 | + } |
|
374 | 388 | |
375 | - if ($topic['quick_mod']['move']) |
|
376 | - echo ' |
|
389 | + if ($topic['quick_mod']['move']) { |
|
390 | + echo ' |
|
377 | 391 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
392 | + } |
|
378 | 393 | } |
379 | 394 | |
380 | 395 | echo ' |
@@ -384,20 +399,22 @@ discard block |
||
384 | 399 | echo ' |
385 | 400 | </div><!-- .block -->'; |
386 | 401 | |
387 | - if ($message['body_highlighted'] != '') |
|
388 | - echo ' |
|
402 | + if ($message['body_highlighted'] != '') { |
|
403 | + echo ' |
|
389 | 404 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
405 | + } |
|
390 | 406 | } |
391 | 407 | |
392 | 408 | echo ' |
393 | 409 | </div><!-- $topic[css_class] -->'; |
394 | 410 | |
395 | 411 | } |
396 | - if (!empty($context['topics'])) |
|
397 | - echo ' |
|
412 | + if (!empty($context['topics'])) { |
|
413 | + echo ' |
|
398 | 414 | <div class="pagesection"> |
399 | 415 | <span>', $context['page_index'], '</span> |
400 | 416 | </div>'; |
417 | + } |
|
401 | 418 | |
402 | 419 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
403 | 420 | { |
@@ -406,17 +423,19 @@ discard block |
||
406 | 423 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
407 | 424 | <option value="">--------</option>'; |
408 | 425 | |
409 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
410 | - if ($context['can_' . $qmod_action]) |
|
426 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
427 | + if ($context['can_' . $qmod_action]) |
|
411 | 428 | echo ' |
412 | 429 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
430 | + } |
|
413 | 431 | |
414 | 432 | echo ' |
415 | 433 | </select>'; |
416 | 434 | |
417 | - if ($context['can_move']) |
|
418 | - echo ' |
|
435 | + if ($context['can_move']) { |
|
436 | + echo ' |
|
419 | 437 | <span id="quick_mod_jump_to"></span>'; |
438 | + } |
|
420 | 439 | |
421 | 440 | echo ' |
422 | 441 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -425,13 +444,13 @@ discard block |
||
425 | 444 | } |
426 | 445 | |
427 | 446 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
429 | - echo ' |
|
447 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
448 | + echo ' |
|
430 | 449 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
431 | 450 | </form>'; |
451 | + } |
|
432 | 452 | |
433 | - } |
|
434 | - else |
|
453 | + } else |
|
435 | 454 | { |
436 | 455 | echo ' |
437 | 456 | <div class="cat_bar"> |
@@ -443,9 +462,10 @@ discard block |
||
443 | 462 | <span>', $context['page_index'], '</span> |
444 | 463 | </div>'; |
445 | 464 | |
446 | - if (empty($context['topics'])) |
|
447 | - echo ' |
|
465 | + if (empty($context['topics'])) { |
|
466 | + echo ' |
|
448 | 467 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
468 | + } |
|
449 | 469 | |
450 | 470 | while ($topic = $context['get_topics']()) |
451 | 471 | { |
@@ -462,23 +482,27 @@ discard block |
||
462 | 482 | </div> |
463 | 483 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
464 | 484 | |
465 | - if ($topic['can_reply']) |
|
466 | - echo ' |
|
485 | + if ($topic['can_reply']) { |
|
486 | + echo ' |
|
467 | 487 | <ul class="quickbuttons">'; |
488 | + } |
|
468 | 489 | |
469 | 490 | // If they *can* reply? |
470 | - if ($topic['can_reply']) |
|
471 | - echo ' |
|
491 | + if ($topic['can_reply']) { |
|
492 | + echo ' |
|
472 | 493 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
494 | + } |
|
473 | 495 | |
474 | 496 | // If they *can* quote? |
475 | - if ($topic['can_quote']) |
|
476 | - echo ' |
|
497 | + if ($topic['can_quote']) { |
|
498 | + echo ' |
|
477 | 499 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
500 | + } |
|
478 | 501 | |
479 | - if ($topic['can_reply']) |
|
480 | - echo ' |
|
502 | + if ($topic['can_reply']) { |
|
503 | + echo ' |
|
481 | 504 | </ul>'; |
505 | + } |
|
482 | 506 | echo ' |
483 | 507 | <br class="clear"> |
484 | 508 | </div><!-- $topic[css_class] -->'; |
@@ -497,8 +521,8 @@ discard block |
||
497 | 521 | <div class="smalltext righttext" id="search_jump_to"></div> |
498 | 522 | <script>'; |
499 | 523 | |
500 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
501 | - echo ' |
|
524 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
525 | + echo ' |
|
502 | 526 | if (typeof(window.XMLHttpRequest) != "undefined") |
503 | 527 | aJumpTo[aJumpTo.length] = new JumpTo({ |
504 | 528 | sContainerId: "quick_mod_jump_to", |
@@ -513,6 +537,7 @@ discard block |
||
513 | 537 | bDisabled: true, |
514 | 538 | sCustomName: "move_to" |
515 | 539 | });'; |
540 | + } |
|
516 | 541 | |
517 | 542 | echo ' |
518 | 543 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -54,18 +54,20 @@ discard block |
||
54 | 54 | <div class="windowbg2 noup" 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="windowbg2 noup" 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="windowbg2 noup" 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="windowbg2 noup" 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="windowbg2"> |
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"> |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | |
50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
51 | 52 | |
52 | - if (pg_affected_rows($result) === 0) |
|
53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
53 | + if (pg_affected_rows($result) === 0) { |
|
54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | |
56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
60 | 62 | { |
61 | 63 | global $smcFunc, $db_connection; |
62 | 64 | |
63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
64 | - return false; |
|
65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
66 | + return false; |
|
67 | + } |
|
65 | 68 | |
66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
67 | 70 | $res = pg_fetch_assoc($result); |
68 | 71 | |
69 | - if ($res['server_version_num'] < 90500) |
|
70 | - return false; |
|
72 | + if ($res['server_version_num'] < 90500) { |
|
73 | + return false; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | return $test ? true : parent::isSupported(); |
73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
81 | 85 | |
82 | 86 | $ttl = time() - $ttl; |
83 | 87 | |
84 | - if (empty($this->pg_get_data_prep)) |
|
85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
88 | + if (empty($this->pg_get_data_prep)) { |
|
89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
88 | 93 | |
89 | - if (pg_affected_rows($result) === 0) |
|
90 | - return null; |
|
94 | + if (pg_affected_rows($result) === 0) { |
|
95 | + return null; |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $res = pg_fetch_assoc($result); |
93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
101 | 107 | { |
102 | 108 | global $db_prefix, $db_connection; |
103 | 109 | |
104 | - if (!isset($value)) |
|
105 | - $value = ''; |
|
110 | + if (!isset($value)) { |
|
111 | + $value = ''; |
|
112 | + } |
|
106 | 113 | |
107 | 114 | $ttl = time() + $ttl; |
108 | 115 | |
109 | - if (empty($this->pg_put_data_prep)) |
|
110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
116 | + if (empty($this->pg_put_data_prep)) { |
|
117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
113 | 120 | ); |
121 | + } |
|
114 | 122 | |
115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
116 | 124 | |
117 | - if (pg_affected_rows($result) > 0) |
|
118 | - return true; |
|
119 | - else |
|
120 | - return false; |
|
125 | + if (pg_affected_rows($result) > 0) { |
|
126 | + return true; |
|
127 | + } else { |
|
128 | + return false; |
|
129 | + } |
|
121 | 130 | } |
122 | 131 | |
123 | 132 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | global $db_connection, $db_prefix; |
167 | 167 | |
168 | - pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time() ); |
|
168 | + pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | global $db_connection, $db_prefix; |
191 | 191 | |
192 | - pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM '. $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING'); |
|
192 | + pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM ' . $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING'); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -29,18 +30,21 @@ discard block |
||
29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
30 | 31 | |
31 | 32 | // Don't reload this as we may have processed error strings. |
32 | - if (empty($post_errors)) |
|
33 | - loadLanguage('Profile+Drafts'); |
|
33 | + if (empty($post_errors)) { |
|
34 | + loadLanguage('Profile+Drafts'); |
|
35 | + } |
|
34 | 36 | loadTemplate('Profile'); |
35 | 37 | |
36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
37 | 39 | |
38 | 40 | // Did we get the user by name... |
39 | - if (isset($_REQUEST['user'])) |
|
40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
41 | + if (isset($_REQUEST['user'])) { |
|
42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
43 | + } |
|
41 | 44 | // ... or by id_member? |
42 | - elseif (!empty($_REQUEST['u'])) |
|
43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
45 | + elseif (!empty($_REQUEST['u'])) { |
|
46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
47 | + } |
|
44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
45 | 49 | else |
46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
50 | 54 | } |
51 | 55 | |
52 | 56 | // Check if loadMemberData() has returned a valid result. |
53 | - if (!$memberResult) |
|
54 | - fatal_lang_error('not_a_user', false, 404); |
|
57 | + if (!$memberResult) { |
|
58 | + fatal_lang_error('not_a_user', false, 404); |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // If all went well, we have a valid member ID! |
57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
67 | 72 | |
68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
436 | 442 | foreach ($section['areas'] as $area_id => $area) |
437 | 443 | { |
438 | 444 | // If it said no permissions that meant it wasn't valid! |
439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
447 | + } |
|
441 | 448 | // Otherwise pick the right set. |
442 | - else |
|
443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
449 | + else { |
|
450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
451 | + } |
|
444 | 452 | |
445 | 453 | // Password required in most cases |
446 | - if (!empty($area['password'])) |
|
447 | - $context['password_areas'][] = $area_id; |
|
454 | + if (!empty($area['password'])) { |
|
455 | + $context['password_areas'][] = $area_id; |
|
456 | + } |
|
448 | 457 | } |
449 | 458 | } |
450 | 459 | |
451 | 460 | // Is there an updated message to show? |
452 | - if (isset($_GET['updated'])) |
|
453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
461 | + if (isset($_GET['updated'])) { |
|
462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
463 | + } |
|
454 | 464 | |
455 | 465 | // Set a few options for the menu. |
456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
466 | 476 | |
467 | 477 | // No menu means no access. |
468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
469 | - fatal_lang_error('no_access', false); |
|
478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
479 | + fatal_lang_error('no_access', false); |
|
480 | + } |
|
470 | 481 | |
471 | 482 | // Make a note of the Unique ID for this menu. |
472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
492 | 503 | if ($current_area == $area_id) |
493 | 504 | { |
494 | 505 | // This can't happen - but is a security check. |
495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
496 | - fatal_lang_error('no_access', false); |
|
506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
507 | + fatal_lang_error('no_access', false); |
|
508 | + } |
|
497 | 509 | |
498 | 510 | // Are we saving data in a valid area? |
499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
512 | 524 | } |
513 | 525 | |
514 | 526 | // Does this require session validating? |
515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
516 | - $security_checks['validate'] = true; |
|
527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
528 | + $security_checks['validate'] = true; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | // Permissions for good measure. |
519 | - if (!empty($profile_include_data['permission'])) |
|
520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
532 | + if (!empty($profile_include_data['permission'])) { |
|
533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
534 | + } |
|
521 | 535 | |
522 | 536 | // Either way got something. |
523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
526 | 540 | } |
527 | 541 | |
528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
529 | - if (!$found_area) |
|
530 | - fatal_lang_error('no_access', false); |
|
543 | + if (!$found_area) { |
|
544 | + fatal_lang_error('no_access', false); |
|
545 | + } |
|
531 | 546 | |
532 | 547 | // Release this now. |
533 | 548 | unset($profile_areas); |
534 | 549 | |
535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
536 | - if (isset($security_checks['session'])) |
|
537 | - checkSession($security_checks['session']); |
|
538 | - if (isset($security_checks['validate'])) |
|
539 | - validateSession(); |
|
540 | - if (isset($security_checks['validateToken'])) |
|
541 | - validateToken($token_name, $token_type); |
|
542 | - if (isset($security_checks['permission'])) |
|
543 | - isAllowedTo($security_checks['permission']); |
|
551 | + if (isset($security_checks['session'])) { |
|
552 | + checkSession($security_checks['session']); |
|
553 | + } |
|
554 | + if (isset($security_checks['validate'])) { |
|
555 | + validateSession(); |
|
556 | + } |
|
557 | + if (isset($security_checks['validateToken'])) { |
|
558 | + validateToken($token_name, $token_type); |
|
559 | + } |
|
560 | + if (isset($security_checks['permission'])) { |
|
561 | + isAllowedTo($security_checks['permission']); |
|
562 | + } |
|
544 | 563 | |
545 | 564 | // Create a token if needed. |
546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
550 | 569 | } |
551 | 570 | |
552 | 571 | // File to include? |
553 | - if (isset($profile_include_data['file'])) |
|
554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
572 | + if (isset($profile_include_data['file'])) { |
|
573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
574 | + } |
|
555 | 575 | |
556 | 576 | // Build the link tree. |
557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
560 | 580 | ); |
561 | 581 | |
562 | - if (!empty($profile_include_data['label'])) |
|
563 | - $context['linktree'][] = array( |
|
582 | + if (!empty($profile_include_data['label'])) { |
|
583 | + $context['linktree'][] = array( |
|
564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
565 | 585 | 'name' => $profile_include_data['label'], |
566 | 586 | ); |
587 | + } |
|
567 | 588 | |
568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
569 | - $context['linktree'][] = array( |
|
589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
590 | + $context['linktree'][] = array( |
|
570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
572 | 593 | ); |
594 | + } |
|
573 | 595 | |
574 | 596 | // Set the template for this area and add the profile layer. |
575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
595 | 617 | if ($check_password) |
596 | 618 | { |
597 | 619 | // Check to ensure we're forcing SSL for authentication |
598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
599 | - fatal_lang_error('login_ssl_required'); |
|
620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
621 | + fatal_lang_error('login_ssl_required'); |
|
622 | + } |
|
600 | 623 | |
601 | 624 | // You didn't even enter a password! |
602 | - if (trim($_POST['oldpasswrd']) == '') |
|
603 | - $post_errors[] = 'no_password'; |
|
625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
626 | + $post_errors[] = 'no_password'; |
|
627 | + } |
|
604 | 628 | |
605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
610 | 634 | |
611 | 635 | // Bad password!!! |
612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
613 | - $post_errors[] = 'bad_password'; |
|
636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
637 | + $post_errors[] = 'bad_password'; |
|
638 | + } |
|
614 | 639 | |
615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
616 | - if (in_array('bad_password', $post_errors)) |
|
617 | - $context['password_auth_failed'] = true; |
|
641 | + if (in_array('bad_password', $post_errors)) { |
|
642 | + $context['password_auth_failed'] = true; |
|
643 | + } |
|
618 | 644 | } |
619 | 645 | |
620 | 646 | // Change the IP address in the database. |
621 | - if ($context['user']['is_owner']) |
|
622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
647 | + if ($context['user']['is_owner']) { |
|
648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
649 | + } |
|
623 | 650 | |
624 | 651 | // Now call the sub-action function... |
625 | 652 | if ($current_area == 'activateaccount') |
626 | 653 | { |
627 | - if (empty($post_errors)) |
|
628 | - activateAccount($memID); |
|
629 | - } |
|
630 | - elseif ($current_area == 'deleteaccount') |
|
654 | + if (empty($post_errors)) { |
|
655 | + activateAccount($memID); |
|
656 | + } |
|
657 | + } elseif ($current_area == 'deleteaccount') |
|
631 | 658 | { |
632 | 659 | if (empty($post_errors)) |
633 | 660 | { |
634 | 661 | deleteAccount2($memID); |
635 | 662 | redirectexit(); |
636 | 663 | } |
637 | - } |
|
638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
639 | 665 | { |
640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
641 | 667 | |
642 | 668 | // Whatever we've done, we have nothing else to do here... |
643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
644 | - } |
|
645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
646 | - saveProfileFields(); |
|
647 | - else |
|
670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
671 | + saveProfileFields(); |
|
672 | + } else |
|
648 | 673 | { |
649 | 674 | $force_redirect = true; |
650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
661 | 686 | loadLanguage('Errors'); |
662 | 687 | $context['post_errors'] = $post_errors; |
663 | - } |
|
664 | - elseif (!empty($profile_vars)) |
|
688 | + } elseif (!empty($profile_vars)) |
|
665 | 689 | { |
666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
667 | - if (isset($profile_vars['passwd'])) |
|
668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
691 | + if (isset($profile_vars['passwd'])) { |
|
692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
693 | + } |
|
669 | 694 | |
670 | 695 | updateMemberData($memID, $profile_vars); |
671 | 696 | |
672 | 697 | // What if this is the newest member? |
673 | - if ($modSettings['latestMember'] == $memID) |
|
674 | - updateStats('member'); |
|
675 | - elseif (isset($profile_vars['real_name'])) |
|
676 | - updateSettings(array('memberlist_updated' => time())); |
|
698 | + if ($modSettings['latestMember'] == $memID) { |
|
699 | + updateStats('member'); |
|
700 | + } elseif (isset($profile_vars['real_name'])) { |
|
701 | + updateSettings(array('memberlist_updated' => time())); |
|
702 | + } |
|
677 | 703 | |
678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
680 | - updateSettings(array( |
|
705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
706 | + updateSettings(array( |
|
681 | 707 | 'calendar_updated' => time(), |
682 | 708 | )); |
709 | + } |
|
683 | 710 | |
684 | 711 | // Anything worth logging? |
685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
686 | 713 | { |
687 | 714 | $log_changes = array(); |
688 | 715 | require_once($sourcedir . '/Logging.php'); |
689 | - foreach ($context['log_changes'] as $k => $v) |
|
690 | - $log_changes[] = array( |
|
716 | + foreach ($context['log_changes'] as $k => $v) { |
|
717 | + $log_changes[] = array( |
|
691 | 718 | 'action' => $k, |
692 | 719 | 'log_type' => 'user', |
693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
695 | 722 | 'member_affected' => $memID, |
696 | 723 | )), |
697 | 724 | ); |
725 | + } |
|
698 | 726 | |
699 | 727 | logActions($log_changes); |
700 | 728 | } |
701 | 729 | |
702 | 730 | // Have we got any post save functions to execute? |
703 | - if (!empty($context['profile_execute_on_save'])) |
|
704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
731 | + if (!empty($context['profile_execute_on_save'])) { |
|
732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
705 | 733 | $saveFunc(); |
734 | + } |
|
706 | 735 | |
707 | 736 | // Let them know it worked! |
708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
716 | 745 | if (!empty($post_errors)) |
717 | 746 | { |
718 | 747 | // Set all the errors so the template knows what went wrong. |
719 | - foreach ($post_errors as $error_type) |
|
720 | - $context['modify_error'][$error_type] = true; |
|
748 | + foreach ($post_errors as $error_type) { |
|
749 | + $context['modify_error'][$error_type] = true; |
|
750 | + } |
|
721 | 751 | } |
722 | 752 | // If it's you then we should redirect upon save. |
723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
725 | - elseif (!empty($force_redirect)) |
|
726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
755 | + } elseif (!empty($force_redirect)) { |
|
756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
757 | + } |
|
727 | 758 | |
728 | 759 | |
729 | 760 | // Get the right callable. |
730 | 761 | $call = call_helper($profile_include_data['function'], true); |
731 | 762 | |
732 | 763 | // Is it valid? |
733 | - if (!empty($call)) |
|
734 | - call_user_func($call, $memID); |
|
764 | + if (!empty($call)) { |
|
765 | + call_user_func($call, $memID); |
|
766 | + } |
|
735 | 767 | |
736 | 768 | // Set the page title if it's not already set... |
737 | - if (!isset($context['page_title'])) |
|
738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
739 | -} |
|
769 | + if (!isset($context['page_title'])) { |
|
770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
771 | + } |
|
772 | + } |
|
740 | 773 | |
741 | 774 | /** |
742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
860 | 893 | { |
861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
862 | - if ($memID == $user_info['id']) |
|
863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
864 | - else |
|
865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
895 | + if ($memID == $user_info['id']) { |
|
896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
897 | + } else { |
|
898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
899 | + } |
|
866 | 900 | } |
867 | 901 | |
868 | - if ($area == 'register') |
|
869 | - $where .= ' AND show_reg != 0'; |
|
870 | - elseif ($area != 'summary') |
|
871 | - $where .= ' AND show_profile = {string:area}'; |
|
902 | + if ($area == 'register') { |
|
903 | + $where .= ' AND show_reg != 0'; |
|
904 | + } elseif ($area != 'summary') { |
|
905 | + $where .= ' AND show_profile = {string:area}'; |
|
906 | + } |
|
872 | 907 | |
873 | 908 | // Load all the relevant fields - and data. |
874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -894,13 +929,15 @@ discard block |
||
894 | 929 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
895 | 930 | { |
896 | 931 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
897 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
898 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
932 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
933 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
934 | + } |
|
899 | 935 | } |
900 | 936 | |
901 | 937 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
902 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') |
|
903 | - continue; |
|
938 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') { |
|
939 | + continue; |
|
940 | + } |
|
904 | 941 | |
905 | 942 | // HTML for the input form. |
906 | 943 | $output_html = $value; |
@@ -909,8 +946,7 @@ discard block |
||
909 | 946 | $true = (!$exists && $row['default_value']) || $value; |
910 | 947 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
911 | 948 | $output_html = $true ? $txt['yes'] : $txt['no']; |
912 | - } |
|
913 | - elseif ($row['field_type'] == 'select') |
|
949 | + } elseif ($row['field_type'] == 'select') |
|
914 | 950 | { |
915 | 951 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
916 | 952 | $options = explode(',', $row['field_options']); |
@@ -918,13 +954,13 @@ discard block |
||
918 | 954 | { |
919 | 955 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
920 | 956 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
921 | - if ($true) |
|
922 | - $output_html = $v; |
|
957 | + if ($true) { |
|
958 | + $output_html = $v; |
|
959 | + } |
|
923 | 960 | } |
924 | 961 | |
925 | 962 | $input_html .= '</select>'; |
926 | - } |
|
927 | - elseif ($row['field_type'] == 'radio') |
|
963 | + } elseif ($row['field_type'] == 'radio') |
|
928 | 964 | { |
929 | 965 | $input_html = '<fieldset>'; |
930 | 966 | $options = explode(',', $row['field_options']); |
@@ -932,36 +968,37 @@ discard block |
||
932 | 968 | { |
933 | 969 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
934 | 970 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
935 | - if ($true) |
|
936 | - $output_html = $v; |
|
971 | + if ($true) { |
|
972 | + $output_html = $v; |
|
973 | + } |
|
937 | 974 | } |
938 | 975 | $input_html .= '</fieldset>'; |
939 | - } |
|
940 | - elseif ($row['field_type'] == 'text') |
|
976 | + } elseif ($row['field_type'] == 'text') |
|
941 | 977 | { |
942 | 978 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
943 | - } |
|
944 | - else |
|
979 | + } else |
|
945 | 980 | { |
946 | 981 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
947 | 982 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>'; |
948 | 983 | } |
949 | 984 | |
950 | 985 | // Parse BBCode |
951 | - if ($row['bbc']) |
|
952 | - $output_html = parse_bbc($output_html); |
|
953 | - elseif ($row['field_type'] == 'textarea') |
|
954 | - // Allow for newlines at least |
|
986 | + if ($row['bbc']) { |
|
987 | + $output_html = parse_bbc($output_html); |
|
988 | + } elseif ($row['field_type'] == 'textarea') { |
|
989 | + // Allow for newlines at least |
|
955 | 990 | $output_html = strtr($output_html, array("\n" => '<br>')); |
991 | + } |
|
956 | 992 | |
957 | 993 | // Enclosing the user input within some other text? |
958 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
959 | - $output_html = strtr($row['enclose'], array( |
|
994 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
995 | + $output_html = strtr($row['enclose'], array( |
|
960 | 996 | '{SCRIPTURL}' => $scripturl, |
961 | 997 | '{IMAGES_URL}' => $settings['images_url'], |
962 | 998 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
963 | 999 | '{INPUT}' => un_htmlspecialchars($output_html), |
964 | 1000 | )); |
1001 | + } |
|
965 | 1002 | |
966 | 1003 | $context['custom_fields'][] = array( |
967 | 1004 | 'name' => $row['field_name'], |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | )); |
75 | 77 | |
76 | 78 | // Old school or no school? |
77 | - if ($request) |
|
78 | - return $request; |
|
79 | + if ($request) { |
|
80 | + return $request; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
99 | 102 | foreach ($create as $k => $l) |
100 | 103 | { |
101 | 104 | // Get the name of the auto_increment column. |
102 | - if (strpos($l, 'auto_increment')) |
|
103 | - $auto_inc = trim($l); |
|
105 | + if (strpos($l, 'auto_increment')) { |
|
106 | + $auto_inc = trim($l); |
|
107 | + } |
|
104 | 108 | |
105 | 109 | // For the engine type, see if we can work out what it is. |
106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
108 | 112 | // Extract the engine type. |
109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
110 | 114 | |
111 | - if (!empty($match[1])) |
|
112 | - $engine = $match[1]; |
|
115 | + if (!empty($match[1])) { |
|
116 | + $engine = $match[1]; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!empty($match[2])) |
|
115 | - $engine = $match[2]; |
|
119 | + if (!empty($match[2])) { |
|
120 | + $engine = $match[2]; |
|
121 | + } |
|
116 | 122 | |
117 | - if (!empty($match[5])) |
|
118 | - $charset = $match[5]; |
|
123 | + if (!empty($match[5])) { |
|
124 | + $charset = $match[5]; |
|
125 | + } |
|
119 | 126 | |
120 | - if (!empty($match[7])) |
|
121 | - $collate = $match[7]; |
|
127 | + if (!empty($match[7])) { |
|
128 | + $collate = $match[7]; |
|
129 | + } |
|
122 | 130 | } |
123 | 131 | |
124 | 132 | // Skip everything but keys... |
125 | - if (strpos($l, 'KEY') === false) |
|
126 | - unset($create[$k]); |
|
133 | + if (strpos($l, 'KEY') === false) { |
|
134 | + unset($create[$k]); |
|
135 | + } |
|
127 | 136 | } |
128 | 137 | |
129 | - if (!empty($create)) |
|
130 | - $create = '( |
|
138 | + if (!empty($create)) { |
|
139 | + $create = '( |
|
131 | 140 | ' . implode(' |
132 | 141 | ', $create) . ')'; |
133 | - else |
|
134 | - $create = ''; |
|
142 | + } else { |
|
143 | + $create = ''; |
|
144 | + } |
|
135 | 145 | |
136 | 146 | $request = $smcFunc['db_query']('', ' |
137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
150 | 160 | |
151 | 161 | if ($auto_inc != '') |
152 | 162 | { |
153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | $smcFunc['db_query']('', ' |
157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
195 | 206 | 'table' => $table, |
196 | 207 | ) |
197 | 208 | ); |
198 | - if (!$request) |
|
199 | - return -1; |
|
209 | + if (!$request) { |
|
210 | + return -1; |
|
211 | + } |
|
200 | 212 | |
201 | 213 | // How much left? |
202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
239 | 251 | ) |
240 | 252 | ); |
241 | 253 | $tables = array(); |
242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
243 | - $tables[] = $row[0]; |
|
254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
255 | + $tables[] = $row[0]; |
|
256 | + } |
|
244 | 257 | $smcFunc['db_free_result']($request); |
245 | 258 | |
246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
285 | 298 | { |
286 | 299 | // Make a special case of auto-timestamp. |
287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
302 | + } |
|
289 | 303 | // Text shouldn't have a default. |
290 | 304 | elseif ($row['Default'] !== null) |
291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
320 | 334 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
321 | 335 | |
322 | 336 | // Is this the first column in the index? |
323 | - if (empty($indexes[$row['Key_name']])) |
|
324 | - $indexes[$row['Key_name']] = array(); |
|
337 | + if (empty($indexes[$row['Key_name']])) { |
|
338 | + $indexes[$row['Key_name']] = array(); |
|
339 | + } |
|
325 | 340 | |
326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
327 | - if (!empty($row['Sub_part'])) |
|
328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
329 | - else |
|
330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
342 | + if (!empty($row['Sub_part'])) { |
|
343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
344 | + } else { |
|
345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
346 | + } |
|
331 | 347 | } |
332 | 348 | $smcFunc['db_free_result']($result); |
333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
365 | 381 | { |
366 | 382 | static $ver; |
367 | 383 | |
368 | - if (!empty($ver)) |
|
369 | - return $ver; |
|
384 | + if (!empty($ver)) { |
|
385 | + return $ver; |
|
386 | + } |
|
370 | 387 | |
371 | 388 | global $smcFunc; |
372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
391 | 408 | global $smcFunc; |
392 | 409 | static $db_type; |
393 | 410 | |
394 | - if (!empty($db_type)) |
|
395 | - return $db_type; |
|
411 | + if (!empty($db_type)) { |
|
412 | + return $db_type; |
|
413 | + } |
|
396 | 414 | |
397 | 415 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
398 | 416 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -401,13 +419,15 @@ discard block |
||
401 | 419 | // Skip these if we don't have a comment. |
402 | 420 | if (!empty($comment)) |
403 | 421 | { |
404 | - if (stripos($comment, 'percona') !== false) |
|
405 | - return 'Percona'; |
|
406 | - if (stripos($comment, 'mariadb') !== false) |
|
407 | - return 'MariaDB'; |
|
422 | + if (stripos($comment, 'percona') !== false) { |
|
423 | + return 'Percona'; |
|
424 | + } |
|
425 | + if (stripos($comment, 'mariadb') !== false) { |
|
426 | + return 'MariaDB'; |
|
427 | + } |
|
428 | + } else { |
|
429 | + return 'fail'; |
|
408 | 430 | } |
409 | - else |
|
410 | - return 'fail'; |
|
411 | 431 | |
412 | 432 | return 'MySQL'; |
413 | 433 | } |
@@ -27,9 +27,10 @@ discard block |
||
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
29 | 29 | |
30 | - if (!isset($context['old_search'])) |
|
31 | - echo ' |
|
30 | + if (!isset($context['old_search'])) { |
|
31 | + echo ' |
|
32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
33 | + } |
|
33 | 34 | echo ' |
34 | 35 | </h3> |
35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
44 | 45 | foreach ($context['columns'] as $key => $column) |
45 | 46 | { |
46 | 47 | // @TODO maybe find something nicer? |
47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
48 | - continue; |
|
48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
49 | + continue; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // This is a selected column, so underline it or some such. |
51 | - if ($column['selected']) |
|
52 | - echo ' |
|
53 | + if ($column['selected']) { |
|
54 | + echo ' |
|
53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
57 | + } |
|
55 | 58 | |
56 | 59 | // This is just some column... show the link and be done with it. |
57 | - else |
|
58 | - echo ' |
|
60 | + else { |
|
61 | + echo ' |
|
59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
60 | 63 | ', $column['link'], '</th>'; |
64 | + } |
|
61 | 65 | } |
62 | 66 | |
63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
77 | 81 | </td> |
78 | 82 | <td class="lefttext">', $member['link'], '</td>'; |
79 | 83 | |
80 | - if (!isset($context['disabled_fields']['website'])) |
|
81 | - echo ' |
|
84 | + if (!isset($context['disabled_fields']['website'])) { |
|
85 | + echo ' |
|
82 | 86 | <td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
87 | + } |
|
83 | 88 | |
84 | 89 | // Group and date. |
85 | 90 | echo ' |
@@ -92,32 +97,35 @@ discard block |
||
92 | 97 | <td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td> |
93 | 98 | <td class="centertext statsbar" style="width: 120px">'; |
94 | 99 | |
95 | - if (!empty($member['post_percent'])) |
|
96 | - echo ' |
|
100 | + if (!empty($member['post_percent'])) { |
|
101 | + echo ' |
|
97 | 102 | <div class="bar" style="width: ', $member['post_percent'] + 4, 'px;"> |
98 | 103 | <div style="width: ', $member['post_percent'], 'px;"></div> |
99 | 104 | </div>'; |
105 | + } |
|
100 | 106 | |
101 | 107 | echo ' |
102 | 108 | </td>'; |
103 | 109 | } |
104 | 110 | |
105 | 111 | // Show custom fields marked to be shown here |
106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
108 | 114 | echo ' |
109 | 115 | <td class="righttext">', $member['options'][$key], '</td>'; |
116 | + } |
|
110 | 117 | |
111 | 118 | echo ' |
112 | 119 | </tr>'; |
113 | 120 | } |
114 | 121 | } |
115 | 122 | // No members? |
116 | - else |
|
117 | - echo ' |
|
123 | + else { |
|
124 | + echo ' |
|
118 | 125 | <tr> |
119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
120 | 127 | </tr>'; |
128 | + } |
|
121 | 129 | |
122 | 130 | echo ' |
123 | 131 | </tbody> |
@@ -130,11 +138,12 @@ discard block |
||
130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
131 | 139 | |
132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
133 | - if (isset($context['old_search'])) |
|
134 | - echo ' |
|
141 | + if (isset($context['old_search'])) { |
|
142 | + echo ' |
|
135 | 143 | <div class="buttonlist floatright"> |
136 | 144 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a> |
137 | 145 | </div>'; |
146 | + } |
|
138 | 147 | echo ' |
139 | 148 | </div> |
140 | 149 | </div><!-- #memberlist -->'; |
@@ -174,12 +183,13 @@ discard block |
||
174 | 183 | <dd> |
175 | 184 | <ul>'; |
176 | 185 | |
177 | - foreach ($context['search_fields'] as $id => $title) |
|
178 | - echo ' |
|
186 | + foreach ($context['search_fields'] as $id => $title) { |
|
187 | + echo ' |
|
179 | 188 | <li> |
180 | 189 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
181 | 190 | <label for="fields-', $id, '">', $title, '</label> |
182 | 191 | </li>'; |
192 | + } |
|
183 | 193 | |
184 | 194 | echo ' |
185 | 195 | </ul> |
@@ -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'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -98,23 +102,26 @@ discard block |
||
98 | 102 | if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest']) |
99 | 103 | { |
100 | 104 | // First check for 2.1 json-format cookie in $_COOKIE |
101 | - if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) |
|
102 | - list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
105 | + if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) { |
|
106 | + list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
107 | + } |
|
103 | 108 | |
104 | 109 | // Try checking for 2.1 json-format cookie in $_SESSION |
105 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) |
|
106 | - list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
110 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) { |
|
111 | + list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
112 | + } |
|
107 | 113 | |
108 | 114 | // Next, try checking for 2.0 serialized string cookie in $_COOKIE |
109 | - 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) |
|
110 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
115 | + 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) { |
|
116 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION |
113 | - 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) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
115 | - |
|
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
120 | + 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) { |
|
121 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
122 | + } else { |
|
123 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 127 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +134,11 @@ discard block |
||
127 | 134 | list ($tfamember, $tfasecret, $exp, $domain, $path, $preserve) = $tfadata; |
128 | 135 | |
129 | 136 | // If we're preserving the cookie, reset it with updated salt |
130 | - if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) |
|
131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
132 | - else |
|
133 | - setTFACookie(-3600, 0, ''); |
|
137 | + if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) { |
|
138 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
139 | + } else { |
|
140 | + setTFACookie(-3600, 0, ''); |
|
141 | + } |
|
134 | 142 | } |
135 | 143 | |
136 | 144 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +149,20 @@ discard block |
||
141 | 149 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
142 | 150 | { |
143 | 151 | // Strike! You're outta there! |
144 | - if ($_GET['member'] != $user_info['id']) |
|
145 | - fatal_lang_error('login_cookie_error', false); |
|
152 | + if ($_GET['member'] != $user_info['id']) { |
|
153 | + fatal_lang_error('login_cookie_error', false); |
|
154 | + } |
|
146 | 155 | |
147 | 156 | $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'])))); |
148 | 157 | |
149 | 158 | // Some whitelisting for login_url... |
150 | - if (empty($_SESSION['login_url'])) |
|
151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
159 | + if (empty($_SESSION['login_url'])) { |
|
160 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
161 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
153 | 162 | { |
154 | 163 | unset ($_SESSION['login_url']); |
155 | 164 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
156 | - } |
|
157 | - else |
|
165 | + } else |
|
158 | 166 | { |
159 | 167 | // Best not to clutter the session data too much... |
160 | 168 | $temp = $_SESSION['login_url']; |
@@ -165,8 +173,9 @@ discard block |
||
165 | 173 | } |
166 | 174 | |
167 | 175 | // Beyond this point you are assumed to be a guest trying to login. |
168 | - if (!$user_info['is_guest']) |
|
169 | - redirectexit(); |
|
176 | + if (!$user_info['is_guest']) { |
|
177 | + redirectexit(); |
|
178 | + } |
|
170 | 179 | |
171 | 180 | // Are you guessing with a script? |
172 | 181 | checkSession(); |
@@ -174,18 +183,21 @@ discard block |
||
174 | 183 | spamProtection('login'); |
175 | 184 | |
176 | 185 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
177 | - 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)) |
|
178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
186 | + 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)) { |
|
187 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
188 | + } |
|
179 | 189 | |
180 | 190 | // Been guessing a lot, haven't we? |
181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
191 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
192 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
193 | + } |
|
183 | 194 | |
184 | 195 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
186 | - $modSettings['cookieTime'] = 3153600; |
|
187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
196 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
197 | + $modSettings['cookieTime'] = 3153600; |
|
198 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
199 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
200 | + } |
|
189 | 201 | |
190 | 202 | loadLanguage('Login'); |
191 | 203 | // Load the template stuff. |
@@ -305,8 +317,9 @@ discard block |
||
305 | 317 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
306 | 318 | |
307 | 319 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
320 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
321 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
322 | + } |
|
310 | 323 | |
311 | 324 | // phpBB3 users new hashing. We now support it as well ;). |
312 | 325 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +339,29 @@ discard block |
||
326 | 339 | // Some common md5 ones. |
327 | 340 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
328 | 341 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
329 | - } |
|
330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
342 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
331 | 343 | { |
332 | 344 | // Maybe they are using a hash from before the password fix. |
333 | 345 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
334 | 346 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
335 | 347 | |
336 | 348 | // BurningBoard3 style of hashing. |
337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
349 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
350 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
351 | + } |
|
339 | 352 | |
340 | 353 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
341 | 354 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
342 | 355 | { |
343 | 356 | // Try iconv first, for no particular reason. |
344 | - if (function_exists('iconv')) |
|
345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
357 | + if (function_exists('iconv')) { |
|
358 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
359 | + } |
|
346 | 360 | |
347 | 361 | // Say it aint so, iconv failed! |
348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
349 | - $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']))); |
|
362 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
363 | + $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']))); |
|
364 | + } |
|
350 | 365 | } |
351 | 366 | } |
352 | 367 | |
@@ -376,8 +391,9 @@ discard block |
||
376 | 391 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
377 | 392 | |
378 | 393 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
380 | - redirectexit('action=reminder'); |
|
394 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
395 | + redirectexit('action=reminder'); |
|
396 | + } |
|
381 | 397 | // We'll give you another chance... |
382 | 398 | else |
383 | 399 | { |
@@ -388,8 +404,7 @@ discard block |
||
388 | 404 | return; |
389 | 405 | } |
390 | 406 | } |
391 | - } |
|
392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
407 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
393 | 408 | { |
394 | 409 | // Let's be sure they weren't a little hacker. |
395 | 410 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +421,9 @@ discard block |
||
406 | 421 | } |
407 | 422 | |
408 | 423 | // Check their activation status. |
409 | - if (!checkActivation()) |
|
410 | - return; |
|
424 | + if (!checkActivation()) { |
|
425 | + return; |
|
426 | + } |
|
411 | 427 | |
412 | 428 | DoLogin(); |
413 | 429 | } |
@@ -419,8 +435,9 @@ discard block |
||
419 | 435 | { |
420 | 436 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
421 | 437 | |
422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
423 | - fatal_lang_error('no_access', false); |
|
438 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
439 | + fatal_lang_error('no_access', false); |
|
440 | + } |
|
424 | 441 | |
425 | 442 | loadLanguage('Profile'); |
426 | 443 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +445,9 @@ discard block |
||
428 | 445 | $member = $context['tfa_member']; |
429 | 446 | |
430 | 447 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
431 | - if (time() - $member['last_login'] < 120) |
|
432 | - fatal_lang_error('tfa_wait', false); |
|
448 | + if (time() - $member['last_login'] < 120) { |
|
449 | + fatal_lang_error('tfa_wait', false); |
|
450 | + } |
|
433 | 451 | |
434 | 452 | $totp = new \TOTP\Auth($member['tfa_secret']); |
435 | 453 | $totp->setRange(1); |
@@ -443,8 +461,9 @@ discard block |
||
443 | 461 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
444 | 462 | { |
445 | 463 | // Check to ensure we're forcing SSL for authentication |
446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
447 | - fatal_lang_error('login_ssl_required'); |
|
464 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
465 | + fatal_lang_error('login_ssl_required'); |
|
466 | + } |
|
448 | 467 | |
449 | 468 | $code = $_POST['tfa_code']; |
450 | 469 | |
@@ -454,20 +473,19 @@ discard block |
||
454 | 473 | |
455 | 474 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
456 | 475 | redirectexit(); |
457 | - } |
|
458 | - else |
|
476 | + } else |
|
459 | 477 | { |
460 | 478 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
461 | 479 | |
462 | 480 | $context['tfa_error'] = true; |
463 | 481 | $context['tfa_value'] = $_POST['tfa_code']; |
464 | 482 | } |
465 | - } |
|
466 | - elseif (!empty($_POST['tfa_backup'])) |
|
483 | + } elseif (!empty($_POST['tfa_backup'])) |
|
467 | 484 | { |
468 | 485 | // Check to ensure we're forcing SSL for authentication |
469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
470 | - fatal_lang_error('login_ssl_required'); |
|
486 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
487 | + fatal_lang_error('login_ssl_required'); |
|
488 | + } |
|
471 | 489 | |
472 | 490 | $backup = $_POST['tfa_backup']; |
473 | 491 | |
@@ -481,8 +499,7 @@ discard block |
||
481 | 499 | )); |
482 | 500 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
483 | 501 | redirectexit('action=profile;area=tfasetup;backup'); |
484 | - } |
|
485 | - else |
|
502 | + } else |
|
486 | 503 | { |
487 | 504 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
488 | 505 | |
@@ -505,8 +522,9 @@ discard block |
||
505 | 522 | { |
506 | 523 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
507 | 524 | |
508 | - if (!isset($context['login_errors'])) |
|
509 | - $context['login_errors'] = array(); |
|
525 | + if (!isset($context['login_errors'])) { |
|
526 | + $context['login_errors'] = array(); |
|
527 | + } |
|
510 | 528 | |
511 | 529 | // What is the true activation status of this account? |
512 | 530 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +536,9 @@ discard block |
||
518 | 536 | return false; |
519 | 537 | } |
520 | 538 | // Awaiting approval still? |
521 | - elseif ($activation_status == 3) |
|
522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
539 | + elseif ($activation_status == 3) { |
|
540 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
541 | + } |
|
523 | 542 | // Awaiting deletion, changed their mind? |
524 | 543 | elseif ($activation_status == 4) |
525 | 544 | { |
@@ -527,8 +546,7 @@ discard block |
||
527 | 546 | { |
528 | 547 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
529 | 548 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
530 | - } |
|
531 | - else |
|
549 | + } else |
|
532 | 550 | { |
533 | 551 | $context['disable_login_hashing'] = true; |
534 | 552 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +586,9 @@ discard block |
||
568 | 586 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
569 | 587 | |
570 | 588 | // Reset the login threshold. |
571 | - if (isset($_SESSION['failed_login'])) |
|
572 | - unset($_SESSION['failed_login']); |
|
589 | + if (isset($_SESSION['failed_login'])) { |
|
590 | + unset($_SESSION['failed_login']); |
|
591 | + } |
|
573 | 592 | |
574 | 593 | $user_info['is_guest'] = false; |
575 | 594 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +610,18 @@ discard block |
||
591 | 610 | 'id_member' => $user_info['id'], |
592 | 611 | ) |
593 | 612 | ); |
594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
595 | - $_SESSION['first_login'] = true; |
|
596 | - else |
|
597 | - unset($_SESSION['first_login']); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
614 | + $_SESSION['first_login'] = true; |
|
615 | + } else { |
|
616 | + unset($_SESSION['first_login']); |
|
617 | + } |
|
598 | 618 | $smcFunc['db_free_result']($request); |
599 | 619 | |
600 | 620 | // You've logged in, haven't you? |
601 | 621 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
602 | - if (empty($user_settings['tfa_secret'])) |
|
603 | - $update['last_login'] = time(); |
|
622 | + if (empty($user_settings['tfa_secret'])) { |
|
623 | + $update['last_login'] = time(); |
|
624 | + } |
|
604 | 625 | updateMemberData($user_info['id'], $update); |
605 | 626 | |
606 | 627 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +635,8 @@ discard block |
||
614 | 635 | $_SESSION['log_time'] = 0; |
615 | 636 | |
616 | 637 | // Log this entry, only if we have it enabled. |
617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
618 | - $smcFunc['db_insert']('insert', |
|
638 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
639 | + $smcFunc['db_insert']('insert', |
|
619 | 640 | '{db_prefix}member_logins', |
620 | 641 | array( |
621 | 642 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +648,15 @@ discard block |
||
627 | 648 | 'id_member', 'time' |
628 | 649 | ) |
629 | 650 | ); |
651 | + } |
|
630 | 652 | |
631 | 653 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
634 | - else |
|
635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
636 | -} |
|
654 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
655 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
656 | + } else { |
|
657 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
658 | + } |
|
659 | + } |
|
637 | 660 | |
638 | 661 | /** |
639 | 662 | * Logs the current user out of their account. |
@@ -649,13 +672,15 @@ discard block |
||
649 | 672 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
650 | 673 | |
651 | 674 | // Make sure they aren't being auto-logged out. |
652 | - if (!$internal) |
|
653 | - checkSession('get'); |
|
675 | + if (!$internal) { |
|
676 | + checkSession('get'); |
|
677 | + } |
|
654 | 678 | |
655 | 679 | require_once($sourcedir . '/Subs-Auth.php'); |
656 | 680 | |
657 | - if (isset($_SESSION['pack_ftp'])) |
|
658 | - $_SESSION['pack_ftp'] = null; |
|
681 | + if (isset($_SESSION['pack_ftp'])) { |
|
682 | + $_SESSION['pack_ftp'] = null; |
|
683 | + } |
|
659 | 684 | |
660 | 685 | // It won't be first login anymore. |
661 | 686 | unset($_SESSION['first_login']); |
@@ -683,8 +708,9 @@ discard block |
||
683 | 708 | |
684 | 709 | // And some other housekeeping while we're at it. |
685 | 710 | $salt = substr(md5(mt_rand()), 0, 4); |
686 | - if (!empty($user_info['id'])) |
|
687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
711 | + if (!empty($user_info['id'])) { |
|
712 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
713 | + } |
|
688 | 714 | |
689 | 715 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
690 | 716 | { |
@@ -693,10 +719,11 @@ discard block |
||
693 | 719 | list ($tfamember, $tfasecret, $exp, $domain, $path, $preserve) = $tfadata; |
694 | 720 | |
695 | 721 | // If we're preserving the cookie, reset it with updated salt |
696 | - if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) |
|
697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
698 | - else |
|
699 | - setTFACookie(-3600, 0, ''); |
|
722 | + if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) { |
|
723 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
724 | + } else { |
|
725 | + setTFACookie(-3600, 0, ''); |
|
726 | + } |
|
700 | 727 | } |
701 | 728 | |
702 | 729 | session_destroy(); |
@@ -704,14 +731,13 @@ discard block |
||
704 | 731 | // Off to the merry board index we go! |
705 | 732 | if ($redirect) |
706 | 733 | { |
707 | - if (empty($_SESSION['logout_url'])) |
|
708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
734 | + if (empty($_SESSION['logout_url'])) { |
|
735 | + redirectexit('', $context['server']['needs_login_fix']); |
|
736 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
710 | 737 | { |
711 | 738 | unset ($_SESSION['logout_url']); |
712 | 739 | redirectexit(); |
713 | - } |
|
714 | - else |
|
740 | + } else |
|
715 | 741 | { |
716 | 742 | $temp = $_SESSION['logout_url']; |
717 | 743 | unset($_SESSION['logout_url']); |
@@ -744,8 +770,9 @@ discard block |
||
744 | 770 | function phpBB3_password_check($passwd, $passwd_hash) |
745 | 771 | { |
746 | 772 | // Too long or too short? |
747 | - if (strlen($passwd_hash) != 34) |
|
748 | - return; |
|
773 | + if (strlen($passwd_hash) != 34) { |
|
774 | + return; |
|
775 | + } |
|
749 | 776 | |
750 | 777 | // Range of characters allowed. |
751 | 778 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +783,9 @@ discard block |
||
756 | 783 | $salt = substr($passwd_hash, 4, 8); |
757 | 784 | |
758 | 785 | $hash = md5($salt . $passwd, true); |
759 | - for (; $count != 0; --$count) |
|
760 | - $hash = md5($hash . $passwd, true); |
|
786 | + for (; $count != 0; --$count) { |
|
787 | + $hash = md5($hash . $passwd, true); |
|
788 | + } |
|
761 | 789 | |
762 | 790 | $output = substr($passwd_hash, 0, 12); |
763 | 791 | $i = 0; |
@@ -766,21 +794,25 @@ discard block |
||
766 | 794 | $value = ord($hash[$i++]); |
767 | 795 | $output .= $range[$value & 0x3f]; |
768 | 796 | |
769 | - if ($i < 16) |
|
770 | - $value |= ord($hash[$i]) << 8; |
|
797 | + if ($i < 16) { |
|
798 | + $value |= ord($hash[$i]) << 8; |
|
799 | + } |
|
771 | 800 | |
772 | 801 | $output .= $range[($value >> 6) & 0x3f]; |
773 | 802 | |
774 | - if ($i++ >= 16) |
|
775 | - break; |
|
803 | + if ($i++ >= 16) { |
|
804 | + break; |
|
805 | + } |
|
776 | 806 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 16; |
|
807 | + if ($i < 16) { |
|
808 | + $value |= ord($hash[$i]) << 16; |
|
809 | + } |
|
779 | 810 | |
780 | 811 | $output .= $range[($value >> 12) & 0x3f]; |
781 | 812 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
813 | + if ($i++ >= 16) { |
|
814 | + break; |
|
815 | + } |
|
784 | 816 | |
785 | 817 | $output .= $range[($value >> 18) & 0x3f]; |
786 | 818 | } |
@@ -812,8 +844,9 @@ discard block |
||
812 | 844 | require_once($sourcedir . '/Subs-Auth.php'); |
813 | 845 | setLoginCookie(-3600, 0); |
814 | 846 | |
815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
816 | - unset($_SESSION['login_' . $cookiename]); |
|
847 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
848 | + unset($_SESSION['login_' . $cookiename]); |
|
849 | + } |
|
817 | 850 | } |
818 | 851 | |
819 | 852 | // We need a member! |
@@ -827,8 +860,9 @@ discard block |
||
827 | 860 | } |
828 | 861 | |
829 | 862 | // Right, have we got a flood value? |
830 | - if ($password_flood_value !== false) |
|
831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
863 | + if ($password_flood_value !== false) { |
|
864 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
865 | + } |
|
832 | 866 | |
833 | 867 | // Timestamp or number of tries invalid? |
834 | 868 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +878,17 @@ discard block |
||
844 | 878 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
845 | 879 | |
846 | 880 | // They are trying too fast, make them wait longer |
847 | - if ($time_stamp < time() - 10) |
|
848 | - $time_stamp = time(); |
|
881 | + if ($time_stamp < time() - 10) { |
|
882 | + $time_stamp = time(); |
|
883 | + } |
|
849 | 884 | } |
850 | 885 | |
851 | 886 | $number_tries++; |
852 | 887 | |
853 | 888 | // Broken the law? |
854 | - if ($number_tries > 5) |
|
855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
889 | + if ($number_tries > 5) { |
|
890 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
891 | + } |
|
856 | 892 | |
857 | 893 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
858 | 894 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -1697,8 +1697,7 @@ discard block |
||
1697 | 1697 | updateStats('topic'); |
1698 | 1698 | |
1699 | 1699 | // This function is needed to do the updateStats('subject') call. |
1700 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
1701 | - function($string){ |
|
1700 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
1702 | 1701 | global $sourcedir; |
1703 | 1702 | if (function_exists('mb_strtolower')) |
1704 | 1703 | return mb_strtolower($string, 'UTF-8'); |
@@ -1767,7 +1766,7 @@ discard block |
||
1767 | 1766 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
1768 | 1767 | { |
1769 | 1768 | // Set the ten lines to nothing. |
1770 | - for ($j=0; $j < 10; $j++) |
|
1769 | + for ($j = 0; $j < 10; $j++) |
|
1771 | 1770 | $settingsArray[$i++] = ''; |
1772 | 1771 | |
1773 | 1772 | continue; |
@@ -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 | } |
@@ -313,10 +325,11 @@ discard block |
||
313 | 325 | } |
314 | 326 | |
315 | 327 | // Override the language file? |
316 | - if (isset($_GET['lang_file'])) |
|
317 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
318 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
319 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_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']; |
|
332 | + } |
|
320 | 333 | |
321 | 334 | // Make sure it exists, if it doesn't reset it. |
322 | 335 | 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'])) |
@@ -325,8 +338,9 @@ discard block |
||
325 | 338 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
326 | 339 | |
327 | 340 | // If we have english and some other language, use the other language. We Americans hate english :P. |
328 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
329 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
341 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
342 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
343 | + } |
|
330 | 344 | } |
331 | 345 | |
332 | 346 | // And now include the actual language file itself. |
@@ -343,15 +357,18 @@ discard block |
||
343 | 357 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
344 | 358 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
345 | 359 | |
346 | - if (empty($sourcedir)) |
|
347 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
360 | + if (empty($sourcedir)) { |
|
361 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
362 | + } |
|
348 | 363 | |
349 | 364 | // Need this to check whether we need the database password. |
350 | 365 | require(dirname(__FILE__) . '/Settings.php'); |
351 | - if (!defined('SMF')) |
|
352 | - define('SMF', 1); |
|
353 | - if (empty($smcFunc)) |
|
354 | - $smcFunc = array(); |
|
366 | + if (!defined('SMF')) { |
|
367 | + define('SMF', 1); |
|
368 | + } |
|
369 | + if (empty($smcFunc)) { |
|
370 | + $smcFunc = array(); |
|
371 | + } |
|
355 | 372 | |
356 | 373 | $modSettings['disableQueryCheck'] = true; |
357 | 374 | |
@@ -359,8 +376,9 @@ discard block |
||
359 | 376 | if (!$db_connection) |
360 | 377 | { |
361 | 378 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
362 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
363 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
379 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
380 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
381 | + } |
|
364 | 382 | |
365 | 383 | $db_options = array('persist' => $db_persist); |
366 | 384 | $port = ''; |
@@ -371,19 +389,20 @@ discard block |
||
371 | 389 | if ($db_type == 'mysql') |
372 | 390 | { |
373 | 391 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
374 | - } |
|
375 | - elseif ($db_type == 'postgresql') |
|
392 | + } elseif ($db_type == 'postgresql') |
|
376 | 393 | { |
377 | 394 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
378 | 395 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
379 | 396 | } |
380 | 397 | } |
381 | 398 | |
382 | - if (!empty($port)) |
|
383 | - $db_options['port'] = $port; |
|
399 | + if (!empty($port)) { |
|
400 | + $db_options['port'] = $port; |
|
401 | + } |
|
384 | 402 | |
385 | - if (!$db_connection) |
|
386 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
403 | + if (!$db_connection) { |
|
404 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
405 | + } |
|
387 | 406 | } |
388 | 407 | } |
389 | 408 | |
@@ -411,8 +430,9 @@ discard block |
||
411 | 430 | // @todo REMOVE THIS!! |
412 | 431 | else |
413 | 432 | { |
414 | - if (function_exists('doStep' . $_GET['step'])) |
|
415 | - call_user_func('doStep' . $_GET['step']); |
|
433 | + if (function_exists('doStep' . $_GET['step'])) { |
|
434 | + call_user_func('doStep' . $_GET['step']); |
|
435 | + } |
|
416 | 436 | } |
417 | 437 | // Show the footer. |
418 | 438 | template_install_below(); |
@@ -430,8 +450,9 @@ discard block |
||
430 | 450 | $incontext['sub_template'] = 'welcome_message'; |
431 | 451 | |
432 | 452 | // Done the submission? |
433 | - if (isset($_POST['contbutt'])) |
|
434 | - return true; |
|
453 | + if (isset($_POST['contbutt'])) { |
|
454 | + return true; |
|
455 | + } |
|
435 | 456 | |
436 | 457 | // See if we think they have already installed it? |
437 | 458 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -439,14 +460,17 @@ discard block |
||
439 | 460 | $probably_installed = 0; |
440 | 461 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
441 | 462 | { |
442 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
443 | - $probably_installed++; |
|
444 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
445 | - $probably_installed++; |
|
463 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
464 | + $probably_installed++; |
|
465 | + } |
|
466 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
467 | + $probably_installed++; |
|
468 | + } |
|
446 | 469 | } |
447 | 470 | |
448 | - if ($probably_installed == 2) |
|
449 | - $incontext['warning'] = $txt['error_already_installed']; |
|
471 | + if ($probably_installed == 2) { |
|
472 | + $incontext['warning'] = $txt['error_already_installed']; |
|
473 | + } |
|
450 | 474 | } |
451 | 475 | |
452 | 476 | // Is some database support even compiled in? |
@@ -461,45 +485,54 @@ discard block |
||
461 | 485 | $databases[$key]['supported'] = false; |
462 | 486 | $notFoundSQLFile = true; |
463 | 487 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
488 | + } else { |
|
489 | + $incontext['supported_databases'][] = $db; |
|
464 | 490 | } |
465 | - else |
|
466 | - $incontext['supported_databases'][] = $db; |
|
467 | 491 | } |
468 | 492 | } |
469 | 493 | |
470 | 494 | // Check the PHP version. |
471 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
472 | - $error = 'error_php_too_low'; |
|
495 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
496 | + $error = 'error_php_too_low'; |
|
497 | + } |
|
473 | 498 | // Make sure we have a supported database |
474 | - elseif (empty($incontext['supported_databases'])) |
|
475 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
499 | + elseif (empty($incontext['supported_databases'])) { |
|
500 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
501 | + } |
|
476 | 502 | // How about session support? Some crazy sysadmin remove it? |
477 | - elseif (!function_exists('session_start')) |
|
478 | - $error = 'error_session_missing'; |
|
503 | + elseif (!function_exists('session_start')) { |
|
504 | + $error = 'error_session_missing'; |
|
505 | + } |
|
479 | 506 | // Make sure they uploaded all the files. |
480 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
481 | - $error = 'error_missing_files'; |
|
507 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
508 | + $error = 'error_missing_files'; |
|
509 | + } |
|
482 | 510 | // Very simple check on the session.save_path for Windows. |
483 | 511 | // @todo Move this down later if they don't use database-driven sessions? |
484 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
485 | - $error = 'error_session_save_path'; |
|
512 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
513 | + $error = 'error_session_save_path'; |
|
514 | + } |
|
486 | 515 | |
487 | 516 | // Since each of the three messages would look the same, anyway... |
488 | - if (isset($error)) |
|
489 | - $incontext['error'] = $txt[$error]; |
|
517 | + if (isset($error)) { |
|
518 | + $incontext['error'] = $txt[$error]; |
|
519 | + } |
|
490 | 520 | |
491 | 521 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
492 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
493 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
522 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
523 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
524 | + } |
|
494 | 525 | |
495 | 526 | // Confirm mbstring is loaded... |
496 | - if (!extension_loaded('mbstring')) |
|
497 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
527 | + if (!extension_loaded('mbstring')) { |
|
528 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
529 | + } |
|
498 | 530 | |
499 | 531 | // Check for https stream support. |
500 | 532 | $supported_streams = stream_get_wrappers(); |
501 | - if (!in_array('https', $supported_streams)) |
|
502 | - $incontext['warning'] = $txt['install_no_https']; |
|
533 | + if (!in_array('https', $supported_streams)) { |
|
534 | + $incontext['warning'] = $txt['install_no_https']; |
|
535 | + } |
|
503 | 536 | |
504 | 537 | return false; |
505 | 538 | } |
@@ -524,12 +557,14 @@ discard block |
||
524 | 557 | 'Settings_bak.php', |
525 | 558 | ); |
526 | 559 | |
527 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
528 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
560 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
561 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
562 | + } |
|
529 | 563 | |
530 | 564 | // With mod_security installed, we could attempt to fix it with .htaccess. |
531 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
532 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
565 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
566 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
567 | + } |
|
533 | 568 | |
534 | 569 | $failed_files = array(); |
535 | 570 | |
@@ -541,20 +576,23 @@ discard block |
||
541 | 576 | foreach ($writable_files as $file) |
542 | 577 | { |
543 | 578 | // Some files won't exist, try to address up front |
544 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
545 | - @touch(dirname(__FILE__) . '/' . $file); |
|
579 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
580 | + @touch(dirname(__FILE__) . '/' . $file); |
|
581 | + } |
|
546 | 582 | // NOW do the writable check... |
547 | 583 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
548 | 584 | { |
549 | 585 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
550 | 586 | |
551 | 587 | // Well, 755 hopefully worked... if not, try 777. |
552 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
553 | - $failed_files[] = $file; |
|
588 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
589 | + $failed_files[] = $file; |
|
590 | + } |
|
554 | 591 | } |
555 | 592 | } |
556 | - foreach ($extra_files as $file) |
|
557 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
593 | + foreach ($extra_files as $file) { |
|
594 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
595 | + } |
|
558 | 596 | } |
559 | 597 | // Windows is trickier. Let's try opening for r+... |
560 | 598 | else |
@@ -564,30 +602,35 @@ discard block |
||
564 | 602 | foreach ($writable_files as $file) |
565 | 603 | { |
566 | 604 | // Folders can't be opened for write... but the index.php in them can ;) |
567 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
568 | - $file .= '/index.php'; |
|
605 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
606 | + $file .= '/index.php'; |
|
607 | + } |
|
569 | 608 | |
570 | 609 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
571 | 610 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
572 | 611 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
573 | 612 | |
574 | 613 | // Hmm, okay, try just for write in that case... |
575 | - if (!is_resource($fp)) |
|
576 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
614 | + if (!is_resource($fp)) { |
|
615 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
616 | + } |
|
577 | 617 | |
578 | - if (!is_resource($fp)) |
|
579 | - $failed_files[] = $file; |
|
618 | + if (!is_resource($fp)) { |
|
619 | + $failed_files[] = $file; |
|
620 | + } |
|
580 | 621 | |
581 | 622 | @fclose($fp); |
582 | 623 | } |
583 | - foreach ($extra_files as $file) |
|
584 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
624 | + foreach ($extra_files as $file) { |
|
625 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
626 | + } |
|
585 | 627 | } |
586 | 628 | |
587 | 629 | $failure = count($failed_files) >= 1; |
588 | 630 | |
589 | - if (!isset($_SERVER)) |
|
590 | - return !$failure; |
|
631 | + if (!isset($_SERVER)) { |
|
632 | + return !$failure; |
|
633 | + } |
|
591 | 634 | |
592 | 635 | // Put the list into context. |
593 | 636 | $incontext['failed_files'] = $failed_files; |
@@ -635,19 +678,23 @@ discard block |
||
635 | 678 | |
636 | 679 | if (!isset($ftp) || $ftp->error !== false) |
637 | 680 | { |
638 | - if (!isset($ftp)) |
|
639 | - $ftp = new ftp_connection(null); |
|
681 | + if (!isset($ftp)) { |
|
682 | + $ftp = new ftp_connection(null); |
|
683 | + } |
|
640 | 684 | // Save the error so we can mess with listing... |
641 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
642 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
685 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
686 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
687 | + } |
|
643 | 688 | |
644 | 689 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
645 | 690 | |
646 | - if (empty($_POST['ftp_path']) && $found_path) |
|
647 | - $_POST['ftp_path'] = $detect_path; |
|
691 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
692 | + $_POST['ftp_path'] = $detect_path; |
|
693 | + } |
|
648 | 694 | |
649 | - if (!isset($_POST['ftp_username'])) |
|
650 | - $_POST['ftp_username'] = $username; |
|
695 | + if (!isset($_POST['ftp_username'])) { |
|
696 | + $_POST['ftp_username'] = $username; |
|
697 | + } |
|
651 | 698 | |
652 | 699 | // Set the username etc, into context. |
653 | 700 | $incontext['ftp'] = array( |
@@ -659,8 +706,7 @@ discard block |
||
659 | 706 | ); |
660 | 707 | |
661 | 708 | return false; |
662 | - } |
|
663 | - else |
|
709 | + } else |
|
664 | 710 | { |
665 | 711 | $_SESSION['installer_temp_ftp'] = array( |
666 | 712 | 'server' => $_POST['ftp_server'], |
@@ -674,10 +720,12 @@ discard block |
||
674 | 720 | |
675 | 721 | foreach ($failed_files as $file) |
676 | 722 | { |
677 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
678 | - $ftp->chmod($file, 0755); |
|
679 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
680 | - $ftp->chmod($file, 0777); |
|
723 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
724 | + $ftp->chmod($file, 0755); |
|
725 | + } |
|
726 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
727 | + $ftp->chmod($file, 0777); |
|
728 | + } |
|
681 | 729 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
682 | 730 | { |
683 | 731 | $failed_files_updated[] = $file; |
@@ -733,15 +781,17 @@ discard block |
||
733 | 781 | |
734 | 782 | if (!$foundOne) |
735 | 783 | { |
736 | - if (isset($db['default_host'])) |
|
737 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
784 | + if (isset($db['default_host'])) { |
|
785 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
786 | + } |
|
738 | 787 | if (isset($db['default_user'])) |
739 | 788 | { |
740 | 789 | $incontext['db']['user'] = ini_get($db['default_user']); |
741 | 790 | $incontext['db']['name'] = ini_get($db['default_user']); |
742 | 791 | } |
743 | - if (isset($db['default_password'])) |
|
744 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
792 | + if (isset($db['default_password'])) { |
|
793 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
794 | + } |
|
745 | 795 | |
746 | 796 | // For simplicity and less confusion, leave the port blank by default |
747 | 797 | $incontext['db']['port'] = ''; |
@@ -760,10 +810,10 @@ discard block |
||
760 | 810 | $incontext['db']['server'] = $_POST['db_server']; |
761 | 811 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
762 | 812 | |
763 | - if (!empty($_POST['db_port'])) |
|
764 | - $incontext['db']['port'] = $_POST['db_port']; |
|
765 | - } |
|
766 | - else |
|
813 | + if (!empty($_POST['db_port'])) { |
|
814 | + $incontext['db']['port'] = $_POST['db_port']; |
|
815 | + } |
|
816 | + } else |
|
767 | 817 | { |
768 | 818 | $incontext['db']['prefix'] = 'smf_'; |
769 | 819 | } |
@@ -799,10 +849,11 @@ discard block |
||
799 | 849 | if (!empty($_POST['db_port'])) |
800 | 850 | { |
801 | 851 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
802 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
803 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
804 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
805 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
852 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
853 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
854 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
855 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
856 | + } |
|
806 | 857 | } |
807 | 858 | |
808 | 859 | // God I hope it saved! |
@@ -815,8 +866,9 @@ discard block |
||
815 | 866 | // Make sure it works. |
816 | 867 | require(dirname(__FILE__) . '/Settings.php'); |
817 | 868 | |
818 | - if (empty($sourcedir)) |
|
819 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
869 | + if (empty($sourcedir)) { |
|
870 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
871 | + } |
|
820 | 872 | |
821 | 873 | // Better find the database file! |
822 | 874 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -826,18 +878,21 @@ discard block |
||
826 | 878 | } |
827 | 879 | |
828 | 880 | // Now include it for database functions! |
829 | - if (!defined('SMF')) |
|
830 | - define('SMF', 1); |
|
881 | + if (!defined('SMF')) { |
|
882 | + define('SMF', 1); |
|
883 | + } |
|
831 | 884 | |
832 | 885 | $modSettings['disableQueryCheck'] = true; |
833 | - if (empty($smcFunc)) |
|
834 | - $smcFunc = array(); |
|
886 | + if (empty($smcFunc)) { |
|
887 | + $smcFunc = array(); |
|
888 | + } |
|
835 | 889 | |
836 | 890 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
837 | 891 | |
838 | 892 | // What - running PHP4? The shame! |
839 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
840 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
893 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
894 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
895 | + } |
|
841 | 896 | |
842 | 897 | // Attempt a connection. |
843 | 898 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -925,12 +980,14 @@ discard block |
||
925 | 980 | $incontext['page_title'] = $txt['install_settings']; |
926 | 981 | |
927 | 982 | // Let's see if we got the database type correct. |
928 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
929 | - $db_type = $_POST['db_type']; |
|
983 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
984 | + $db_type = $_POST['db_type']; |
|
985 | + } |
|
930 | 986 | |
931 | 987 | // Else we'd better be able to get the connection. |
932 | - else |
|
933 | - load_database(); |
|
988 | + else { |
|
989 | + load_database(); |
|
990 | + } |
|
934 | 991 | |
935 | 992 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
936 | 993 | |
@@ -939,10 +996,11 @@ discard block |
||
939 | 996 | |
940 | 997 | $secure = false; |
941 | 998 | |
942 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
943 | - $secure = true; |
|
944 | - 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') |
|
945 | - $secure = true; |
|
999 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
1000 | + $secure = true; |
|
1001 | + } 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') { |
|
1002 | + $secure = true; |
|
1003 | + } |
|
946 | 1004 | |
947 | 1005 | // Now, to put what we've learned together... and add a path. |
948 | 1006 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -974,18 +1032,21 @@ discard block |
||
974 | 1032 | // Submitting? |
975 | 1033 | if (isset($_POST['boardurl'])) |
976 | 1034 | { |
977 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
978 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
979 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
980 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
981 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
982 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1035 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1036 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1037 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1038 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1039 | + } |
|
1040 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1041 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1042 | + } |
|
983 | 1043 | |
984 | 1044 | //Make sure boardurl is aligned with ssl setting |
985 | - if (empty($_POST['force_ssl'])) |
|
986 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
987 | - else |
|
988 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1045 | + if (empty($_POST['force_ssl'])) { |
|
1046 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1047 | + } else { |
|
1048 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1049 | + } |
|
989 | 1050 | |
990 | 1051 | // Save these variables. |
991 | 1052 | $vars = array( |
@@ -1024,10 +1085,10 @@ discard block |
||
1024 | 1085 | { |
1025 | 1086 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1026 | 1087 | return false; |
1027 | - } |
|
1028 | - else |
|
1029 | - // Set the character set here. |
|
1088 | + } else { |
|
1089 | + // Set the character set here. |
|
1030 | 1090 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1091 | + } |
|
1031 | 1092 | } |
1032 | 1093 | |
1033 | 1094 | // Good, skip on. |
@@ -1047,8 +1108,9 @@ discard block |
||
1047 | 1108 | $incontext['continue'] = 1; |
1048 | 1109 | |
1049 | 1110 | // Already done? |
1050 | - if (isset($_POST['pop_done'])) |
|
1051 | - return true; |
|
1111 | + if (isset($_POST['pop_done'])) { |
|
1112 | + return true; |
|
1113 | + } |
|
1052 | 1114 | |
1053 | 1115 | // Reload settings. |
1054 | 1116 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1066,8 +1128,9 @@ discard block |
||
1066 | 1128 | $modSettings = array(); |
1067 | 1129 | if ($result !== false) |
1068 | 1130 | { |
1069 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1070 | - $modSettings[$row['variable']] = $row['value']; |
|
1131 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1132 | + $modSettings[$row['variable']] = $row['value']; |
|
1133 | + } |
|
1071 | 1134 | $smcFunc['db_free_result']($result); |
1072 | 1135 | |
1073 | 1136 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1080,20 +1143,22 @@ discard block |
||
1080 | 1143 | $modSettings['disableQueryCheck'] = true; |
1081 | 1144 | |
1082 | 1145 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1083 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1084 | - $smcFunc['db_query']('', ' |
|
1146 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1147 | + $smcFunc['db_query']('', ' |
|
1085 | 1148 | SET NAMES {string:utf8}', |
1086 | 1149 | array( |
1087 | 1150 | 'db_error_skip' => true, |
1088 | 1151 | 'utf8' => 'utf8', |
1089 | 1152 | ) |
1090 | 1153 | ); |
1154 | + } |
|
1091 | 1155 | |
1092 | 1156 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1093 | - if (substr(__DIR__, -1) == '\\') |
|
1094 | - $attachdir = __DIR__ . 'attachments'; |
|
1095 | - else |
|
1096 | - $attachdir = __DIR__ . '/attachments'; |
|
1157 | + if (substr(__DIR__, -1) == '\\') { |
|
1158 | + $attachdir = __DIR__ . 'attachments'; |
|
1159 | + } else { |
|
1160 | + $attachdir = __DIR__ . '/attachments'; |
|
1161 | + } |
|
1097 | 1162 | |
1098 | 1163 | $replaces = array( |
1099 | 1164 | '{$db_prefix}' => $db_prefix, |
@@ -1110,8 +1175,9 @@ discard block |
||
1110 | 1175 | |
1111 | 1176 | foreach ($txt as $key => $value) |
1112 | 1177 | { |
1113 | - if (substr($key, 0, 8) == 'default_') |
|
1114 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1178 | + if (substr($key, 0, 8) == 'default_') { |
|
1179 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1180 | + } |
|
1115 | 1181 | } |
1116 | 1182 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1117 | 1183 | |
@@ -1126,8 +1192,9 @@ discard block |
||
1126 | 1192 | |
1127 | 1193 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1128 | 1194 | { |
1129 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1130 | - $engines[] = $row['Engine']; |
|
1195 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1196 | + $engines[] = $row['Engine']; |
|
1197 | + } |
|
1131 | 1198 | } |
1132 | 1199 | |
1133 | 1200 | // Done with this now |
@@ -1151,8 +1218,7 @@ discard block |
||
1151 | 1218 | $replaces['START TRANSACTION;'] = ''; |
1152 | 1219 | $replaces['COMMIT;'] = ''; |
1153 | 1220 | } |
1154 | - } |
|
1155 | - else |
|
1221 | + } else |
|
1156 | 1222 | { |
1157 | 1223 | $has_innodb = false; |
1158 | 1224 | } |
@@ -1174,21 +1240,24 @@ discard block |
||
1174 | 1240 | foreach ($sql_lines as $count => $line) |
1175 | 1241 | { |
1176 | 1242 | // No comments allowed! |
1177 | - if (substr(trim($line), 0, 1) != '#') |
|
1178 | - $current_statement .= "\n" . rtrim($line); |
|
1243 | + if (substr(trim($line), 0, 1) != '#') { |
|
1244 | + $current_statement .= "\n" . rtrim($line); |
|
1245 | + } |
|
1179 | 1246 | |
1180 | 1247 | // Is this the end of the query string? |
1181 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1182 | - continue; |
|
1248 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1249 | + continue; |
|
1250 | + } |
|
1183 | 1251 | |
1184 | 1252 | // Does this table already exist? If so, don't insert more data into it! |
1185 | 1253 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1186 | 1254 | { |
1187 | 1255 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1188 | - if (!empty($matches[0])) |
|
1189 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1190 | - else |
|
1191 | - $incontext['sql_results']['insert_dups']++; |
|
1256 | + if (!empty($matches[0])) { |
|
1257 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1258 | + } else { |
|
1259 | + $incontext['sql_results']['insert_dups']++; |
|
1260 | + } |
|
1192 | 1261 | |
1193 | 1262 | $current_statement = ''; |
1194 | 1263 | continue; |
@@ -1197,8 +1266,9 @@ discard block |
||
1197 | 1266 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1198 | 1267 | { |
1199 | 1268 | // Use the appropriate function based on the DB type |
1200 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1201 | - $db_errorno = $db_type . '_errno'; |
|
1269 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1270 | + $db_errorno = $db_type . '_errno'; |
|
1271 | + } |
|
1202 | 1272 | |
1203 | 1273 | // Error 1050: Table already exists! |
1204 | 1274 | // @todo Needs to be made better! |
@@ -1213,18 +1283,18 @@ discard block |
||
1213 | 1283 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1214 | 1284 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1215 | 1285 | } |
1216 | - } |
|
1217 | - else |
|
1286 | + } else |
|
1218 | 1287 | { |
1219 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1220 | - $incontext['sql_results']['tables']++; |
|
1221 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1288 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1289 | + $incontext['sql_results']['tables']++; |
|
1290 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1222 | 1291 | { |
1223 | 1292 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1224 | - if (!empty($matches[0])) |
|
1225 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1226 | - else |
|
1227 | - $incontext['sql_results']['inserts']++; |
|
1293 | + if (!empty($matches[0])) { |
|
1294 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1295 | + } else { |
|
1296 | + $incontext['sql_results']['inserts']++; |
|
1297 | + } |
|
1228 | 1298 | } |
1229 | 1299 | } |
1230 | 1300 | |
@@ -1237,15 +1307,17 @@ discard block |
||
1237 | 1307 | // Sort out the context for the SQL. |
1238 | 1308 | foreach ($incontext['sql_results'] as $key => $number) |
1239 | 1309 | { |
1240 | - if ($number == 0) |
|
1241 | - unset($incontext['sql_results'][$key]); |
|
1242 | - else |
|
1243 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1310 | + if ($number == 0) { |
|
1311 | + unset($incontext['sql_results'][$key]); |
|
1312 | + } else { |
|
1313 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1314 | + } |
|
1244 | 1315 | } |
1245 | 1316 | |
1246 | 1317 | // Make sure UTF will be used globally. |
1247 | - 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']))) |
|
1248 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1318 | + 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']))) { |
|
1319 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1320 | + } |
|
1249 | 1321 | |
1250 | 1322 | // Auto-detect local & global cookie settings |
1251 | 1323 | $url_parts = parse_url($boardurl); |
@@ -1274,15 +1346,19 @@ discard block |
||
1274 | 1346 | |
1275 | 1347 | // Look for subfolder, if found, set localCookie |
1276 | 1348 | // Checking for len > 1 ensures you don't have just a slash... |
1277 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
1278 | - $localCookies = '1'; |
|
1349 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
1350 | + $localCookies = '1'; |
|
1351 | + } |
|
1279 | 1352 | |
1280 | - if (isset($globalCookies)) |
|
1281 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
1282 | - if (isset($globalCookiesDomain)) |
|
1283 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1284 | - if (isset($localCookies)) |
|
1285 | - $newSettings[] = array('localCookies', $localCookies); |
|
1353 | + if (isset($globalCookies)) { |
|
1354 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
1355 | + } |
|
1356 | + if (isset($globalCookiesDomain)) { |
|
1357 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1358 | + } |
|
1359 | + if (isset($localCookies)) { |
|
1360 | + $newSettings[] = array('localCookies', $localCookies); |
|
1361 | + } |
|
1286 | 1362 | } |
1287 | 1363 | |
1288 | 1364 | // Are we allowing stat collection? |
@@ -1300,16 +1376,17 @@ discard block |
||
1300 | 1376 | fwrite($fp, $out); |
1301 | 1377 | |
1302 | 1378 | $return_data = ''; |
1303 | - while (!feof($fp)) |
|
1304 | - $return_data .= fgets($fp, 128); |
|
1379 | + while (!feof($fp)) { |
|
1380 | + $return_data .= fgets($fp, 128); |
|
1381 | + } |
|
1305 | 1382 | |
1306 | 1383 | fclose($fp); |
1307 | 1384 | |
1308 | 1385 | // Get the unique site ID. |
1309 | 1386 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1310 | 1387 | |
1311 | - if (!empty($ID[1])) |
|
1312 | - $smcFunc['db_insert']('replace', |
|
1388 | + if (!empty($ID[1])) { |
|
1389 | + $smcFunc['db_insert']('replace', |
|
1313 | 1390 | $db_prefix . 'settings', |
1314 | 1391 | array('variable' => 'string', 'value' => 'string'), |
1315 | 1392 | array( |
@@ -1318,11 +1395,12 @@ discard block |
||
1318 | 1395 | ), |
1319 | 1396 | array('variable') |
1320 | 1397 | ); |
1398 | + } |
|
1321 | 1399 | } |
1322 | 1400 | } |
1323 | 1401 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1324 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1325 | - $smcFunc['db_query']('', ' |
|
1402 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1403 | + $smcFunc['db_query']('', ' |
|
1326 | 1404 | DELETE FROM {db_prefix}settings |
1327 | 1405 | WHERE variable = {string:enable_sm_stats}', |
1328 | 1406 | array( |
@@ -1330,20 +1408,23 @@ discard block |
||
1330 | 1408 | 'db_error_skip' => true, |
1331 | 1409 | ) |
1332 | 1410 | ); |
1411 | + } |
|
1333 | 1412 | |
1334 | 1413 | // Are we enabling SSL? |
1335 | - if (!empty($_POST['force_ssl'])) |
|
1336 | - $newSettings[] = array('force_ssl', 1); |
|
1414 | + if (!empty($_POST['force_ssl'])) { |
|
1415 | + $newSettings[] = array('force_ssl', 1); |
|
1416 | + } |
|
1337 | 1417 | |
1338 | 1418 | // Setting a timezone is required. |
1339 | 1419 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1340 | 1420 | { |
1341 | 1421 | // Get PHP's default timezone, if set |
1342 | 1422 | $ini_tz = ini_get('date.timezone'); |
1343 | - if (!empty($ini_tz)) |
|
1344 | - $timezone_id = $ini_tz; |
|
1345 | - else |
|
1346 | - $timezone_id = ''; |
|
1423 | + if (!empty($ini_tz)) { |
|
1424 | + $timezone_id = $ini_tz; |
|
1425 | + } else { |
|
1426 | + $timezone_id = ''; |
|
1427 | + } |
|
1347 | 1428 | |
1348 | 1429 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1349 | 1430 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1352,8 +1433,9 @@ discard block |
||
1352 | 1433 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1353 | 1434 | } |
1354 | 1435 | |
1355 | - if (date_default_timezone_set($timezone_id)) |
|
1356 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1436 | + if (date_default_timezone_set($timezone_id)) { |
|
1437 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1438 | + } |
|
1357 | 1439 | } |
1358 | 1440 | |
1359 | 1441 | if (!empty($newSettings)) |
@@ -1384,16 +1466,18 @@ discard block |
||
1384 | 1466 | } |
1385 | 1467 | |
1386 | 1468 | // MySQL specific stuff |
1387 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1388 | - return false; |
|
1469 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1470 | + return false; |
|
1471 | + } |
|
1389 | 1472 | |
1390 | 1473 | // Find database user privileges. |
1391 | 1474 | $privs = array(); |
1392 | 1475 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1393 | 1476 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1394 | 1477 | { |
1395 | - if ($row['Privilege'] == 'Alter') |
|
1396 | - $privs[] = $row['Privilege']; |
|
1478 | + if ($row['Privilege'] == 'Alter') { |
|
1479 | + $privs[] = $row['Privilege']; |
|
1480 | + } |
|
1397 | 1481 | } |
1398 | 1482 | $smcFunc['db_free_result']($get_privs); |
1399 | 1483 | |
@@ -1423,8 +1507,9 @@ discard block |
||
1423 | 1507 | $incontext['continue'] = 1; |
1424 | 1508 | |
1425 | 1509 | // Skipping? |
1426 | - if (!empty($_POST['skip'])) |
|
1427 | - return true; |
|
1510 | + if (!empty($_POST['skip'])) { |
|
1511 | + return true; |
|
1512 | + } |
|
1428 | 1513 | |
1429 | 1514 | // Need this to check whether we need the database password. |
1430 | 1515 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1441,18 +1526,22 @@ discard block |
||
1441 | 1526 | // We need this to properly hash the password for Admin |
1442 | 1527 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1443 | 1528 | global $sourcedir; |
1444 | - if (function_exists('mb_strtolower')) |
|
1445 | - return mb_strtolower($string, 'UTF-8'); |
|
1529 | + if (function_exists('mb_strtolower')) { |
|
1530 | + return mb_strtolower($string, 'UTF-8'); |
|
1531 | + } |
|
1446 | 1532 | require_once($sourcedir . '/Subs-Charset.php'); |
1447 | 1533 | return utf8_strtolower($string); |
1448 | 1534 | }; |
1449 | 1535 | |
1450 | - if (!isset($_POST['username'])) |
|
1451 | - $_POST['username'] = ''; |
|
1452 | - if (!isset($_POST['email'])) |
|
1453 | - $_POST['email'] = ''; |
|
1454 | - if (!isset($_POST['server_email'])) |
|
1455 | - $_POST['server_email'] = ''; |
|
1536 | + if (!isset($_POST['username'])) { |
|
1537 | + $_POST['username'] = ''; |
|
1538 | + } |
|
1539 | + if (!isset($_POST['email'])) { |
|
1540 | + $_POST['email'] = ''; |
|
1541 | + } |
|
1542 | + if (!isset($_POST['server_email'])) { |
|
1543 | + $_POST['server_email'] = ''; |
|
1544 | + } |
|
1456 | 1545 | |
1457 | 1546 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1458 | 1547 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1471,8 +1560,9 @@ discard block |
||
1471 | 1560 | 'admin_group' => 1, |
1472 | 1561 | ) |
1473 | 1562 | ); |
1474 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1475 | - $incontext['skip'] = 1; |
|
1563 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1564 | + $incontext['skip'] = 1; |
|
1565 | + } |
|
1476 | 1566 | $smcFunc['db_free_result']($request); |
1477 | 1567 | |
1478 | 1568 | // Trying to create an account? |
@@ -1503,8 +1593,9 @@ discard block |
||
1503 | 1593 | } |
1504 | 1594 | |
1505 | 1595 | // Update the webmaster's email? |
1506 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1507 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1596 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1597 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1598 | + } |
|
1508 | 1599 | |
1509 | 1600 | // Work out whether we're going to have dodgy characters and remove them. |
1510 | 1601 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1527,32 +1618,27 @@ discard block |
||
1527 | 1618 | $smcFunc['db_free_result']($result); |
1528 | 1619 | |
1529 | 1620 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1530 | - } |
|
1531 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1621 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1532 | 1622 | { |
1533 | 1623 | // Try the previous step again. |
1534 | 1624 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1535 | 1625 | return false; |
1536 | - } |
|
1537 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1626 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1538 | 1627 | { |
1539 | 1628 | // Try the previous step again. |
1540 | 1629 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1541 | 1630 | return false; |
1542 | - } |
|
1543 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1631 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1544 | 1632 | { |
1545 | 1633 | // One step back, this time fill out a proper admin email address. |
1546 | 1634 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1547 | 1635 | return false; |
1548 | - } |
|
1549 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1636 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1550 | 1637 | { |
1551 | 1638 | // One step back, this time fill out a proper admin email address. |
1552 | 1639 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1553 | 1640 | return false; |
1554 | - } |
|
1555 | - elseif ($_POST['username'] != '') |
|
1641 | + } elseif ($_POST['username'] != '') |
|
1556 | 1642 | { |
1557 | 1643 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1558 | 1644 | |
@@ -1620,17 +1706,19 @@ discard block |
||
1620 | 1706 | reloadSettings(); |
1621 | 1707 | |
1622 | 1708 | // Bring a warning over. |
1623 | - if (!empty($incontext['account_existed'])) |
|
1624 | - $incontext['warning'] = $incontext['account_existed']; |
|
1709 | + if (!empty($incontext['account_existed'])) { |
|
1710 | + $incontext['warning'] = $incontext['account_existed']; |
|
1711 | + } |
|
1625 | 1712 | |
1626 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1627 | - $smcFunc['db_query']('', ' |
|
1713 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1714 | + $smcFunc['db_query']('', ' |
|
1628 | 1715 | SET NAMES {string:db_character_set}', |
1629 | 1716 | array( |
1630 | 1717 | 'db_character_set' => $db_character_set, |
1631 | 1718 | 'db_error_skip' => true, |
1632 | 1719 | ) |
1633 | 1720 | ); |
1721 | + } |
|
1634 | 1722 | |
1635 | 1723 | // As track stats is by default enabled let's add some activity. |
1636 | 1724 | $smcFunc['db_insert']('ignore', |
@@ -1651,14 +1739,16 @@ discard block |
||
1651 | 1739 | // Only proceed if we can load the data. |
1652 | 1740 | if ($request) |
1653 | 1741 | { |
1654 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1655 | - $modSettings[$row[0]] = $row[1]; |
|
1742 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1743 | + $modSettings[$row[0]] = $row[1]; |
|
1744 | + } |
|
1656 | 1745 | $smcFunc['db_free_result']($request); |
1657 | 1746 | } |
1658 | 1747 | |
1659 | 1748 | // Automatically log them in ;) |
1660 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1661 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1749 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1750 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1751 | + } |
|
1662 | 1752 | |
1663 | 1753 | $result = $smcFunc['db_query']('', ' |
1664 | 1754 | SELECT value |
@@ -1669,13 +1759,14 @@ discard block |
||
1669 | 1759 | 'db_error_skip' => true, |
1670 | 1760 | ) |
1671 | 1761 | ); |
1672 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1673 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1762 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1763 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1764 | + } |
|
1674 | 1765 | $smcFunc['db_free_result']($result); |
1675 | 1766 | |
1676 | - if (empty($db_sessions)) |
|
1677 | - $_SESSION['admin_time'] = time(); |
|
1678 | - else |
|
1767 | + if (empty($db_sessions)) { |
|
1768 | + $_SESSION['admin_time'] = time(); |
|
1769 | + } else |
|
1679 | 1770 | { |
1680 | 1771 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1681 | 1772 | |
@@ -1699,8 +1790,9 @@ discard block |
||
1699 | 1790 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1700 | 1791 | function($string){ |
1701 | 1792 | global $sourcedir; |
1702 | - if (function_exists('mb_strtolower')) |
|
1703 | - return mb_strtolower($string, 'UTF-8'); |
|
1793 | + if (function_exists('mb_strtolower')) { |
|
1794 | + return mb_strtolower($string, 'UTF-8'); |
|
1795 | + } |
|
1704 | 1796 | require_once($sourcedir . '/Subs-Charset.php'); |
1705 | 1797 | return utf8_strtolower($string); |
1706 | 1798 | }; |
@@ -1716,8 +1808,9 @@ discard block |
||
1716 | 1808 | ) |
1717 | 1809 | ); |
1718 | 1810 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1719 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1720 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1811 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1812 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1813 | + } |
|
1721 | 1814 | $smcFunc['db_free_result']($request); |
1722 | 1815 | |
1723 | 1816 | // Now is the perfect time to fetch the SM files. |
@@ -1736,8 +1829,9 @@ discard block |
||
1736 | 1829 | |
1737 | 1830 | // Check if we need some stupid MySQL fix. |
1738 | 1831 | $server_version = $smcFunc['db_server_info'](); |
1739 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1740 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1832 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1833 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1834 | + } |
|
1741 | 1835 | |
1742 | 1836 | // Some final context for the template. |
1743 | 1837 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1757,8 +1851,9 @@ discard block |
||
1757 | 1851 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1758 | 1852 | |
1759 | 1853 | // @todo Do we just want to read the file in clean, and split it this way always? |
1760 | - if (count($settingsArray) == 1) |
|
1761 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1854 | + if (count($settingsArray) == 1) { |
|
1855 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1856 | + } |
|
1762 | 1857 | |
1763 | 1858 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1764 | 1859 | { |
@@ -1766,25 +1861,29 @@ discard block |
||
1766 | 1861 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
1767 | 1862 | { |
1768 | 1863 | // Set the ten lines to nothing. |
1769 | - for ($j=0; $j < 10; $j++) |
|
1770 | - $settingsArray[$i++] = ''; |
|
1864 | + for ($j=0; $j < 10; $j++) { |
|
1865 | + $settingsArray[$i++] = ''; |
|
1866 | + } |
|
1771 | 1867 | |
1772 | 1868 | continue; |
1773 | 1869 | } |
1774 | 1870 | |
1775 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1776 | - $settingsArray[$i] = ''; |
|
1871 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1872 | + $settingsArray[$i] = ''; |
|
1873 | + } |
|
1777 | 1874 | |
1778 | 1875 | // Don't trim or bother with it if it's not a variable. |
1779 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1780 | - continue; |
|
1876 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1877 | + continue; |
|
1878 | + } |
|
1781 | 1879 | |
1782 | 1880 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1783 | 1881 | |
1784 | - foreach ($vars as $var => $val) |
|
1785 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1882 | + foreach ($vars as $var => $val) { |
|
1883 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1786 | 1884 | { |
1787 | 1885 | $comment = strstr($settingsArray[$i], '#'); |
1886 | + } |
|
1788 | 1887 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1789 | 1888 | unset($vars[$var]); |
1790 | 1889 | } |
@@ -1794,36 +1893,41 @@ discard block |
||
1794 | 1893 | if (!empty($vars)) |
1795 | 1894 | { |
1796 | 1895 | $settingsArray[$i++] = ''; |
1797 | - foreach ($vars as $var => $val) |
|
1798 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1896 | + foreach ($vars as $var => $val) { |
|
1897 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1898 | + } |
|
1799 | 1899 | } |
1800 | 1900 | |
1801 | 1901 | // Blank out the file - done to fix a oddity with some servers. |
1802 | 1902 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1803 | - if (!$fp) |
|
1804 | - return false; |
|
1903 | + if (!$fp) { |
|
1904 | + return false; |
|
1905 | + } |
|
1805 | 1906 | fclose($fp); |
1806 | 1907 | |
1807 | 1908 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1808 | 1909 | |
1809 | 1910 | // Gotta have one of these ;) |
1810 | - if (trim($settingsArray[0]) != '<?php') |
|
1811 | - fwrite($fp, "<?php\n"); |
|
1911 | + if (trim($settingsArray[0]) != '<?php') { |
|
1912 | + fwrite($fp, "<?php\n"); |
|
1913 | + } |
|
1812 | 1914 | |
1813 | 1915 | $lines = count($settingsArray); |
1814 | 1916 | for ($i = 0; $i < $lines - 1; $i++) |
1815 | 1917 | { |
1816 | 1918 | // Don't just write a bunch of blank lines. |
1817 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1818 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1919 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1920 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1921 | + } |
|
1819 | 1922 | } |
1820 | 1923 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1821 | 1924 | fclose($fp); |
1822 | 1925 | |
1823 | 1926 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1824 | 1927 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1825 | - if (function_exists('opcache_invalidate')) |
|
1826 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1928 | + if (function_exists('opcache_invalidate')) { |
|
1929 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1930 | + } |
|
1827 | 1931 | |
1828 | 1932 | return true; |
1829 | 1933 | } |
@@ -1833,10 +1937,11 @@ discard block |
||
1833 | 1937 | global $cachedir; |
1834 | 1938 | |
1835 | 1939 | // Write out the db_last_error file with the error timestamp |
1836 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
1837 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1838 | - else |
|
1839 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1940 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
1941 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1942 | + } else { |
|
1943 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1944 | + } |
|
1840 | 1945 | |
1841 | 1946 | return true; |
1842 | 1947 | } |
@@ -1853,9 +1958,9 @@ discard block |
||
1853 | 1958 | SecFilterScanPOST Off |
1854 | 1959 | </IfModule>'; |
1855 | 1960 | |
1856 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1857 | - return true; |
|
1858 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1961 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1962 | + return true; |
|
1963 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1859 | 1964 | { |
1860 | 1965 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1861 | 1966 | |
@@ -1867,29 +1972,28 @@ discard block |
||
1867 | 1972 | fwrite($ht_handle, $htaccess_addition); |
1868 | 1973 | fclose($ht_handle); |
1869 | 1974 | return true; |
1975 | + } else { |
|
1976 | + return false; |
|
1870 | 1977 | } |
1871 | - else |
|
1872 | - return false; |
|
1978 | + } else { |
|
1979 | + return true; |
|
1873 | 1980 | } |
1874 | - else |
|
1875 | - return true; |
|
1876 | - } |
|
1877 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1878 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1879 | - elseif (is_writable(dirname(__FILE__))) |
|
1981 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1982 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1983 | + } elseif (is_writable(dirname(__FILE__))) |
|
1880 | 1984 | { |
1881 | 1985 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1882 | 1986 | { |
1883 | 1987 | fwrite($ht_handle, $htaccess_addition); |
1884 | 1988 | fclose($ht_handle); |
1885 | 1989 | return true; |
1990 | + } else { |
|
1991 | + return false; |
|
1886 | 1992 | } |
1887 | - else |
|
1993 | + } else { |
|
1888 | 1994 | return false; |
1889 | 1995 | } |
1890 | - else |
|
1891 | - return false; |
|
1892 | -} |
|
1996 | + } |
|
1893 | 1997 | |
1894 | 1998 | function template_install_above() |
1895 | 1999 | { |
@@ -1927,9 +2031,10 @@ discard block |
||
1927 | 2031 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1928 | 2032 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1929 | 2033 | |
1930 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1931 | - echo ' |
|
2034 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2035 | + echo ' |
|
1932 | 2036 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
2037 | + } |
|
1933 | 2038 | |
1934 | 2039 | echo ' |
1935 | 2040 | </select> |
@@ -1949,9 +2054,10 @@ discard block |
||
1949 | 2054 | <h2>', $txt['upgrade_progress'], '</h2> |
1950 | 2055 | <ul>'; |
1951 | 2056 | |
1952 | - foreach ($incontext['steps'] as $num => $step) |
|
1953 | - echo ' |
|
2057 | + foreach ($incontext['steps'] as $num => $step) { |
|
2058 | + echo ' |
|
1954 | 2059 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2060 | + } |
|
1955 | 2061 | |
1956 | 2062 | echo ' |
1957 | 2063 | </ul> |
@@ -1976,20 +2082,23 @@ discard block |
||
1976 | 2082 | echo ' |
1977 | 2083 | <div class="floatright">'; |
1978 | 2084 | |
1979 | - if (!empty($incontext['continue'])) |
|
1980 | - echo ' |
|
2085 | + if (!empty($incontext['continue'])) { |
|
2086 | + echo ' |
|
1981 | 2087 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
1982 | - if (!empty($incontext['skip'])) |
|
1983 | - echo ' |
|
2088 | + } |
|
2089 | + if (!empty($incontext['skip'])) { |
|
2090 | + echo ' |
|
1984 | 2091 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
2092 | + } |
|
1985 | 2093 | echo ' |
1986 | 2094 | </div>'; |
1987 | 2095 | } |
1988 | 2096 | |
1989 | 2097 | // Show the closing form tag and other data only if not in the last step |
1990 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1991 | - echo ' |
|
2098 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2099 | + echo ' |
|
1992 | 2100 | </form>'; |
2101 | + } |
|
1993 | 2102 | |
1994 | 2103 | echo ' |
1995 | 2104 | </div> |
@@ -2024,13 +2133,15 @@ discard block |
||
2024 | 2133 | </div>'; |
2025 | 2134 | |
2026 | 2135 | // Show the warnings, or not. |
2027 | - if (template_warning_divs()) |
|
2028 | - echo ' |
|
2136 | + if (template_warning_divs()) { |
|
2137 | + echo ' |
|
2029 | 2138 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2139 | + } |
|
2030 | 2140 | |
2031 | 2141 | // Say we want the continue button! |
2032 | - if (empty($incontext['error'])) |
|
2033 | - $incontext['continue'] = 1; |
|
2142 | + if (empty($incontext['error'])) { |
|
2143 | + $incontext['continue'] = 1; |
|
2144 | + } |
|
2034 | 2145 | |
2035 | 2146 | // For the latest version stuff. |
2036 | 2147 | echo ' |
@@ -2064,8 +2175,8 @@ discard block |
||
2064 | 2175 | global $txt, $incontext; |
2065 | 2176 | |
2066 | 2177 | // Errors are very serious.. |
2067 | - if (!empty($incontext['error'])) |
|
2068 | - echo ' |
|
2178 | + if (!empty($incontext['error'])) { |
|
2179 | + echo ' |
|
2069 | 2180 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2070 | 2181 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2071 | 2182 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2073,9 +2184,10 @@ discard block |
||
2073 | 2184 | ', $incontext['error'], ' |
2074 | 2185 | </div> |
2075 | 2186 | </div>'; |
2187 | + } |
|
2076 | 2188 | // A warning message? |
2077 | - elseif (!empty($incontext['warning'])) |
|
2078 | - echo ' |
|
2189 | + elseif (!empty($incontext['warning'])) { |
|
2190 | + echo ' |
|
2079 | 2191 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2080 | 2192 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2081 | 2193 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2083,6 +2195,7 @@ discard block |
||
2083 | 2195 | ', $incontext['warning'], ' |
2084 | 2196 | </div> |
2085 | 2197 | </div>'; |
2198 | + } |
|
2086 | 2199 | |
2087 | 2200 | return empty($incontext['error']) && empty($incontext['warning']); |
2088 | 2201 | } |
@@ -2098,27 +2211,30 @@ discard block |
||
2098 | 2211 | <li>', $incontext['failed_files']), '</li> |
2099 | 2212 | </ul>'; |
2100 | 2213 | |
2101 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2102 | - echo ' |
|
2214 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2215 | + echo ' |
|
2103 | 2216 | <hr> |
2104 | 2217 | <p>', $txt['chmod_linux_info'], '</p> |
2105 | 2218 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2219 | + } |
|
2106 | 2220 | |
2107 | 2221 | // This is serious! |
2108 | - if (!template_warning_divs()) |
|
2109 | - return; |
|
2222 | + if (!template_warning_divs()) { |
|
2223 | + return; |
|
2224 | + } |
|
2110 | 2225 | |
2111 | 2226 | echo ' |
2112 | 2227 | <hr> |
2113 | 2228 | <p>', $txt['ftp_setup_info'], '</p>'; |
2114 | 2229 | |
2115 | - if (!empty($incontext['ftp_errors'])) |
|
2116 | - echo ' |
|
2230 | + if (!empty($incontext['ftp_errors'])) { |
|
2231 | + echo ' |
|
2117 | 2232 | <div class="error_message"> |
2118 | 2233 | ', $txt['error_ftp_no_connect'], '<br><br> |
2119 | 2234 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2120 | 2235 | </div> |
2121 | 2236 | <br>'; |
2237 | + } |
|
2122 | 2238 | |
2123 | 2239 | echo ' |
2124 | 2240 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2178,17 +2294,17 @@ discard block |
||
2178 | 2294 | <td> |
2179 | 2295 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2180 | 2296 | |
2181 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2182 | - echo ' |
|
2297 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2298 | + echo ' |
|
2183 | 2299 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2300 | + } |
|
2184 | 2301 | |
2185 | 2302 | echo ' |
2186 | 2303 | </select> |
2187 | 2304 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2188 | 2305 | </td> |
2189 | 2306 | </tr>'; |
2190 | - } |
|
2191 | - else |
|
2307 | + } else |
|
2192 | 2308 | { |
2193 | 2309 | echo ' |
2194 | 2310 | <tr style="display: none;"> |
@@ -2381,9 +2497,10 @@ discard block |
||
2381 | 2497 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2382 | 2498 | <ul>'; |
2383 | 2499 | |
2384 | - foreach ($incontext['failures'] as $line => $fail) |
|
2385 | - echo ' |
|
2500 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2501 | + echo ' |
|
2386 | 2502 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2503 | + } |
|
2387 | 2504 | |
2388 | 2505 | echo ' |
2389 | 2506 | </ul>'; |
@@ -2444,15 +2561,16 @@ discard block |
||
2444 | 2561 | </tr> |
2445 | 2562 | </table>'; |
2446 | 2563 | |
2447 | - if ($incontext['require_db_confirm']) |
|
2448 | - echo ' |
|
2564 | + if ($incontext['require_db_confirm']) { |
|
2565 | + echo ' |
|
2449 | 2566 | <h2>', $txt['user_settings_database'], '</h2> |
2450 | 2567 | <p>', $txt['user_settings_database_info'], '</p> |
2451 | 2568 | |
2452 | 2569 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2453 | 2570 | <input type="password" name="password3" size="30" /> |
2454 | 2571 | </div>'; |
2455 | -} |
|
2572 | + } |
|
2573 | + } |
|
2456 | 2574 | |
2457 | 2575 | // Tell them it's done, and to delete. |
2458 | 2576 | function template_delete_install() |
@@ -2465,14 +2583,15 @@ discard block |
||
2465 | 2583 | template_warning_divs(); |
2466 | 2584 | |
2467 | 2585 | // Install directory still writable? |
2468 | - if ($incontext['dir_still_writable']) |
|
2469 | - echo ' |
|
2586 | + if ($incontext['dir_still_writable']) { |
|
2587 | + echo ' |
|
2470 | 2588 | <em>', $txt['still_writable'], '</em><br> |
2471 | 2589 | <br>'; |
2590 | + } |
|
2472 | 2591 | |
2473 | 2592 | // Don't show the box if it's like 99% sure it won't work :P. |
2474 | - if ($incontext['probably_delete_install']) |
|
2475 | - echo ' |
|
2593 | + if ($incontext['probably_delete_install']) { |
|
2594 | + echo ' |
|
2476 | 2595 | <div style="margin: 1ex; font-weight: bold;"> |
2477 | 2596 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2478 | 2597 | </div> |
@@ -2488,6 +2607,7 @@ discard block |
||
2488 | 2607 | } |
2489 | 2608 | </script> |
2490 | 2609 | <br>'; |
2610 | + } |
|
2491 | 2611 | |
2492 | 2612 | echo ' |
2493 | 2613 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |