@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param bool $single_file If true returns the contents of the file specified by destination if it exists |
29 | 29 | * @param bool $overwrite Whether to overwrite existing files |
30 | 30 | * @param null|array $files_to_extract Specific files to extract |
31 | - * @return array|false An array of information about extracted files or false on failure |
|
31 | + * @return string An array of information about extracted files or false on failure |
|
32 | 32 | */ |
33 | 33 | function read_tgz_file($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
34 | 34 | { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param bool $single_file Whether to only extract a single file |
60 | 60 | * @param bool $overwrite Whether to overwrite existing data |
61 | 61 | * @param null|array $files_to_extract If set, only extracts the specified files |
62 | - * @return array|false An array of information about the extracted files or false on failure |
|
62 | + * @return string An array of information about the extracted files or false on failure |
|
63 | 63 | */ |
64 | 64 | function read_tgz_data($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
65 | 65 | { |
@@ -3255,7 +3255,7 @@ discard block |
||
3255 | 3255 | * https://php.net/crc32#79567 |
3256 | 3256 | * |
3257 | 3257 | * @param string $number |
3258 | - * @return string The crc32 |
|
3258 | + * @return integer The crc32 |
|
3259 | 3259 | */ |
3260 | 3260 | function smf_crc32($number) |
3261 | 3261 | { |
@@ -118,7 +118,7 @@ |
||
118 | 118 | |
119 | 119 | // Right, image not cached? Simply redirect, then. |
120 | 120 | if (!$response) |
121 | - redirectexit($request); |
|
121 | + redirectexit($request); |
|
122 | 122 | |
123 | 123 | // Make sure we're serving an image |
124 | 124 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
@@ -63,26 +63,31 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function checkRequest() |
65 | 65 | { |
66 | - if (!$this->enabled) |
|
67 | - return false; |
|
66 | + if (!$this->enabled) { |
|
67 | + return false; |
|
68 | + } |
|
68 | 69 | |
69 | 70 | // Try to create the image cache directory if it doesn't exist |
70 | - if (!file_exists($this->cache)) |
|
71 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
71 | + if (!file_exists($this->cache)) { |
|
72 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
72 | 73 | return false; |
74 | + } |
|
73 | 75 | |
74 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
75 | - return false; |
|
76 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
77 | + return false; |
|
78 | + } |
|
76 | 79 | |
77 | 80 | $hash = $_GET['hash']; |
78 | 81 | $request = $_GET['request']; |
79 | 82 | |
80 | - if (md5($request . $this->secret) != $hash) |
|
81 | - return false; |
|
83 | + if (md5($request . $this->secret) != $hash) { |
|
84 | + return false; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // Attempt to cache the request if it doesn't exist |
84 | - if (!$this->isCached($request)) |
|
85 | - return $this->cacheImage($request); |
|
88 | + if (!$this->isCached($request)) { |
|
89 | + return $this->cacheImage($request); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | return true; |
88 | 93 | } |
@@ -111,19 +116,22 @@ discard block |
||
111 | 116 | if (!$cached || time() - $cached['time'] > (5 * 86400)) |
112 | 117 | { |
113 | 118 | @unlink($cached_file); |
114 | - if ($this->checkRequest()) |
|
115 | - $this->serve(); |
|
119 | + if ($this->checkRequest()) { |
|
120 | + $this->serve(); |
|
121 | + } |
|
116 | 122 | redirectexit($request); |
117 | 123 | } |
118 | 124 | |
119 | 125 | // Right, image not cached? Simply redirect, then. |
120 | - if (!$response) |
|
121 | - redirectexit($request); |
|
126 | + if (!$response) { |
|
127 | + redirectexit($request); |
|
128 | + } |
|
122 | 129 | |
123 | 130 | // Make sure we're serving an image |
124 | 131 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
125 | - if ($contentParts[0] != 'image') |
|
126 | - exit; |
|
132 | + if ($contentParts[0] != 'image') { |
|
133 | + exit; |
|
134 | + } |
|
127 | 135 | |
128 | 136 | header('Content-type: ' . $cached['content_type']); |
129 | 137 | header('Content-length: ' . $cached['size']); |
@@ -170,8 +178,9 @@ discard block |
||
170 | 178 | $responseCode = $request->result('code'); |
171 | 179 | $response = $request->result(); |
172 | 180 | |
173 | - if (empty($response)) |
|
174 | - return false; |
|
181 | + if (empty($response)) { |
|
182 | + return false; |
|
183 | + } |
|
175 | 184 | |
176 | 185 | if ($responseCode != 200) { |
177 | 186 | return $request->result('code'); |
@@ -181,12 +190,14 @@ discard block |
||
181 | 190 | |
182 | 191 | // Make sure the url is returning an image |
183 | 192 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
184 | - if ($contentParts[0] != 'image') |
|
185 | - return false; |
|
193 | + if ($contentParts[0] != 'image') { |
|
194 | + return false; |
|
195 | + } |
|
186 | 196 | |
187 | 197 | // Validate the filesize |
188 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
189 | - return false; |
|
198 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
199 | + return false; |
|
200 | + } |
|
190 | 201 | |
191 | 202 | return file_put_contents($dest, json_encode(array( |
192 | 203 | 'content_type' => $headers['content-type'], |
@@ -670,7 +670,7 @@ |
||
670 | 670 | // Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified! |
671 | 671 | // Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it. |
672 | 672 | echo ' |
673 | - <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
|
673 | + <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">'; |
|
674 | 674 | |
675 | 675 | if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
676 | 676 | echo |
@@ -51,11 +51,13 @@ discard block |
||
51 | 51 | <p>'; |
52 | 52 | |
53 | 53 | // Show just numbers...? |
54 | - if ($settings['display_who_viewing'] == 1) |
|
55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
54 | + if ($settings['display_who_viewing'] == 1) { |
|
55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
56 | + } |
|
56 | 57 | // Or show the actual people viewing the topic? |
57 | - else |
|
58 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
58 | + else { |
|
59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | // Now show how many guests are here too. |
61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
95 | 97 | |
96 | - if ($context['allow_results_view']) |
|
97 | - echo ' |
|
98 | + if ($context['allow_results_view']) { |
|
99 | + echo ' |
|
98 | 100 | ', $option['bar_ndt'], ' |
99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
102 | + } |
|
100 | 103 | |
101 | 104 | echo ' |
102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
105 | 108 | echo ' |
106 | 109 | </dl>'; |
107 | 110 | |
108 | - if ($context['allow_results_view']) |
|
109 | - echo ' |
|
111 | + if ($context['allow_results_view']) { |
|
112 | + echo ' |
|
110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
114 | + } |
|
111 | 115 | } |
112 | 116 | // They are allowed to vote! Go to it! |
113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
117 | 121 | |
118 | 122 | // Show a warning if they are allowed more than one option. |
119 | - if ($context['poll']['allowed_warning']) |
|
120 | - echo ' |
|
123 | + if ($context['poll']['allowed_warning']) { |
|
124 | + echo ' |
|
121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
126 | + } |
|
122 | 127 | |
123 | 128 | echo ' |
124 | 129 | <ul class="options">'; |
125 | 130 | |
126 | 131 | // Show each option with its button - a radio likely. |
127 | - foreach ($context['poll']['options'] as $option) |
|
128 | - echo ' |
|
132 | + foreach ($context['poll']['options'] as $option) { |
|
133 | + echo ' |
|
129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
135 | + } |
|
130 | 136 | |
131 | 137 | echo ' |
132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
138 | 144 | } |
139 | 145 | |
140 | 146 | // Is the clock ticking? |
141 | - if (!empty($context['poll']['expire_time'])) |
|
142 | - echo ' |
|
147 | + if (!empty($context['poll']['expire_time'])) { |
|
148 | + echo ' |
|
143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
150 | + } |
|
144 | 151 | |
145 | 152 | echo ' |
146 | 153 | </div> |
@@ -170,11 +177,13 @@ discard block |
||
170 | 177 | <li> |
171 | 178 | <b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>'; |
172 | 179 | |
173 | - if ($event['can_edit']) |
|
174 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
180 | + if ($event['can_edit']) { |
|
181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
182 | + } |
|
175 | 183 | |
176 | - if ($event['can_export']) |
|
177 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
184 | + if ($event['can_export']) { |
|
185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
186 | + } |
|
178 | 187 | |
179 | 188 | echo ' |
180 | 189 | <br>'; |
@@ -182,14 +191,14 @@ discard block |
||
182 | 191 | if (!empty($event['allday'])) |
183 | 192 | { |
184 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
185 | - } |
|
186 | - else |
|
194 | + } else |
|
187 | 195 | { |
188 | 196 | // Display event info relative to user's local timezone |
189 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
190 | 198 | |
191 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
192 | - echo trim($event['end_date_local']) . ', '; |
|
199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
200 | + echo trim($event['end_date_local']) . ', '; |
|
201 | + } |
|
193 | 202 | |
194 | 203 | echo trim($event['end_time_local']); |
195 | 204 | |
@@ -198,23 +207,27 @@ discard block |
||
198 | 207 | { |
199 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
200 | 209 | |
201 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
202 | - echo trim($event['start_date_orig']), ', '; |
|
210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
211 | + echo trim($event['start_date_orig']), ', '; |
|
212 | + } |
|
203 | 213 | |
204 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
205 | 215 | |
206 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
207 | - echo trim($event['end_date_orig']) . ', '; |
|
216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
217 | + echo trim($event['end_date_orig']) . ', '; |
|
218 | + } |
|
208 | 219 | |
209 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
210 | 221 | } |
211 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
212 | - else |
|
213 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
223 | + else { |
|
224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
225 | + } |
|
214 | 226 | } |
215 | 227 | |
216 | - if (!empty($event['location'])) |
|
217 | - echo '<br>', $event['location']; |
|
228 | + if (!empty($event['location'])) { |
|
229 | + echo '<br>', $event['location']; |
|
230 | + } |
|
218 | 231 | |
219 | 232 | echo ' |
220 | 233 | </li>'; |
@@ -252,8 +265,9 @@ discard block |
||
252 | 265 | $context['removableMessageIDs'] = array(); |
253 | 266 | |
254 | 267 | // Get all the messages... |
255 | - while ($message = $context['get_message']()) |
|
256 | - template_single_post($message); |
|
268 | + while ($message = $context['get_message']()) { |
|
269 | + template_single_post($message); |
|
270 | + } |
|
257 | 271 | |
258 | 272 | echo ' |
259 | 273 | </form> |
@@ -290,8 +304,9 @@ discard block |
||
290 | 304 | <div id="display_jump_to"> </div>'; |
291 | 305 | |
292 | 306 | // Show quickreply |
293 | - if ($context['can_reply']) |
|
294 | - template_quickreply(); |
|
307 | + if ($context['can_reply']) { |
|
308 | + template_quickreply(); |
|
309 | + } |
|
295 | 310 | |
296 | 311 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
297 | 312 | echo ' |
@@ -304,8 +319,8 @@ discard block |
||
304 | 319 | </div>'; |
305 | 320 | |
306 | 321 | // Show the moderation button & pop only if user can moderate |
307 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
308 | - echo ' |
|
322 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
323 | + echo ' |
|
309 | 324 | <div id="mobile_moderation" class="popup_container"> |
310 | 325 | <div class="popup_window description"> |
311 | 326 | <div class="popup_heading">', $txt['mobile_moderation'], ' |
@@ -315,6 +330,7 @@ discard block |
||
315 | 330 | </div> |
316 | 331 | </div> |
317 | 332 | </div>'; |
333 | + } |
|
318 | 334 | |
319 | 335 | echo ' |
320 | 336 | <script>'; |
@@ -438,9 +454,10 @@ discard block |
||
438 | 454 | }); |
439 | 455 | }'; |
440 | 456 | |
441 | - if (!empty($context['ignoredMsgs'])) |
|
442 | - echo ' |
|
457 | + if (!empty($context['ignoredMsgs'])) { |
|
458 | + echo ' |
|
443 | 459 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
460 | + } |
|
444 | 461 | |
445 | 462 | echo ' |
446 | 463 | </script>'; |
@@ -457,8 +474,9 @@ discard block |
||
457 | 474 | |
458 | 475 | $ignoring = false; |
459 | 476 | |
460 | - if ($message['can_remove']) |
|
461 | - $context['removableMessageIDs'][] = $message['id']; |
|
477 | + if ($message['can_remove']) { |
|
478 | + $context['removableMessageIDs'][] = $message['id']; |
|
479 | + } |
|
462 | 480 | |
463 | 481 | // Are we ignoring this message? |
464 | 482 | if (!empty($message['is_ignored'])) |
@@ -484,9 +502,10 @@ discard block |
||
484 | 502 | <div class="custom_fields_above_member"> |
485 | 503 | <ul class="nolist">'; |
486 | 504 | |
487 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
488 | - echo ' |
|
505 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
506 | + echo ' |
|
489 | 507 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
508 | + } |
|
490 | 509 | |
491 | 510 | echo ' |
492 | 511 | </ul> |
@@ -497,9 +516,10 @@ discard block |
||
497 | 516 | <h4>'; |
498 | 517 | |
499 | 518 | // Show online and offline buttons? |
500 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
501 | - echo ' |
|
519 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
520 | + echo ' |
|
502 | 521 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
522 | + } |
|
503 | 523 | |
504 | 524 | |
505 | 525 | // Show a link to the member's profile. |
@@ -512,51 +532,59 @@ discard block |
||
512 | 532 | |
513 | 533 | |
514 | 534 | // Show the user's avatar. |
515 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
516 | - echo ' |
|
535 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
536 | + echo ' |
|
517 | 537 | <li class="avatar"> |
518 | 538 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
519 | 539 | </li>'; |
540 | + } |
|
520 | 541 | |
521 | 542 | // Are there any custom fields below the avatar? |
522 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
523 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
543 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
544 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
524 | 545 | echo ' |
525 | 546 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
547 | + } |
|
526 | 548 | |
527 | 549 | // Show the post group icons, but not for guests. |
528 | - if (!$message['member']['is_guest']) |
|
529 | - echo ' |
|
550 | + if (!$message['member']['is_guest']) { |
|
551 | + echo ' |
|
530 | 552 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
553 | + } |
|
531 | 554 | |
532 | 555 | // Show the member's primary group (like 'Administrator') if they have one. |
533 | - if (!empty($message['member']['group'])) |
|
534 | - echo ' |
|
556 | + if (!empty($message['member']['group'])) { |
|
557 | + echo ' |
|
535 | 558 | <li class="membergroup">', $message['member']['group'], '</li>'; |
559 | + } |
|
536 | 560 | |
537 | 561 | // Show the member's custom title, if they have one. |
538 | - if (!empty($message['member']['title'])) |
|
539 | - echo ' |
|
562 | + if (!empty($message['member']['title'])) { |
|
563 | + echo ' |
|
540 | 564 | <li class="title">', $message['member']['title'], '</li>'; |
565 | + } |
|
541 | 566 | |
542 | 567 | // Don't show these things for guests. |
543 | 568 | if (!$message['member']['is_guest']) |
544 | 569 | { |
545 | 570 | |
546 | 571 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
547 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
548 | - echo ' |
|
572 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
573 | + echo ' |
|
549 | 574 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
575 | + } |
|
550 | 576 | |
551 | 577 | // Show how many posts they have made. |
552 | - if (!isset($context['disabled_fields']['posts'])) |
|
553 | - echo ' |
|
578 | + if (!isset($context['disabled_fields']['posts'])) { |
|
579 | + echo ' |
|
554 | 580 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
581 | + } |
|
555 | 582 | |
556 | 583 | // Show their personal text? |
557 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
558 | - echo ' |
|
584 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
585 | + echo ' |
|
559 | 586 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
587 | + } |
|
560 | 588 | |
561 | 589 | // Any custom fields to show as icons? |
562 | 590 | if (!empty($message['custom_fields']['icons'])) |
@@ -565,9 +593,10 @@ discard block |
||
565 | 593 | <li class="im_icons"> |
566 | 594 | <ol>'; |
567 | 595 | |
568 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
569 | - echo ' |
|
596 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
597 | + echo ' |
|
570 | 598 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
599 | + } |
|
571 | 600 | |
572 | 601 | echo ' |
573 | 602 | </ol> |
@@ -582,19 +611,22 @@ discard block |
||
582 | 611 | <ol class="profile_icons">'; |
583 | 612 | |
584 | 613 | // Don't show an icon if they haven't specified a website. |
585 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
586 | - echo ' |
|
614 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
615 | + echo ' |
|
587 | 616 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
617 | + } |
|
588 | 618 | |
589 | 619 | // Since we know this person isn't a guest, you *can* message them. |
590 | - if ($context['can_send_pm']) |
|
591 | - echo ' |
|
620 | + if ($context['can_send_pm']) { |
|
621 | + echo ' |
|
592 | 622 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
623 | + } |
|
593 | 624 | |
594 | 625 | // Show the email if necessary |
595 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
596 | - echo ' |
|
626 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
627 | + echo ' |
|
597 | 628 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
629 | + } |
|
598 | 630 | |
599 | 631 | echo ' |
600 | 632 | </ol> |
@@ -602,48 +634,56 @@ discard block |
||
602 | 634 | } |
603 | 635 | |
604 | 636 | // Any custom fields for standard placement? |
605 | - if (!empty($message['custom_fields']['standard'])) |
|
606 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
637 | + if (!empty($message['custom_fields']['standard'])) { |
|
638 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
607 | 639 | echo ' |
608 | 640 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
641 | + } |
|
609 | 642 | |
610 | 643 | } |
611 | 644 | // Otherwise, show the guest's email. |
612 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
613 | - echo ' |
|
645 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
646 | + echo ' |
|
614 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
648 | + } |
|
615 | 649 | |
616 | 650 | // Show the IP to this user for this post - because you can moderate? |
617 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
618 | - echo ' |
|
651 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
652 | + echo ' |
|
619 | 653 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
654 | + } |
|
620 | 655 | |
621 | 656 | // Or, should we show it because this is you? |
622 | - elseif ($message['can_see_ip']) |
|
623 | - echo ' |
|
657 | + elseif ($message['can_see_ip']) { |
|
658 | + echo ' |
|
624 | 659 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
660 | + } |
|
625 | 661 | |
626 | 662 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
627 | - elseif (!$context['user']['is_guest']) |
|
628 | - echo ' |
|
663 | + elseif (!$context['user']['is_guest']) { |
|
664 | + echo ' |
|
629 | 665 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
666 | + } |
|
630 | 667 | |
631 | 668 | // Otherwise, you see NOTHING! |
632 | - else |
|
633 | - echo ' |
|
669 | + else { |
|
670 | + echo ' |
|
634 | 671 | <li class="poster_ip">', $txt['logged'], '</li>'; |
672 | + } |
|
635 | 673 | |
636 | 674 | // Are we showing the warning status? |
637 | 675 | // Don't show these things for guests. |
638 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
639 | - echo ' |
|
676 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
677 | + echo ' |
|
640 | 678 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
679 | + } |
|
641 | 680 | |
642 | 681 | // Are there any custom fields to show at the bottom of the poster info? |
643 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
644 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
682 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
683 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
645 | 684 | echo ' |
646 | 685 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
686 | + } |
|
647 | 687 | |
648 | 688 | // Poster info ends. |
649 | 689 | echo ' |
@@ -672,9 +712,10 @@ discard block |
||
672 | 712 | echo ' |
673 | 713 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
674 | 714 | |
675 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
676 | - echo |
|
715 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
716 | + echo |
|
677 | 717 | $message['modified']['last_edit_text']; |
718 | + } |
|
678 | 719 | |
679 | 720 | echo ' |
680 | 721 | </span> |
@@ -683,22 +724,24 @@ discard block |
||
683 | 724 | </div>'; |
684 | 725 | |
685 | 726 | // Ignoring this user? Hide the post. |
686 | - if ($ignoring) |
|
687 | - echo ' |
|
727 | + if ($ignoring) { |
|
728 | + echo ' |
|
688 | 729 | <div id="msg_', $message['id'], '_ignored_prompt"> |
689 | 730 | ', $txt['ignoring_user'], ' |
690 | 731 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
691 | 732 | </div>'; |
733 | + } |
|
692 | 734 | |
693 | 735 | // Show the post itself, finally! |
694 | 736 | echo ' |
695 | 737 | <div class="post">'; |
696 | 738 | |
697 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
698 | - echo ' |
|
739 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
740 | + echo ' |
|
699 | 741 | <div class="approve_post"> |
700 | 742 | ', $txt['post_awaiting_approval'], ' |
701 | 743 | </div>'; |
744 | + } |
|
702 | 745 | echo ' |
703 | 746 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
704 | 747 | </div>'; |
@@ -715,9 +758,9 @@ discard block |
||
715 | 758 | foreach ($message['attachment'] as $attachment) |
716 | 759 | { |
717 | 760 | // Do we want this attachment to not be showed here? |
718 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
719 | - continue; |
|
720 | - elseif (!$div_output) |
|
761 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
762 | + continue; |
|
763 | + } elseif (!$div_output) |
|
721 | 764 | { |
722 | 765 | $div_output = true; |
723 | 766 | |
@@ -733,9 +776,10 @@ discard block |
||
733 | 776 | <fieldset> |
734 | 777 | <legend>', $txt['attach_awaiting_approve']; |
735 | 778 | |
736 | - if ($context['can_approve']) |
|
737 | - echo ' |
|
779 | + if ($context['can_approve']) { |
|
780 | + echo ' |
|
738 | 781 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
782 | + } |
|
739 | 783 | |
740 | 784 | echo ' |
741 | 785 | </legend>'; |
@@ -749,12 +793,13 @@ discard block |
||
749 | 793 | echo ' |
750 | 794 | <div class="attachments_top">'; |
751 | 795 | |
752 | - if ($attachment['thumbnail']['has_thumb']) |
|
753 | - echo ' |
|
796 | + if ($attachment['thumbnail']['has_thumb']) { |
|
797 | + echo ' |
|
754 | 798 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
755 | - else |
|
756 | - echo ' |
|
799 | + } else { |
|
800 | + echo ' |
|
757 | 801 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
802 | + } |
|
758 | 803 | |
759 | 804 | echo ' |
760 | 805 | </div>'; |
@@ -764,9 +809,10 @@ discard block |
||
764 | 809 | <div class="attachments_bot"> |
765 | 810 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
766 | 811 | |
767 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
768 | - echo ' |
|
812 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
813 | + echo ' |
|
769 | 814 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
815 | + } |
|
770 | 816 | echo ' |
771 | 817 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
772 | 818 | </div>'; |
@@ -775,33 +821,38 @@ discard block |
||
775 | 821 | </div>'; |
776 | 822 | |
777 | 823 | // Next attachment line ? |
778 | - if (++$i % $attachments_per_line === 0) |
|
779 | - echo ' |
|
824 | + if (++$i % $attachments_per_line === 0) { |
|
825 | + echo ' |
|
780 | 826 | <br>'; |
827 | + } |
|
781 | 828 | } |
782 | 829 | |
783 | 830 | // If we had unapproved attachments clean up. |
784 | - if ($last_approved_state == 0) |
|
785 | - echo ' |
|
831 | + if ($last_approved_state == 0) { |
|
832 | + echo ' |
|
786 | 833 | </fieldset>'; |
834 | + } |
|
787 | 835 | |
788 | 836 | // Only do this if we output a div above - otherwise it'll break things |
789 | - if ($div_output) |
|
790 | - echo ' |
|
837 | + if ($div_output) { |
|
838 | + echo ' |
|
791 | 839 | </div>'; |
840 | + } |
|
792 | 841 | } |
793 | 842 | |
794 | 843 | // And stuff below the attachments. |
795 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
796 | - echo ' |
|
844 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
845 | + echo ' |
|
797 | 846 | <div class="under_message">'; |
847 | + } |
|
798 | 848 | |
799 | 849 | // Maybe they want to report this post to the moderator(s)? |
800 | - if ($context['can_report_moderator']) |
|
801 | - echo ' |
|
850 | + if ($context['can_report_moderator']) { |
|
851 | + echo ' |
|
802 | 852 | <ul class="floatright smalltext"> |
803 | 853 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
804 | 854 | </ul>'; |
855 | + } |
|
805 | 856 | |
806 | 857 | // What about likes? |
807 | 858 | if (!empty($modSettings['enable_likes'])) |
@@ -842,78 +893,91 @@ discard block |
||
842 | 893 | <ul class="quickbuttons">'; |
843 | 894 | |
844 | 895 | // Can they quote? if so they can select and quote as well! |
845 | - if ($context['can_quote']) |
|
846 | - echo ' |
|
896 | + if ($context['can_quote']) { |
|
897 | + echo ' |
|
847 | 898 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
848 | 899 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>'; |
900 | + } |
|
849 | 901 | |
850 | 902 | // Can the user modify the contents of this post? Show the modify inline image. |
851 | - if ($message['can_modify']) |
|
852 | - echo ' |
|
903 | + if ($message['can_modify']) { |
|
904 | + echo ' |
|
853 | 905 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
906 | + } |
|
854 | 907 | |
855 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
856 | - echo ' |
|
908 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
909 | + echo ' |
|
857 | 910 | <li class="post_options">', $txt['post_options']; |
911 | + } |
|
858 | 912 | |
859 | 913 | echo ' |
860 | 914 | <ul>'; |
861 | 915 | |
862 | 916 | // Can the user modify the contents of this post? |
863 | - if ($message['can_modify']) |
|
864 | - echo ' |
|
917 | + if ($message['can_modify']) { |
|
918 | + echo ' |
|
865 | 919 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
920 | + } |
|
866 | 921 | |
867 | 922 | // How about... even... remove it entirely?! |
868 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
869 | - echo ' |
|
923 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
924 | + echo ' |
|
870 | 925 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
871 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
872 | - echo ' |
|
926 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
927 | + echo ' |
|
873 | 928 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
929 | + } |
|
874 | 930 | |
875 | 931 | // What about splitting it off the rest of the topic? |
876 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
877 | - echo ' |
|
932 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
933 | + echo ' |
|
878 | 934 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
935 | + } |
|
879 | 936 | |
880 | 937 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
881 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
882 | - echo ' |
|
938 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
939 | + echo ' |
|
883 | 940 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
941 | + } |
|
884 | 942 | |
885 | 943 | // Can we restore topics? |
886 | - if ($context['can_restore_msg']) |
|
887 | - echo ' |
|
944 | + if ($context['can_restore_msg']) { |
|
945 | + echo ' |
|
888 | 946 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
947 | + } |
|
889 | 948 | |
890 | 949 | // Maybe we can approve it, maybe we should? |
891 | - if ($message['can_approve']) |
|
892 | - echo ' |
|
950 | + if ($message['can_approve']) { |
|
951 | + echo ' |
|
893 | 952 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
953 | + } |
|
894 | 954 | |
895 | 955 | // Maybe we can unapprove it? |
896 | - if ($message['can_unapprove']) |
|
897 | - echo ' |
|
956 | + if ($message['can_unapprove']) { |
|
957 | + echo ' |
|
898 | 958 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
959 | + } |
|
899 | 960 | |
900 | 961 | echo ' |
901 | 962 | </ul> |
902 | 963 | </li>'; |
903 | 964 | |
904 | 965 | // Show a checkbox for quick moderation? |
905 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
906 | - echo ' |
|
966 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
967 | + echo ' |
|
907 | 968 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
969 | + } |
|
908 | 970 | |
909 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
910 | - echo ' |
|
971 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
972 | + echo ' |
|
911 | 973 | </ul>'; |
974 | + } |
|
912 | 975 | } |
913 | 976 | |
914 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
915 | - echo ' |
|
977 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
978 | + echo ' |
|
916 | 979 | </div>'; |
980 | + } |
|
917 | 981 | |
918 | 982 | echo ' |
919 | 983 | </div> |
@@ -926,9 +990,10 @@ discard block |
||
926 | 990 | <div class="custom_fields_above_signature"> |
927 | 991 | <ul class="nolist">'; |
928 | 992 | |
929 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
930 | - echo ' |
|
993 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
994 | + echo ' |
|
931 | 995 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
996 | + } |
|
932 | 997 | |
933 | 998 | echo ' |
934 | 999 | </ul> |
@@ -936,9 +1001,10 @@ discard block |
||
936 | 1001 | } |
937 | 1002 | |
938 | 1003 | // Show the member's signature? |
939 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
940 | - echo ' |
|
1004 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
1005 | + echo ' |
|
941 | 1006 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
1007 | + } |
|
942 | 1008 | |
943 | 1009 | |
944 | 1010 | // Are there any custom profile fields for below the signature? |
@@ -948,9 +1014,10 @@ discard block |
||
948 | 1014 | <div class="custom_fields_below_signature"> |
949 | 1015 | <ul class="nolist">'; |
950 | 1016 | |
951 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
952 | - echo ' |
|
1017 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
1018 | + echo ' |
|
953 | 1019 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
1020 | + } |
|
954 | 1021 | |
955 | 1022 | echo ' |
956 | 1023 | </ul> |
@@ -998,8 +1065,8 @@ discard block |
||
998 | 1065 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
999 | 1066 | |
1000 | 1067 | // Guests just need more. |
1001 | - if ($context['user']['is_guest']) |
|
1002 | - echo ' |
|
1068 | + if ($context['user']['is_guest']) { |
|
1069 | + echo ' |
|
1003 | 1070 | <dl id="post_header"> |
1004 | 1071 | <dt> |
1005 | 1072 | ', $txt['name'], ': |
@@ -1014,6 +1081,7 @@ discard block |
||
1014 | 1081 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required> |
1015 | 1082 | </dd> |
1016 | 1083 | </dl>'; |
1084 | + } |
|
1017 | 1085 | |
1018 | 1086 | echo ' |
1019 | 1087 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1061,8 +1129,8 @@ discard block |
||
1061 | 1129 | <br class="clear">'; |
1062 | 1130 | |
1063 | 1131 | // draft autosave available and the user has it enabled? |
1064 | - if (!empty($context['drafts_autosave'])) |
|
1065 | - echo ' |
|
1132 | + if (!empty($context['drafts_autosave'])) { |
|
1133 | + echo ' |
|
1066 | 1134 | <script> |
1067 | 1135 | var oDraftAutoSave = new smf_DraftAutoSave({ |
1068 | 1136 | sSelf: \'oDraftAutoSave\', |
@@ -1074,10 +1142,12 @@ discard block |
||
1074 | 1142 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
1075 | 1143 | }); |
1076 | 1144 | </script>'; |
1145 | + } |
|
1077 | 1146 | |
1078 | - if ($context['show_spellchecking']) |
|
1079 | - echo ' |
|
1147 | + if ($context['show_spellchecking']) { |
|
1148 | + echo ' |
|
1080 | 1149 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
1150 | + } |
|
1081 | 1151 | |
1082 | 1152 | echo ' |
1083 | 1153 | <script> |
@@ -72,9 +72,10 @@ discard block |
||
72 | 72 | |
73 | 73 | // Allow css/js files to be disable for this specific theme. |
74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
75 | - if (!isset($settings['disable_files'])) |
|
76 | - $settings['disable_files'] = array(); |
|
77 | -} |
|
75 | + if (!isset($settings['disable_files'])) { |
|
76 | + $settings['disable_files'] = array(); |
|
77 | + } |
|
78 | + } |
|
78 | 79 | |
79 | 80 | /** |
80 | 81 | * The main sub template above the content. |
@@ -111,8 +112,9 @@ discard block |
||
111 | 112 | echo ' |
112 | 113 | <meta'; |
113 | 114 | |
114 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
115 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
115 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
116 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
117 | + } |
|
116 | 118 | |
117 | 119 | echo '>'; |
118 | 120 | } |
@@ -123,14 +125,16 @@ discard block |
||
123 | 125 | <meta name="theme-color" content="#557EA0">'; |
124 | 126 | |
125 | 127 | // Please don't index these Mr Robot. |
126 | - if (!empty($context['robot_no_index'])) |
|
127 | - echo ' |
|
128 | + if (!empty($context['robot_no_index'])) { |
|
129 | + echo ' |
|
128 | 130 | <meta name="robots" content="noindex">'; |
131 | + } |
|
129 | 132 | |
130 | 133 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
131 | - if (!empty($context['canonical_url'])) |
|
132 | - echo ' |
|
134 | + if (!empty($context['canonical_url'])) { |
|
135 | + echo ' |
|
133 | 136 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
137 | + } |
|
134 | 138 | |
135 | 139 | // Show all the relative links, such as help, search, contents, and the like. |
136 | 140 | echo ' |
@@ -139,10 +143,11 @@ discard block |
||
139 | 143 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
140 | 144 | |
141 | 145 | // If RSS feeds are enabled, advertise the presence of one. |
142 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
143 | - echo ' |
|
146 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
147 | + echo ' |
|
144 | 148 | <link rel="alternate feed" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '"> |
145 | 149 | <link rel="alternate feed" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">'; |
150 | + } |
|
146 | 151 | |
147 | 152 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
148 | 153 | if (!empty($context['links']['next'])) |
@@ -158,9 +163,10 @@ discard block |
||
158 | 163 | } |
159 | 164 | |
160 | 165 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
161 | - if (!empty($context['current_board'])) |
|
162 | - echo ' |
|
166 | + if (!empty($context['current_board'])) { |
|
167 | + echo ' |
|
163 | 168 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
169 | + } |
|
164 | 170 | |
165 | 171 | // Output any remaining HTML headers. (from mods, maybe?) |
166 | 172 | echo $context['html_headers']; |
@@ -191,8 +197,9 @@ discard block |
||
191 | 197 | <ul class="floatleft" id="top_info"> |
192 | 198 | <li> |
193 | 199 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
194 | - if (!empty($context['user']['avatar'])) |
|
195 | - echo $context['user']['avatar']['image']; |
|
200 | + if (!empty($context['user']['avatar'])) { |
|
201 | + echo $context['user']['avatar']['image']; |
|
202 | + } |
|
196 | 203 | echo $context['user']['name'], '</a> |
197 | 204 | <div id="profile_menu" class="top_menu"></div> |
198 | 205 | </li>'; |
@@ -220,17 +227,18 @@ discard block |
||
220 | 227 | } |
221 | 228 | // Otherwise they're a guest. Ask them to either register or login. |
222 | 229 | else |
223 | - if (empty($maintenance)) |
|
224 | - echo ' |
|
230 | + if (empty($maintenance)) { |
|
231 | + echo ' |
|
225 | 232 | <ul class="floatleft welcome"> |
226 | 233 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
227 | 234 | </ul>'; |
228 | - else |
|
229 | - //In maintenance mode, only login is allowed and don't show OverlayDiv |
|
235 | + } else { |
|
236 | + //In maintenance mode, only login is allowed and don't show OverlayDiv |
|
230 | 237 | echo ' |
231 | 238 | <ul class="floatleft welcome"> |
232 | 239 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
233 | 240 | </ul>'; |
241 | + } |
|
234 | 242 | |
235 | 243 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
236 | 244 | { |
@@ -238,9 +246,10 @@ discard block |
||
238 | 246 | <form id="languages_form" method="get" class="floatright"> |
239 | 247 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
240 | 248 | |
241 | - foreach ($context['languages'] as $language) |
|
242 | - echo ' |
|
249 | + foreach ($context['languages'] as $language) { |
|
250 | + echo ' |
|
243 | 251 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
252 | + } |
|
244 | 253 | |
245 | 254 | echo ' |
246 | 255 | </select> |
@@ -264,31 +273,36 @@ discard block |
||
264 | 273 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
265 | 274 | |
266 | 275 | // Can't limit it to a specific topic if we are not in one |
267 | - if (!empty($context['current_topic'])) |
|
268 | - echo ' |
|
276 | + if (!empty($context['current_topic'])) { |
|
277 | + echo ' |
|
269 | 278 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
279 | + } |
|
270 | 280 | |
271 | 281 | // Can't limit it to a specific board if we are not in one |
272 | - if (!empty($context['current_board'])) |
|
273 | - echo ' |
|
282 | + if (!empty($context['current_board'])) { |
|
283 | + echo ' |
|
274 | 284 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
285 | + } |
|
275 | 286 | |
276 | 287 | // Can't search for members if we can't see the memberlist |
277 | - if (!empty($context['allow_memberlist'])) |
|
278 | - echo ' |
|
288 | + if (!empty($context['allow_memberlist'])) { |
|
289 | + echo ' |
|
279 | 290 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
291 | + } |
|
280 | 292 | |
281 | 293 | echo ' |
282 | 294 | </select>'; |
283 | 295 | |
284 | 296 | // Search within current topic? |
285 | - if (!empty($context['current_topic'])) |
|
286 | - echo ' |
|
297 | + if (!empty($context['current_topic'])) { |
|
298 | + echo ' |
|
287 | 299 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
300 | + } |
|
288 | 301 | // If we're on a certain board, limit it to this board ;). |
289 | - elseif (!empty($context['current_board'])) |
|
290 | - echo ' |
|
302 | + elseif (!empty($context['current_board'])) { |
|
303 | + echo ' |
|
291 | 304 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
305 | + } |
|
292 | 306 | |
293 | 307 | echo ' |
294 | 308 | <input type="submit" name="search2" value="', $txt['search'], '" class="button_submit"> |
@@ -318,12 +332,13 @@ discard block |
||
318 | 332 | ', $context['current_time'], ' |
319 | 333 | </div>'; |
320 | 334 | // Show a random news item? (or you could pick one from news_lines...) |
321 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
322 | - echo ' |
|
335 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
336 | + echo ' |
|
323 | 337 | <div class="news"> |
324 | 338 | <h2>', $txt['news'], ': </h2> |
325 | 339 | <p>', $context['random_news_line'], '</p> |
326 | 340 | </div>'; |
341 | + } |
|
327 | 342 | |
328 | 343 | echo ' |
329 | 344 | <hr class="clear"> |
@@ -386,9 +401,10 @@ discard block |
||
386 | 401 | </ul>'; |
387 | 402 | |
388 | 403 | // Show the load time? |
389 | - if ($context['show_load_time']) |
|
390 | - echo ' |
|
404 | + if ($context['show_load_time']) { |
|
405 | + echo ' |
|
391 | 406 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
407 | + } |
|
392 | 408 | |
393 | 409 | echo ' |
394 | 410 | </div>'; |
@@ -418,19 +434,21 @@ discard block |
||
418 | 434 | global $context, $shown_linktree, $scripturl, $txt; |
419 | 435 | |
420 | 436 | // If linktree is empty, just return - also allow an override. |
421 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
422 | - return; |
|
437 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
438 | + return; |
|
439 | + } |
|
423 | 440 | |
424 | 441 | echo ' |
425 | 442 | <div class="navigate_section"> |
426 | 443 | <ul>'; |
427 | 444 | |
428 | - if ($context['user']['is_logged']) |
|
429 | - echo ' |
|
445 | + if ($context['user']['is_logged']) { |
|
446 | + echo ' |
|
430 | 447 | <li class="unread_links"> |
431 | 448 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
432 | 449 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
433 | 450 | </li>'; |
451 | + } |
|
434 | 452 | |
435 | 453 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
436 | 454 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -441,25 +459,29 @@ discard block |
||
441 | 459 | // Don't show a separator for the first one. |
442 | 460 | // Better here. Always points to the next level when the linktree breaks to a second line. |
443 | 461 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
444 | - if ($link_num != 0) |
|
445 | - echo ' |
|
462 | + if ($link_num != 0) { |
|
463 | + echo ' |
|
446 | 464 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
465 | + } |
|
447 | 466 | |
448 | 467 | // Show something before the link? |
449 | - if (isset($tree['extra_before'])) |
|
450 | - echo $tree['extra_before'], ' '; |
|
468 | + if (isset($tree['extra_before'])) { |
|
469 | + echo $tree['extra_before'], ' '; |
|
470 | + } |
|
451 | 471 | |
452 | 472 | // Show the link, including a URL if it should have one. |
453 | - if (isset($tree['url'])) |
|
454 | - echo ' |
|
473 | + if (isset($tree['url'])) { |
|
474 | + echo ' |
|
455 | 475 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
456 | - else |
|
457 | - echo ' |
|
476 | + } else { |
|
477 | + echo ' |
|
458 | 478 | <span>' . $tree['name'] . '</span>'; |
479 | + } |
|
459 | 480 | |
460 | 481 | // Show something after the link...? |
461 | - if (isset($tree['extra_after'])) |
|
462 | - echo ' ', $tree['extra_after']; |
|
482 | + if (isset($tree['extra_after'])) { |
|
483 | + echo ' ', $tree['extra_after']; |
|
484 | + } |
|
463 | 485 | |
464 | 486 | echo ' |
465 | 487 | </li>'; |
@@ -509,13 +531,14 @@ discard block |
||
509 | 531 | echo ' |
510 | 532 | <ul>'; |
511 | 533 | |
512 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
513 | - echo ' |
|
534 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
535 | + echo ' |
|
514 | 536 | <li> |
515 | 537 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
516 | 538 | ', $grandchildbutton['title'], ' |
517 | 539 | </a> |
518 | 540 | </li>'; |
541 | + } |
|
519 | 542 | |
520 | 543 | echo ' |
521 | 544 | </ul>'; |
@@ -546,8 +569,9 @@ discard block |
||
546 | 569 | { |
547 | 570 | global $context, $txt; |
548 | 571 | |
549 | - if (!is_array($strip_options)) |
|
550 | - $strip_options = array(); |
|
572 | + if (!is_array($strip_options)) { |
|
573 | + $strip_options = array(); |
|
574 | + } |
|
551 | 575 | |
552 | 576 | // Create the buttons... |
553 | 577 | $buttons = array(); |
@@ -556,8 +580,9 @@ discard block |
||
556 | 580 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
557 | 581 | if (!isset($value['test']) || !empty($context[$value['test']])) |
558 | 582 | { |
559 | - if (!isset($value['id'])) |
|
560 | - $value['id'] = $key; |
|
583 | + if (!isset($value['id'])) { |
|
584 | + $value['id'] = $key; |
|
585 | + } |
|
561 | 586 | |
562 | 587 | $button = ' |
563 | 588 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -570,13 +595,15 @@ discard block |
||
570 | 595 | <div class="overview">'; |
571 | 596 | foreach ($value['sub_buttons'] as $element) |
572 | 597 | { |
573 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
574 | - continue; |
|
598 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
599 | + continue; |
|
600 | + } |
|
575 | 601 | |
576 | 602 | $button .= ' |
577 | 603 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
578 | - if (isset($txt[$element['text'] . '_desc'])) |
|
579 | - $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
604 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
605 | + $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
606 | + } |
|
580 | 607 | $button .= '</a>'; |
581 | 608 | } |
582 | 609 | $button .= ' |
@@ -590,8 +617,9 @@ discard block |
||
590 | 617 | } |
591 | 618 | |
592 | 619 | // No buttons? No button strip either. |
593 | - if (empty($buttons)) |
|
594 | - return; |
|
620 | + if (empty($buttons)) { |
|
621 | + return; |
|
622 | + } |
|
595 | 623 | |
596 | 624 | echo ' |
597 | 625 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -25,18 +25,20 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | <div class="windowbg2 noup">'; |
27 | 27 | |
28 | - if (!empty($context['move_board'])) |
|
29 | - echo ' |
|
28 | + if (!empty($context['move_board'])) { |
|
29 | + echo ' |
|
30 | 30 | <div class="noticebox"> |
31 | 31 | ', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', ' |
32 | 32 | </div>'; |
33 | + } |
|
33 | 34 | |
34 | 35 | // No categories so show a label. |
35 | - if (empty($context['categories'])) |
|
36 | - echo ' |
|
36 | + if (empty($context['categories'])) { |
|
37 | + echo ' |
|
37 | 38 | <div class="windowbg centertext"> |
38 | 39 | ', $txt['mboards_no_cats'], ' |
39 | 40 | </div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Loop through every category, listing the boards in each as we go. |
42 | 44 | foreach ($context['categories'] as $category) |
@@ -54,9 +56,10 @@ discard block |
||
54 | 56 | <form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '"> |
55 | 57 | <ul id="category_', $category['id'], '" class="nolist">'; |
56 | 58 | |
57 | - if (!empty($category['move_link'])) |
|
58 | - echo ' |
|
59 | + if (!empty($category['move_link'])) { |
|
60 | + echo ' |
|
59 | 61 | <li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | $recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>'; |
62 | 65 | $redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">'; |
@@ -81,9 +84,10 @@ discard block |
||
81 | 84 | echo ' |
82 | 85 | <li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">'; |
83 | 86 | |
84 | - foreach ($board['move_links'] as $link) |
|
85 | - echo ' |
|
87 | + foreach ($board['move_links'] as $link) { |
|
88 | + echo ' |
|
86 | 89 | <a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>'; |
90 | + } |
|
87 | 91 | |
88 | 92 | echo ' |
89 | 93 | </li>'; |
@@ -132,9 +136,10 @@ discard block |
||
132 | 136 | <select name="cat_order">'; |
133 | 137 | |
134 | 138 | // Print every existing category into a select box. |
135 | - foreach ($context['category_order'] as $order) |
|
136 | - echo ' |
|
139 | + foreach ($context['category_order'] as $order) { |
|
140 | + echo ' |
|
137 | 141 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
142 | + } |
|
138 | 143 | echo ' |
139 | 144 | </select> |
140 | 145 | </dd>'; |
@@ -169,14 +174,15 @@ discard block |
||
169 | 174 | { |
170 | 175 | foreach ($context['custom_category_settings'] as $catset_id => $catset) |
171 | 176 | { |
172 | - if (!empty($catset['dt']) && !empty($catset['dd'])) |
|
173 | - echo ' |
|
177 | + if (!empty($catset['dt']) && !empty($catset['dd'])) { |
|
178 | + echo ' |
|
174 | 179 | <dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '"> |
175 | 180 | ', $catset['dt'], ' |
176 | 181 | </dt> |
177 | 182 | <dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '> |
178 | 183 | ', $catset['dd'], ' |
179 | 184 | </dd>'; |
185 | + } |
|
180 | 186 | } |
181 | 187 | } |
182 | 188 | |
@@ -184,21 +190,23 @@ discard block |
||
184 | 190 | echo ' |
185 | 191 | </dl>'; |
186 | 192 | |
187 | - if (isset($context['category']['is_new'])) |
|
188 | - echo ' |
|
193 | + if (isset($context['category']['is_new'])) { |
|
194 | + echo ' |
|
189 | 195 | <input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">'; |
190 | - else |
|
191 | - echo ' |
|
196 | + } else { |
|
197 | + echo ' |
|
192 | 198 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit"> |
193 | 199 | <input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button_submit you_sure">'; |
200 | + } |
|
194 | 201 | echo ' |
195 | 202 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
196 | 203 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
197 | 204 | |
198 | 205 | // If this category is empty we don't bother with the next confirmation screen. |
199 | - if ($context['category']['is_empty']) |
|
200 | - echo ' |
|
206 | + if ($context['category']['is_empty']) { |
|
207 | + echo ' |
|
201 | 208 | <input type="hidden" name="empty" value="1">'; |
209 | + } |
|
202 | 210 | |
203 | 211 | echo ' |
204 | 212 | </div> |
@@ -225,9 +233,10 @@ discard block |
||
225 | 233 | <p>', $txt['mboards_delete_cat_contains'], ':</p> |
226 | 234 | <ul>'; |
227 | 235 | |
228 | - foreach ($context['category']['children'] as $child) |
|
229 | - echo ' |
|
236 | + foreach ($context['category']['children'] as $child) { |
|
237 | + echo ' |
|
230 | 238 | <li>', $child, '</li>'; |
239 | + } |
|
231 | 240 | |
232 | 241 | echo ' |
233 | 242 | </ul> |
@@ -241,10 +250,11 @@ discard block |
||
241 | 250 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>: |
242 | 251 | <select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>'; |
243 | 252 | |
244 | - foreach ($context['category_order'] as $cat) |
|
245 | - if ($cat['id'] != 0) |
|
253 | + foreach ($context['category_order'] as $cat) { |
|
254 | + if ($cat['id'] != 0) |
|
246 | 255 | echo ' |
247 | 256 | <option value="', $cat['id'], '">', $cat['true_name'], '</option>'; |
257 | + } |
|
248 | 258 | |
249 | 259 | echo ' |
250 | 260 | </select> |
@@ -288,9 +298,10 @@ discard block |
||
288 | 298 | </dt> |
289 | 299 | <dd> |
290 | 300 | <select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; |
291 | - foreach ($context['categories'] as $category) |
|
292 | - echo ' |
|
301 | + foreach ($context['categories'] as $category) { |
|
302 | + echo ' |
|
293 | 303 | <option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; |
304 | + } |
|
294 | 305 | echo ' |
295 | 306 | </select> |
296 | 307 | </dd>'; |
@@ -317,9 +328,10 @@ discard block |
||
317 | 328 | echo ' |
318 | 329 | <select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '> |
319 | 330 | ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; |
320 | - foreach ($context['board_order'] as $order) |
|
321 | - echo ' |
|
331 | + foreach ($context['board_order'] as $order) { |
|
332 | + echo ' |
|
322 | 333 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
334 | + } |
|
323 | 335 | echo ' |
324 | 336 | </select> |
325 | 337 | </dd>'; |
@@ -348,13 +360,15 @@ discard block |
||
348 | 360 | <dd> |
349 | 361 | <select name="profile">'; |
350 | 362 | |
351 | - if (isset($context['board']['is_new'])) |
|
352 | - echo ' |
|
363 | + if (isset($context['board']['is_new'])) { |
|
364 | + echo ' |
|
353 | 365 | <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; |
366 | + } |
|
354 | 367 | |
355 | - foreach ($context['profiles'] as $id => $profile) |
|
356 | - echo ' |
|
368 | + foreach ($context['profiles'] as $id => $profile) { |
|
369 | + echo ' |
|
357 | 370 | <option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
371 | + } |
|
358 | 372 | |
359 | 373 | echo ' |
360 | 374 | </select> |
@@ -367,8 +381,8 @@ discard block |
||
367 | 381 | </dt> |
368 | 382 | <dd>'; |
369 | 383 | |
370 | - if (!empty($modSettings['deny_boards_access'])) |
|
371 | - echo ' |
|
384 | + if (!empty($modSettings['deny_boards_access'])) { |
|
385 | + echo ' |
|
372 | 386 | <table> |
373 | 387 | <tr> |
374 | 388 | <td></td> |
@@ -376,10 +390,11 @@ discard block |
||
376 | 390 | <th>', $txt['permissions_option_off'], '</th> |
377 | 391 | <th>', $txt['permissions_option_deny'], '</th> |
378 | 392 | </tr>'; |
393 | + } |
|
379 | 394 | |
380 | 395 | // List all the membergroups so the user can choose who may access this board. |
381 | - foreach ($context['groups'] as $group) |
|
382 | - if (empty($modSettings['deny_boards_access'])) |
|
396 | + foreach ($context['groups'] as $group) { |
|
397 | + if (empty($modSettings['deny_boards_access'])) |
|
383 | 398 | echo ' |
384 | 399 | <label for="groups_', $group['id'], '"> |
385 | 400 | <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), ' class="input_check"> |
@@ -387,8 +402,9 @@ discard block |
||
387 | 402 | ', $group['name'], ' |
388 | 403 | </span> |
389 | 404 | </label><br>'; |
390 | - else |
|
391 | - echo ' |
|
405 | + } |
|
406 | + else { |
|
407 | + echo ' |
|
392 | 408 | <tr> |
393 | 409 | <td> |
394 | 410 | <label for="groups_', $group['id'], '_a"> |
@@ -408,16 +424,17 @@ discard block |
||
408 | 424 | </td> |
409 | 425 | <td></td> |
410 | 426 | </tr>'; |
427 | + } |
|
411 | 428 | |
412 | - if (empty($modSettings['deny_boards_access'])) |
|
413 | - echo ' |
|
429 | + if (empty($modSettings['deny_boards_access'])) { |
|
430 | + echo ' |
|
414 | 431 | <span class="select_all_box"> |
415 | 432 | <em>', $txt['check_all'], '</em> <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'groups[\');"> |
416 | 433 | </span> |
417 | 434 | <br><br> |
418 | 435 | </dd>'; |
419 | - else |
|
420 | - echo ' |
|
436 | + } else { |
|
437 | + echo ' |
|
421 | 438 | <tr class="select_all_box"> |
422 | 439 | <td> |
423 | 440 | </td> |
@@ -436,6 +453,7 @@ discard block |
||
436 | 453 | </tr> |
437 | 454 | </table> |
438 | 455 | </dd>'; |
456 | + } |
|
439 | 457 | |
440 | 458 | // Options to choose moderators, specify as announcement board and choose whether to count posts here. |
441 | 459 | echo ' |
@@ -490,8 +508,8 @@ discard block |
||
490 | 508 | </dl> |
491 | 509 | </div>'; |
492 | 510 | |
493 | - if ($context['board']['redirect']) |
|
494 | - echo ' |
|
511 | + if ($context['board']['redirect']) { |
|
512 | + echo ' |
|
495 | 513 | <div id="reset_redirect_div"> |
496 | 514 | <dl class="settings"> |
497 | 515 | <dt> |
@@ -504,6 +522,7 @@ discard block |
||
504 | 522 | </dd> |
505 | 523 | </dl> |
506 | 524 | </div>'; |
525 | + } |
|
507 | 526 | } |
508 | 527 | |
509 | 528 | echo ' |
@@ -531,9 +550,10 @@ discard block |
||
531 | 550 | <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> |
532 | 551 | <option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>'; |
533 | 552 | |
534 | - foreach ($context['themes'] as $theme) |
|
535 | - echo ' |
|
553 | + foreach ($context['themes'] as $theme) { |
|
554 | + echo ' |
|
536 | 555 | <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
556 | + } |
|
537 | 557 | |
538 | 558 | echo ' |
539 | 559 | </select> |
@@ -562,14 +582,15 @@ discard block |
||
562 | 582 | |
563 | 583 | foreach ($context['custom_board_settings'] as $cbs_id => $cbs) |
564 | 584 | { |
565 | - if (!empty($cbs['dt']) && !empty($cbs['dd'])) |
|
566 | - echo ' |
|
585 | + if (!empty($cbs['dt']) && !empty($cbs['dd'])) { |
|
586 | + echo ' |
|
567 | 587 | <dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '"> |
568 | 588 | ', $cbs['dt'], ' |
569 | 589 | </dt> |
570 | 590 | <dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '> |
571 | 591 | ', $cbs['dd'], ' |
572 | 592 | </dd>'; |
593 | + } |
|
573 | 594 | } |
574 | 595 | |
575 | 596 | echo ' |
@@ -577,9 +598,10 @@ discard block |
||
577 | 598 | </div>'; |
578 | 599 | } |
579 | 600 | |
580 | - if (!empty($context['board']['is_recycle'])) |
|
581 | - echo ' |
|
601 | + if (!empty($context['board']['is_recycle'])) { |
|
602 | + echo ' |
|
582 | 603 | <div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>'; |
604 | + } |
|
583 | 605 | |
584 | 606 | echo ' |
585 | 607 | <input type="hidden" name="rid" value="', $context['redirect_location'], '"> |
@@ -587,21 +609,24 @@ discard block |
||
587 | 609 | <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">'; |
588 | 610 | |
589 | 611 | // If this board has no children don't bother with the next confirmation screen. |
590 | - if ($context['board']['no_children']) |
|
591 | - echo ' |
|
612 | + if ($context['board']['no_children']) { |
|
613 | + echo ' |
|
592 | 614 | <input type="hidden" name="no_children" value="1">'; |
615 | + } |
|
593 | 616 | |
594 | - if (isset($context['board']['is_new'])) |
|
595 | - echo ' |
|
617 | + if (isset($context['board']['is_new'])) { |
|
618 | + echo ' |
|
596 | 619 | <input type="hidden" name="cur_cat" value="', $context['board']['category'], '"> |
597 | 620 | <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">'; |
598 | - else |
|
599 | - echo ' |
|
621 | + } else { |
|
622 | + echo ' |
|
600 | 623 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">'; |
624 | + } |
|
601 | 625 | |
602 | - if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) |
|
603 | - echo ' |
|
626 | + if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { |
|
627 | + echo ' |
|
604 | 628 | <input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button_submit you_sure">'; |
629 | + } |
|
605 | 630 | echo ' |
606 | 631 | </div> |
607 | 632 | </form> |
@@ -622,12 +647,13 @@ discard block |
||
622 | 647 | sItemListContainerId: \'moderator_container\', |
623 | 648 | aListItems: ['; |
624 | 649 | |
625 | - foreach ($context['board']['moderators'] as $id_member => $member_name) |
|
626 | - echo ' |
|
650 | + foreach ($context['board']['moderators'] as $id_member => $member_name) { |
|
651 | + echo ' |
|
627 | 652 | { |
628 | 653 | sItemId: ', JavaScriptEscape($id_member), ', |
629 | 654 | sItemName: ', JavaScriptEscape($member_name), ' |
630 | 655 | }', $id_member == $context['board']['last_moderator_id'] ? '' : ','; |
656 | + } |
|
631 | 657 | |
632 | 658 | echo ' |
633 | 659 | ] |
@@ -647,12 +673,13 @@ discard block |
||
647 | 673 | sItemListContainerId: \'moderator_group_container\', |
648 | 674 | aListItems: ['; |
649 | 675 | |
650 | - foreach ($context['board']['moderator_groups'] as $id_group => $group_name) |
|
651 | - echo ' |
|
676 | + foreach ($context['board']['moderator_groups'] as $id_group => $group_name) { |
|
677 | + echo ' |
|
652 | 678 | { |
653 | 679 | sItemId: ', JavaScriptEscape($id_group), ', |
654 | 680 | sItemName: ', JavaScriptEscape($group_name), ' |
655 | 681 | }', $id_group == $context['board']['last_moderator_group_id'] ? '' : ','; |
682 | + } |
|
656 | 683 | |
657 | 684 | echo ' |
658 | 685 | ] |
@@ -678,17 +705,19 @@ discard block |
||
678 | 705 | echo ' |
679 | 706 | document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";'; |
680 | 707 | |
681 | - if ($context['board']['redirect']) |
|
682 | - echo ' |
|
708 | + if ($context['board']['redirect']) { |
|
709 | + echo ' |
|
683 | 710 | document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";'; |
711 | + } |
|
684 | 712 | } |
685 | 713 | |
686 | 714 | // Include any JavaScript added by mods using the 'integrate_edit_board' hook. |
687 | 715 | if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions'])) |
688 | 716 | { |
689 | - foreach ($context['custom_refreshOptions'] as $refreshOption) |
|
690 | - echo ' |
|
717 | + foreach ($context['custom_refreshOptions'] as $refreshOption) { |
|
718 | + echo ' |
|
691 | 719 | ', $refreshOption; |
720 | + } |
|
692 | 721 | } |
693 | 722 | |
694 | 723 | echo ' |
@@ -717,9 +746,10 @@ discard block |
||
717 | 746 | <p>', $txt['mboards_delete_board_contains'], '</p> |
718 | 747 | <ul>'; |
719 | 748 | |
720 | - foreach ($context['children'] as $child) |
|
721 | - echo ' |
|
749 | + foreach ($context['children'] as $child) { |
|
750 | + echo ' |
|
722 | 751 | <li>', $child['node']['name'], '</li>'; |
752 | + } |
|
723 | 753 | |
724 | 754 | echo ' |
725 | 755 | </ul> |
@@ -733,10 +763,11 @@ discard block |
||
733 | 763 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>: |
734 | 764 | <select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>'; |
735 | 765 | |
736 | - foreach ($context['board_order'] as $board) |
|
737 | - if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
766 | + foreach ($context['board_order'] as $board) { |
|
767 | + if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
738 | 768 | echo ' |
739 | 769 | <option value="', $board['id'], '">', $board['name'], '</option>'; |
770 | + } |
|
740 | 771 | |
741 | 772 | echo ' |
742 | 773 | </select> |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | </div> |
417 | 417 | <div class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div> |
418 | 418 | <div class="attach-ui"> |
419 | - <a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'] ,'</a> |
|
420 | - <a class="button_submit upload">', $txt['upload'] ,'</a> |
|
419 | + <a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'], '</a> |
|
420 | + <a class="button_submit upload">', $txt['upload'], '</a> |
|
421 | 421 | </div> |
422 | 422 | </div> |
423 | 423 | </div> |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | </dt> |
436 | 436 | <dd class="smalltext fallback"> |
437 | 437 | <div id="attachUpload" class="descbox"> |
438 | - <h5>', $txt['attach_drop_zone'] ,'</h5> |
|
439 | - <a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a> |
|
440 | - <a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a> |
|
441 | - <a class="button_submit fileinput-button">', $txt['attach_add'] ,'</a> |
|
438 | + <h5>', $txt['attach_drop_zone'], '</h5> |
|
439 | + <a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a> |
|
440 | + <a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a> |
|
441 | + <a class="button_submit fileinput-button">', $txt['attach_add'], '</a> |
|
442 | 442 | <div id="total-progress" class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div> |
443 | 443 | <div class="fallback"> |
444 | 444 | <input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="input_file fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>) |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | // Option to delete an event if user is editing one. |
546 | 546 | if ($context['make_event'] && !$context['event']['new']) |
547 | 547 | echo ' |
548 | - <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">'; |
|
548 | + <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button_submit you_sure">'; |
|
549 | 549 | |
550 | 550 | echo ' |
551 | 551 | </span> |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | });'; |
800 | 800 | |
801 | 801 | echo ' |
802 | - var oEditorID = "', $context['post_box_name'] ,'"; |
|
802 | + var oEditorID = "', $context['post_box_name'], '"; |
|
803 | 803 | var oEditorObject = oEditorHandle_', $context['post_box_name'], '; |
804 | 804 | </script>'; |
805 | 805 | |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | { |
832 | 832 | echo ' |
833 | 833 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
834 | - <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
|
834 | + <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li> |
|
835 | 835 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
836 | 836 | </ul>'; |
837 | 837 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | <head> |
919 | 919 | <meta charset="', $context['character_set'], '"> |
920 | 920 | <title>', $txt['spell_check'], '</title> |
921 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
921 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
922 | 922 | <style> |
923 | 923 | body, td |
924 | 924 | { |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | var spell_formname = window.opener.spell_formname; |
952 | 952 | var spell_fieldname = window.opener.spell_fieldname; |
953 | 953 | </script> |
954 | - <script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script> |
|
955 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
954 | + <script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script> |
|
955 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
956 | 956 | <script> |
957 | 957 | ', $context['spell_js'], ' |
958 | 958 | </script> |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | <head> |
995 | 995 | <meta charset="', $context['character_set'], '"> |
996 | 996 | <title>', $txt['retrieving_quote'], '</title> |
997 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
997 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
998 | 998 | </head> |
999 | 999 | <body> |
1000 | 1000 | ', $txt['retrieving_quote'], ' |
@@ -22,22 +22,24 @@ discard block |
||
22 | 22 | <script>'; |
23 | 23 | |
24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
25 | - if (isBrowser('is_firefox')) |
|
26 | - echo ' |
|
25 | + if (isBrowser('is_firefox')) { |
|
26 | + echo ' |
|
27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
28 | + } |
|
28 | 29 | |
29 | 30 | // Start with message icons - and any missing from this theme. |
30 | 31 | echo ' |
31 | 32 | var icon_urls = {'; |
32 | - foreach ($context['icons'] as $icon) |
|
33 | - echo ' |
|
33 | + foreach ($context['icons'] as $icon) { |
|
34 | + echo ' |
|
34 | 35 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
36 | + } |
|
35 | 37 | echo ' |
36 | 38 | };'; |
37 | 39 | |
38 | 40 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
39 | - if ($context['make_poll']) |
|
40 | - echo ' |
|
41 | + if ($context['make_poll']) { |
|
42 | + echo ' |
|
41 | 43 | var pollOptionNum = 0, pollTabIndex; |
42 | 44 | var pollOptionId = ', $context['last_choice_id'], '; |
43 | 45 | function addPollOption() |
@@ -56,11 +58,13 @@ discard block |
||
56 | 58 | |
57 | 59 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text"></dd><p id="pollMoreOptions"></p>'), '); |
58 | 60 | }'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
61 | - if ($context['make_event']) |
|
62 | - echo ' |
|
64 | + if ($context['make_event']) { |
|
65 | + echo ' |
|
63 | 66 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
67 | + } |
|
64 | 68 | |
65 | 69 | // End of the javascript, start the form and display the link tree. |
66 | 70 | echo ' |
@@ -80,9 +84,10 @@ discard block |
||
80 | 84 | </div> |
81 | 85 | </div><br>'; |
82 | 86 | |
83 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
84 | - echo ' |
|
87 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
88 | + echo ' |
|
85 | 89 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
90 | + } |
|
86 | 91 | |
87 | 92 | // Start the main table. |
88 | 93 | echo ' |
@@ -117,18 +122,20 @@ discard block |
||
117 | 122 | } |
118 | 123 | |
119 | 124 | // If it's locked, show a message to warn the replier. |
120 | - if (!empty($context['locked'])) |
|
121 | - echo ' |
|
125 | + if (!empty($context['locked'])) { |
|
126 | + echo ' |
|
122 | 127 | <p class="errorbox"> |
123 | 128 | ', $txt['topic_locked_no_reply'], ' |
124 | 129 | </p>'; |
130 | + } |
|
125 | 131 | |
126 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
127 | - echo ' |
|
132 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
133 | + echo ' |
|
128 | 134 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
129 | 135 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
130 | 136 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
131 | 137 | </div>'; |
138 | + } |
|
132 | 139 | |
133 | 140 | // The post header... important stuff |
134 | 141 | echo ' |
@@ -180,9 +187,10 @@ discard block |
||
180 | 187 | { |
181 | 188 | echo ' |
182 | 189 | <optgroup label="', $category['name'], '">'; |
183 | - foreach ($category['boards'] as $board) |
|
184 | - echo ' |
|
190 | + foreach ($category['boards'] as $board) { |
|
191 | + echo ' |
|
185 | 192 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
193 | + } |
|
186 | 194 | echo ' |
187 | 195 | </optgroup>'; |
188 | 196 | } |
@@ -218,9 +226,10 @@ discard block |
||
218 | 226 | <span class="label">', $txt['calendar_timezone'], '</span> |
219 | 227 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
220 | 228 | |
221 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
222 | - echo ' |
|
229 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
230 | + echo ' |
|
223 | 231 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | echo ' |
226 | 235 | </select> |
@@ -286,14 +295,15 @@ discard block |
||
286 | 295 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', ' class="input_check"> |
287 | 296 | </dd>'; |
288 | 297 | |
289 | - if ($context['poll_options']['guest_vote_enabled']) |
|
290 | - echo ' |
|
298 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
299 | + echo ' |
|
291 | 300 | <dt> |
292 | 301 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
293 | 302 | </dt> |
294 | 303 | <dd> |
295 | 304 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', ' class="input_check"> |
296 | 305 | </dd>'; |
306 | + } |
|
297 | 307 | |
298 | 308 | echo ' |
299 | 309 | <dt> |
@@ -314,8 +324,8 @@ discard block |
||
314 | 324 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
315 | 325 | |
316 | 326 | // If we're editing and displaying edit details, show a box where they can say why |
317 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
318 | - echo ' |
|
327 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
328 | + echo ' |
|
319 | 329 | <dl> |
320 | 330 | <dt class="clear"> |
321 | 331 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -324,20 +334,23 @@ discard block |
||
324 | 334 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text"> |
325 | 335 | </dd> |
326 | 336 | </dl>'; |
337 | + } |
|
327 | 338 | |
328 | 339 | // If this message has been edited in the past - display when it was. |
329 | - if (isset($context['last_modified'])) |
|
330 | - echo ' |
|
340 | + if (isset($context['last_modified'])) { |
|
341 | + echo ' |
|
331 | 342 | <div class="padding smalltext"> |
332 | 343 | ', $context['last_modified_text'], ' |
333 | 344 | </div>'; |
345 | + } |
|
334 | 346 | |
335 | 347 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
336 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
337 | - echo ' |
|
348 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
349 | + echo ' |
|
338 | 350 | <div id="postAdditionalOptionsHeader"> |
339 | 351 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
340 | 352 | </div>'; |
353 | + } |
|
341 | 354 | |
342 | 355 | echo ' |
343 | 356 | <div id="postAdditionalOptions">'; |
@@ -369,19 +382,21 @@ discard block |
||
369 | 382 | <input type="hidden" name="attach_del[]" value="0"> |
370 | 383 | ', $txt['uncheck_unwatchd_attach'], ': |
371 | 384 | </dd>'; |
372 | - foreach ($context['current_attachments'] as $attachment) |
|
373 | - echo ' |
|
385 | + foreach ($context['current_attachments'] as $attachment) { |
|
386 | + echo ' |
|
374 | 387 | <dd class="smalltext"> |
375 | 388 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', ' class="input_check"> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
376 | 389 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label> |
377 | 390 | </dd>'; |
391 | + } |
|
378 | 392 | |
379 | 393 | echo ' |
380 | 394 | </dl>'; |
381 | 395 | |
382 | - if (!empty($context['files_in_session_warning'])) |
|
383 | - echo ' |
|
396 | + if (!empty($context['files_in_session_warning'])) { |
|
397 | + echo ' |
|
384 | 398 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
399 | + } |
|
385 | 400 | } |
386 | 401 | |
387 | 402 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -445,8 +460,8 @@ discard block |
||
445 | 460 | ', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '">'); |
446 | 461 | |
447 | 462 | // Show more boxes if they aren't approaching that limit. |
448 | - if ($context['num_allowed_attachments'] > 1) |
|
449 | - echo ' |
|
463 | + if ($context['num_allowed_attachments'] > 1) { |
|
464 | + echo ' |
|
450 | 465 | <script> |
451 | 466 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
452 | 467 | var current_attachment = 1; |
@@ -467,9 +482,10 @@ discard block |
||
467 | 482 | </div> |
468 | 483 | </div> |
469 | 484 | </dd>'; |
470 | - else |
|
471 | - echo ' |
|
485 | + } else { |
|
486 | + echo ' |
|
472 | 487 | </dd>'; |
488 | + } |
|
473 | 489 | |
474 | 490 | // Add any template changes for an alternative upload system here. |
475 | 491 | call_integration_hook('integrate_upload_template'); |
@@ -478,21 +494,25 @@ discard block |
||
478 | 494 | <dd class="smalltext">'; |
479 | 495 | |
480 | 496 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
481 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
482 | - echo ' |
|
497 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
498 | + echo ' |
|
483 | 499 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
500 | + } |
|
484 | 501 | |
485 | - if (!empty($context['attachment_restrictions'])) |
|
486 | - echo ' |
|
502 | + if (!empty($context['attachment_restrictions'])) { |
|
503 | + echo ' |
|
487 | 504 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
505 | + } |
|
488 | 506 | |
489 | - if ($context['num_allowed_attachments'] == 0) |
|
490 | - echo ' |
|
507 | + if ($context['num_allowed_attachments'] == 0) { |
|
508 | + echo ' |
|
491 | 509 | ', $txt['attach_limit_nag'], '<br>'; |
510 | + } |
|
492 | 511 | |
493 | - if (!$context['can_post_attachment_unapproved']) |
|
494 | - echo ' |
|
512 | + if (!$context['can_post_attachment_unapproved']) { |
|
513 | + echo ' |
|
495 | 514 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
515 | + } |
|
496 | 516 | |
497 | 517 | echo ' |
498 | 518 | </dd> |
@@ -515,10 +535,11 @@ discard block |
||
515 | 535 | <dt><strong>', $txt['subject'], '</strong></dt> |
516 | 536 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
517 | 537 | |
518 | - foreach ($context['drafts'] as $draft) |
|
519 | - echo ' |
|
538 | + foreach ($context['drafts'] as $draft) { |
|
539 | + echo ' |
|
520 | 540 | <dt>', $draft['link'], '</dt> |
521 | 541 | <dd>', $draft['poster_time'], '</dd>'; |
542 | + } |
|
522 | 543 | echo ' |
523 | 544 | </dl> |
524 | 545 | </div>'; |
@@ -543,9 +564,10 @@ discard block |
||
543 | 564 | ', template_control_richedit_buttons($context['post_box_name']); |
544 | 565 | |
545 | 566 | // Option to delete an event if user is editing one. |
546 | - if ($context['make_event'] && !$context['event']['new']) |
|
547 | - echo ' |
|
567 | + if ($context['make_event'] && !$context['event']['new']) { |
|
568 | + echo ' |
|
548 | 569 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | </span> |
@@ -554,9 +576,10 @@ discard block |
||
554 | 576 | <br class="clear">'; |
555 | 577 | |
556 | 578 | // Assuming this isn't a new topic pass across the last message id. |
557 | - if (isset($context['topic_last_message'])) |
|
558 | - echo ' |
|
579 | + if (isset($context['topic_last_message'])) { |
|
580 | + echo ' |
|
559 | 581 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
582 | + } |
|
560 | 583 | |
561 | 584 | echo ' |
562 | 585 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -698,9 +721,10 @@ discard block |
||
698 | 721 | |
699 | 722 | newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">« <strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \' »</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';'; |
700 | 723 | |
701 | - if ($context['can_quote']) |
|
702 | - echo ' |
|
724 | + if ($context['can_quote']) { |
|
725 | + echo ' |
|
703 | 726 | newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';'; |
727 | + } |
|
704 | 728 | |
705 | 729 | echo ' |
706 | 730 | newPostsHTML += \'<br class="clear">\'; |
@@ -743,8 +767,8 @@ discard block |
||
743 | 767 | }'; |
744 | 768 | |
745 | 769 | // Code for showing and hiding additional options. |
746 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
747 | - echo ' |
|
770 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
771 | + echo ' |
|
748 | 772 | var oSwapAdditionalOptions = new smc_Toggle({ |
749 | 773 | bToggleEnabled: true, |
750 | 774 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -772,10 +796,11 @@ discard block |
||
772 | 796 | } |
773 | 797 | ] |
774 | 798 | });'; |
799 | + } |
|
775 | 800 | |
776 | 801 | // Code for showing and hiding drafts |
777 | - if (!empty($context['drafts'])) |
|
778 | - echo ' |
|
802 | + if (!empty($context['drafts'])) { |
|
803 | + echo ' |
|
779 | 804 | var oSwapDraftOptions = new smc_Toggle({ |
780 | 805 | bToggleEnabled: true, |
781 | 806 | bCurrentlyCollapsed: true, |
@@ -797,6 +822,7 @@ discard block |
||
797 | 822 | } |
798 | 823 | ] |
799 | 824 | });'; |
825 | + } |
|
800 | 826 | |
801 | 827 | echo ' |
802 | 828 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -817,8 +843,9 @@ discard block |
||
817 | 843 | foreach ($context['previous_posts'] as $post) |
818 | 844 | { |
819 | 845 | $ignoring = false; |
820 | - if (!empty($post['is_ignored'])) |
|
821 | - $ignored_posts[] = $ignoring = $post['id']; |
|
846 | + if (!empty($post['is_ignored'])) { |
|
847 | + $ignored_posts[] = $ignoring = $post['id']; |
|
848 | + } |
|
822 | 849 | |
823 | 850 | echo ' |
824 | 851 | <div class="windowbg"> |
@@ -1001,10 +1028,10 @@ discard block |
||
1001 | 1028 | <div id="temporary_posting_area" style="display: none;"></div> |
1002 | 1029 | <script>'; |
1003 | 1030 | |
1004 | - if ($context['close_window']) |
|
1005 | - echo ' |
|
1031 | + if ($context['close_window']) { |
|
1032 | + echo ' |
|
1006 | 1033 | window.close();'; |
1007 | - else |
|
1034 | + } else |
|
1008 | 1035 | { |
1009 | 1036 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;). |
1010 | 1037 | echo ' |
@@ -1058,11 +1085,12 @@ discard block |
||
1058 | 1085 | </p> |
1059 | 1086 | <ul>'; |
1060 | 1087 | |
1061 | - foreach ($context['groups'] as $group) |
|
1062 | - echo ' |
|
1088 | + foreach ($context['groups'] as $group) { |
|
1089 | + echo ' |
|
1063 | 1090 | <li> |
1064 | 1091 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
1065 | 1092 | </li>'; |
1093 | + } |
|
1066 | 1094 | |
1067 | 1095 | echo ' |
1068 | 1096 | <li> |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | |
1611 | 1611 | // Our custom error handler - does nothing but does stop public errors from XML! |
1612 | 1612 | set_error_handler( |
1613 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1613 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1614 | 1614 | { |
1615 | 1615 | if ($support_js) |
1616 | 1616 | return true; |
@@ -2595,94 +2595,94 @@ discard block |
||
2595 | 2595 | // Translation table for the character sets not native for MySQL. |
2596 | 2596 | $translation_tables = array( |
2597 | 2597 | 'windows-1255' => array( |
2598 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2599 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2600 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2601 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2602 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2603 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2604 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2605 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2606 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2607 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2608 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2609 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2610 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2611 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2612 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2613 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2614 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2615 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2616 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2617 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2618 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2619 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2620 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2621 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2622 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2623 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2624 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2625 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2626 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2627 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2628 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2629 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2630 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2631 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2632 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2633 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2634 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2635 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2636 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2637 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2638 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2639 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2598 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2599 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2600 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2601 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2602 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2603 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2604 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2605 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2606 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2607 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2608 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2609 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2610 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2611 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2612 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2613 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2614 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2615 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2616 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2617 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2618 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2619 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2620 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2621 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2622 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2623 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2624 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2625 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2626 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2627 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2628 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2629 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2630 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2631 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2632 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2633 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2634 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2635 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2636 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2637 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2638 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2639 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2640 | 2640 | '0xFA' => '0xD7AA', |
2641 | 2641 | ), |
2642 | 2642 | 'windows-1253' => array( |
2643 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2644 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2645 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2646 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2647 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2648 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2649 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2650 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2651 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2652 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2653 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2654 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2655 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2656 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2657 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2658 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2659 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2660 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2661 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2662 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2663 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2664 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2665 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2666 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2667 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2668 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2669 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2670 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2671 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2672 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2673 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2674 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2675 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2676 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2677 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2678 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2679 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2680 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2681 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2682 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2683 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2684 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2685 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2643 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2644 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2645 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2646 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2647 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2648 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2649 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2650 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2651 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2652 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2653 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2654 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2655 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2656 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2657 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2658 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2659 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2660 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2661 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2662 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2663 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2664 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2665 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2666 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2667 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2668 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2669 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2670 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2671 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2672 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2673 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2674 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2675 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2676 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2677 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2678 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2679 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2680 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2681 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2682 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2683 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2684 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2685 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2686 | 2686 | ), |
2687 | 2687 | ); |
2688 | 2688 | |
@@ -3781,7 +3781,7 @@ discard block |
||
3781 | 3781 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
3782 | 3782 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
3783 | 3783 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
3784 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
3784 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
3785 | 3785 | <span id="debuginfo"></span> |
3786 | 3786 | </div>'; |
3787 | 3787 | |
@@ -4282,7 +4282,7 @@ discard block |
||
4282 | 4282 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4283 | 4283 | <input type="hidden" name="utf8_done" id="utf8_done" value="0"> |
4284 | 4284 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
4285 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
4285 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
4286 | 4286 | <span id="debuginfo"></span> |
4287 | 4287 | </div>'; |
4288 | 4288 | |
@@ -4379,7 +4379,7 @@ discard block |
||
4379 | 4379 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4380 | 4380 | <input type="hidden" name="json_done" id="json_done" value="0"> |
4381 | 4381 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
4382 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
4382 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
4383 | 4383 | <span id="debuginfo"></span> |
4384 | 4384 | </div>'; |
4385 | 4385 |
@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | $upcontext['inactive_timeout'] = 10; |
76 | 76 | |
77 | 77 | // The helper is crucial. Include it first thing. |
78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
80 | +} |
|
80 | 81 | |
81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
100 | 101 | ini_set('default_socket_timeout', 900); |
101 | 102 | } |
102 | 103 | // Clean the upgrade path if this is from the client. |
103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
105 | + for ($i = 1; |
|
106 | +} |
|
107 | +$i < $_SERVER['argc']; $i++) |
|
105 | 108 | { |
106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
111 | + } |
|
108 | 112 | } |
109 | 113 | |
110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
112 | 116 | { |
113 | 117 | $command_line = true; |
114 | 118 | $disable_security = true; |
115 | -} |
|
116 | -else |
|
119 | +} else { |
|
117 | 120 | $command_line = false; |
121 | +} |
|
118 | 122 | |
119 | 123 | // Load this now just because we can. |
120 | 124 | require_once($upgrade_path . '/Settings.php'); |
121 | 125 | |
122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
123 | -if (isset($language)) |
|
127 | +if (isset($language)) { |
|
124 | 128 | $language = str_ireplace('-utf8', '', $language); |
129 | +} |
|
125 | 130 | |
126 | 131 | // Are we logged in? |
127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
130 | 135 | |
131 | 136 | // Check for sensible values. |
132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
133 | - $upcontext['user']['started'] = time(); |
|
134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
135 | - $upcontext['user']['updated'] = 0; |
|
137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
138 | + $upcontext['user']['started'] = time(); |
|
139 | + } |
|
140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
141 | + $upcontext['user']['updated'] = 0; |
|
142 | + } |
|
136 | 143 | |
137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
190 | 197 | 'db_error_skip' => true, |
191 | 198 | ) |
192 | 199 | ); |
193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
194 | - $modSettings[$row['variable']] = $row['value']; |
|
200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
201 | + $modSettings[$row['variable']] = $row['value']; |
|
202 | + } |
|
195 | 203 | $smcFunc['db_free_result']($request); |
196 | 204 | } |
197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
203 | 211 | } |
204 | -if (!isset($settings['default_theme_url'])) |
|
212 | +if (!isset($settings['default_theme_url'])) { |
|
205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
206 | -if (!isset($settings['default_theme_dir'])) |
|
214 | +} |
|
215 | +if (!isset($settings['default_theme_dir'])) { |
|
207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
217 | +} |
|
208 | 218 | |
209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
223 | 233 | |
224 | 234 | // Only set this if the upgrader status says so. |
225 | - if (empty($is_debug)) |
|
226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
235 | + if (empty($is_debug)) { |
|
236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
237 | + } |
|
227 | 238 | |
228 | 239 | // Load the language. |
229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
231 | -} |
|
240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
242 | + } |
|
243 | + } |
|
232 | 244 | // Set the defaults. |
233 | 245 | else |
234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
246 | 258 | } |
247 | 259 | |
248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
250 | 262 | checkLogin(); |
263 | +} |
|
251 | 264 | |
252 | -if ($command_line) |
|
265 | +if ($command_line) { |
|
253 | 266 | cmdStep0(); |
267 | +} |
|
254 | 268 | |
255 | 269 | // Don't error if we're using xml. |
256 | -if (isset($_GET['xml'])) |
|
270 | +if (isset($_GET['xml'])) { |
|
257 | 271 | $upcontext['return_error'] = true; |
272 | +} |
|
258 | 273 | |
259 | 274 | // Loop through all the steps doing each one as required. |
260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
275 | 290 | } |
276 | 291 | |
277 | 292 | // Call the step and if it returns false that means pause! |
278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
279 | - break; |
|
280 | - elseif (function_exists($step[2])) { |
|
293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
294 | + break; |
|
295 | + } elseif (function_exists($step[2])) { |
|
281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
282 | 297 | unset($_GET['xml']); |
283 | 298 | $_GET['substep'] = 0; |
@@ -321,17 +336,18 @@ discard block |
||
321 | 336 | // This should not happen my dear... HELP ME DEVELOPERS!! |
322 | 337 | if (!empty($command_line)) |
323 | 338 | { |
324 | - if (function_exists('debug_print_backtrace')) |
|
325 | - debug_print_backtrace(); |
|
339 | + if (function_exists('debug_print_backtrace')) { |
|
340 | + debug_print_backtrace(); |
|
341 | + } |
|
326 | 342 | |
327 | 343 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
328 | 344 | flush(); |
329 | 345 | die(); |
330 | 346 | } |
331 | 347 | |
332 | - if (!isset($_GET['xml'])) |
|
333 | - template_upgrade_above(); |
|
334 | - else |
|
348 | + if (!isset($_GET['xml'])) { |
|
349 | + template_upgrade_above(); |
|
350 | + } else |
|
335 | 351 | { |
336 | 352 | header('Content-Type: text/xml; charset=UTF-8'); |
337 | 353 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -353,25 +369,29 @@ discard block |
||
353 | 369 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
354 | 370 | |
355 | 371 | // Custom stuff to pass back? |
356 | - if (!empty($upcontext['query_string'])) |
|
357 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
372 | + if (!empty($upcontext['query_string'])) { |
|
373 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
374 | + } |
|
358 | 375 | |
359 | 376 | // Call the appropriate subtemplate |
360 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
361 | - call_user_func('template_' . $upcontext['sub_template']); |
|
362 | - else |
|
363 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
377 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
378 | + call_user_func('template_' . $upcontext['sub_template']); |
|
379 | + } else { |
|
380 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
381 | + } |
|
364 | 382 | } |
365 | 383 | |
366 | 384 | // Was there an error? |
367 | - if (!empty($upcontext['forced_error_message'])) |
|
368 | - echo $upcontext['forced_error_message']; |
|
385 | + if (!empty($upcontext['forced_error_message'])) { |
|
386 | + echo $upcontext['forced_error_message']; |
|
387 | + } |
|
369 | 388 | |
370 | 389 | // Show the footer. |
371 | - if (!isset($_GET['xml'])) |
|
372 | - template_upgrade_below(); |
|
373 | - else |
|
374 | - template_xml_below(); |
|
390 | + if (!isset($_GET['xml'])) { |
|
391 | + template_upgrade_below(); |
|
392 | + } else { |
|
393 | + template_xml_below(); |
|
394 | + } |
|
375 | 395 | } |
376 | 396 | |
377 | 397 | |
@@ -383,15 +403,19 @@ discard block |
||
383 | 403 | $seconds = intval($active % 60); |
384 | 404 | |
385 | 405 | $totalTime = ''; |
386 | - if ($hours > 0) |
|
387 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
388 | - if ($minutes > 0) |
|
389 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
390 | - if ($seconds > 0) |
|
391 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
406 | + if ($hours > 0) { |
|
407 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
408 | + } |
|
409 | + if ($minutes > 0) { |
|
410 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
411 | + } |
|
412 | + if ($seconds > 0) { |
|
413 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
414 | + } |
|
392 | 415 | |
393 | - if (!empty($totalTime)) |
|
394 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
416 | + if (!empty($totalTime)) { |
|
417 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
418 | + } |
|
395 | 419 | } |
396 | 420 | |
397 | 421 | // Bang - gone! |
@@ -404,8 +428,9 @@ discard block |
||
404 | 428 | global $upgradeurl, $upcontext, $command_line; |
405 | 429 | |
406 | 430 | // Command line users can't be redirected. |
407 | - if ($command_line) |
|
408 | - upgradeExit(true); |
|
431 | + if ($command_line) { |
|
432 | + upgradeExit(true); |
|
433 | + } |
|
409 | 434 | |
410 | 435 | // Are we providing the core info? |
411 | 436 | if ($addForm) |
@@ -428,19 +453,22 @@ discard block |
||
428 | 453 | global $modSettings, $sourcedir, $smcFunc; |
429 | 454 | |
430 | 455 | // Do the non-SSI stuff... |
431 | - if (function_exists('set_magic_quotes_runtime')) |
|
432 | - @set_magic_quotes_runtime(0); |
|
456 | + if (function_exists('set_magic_quotes_runtime')) { |
|
457 | + @set_magic_quotes_runtime(0); |
|
458 | + } |
|
433 | 459 | |
434 | 460 | error_reporting(E_ALL); |
435 | 461 | define('SMF', 1); |
436 | 462 | |
437 | 463 | // Start the session. |
438 | - if (@ini_get('session.save_handler') == 'user') |
|
439 | - @ini_set('session.save_handler', 'files'); |
|
464 | + if (@ini_get('session.save_handler') == 'user') { |
|
465 | + @ini_set('session.save_handler', 'files'); |
|
466 | + } |
|
440 | 467 | @session_start(); |
441 | 468 | |
442 | - if (empty($smcFunc)) |
|
443 | - $smcFunc = array(); |
|
469 | + if (empty($smcFunc)) { |
|
470 | + $smcFunc = array(); |
|
471 | + } |
|
444 | 472 | |
445 | 473 | // We need this for authentication and some upgrade code |
446 | 474 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -452,32 +480,36 @@ discard block |
||
452 | 480 | initialize_inputs(); |
453 | 481 | |
454 | 482 | // Get the database going! |
455 | - if (empty($db_type) || $db_type == 'mysqli') |
|
456 | - $db_type = 'mysql'; |
|
483 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
484 | + $db_type = 'mysql'; |
|
485 | + } |
|
457 | 486 | |
458 | 487 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
459 | 488 | { |
460 | 489 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
461 | 490 | |
462 | 491 | // Make the connection... |
463 | - if (empty($db_connection)) |
|
464 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
465 | - else |
|
466 | - // If we've returned here, ping/reconnect to be safe |
|
492 | + if (empty($db_connection)) { |
|
493 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
494 | + } else { |
|
495 | + // If we've returned here, ping/reconnect to be safe |
|
467 | 496 | $smcFunc['db_ping']($db_connection); |
497 | + } |
|
468 | 498 | |
469 | 499 | // Oh dear god!! |
470 | - if ($db_connection === null) |
|
471 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
500 | + if ($db_connection === null) { |
|
501 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
502 | + } |
|
472 | 503 | |
473 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
474 | - $smcFunc['db_query']('', ' |
|
504 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
505 | + $smcFunc['db_query']('', ' |
|
475 | 506 | SET NAMES {string:db_character_set}', |
476 | 507 | array( |
477 | 508 | 'db_error_skip' => true, |
478 | 509 | 'db_character_set' => $db_character_set, |
479 | 510 | ) |
480 | 511 | ); |
512 | + } |
|
481 | 513 | |
482 | 514 | // Load the modSettings data... |
483 | 515 | $request = $smcFunc['db_query']('', ' |
@@ -488,11 +520,11 @@ discard block |
||
488 | 520 | ) |
489 | 521 | ); |
490 | 522 | $modSettings = array(); |
491 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
492 | - $modSettings[$row['variable']] = $row['value']; |
|
523 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
524 | + $modSettings[$row['variable']] = $row['value']; |
|
525 | + } |
|
493 | 526 | $smcFunc['db_free_result']($request); |
494 | - } |
|
495 | - else |
|
527 | + } else |
|
496 | 528 | { |
497 | 529 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
498 | 530 | } |
@@ -506,9 +538,10 @@ discard block |
||
506 | 538 | cleanRequest(); |
507 | 539 | } |
508 | 540 | |
509 | - if (!isset($_GET['substep'])) |
|
510 | - $_GET['substep'] = 0; |
|
511 | -} |
|
541 | + if (!isset($_GET['substep'])) { |
|
542 | + $_GET['substep'] = 0; |
|
543 | + } |
|
544 | + } |
|
512 | 545 | |
513 | 546 | function initialize_inputs() |
514 | 547 | { |
@@ -538,8 +571,9 @@ discard block |
||
538 | 571 | $dh = opendir(dirname(__FILE__)); |
539 | 572 | while ($file = readdir($dh)) |
540 | 573 | { |
541 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
542 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
574 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
575 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
576 | + } |
|
543 | 577 | } |
544 | 578 | closedir($dh); |
545 | 579 | |
@@ -568,8 +602,9 @@ discard block |
||
568 | 602 | $temp = 'upgrade_php?step'; |
569 | 603 | while (strlen($temp) > 4) |
570 | 604 | { |
571 | - if (isset($_GET[$temp])) |
|
572 | - unset($_GET[$temp]); |
|
605 | + if (isset($_GET[$temp])) { |
|
606 | + unset($_GET[$temp]); |
|
607 | + } |
|
573 | 608 | $temp = substr($temp, 1); |
574 | 609 | } |
575 | 610 | |
@@ -596,32 +631,39 @@ discard block |
||
596 | 631 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
597 | 632 | |
598 | 633 | // Need legacy scripts? |
599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
601 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
602 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
603 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
604 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
634 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
635 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
636 | + } |
|
637 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
638 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
639 | + } |
|
640 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
641 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
642 | + } |
|
605 | 643 | |
606 | 644 | // We don't need "-utf8" files anymore... |
607 | 645 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
608 | 646 | |
609 | 647 | // This needs to exist! |
610 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
611 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
612 | - else |
|
613 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
648 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
649 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
650 | + } else { |
|
651 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
652 | + } |
|
614 | 653 | |
615 | - if (!$check) |
|
616 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
654 | + if (!$check) { |
|
655 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
617 | 656 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
657 | + } |
|
618 | 658 | |
619 | 659 | // Do they meet the install requirements? |
620 | - if (!php_version_check()) |
|
621 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
660 | + if (!php_version_check()) { |
|
661 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
662 | + } |
|
622 | 663 | |
623 | - if (!db_version_check()) |
|
624 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
664 | + if (!db_version_check()) { |
|
665 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
666 | + } |
|
625 | 667 | |
626 | 668 | // Do some checks to make sure they have proper privileges |
627 | 669 | db_extend('packages'); |
@@ -636,14 +678,16 @@ discard block |
||
636 | 678 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
637 | 679 | |
638 | 680 | // Sorry... we need CREATE, ALTER and DROP |
639 | - if (!$create || !$alter || !$drop) |
|
640 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
681 | + if (!$create || !$alter || !$drop) { |
|
682 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
683 | + } |
|
641 | 684 | |
642 | 685 | // Do a quick version spot check. |
643 | 686 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
644 | 687 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
645 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
646 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
688 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
689 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
690 | + } |
|
647 | 691 | |
648 | 692 | // What absolutely needs to be writable? |
649 | 693 | $writable_files = array( |
@@ -665,12 +709,13 @@ discard block |
||
665 | 709 | quickFileWritable($custom_av_dir); |
666 | 710 | |
667 | 711 | // Are we good now? |
668 | - if (!is_writable($custom_av_dir)) |
|
669 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
670 | - elseif ($need_settings_update) |
|
712 | + if (!is_writable($custom_av_dir)) { |
|
713 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
714 | + } elseif ($need_settings_update) |
|
671 | 715 | { |
672 | - if (!function_exists('cache_put_data')) |
|
673 | - require_once($sourcedir . '/Load.php'); |
|
716 | + if (!function_exists('cache_put_data')) { |
|
717 | + require_once($sourcedir . '/Load.php'); |
|
718 | + } |
|
674 | 719 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
675 | 720 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
676 | 721 | } |
@@ -679,28 +724,33 @@ discard block |
||
679 | 724 | |
680 | 725 | // Check the cache directory. |
681 | 726 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
682 | - if (!file_exists($cachedir_temp)) |
|
683 | - @mkdir($cachedir_temp); |
|
684 | - if (!file_exists($cachedir_temp)) |
|
685 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
686 | - |
|
687 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
688 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
689 | - elseif (!isset($_GET['skiplang'])) |
|
727 | + if (!file_exists($cachedir_temp)) { |
|
728 | + @mkdir($cachedir_temp); |
|
729 | + } |
|
730 | + if (!file_exists($cachedir_temp)) { |
|
731 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
732 | + } |
|
733 | + |
|
734 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
735 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
736 | + } elseif (!isset($_GET['skiplang'])) |
|
690 | 737 | { |
691 | 738 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
692 | 739 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
693 | 740 | |
694 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
695 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
741 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
742 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
743 | + } |
|
696 | 744 | } |
697 | 745 | |
698 | - if (!makeFilesWritable($writable_files)) |
|
699 | - return false; |
|
746 | + if (!makeFilesWritable($writable_files)) { |
|
747 | + return false; |
|
748 | + } |
|
700 | 749 | |
701 | 750 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
702 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
703 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
751 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
752 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
753 | + } |
|
704 | 754 | |
705 | 755 | // Upgrade the agreement. |
706 | 756 | elseif (isset($modSettings['agreement'])) |
@@ -711,8 +761,8 @@ discard block |
||
711 | 761 | } |
712 | 762 | |
713 | 763 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
714 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
715 | - $upcontext['warning'] = ' |
|
764 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
765 | + $upcontext['warning'] = ' |
|
716 | 766 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
717 | 767 | <ul> |
718 | 768 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -720,10 +770,12 @@ discard block |
||
720 | 770 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
721 | 771 | </ul> |
722 | 772 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
773 | + } |
|
723 | 774 | |
724 | 775 | // Either we're logged in or we're going to present the login. |
725 | - if (checkLogin()) |
|
726 | - return true; |
|
776 | + if (checkLogin()) { |
|
777 | + return true; |
|
778 | + } |
|
727 | 779 | |
728 | 780 | $upcontext += createToken('login'); |
729 | 781 | |
@@ -737,15 +789,17 @@ discard block |
||
737 | 789 | global $smcFunc, $db_type, $support_js; |
738 | 790 | |
739 | 791 | // Don't bother if the security is disabled. |
740 | - if ($disable_security) |
|
741 | - return true; |
|
792 | + if ($disable_security) { |
|
793 | + return true; |
|
794 | + } |
|
742 | 795 | |
743 | 796 | // Are we trying to login? |
744 | 797 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
745 | 798 | { |
746 | 799 | // If we've disabled security pick a suitable name! |
747 | - if (empty($_POST['user'])) |
|
748 | - $_POST['user'] = 'Administrator'; |
|
800 | + if (empty($_POST['user'])) { |
|
801 | + $_POST['user'] = 'Administrator'; |
|
802 | + } |
|
749 | 803 | |
750 | 804 | // Before 2.0 these column names were different! |
751 | 805 | $oldDB = false; |
@@ -760,16 +814,17 @@ discard block |
||
760 | 814 | 'db_error_skip' => true, |
761 | 815 | ) |
762 | 816 | ); |
763 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
764 | - $oldDB = true; |
|
817 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
818 | + $oldDB = true; |
|
819 | + } |
|
765 | 820 | $smcFunc['db_free_result']($request); |
766 | 821 | } |
767 | 822 | |
768 | 823 | // Get what we believe to be their details. |
769 | 824 | if (!$disable_security) |
770 | 825 | { |
771 | - if ($oldDB) |
|
772 | - $request = $smcFunc['db_query']('', ' |
|
826 | + if ($oldDB) { |
|
827 | + $request = $smcFunc['db_query']('', ' |
|
773 | 828 | SELECT id_member, memberName AS member_name, passwd, id_group, |
774 | 829 | additionalGroups AS additional_groups, lngfile |
775 | 830 | FROM {db_prefix}members |
@@ -779,8 +834,8 @@ discard block |
||
779 | 834 | 'db_error_skip' => true, |
780 | 835 | ) |
781 | 836 | ); |
782 | - else |
|
783 | - $request = $smcFunc['db_query']('', ' |
|
837 | + } else { |
|
838 | + $request = $smcFunc['db_query']('', ' |
|
784 | 839 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
785 | 840 | FROM {db_prefix}members |
786 | 841 | WHERE member_name = {string:member_name}', |
@@ -789,6 +844,7 @@ discard block |
||
789 | 844 | 'db_error_skip' => true, |
790 | 845 | ) |
791 | 846 | ); |
847 | + } |
|
792 | 848 | if ($smcFunc['db_num_rows']($request) != 0) |
793 | 849 | { |
794 | 850 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -796,16 +852,17 @@ discard block |
||
796 | 852 | $groups = explode(',', $addGroups); |
797 | 853 | $groups[] = $id_group; |
798 | 854 | |
799 | - foreach ($groups as $k => $v) |
|
800 | - $groups[$k] = (int) $v; |
|
855 | + foreach ($groups as $k => $v) { |
|
856 | + $groups[$k] = (int) $v; |
|
857 | + } |
|
801 | 858 | |
802 | 859 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
803 | 860 | |
804 | 861 | // We don't use "-utf8" anymore... |
805 | 862 | $user_language = str_ireplace('-utf8', '', $user_language); |
863 | + } else { |
|
864 | + $upcontext['username_incorrect'] = true; |
|
806 | 865 | } |
807 | - else |
|
808 | - $upcontext['username_incorrect'] = true; |
|
809 | 866 | $smcFunc['db_free_result']($request); |
810 | 867 | } |
811 | 868 | $upcontext['username'] = $_POST['user']; |
@@ -815,13 +872,14 @@ discard block |
||
815 | 872 | { |
816 | 873 | $upcontext['upgrade_status']['js'] = 1; |
817 | 874 | $support_js = 1; |
875 | + } else { |
|
876 | + $support_js = 0; |
|
818 | 877 | } |
819 | - else |
|
820 | - $support_js = 0; |
|
821 | 878 | |
822 | 879 | // Note down the version we are coming from. |
823 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
824 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
880 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
881 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
882 | + } |
|
825 | 883 | |
826 | 884 | // Didn't get anywhere? |
827 | 885 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -855,15 +913,15 @@ discard block |
||
855 | 913 | 'db_error_skip' => true, |
856 | 914 | ) |
857 | 915 | ); |
858 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
859 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
916 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
917 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
918 | + } |
|
860 | 919 | $smcFunc['db_free_result']($request); |
861 | 920 | } |
862 | 921 | |
863 | 922 | $upcontext['user']['id'] = $id_member; |
864 | 923 | $upcontext['user']['name'] = $name; |
865 | - } |
|
866 | - else |
|
924 | + } else |
|
867 | 925 | { |
868 | 926 | $upcontext['user']['id'] = 1; |
869 | 927 | $upcontext['user']['name'] = 'Administrator'; |
@@ -879,11 +937,11 @@ discard block |
||
879 | 937 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
880 | 938 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
881 | 939 | |
882 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
883 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
884 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
885 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
886 | - else |
|
940 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
941 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
942 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
943 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
944 | + } else |
|
887 | 945 | { |
888 | 946 | // Set this as the new language. |
889 | 947 | $upcontext['language'] = $user_language; |
@@ -927,8 +985,9 @@ discard block |
||
927 | 985 | unset($member_columns); |
928 | 986 | |
929 | 987 | // If we've not submitted then we're done. |
930 | - if (empty($_POST['upcont'])) |
|
931 | - return false; |
|
988 | + if (empty($_POST['upcont'])) { |
|
989 | + return false; |
|
990 | + } |
|
932 | 991 | |
933 | 992 | // Firstly, if they're enabling SM stat collection just do it. |
934 | 993 | if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats'])) |
@@ -943,25 +1002,26 @@ discard block |
||
943 | 1002 | fwrite($fp, $out); |
944 | 1003 | |
945 | 1004 | $return_data = ''; |
946 | - while (!feof($fp)) |
|
947 | - $return_data .= fgets($fp, 128); |
|
1005 | + while (!feof($fp)) { |
|
1006 | + $return_data .= fgets($fp, 128); |
|
1007 | + } |
|
948 | 1008 | |
949 | 1009 | fclose($fp); |
950 | 1010 | |
951 | 1011 | // Get the unique site ID. |
952 | 1012 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
953 | 1013 | |
954 | - if (!empty($ID[1])) |
|
955 | - $smcFunc['db_insert']('replace', |
|
1014 | + if (!empty($ID[1])) { |
|
1015 | + $smcFunc['db_insert']('replace', |
|
956 | 1016 | $db_prefix . 'settings', |
957 | 1017 | array('variable' => 'string', 'value' => 'string'), |
958 | 1018 | array('allow_sm_stats', $ID[1]), |
959 | 1019 | array('variable') |
960 | 1020 | ); |
1021 | + } |
|
961 | 1022 | } |
962 | - } |
|
963 | - else |
|
964 | - $smcFunc['db_query']('', ' |
|
1023 | + } else { |
|
1024 | + $smcFunc['db_query']('', ' |
|
965 | 1025 | DELETE FROM {db_prefix}settings |
966 | 1026 | WHERE variable = {string:allow_sm_stats}', |
967 | 1027 | array( |
@@ -969,6 +1029,7 @@ discard block |
||
969 | 1029 | 'db_error_skip' => true, |
970 | 1030 | ) |
971 | 1031 | ); |
1032 | + } |
|
972 | 1033 | |
973 | 1034 | // Deleting old karma stuff? |
974 | 1035 | if (!empty($_POST['delete_karma'])) |
@@ -983,20 +1044,22 @@ discard block |
||
983 | 1044 | ); |
984 | 1045 | |
985 | 1046 | // Cleaning up old karma member settings. |
986 | - if ($upcontext['karma_installed']['good']) |
|
987 | - $smcFunc['db_query']('', ' |
|
1047 | + if ($upcontext['karma_installed']['good']) { |
|
1048 | + $smcFunc['db_query']('', ' |
|
988 | 1049 | ALTER TABLE {db_prefix}members |
989 | 1050 | DROP karma_good', |
990 | 1051 | array() |
991 | 1052 | ); |
1053 | + } |
|
992 | 1054 | |
993 | 1055 | // Does karma bad was enable? |
994 | - if ($upcontext['karma_installed']['bad']) |
|
995 | - $smcFunc['db_query']('', ' |
|
1056 | + if ($upcontext['karma_installed']['bad']) { |
|
1057 | + $smcFunc['db_query']('', ' |
|
996 | 1058 | ALTER TABLE {db_prefix}members |
997 | 1059 | DROP karma_bad', |
998 | 1060 | array() |
999 | 1061 | ); |
1062 | + } |
|
1000 | 1063 | |
1001 | 1064 | // Cleaning up old karma permissions. |
1002 | 1065 | $smcFunc['db_query']('', ' |
@@ -1009,26 +1072,29 @@ discard block |
||
1009 | 1072 | } |
1010 | 1073 | |
1011 | 1074 | // Emptying the error log? |
1012 | - if (!empty($_POST['empty_error'])) |
|
1013 | - $smcFunc['db_query']('truncate_table', ' |
|
1075 | + if (!empty($_POST['empty_error'])) { |
|
1076 | + $smcFunc['db_query']('truncate_table', ' |
|
1014 | 1077 | TRUNCATE {db_prefix}log_errors', |
1015 | 1078 | array( |
1016 | 1079 | ) |
1017 | 1080 | ); |
1081 | + } |
|
1018 | 1082 | |
1019 | 1083 | $changes = array(); |
1020 | 1084 | |
1021 | 1085 | // Add proxy settings. |
1022 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1023 | - $changes += array( |
|
1086 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1087 | + $changes += array( |
|
1024 | 1088 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1025 | 1089 | 'image_proxy_maxsize' => 5190, |
1026 | 1090 | 'image_proxy_enabled' => 0, |
1027 | 1091 | ); |
1092 | + } |
|
1028 | 1093 | |
1029 | 1094 | // If we're overriding the language follow it through. |
1030 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1031 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1095 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1096 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1097 | + } |
|
1032 | 1098 | |
1033 | 1099 | if (!empty($_POST['maint'])) |
1034 | 1100 | { |
@@ -1040,30 +1106,34 @@ discard block |
||
1040 | 1106 | { |
1041 | 1107 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1042 | 1108 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1043 | - } |
|
1044 | - else |
|
1109 | + } else |
|
1045 | 1110 | { |
1046 | 1111 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1047 | 1112 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1048 | 1113 | } |
1049 | 1114 | } |
1050 | 1115 | |
1051 | - if ($command_line) |
|
1052 | - echo ' * Updating Settings.php...'; |
|
1116 | + if ($command_line) { |
|
1117 | + echo ' * Updating Settings.php...'; |
|
1118 | + } |
|
1053 | 1119 | |
1054 | 1120 | // Fix some old paths. |
1055 | - if (substr($boarddir, 0, 1) == '.') |
|
1056 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1121 | + if (substr($boarddir, 0, 1) == '.') { |
|
1122 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1123 | + } |
|
1057 | 1124 | |
1058 | - if (substr($sourcedir, 0, 1) == '.') |
|
1059 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1125 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1126 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1127 | + } |
|
1060 | 1128 | |
1061 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1062 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1129 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1130 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1131 | + } |
|
1063 | 1132 | |
1064 | 1133 | // Not had the database type added before? |
1065 | - if (empty($db_type)) |
|
1066 | - $changes['db_type'] = 'mysql'; |
|
1134 | + if (empty($db_type)) { |
|
1135 | + $changes['db_type'] = 'mysql'; |
|
1136 | + } |
|
1067 | 1137 | |
1068 | 1138 | // If they have a "host:port" setup for the host, split that into separate values |
1069 | 1139 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1074,32 +1144,36 @@ discard block |
||
1074 | 1144 | $changes['db_server'] = '\'' . $db_server . '\''; |
1075 | 1145 | |
1076 | 1146 | // Only set this if we're not using the default port |
1077 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1078 | - $changes['db_port'] = (int) $db_port; |
|
1079 | - } |
|
1080 | - elseif (!empty($db_port)) |
|
1147 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1148 | + $changes['db_port'] = (int) $db_port; |
|
1149 | + } |
|
1150 | + } elseif (!empty($db_port)) |
|
1081 | 1151 | { |
1082 | 1152 | // If db_port is set and is the same as the default, set it to '' |
1083 | 1153 | if ($db_type == 'mysql') |
1084 | 1154 | { |
1085 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1086 | - $changes['db_port'] = '\'\''; |
|
1087 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1088 | - $changes['db_port'] = '\'\''; |
|
1155 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1156 | + $changes['db_port'] = '\'\''; |
|
1157 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1158 | + $changes['db_port'] = '\'\''; |
|
1159 | + } |
|
1089 | 1160 | } |
1090 | 1161 | } |
1091 | 1162 | |
1092 | 1163 | // Maybe we haven't had this option yet? |
1093 | - if (empty($packagesdir)) |
|
1094 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1164 | + if (empty($packagesdir)) { |
|
1165 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1166 | + } |
|
1095 | 1167 | |
1096 | 1168 | // Add support for $tasksdir var. |
1097 | - if (empty($tasksdir)) |
|
1098 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1169 | + if (empty($tasksdir)) { |
|
1170 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1171 | + } |
|
1099 | 1172 | |
1100 | 1173 | // Make sure we fix the language as well. |
1101 | - if (stristr($language, '-utf8')) |
|
1102 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1174 | + if (stristr($language, '-utf8')) { |
|
1175 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1176 | + } |
|
1103 | 1177 | |
1104 | 1178 | // @todo Maybe change the cookie name if going to 1.1, too? |
1105 | 1179 | |
@@ -1107,8 +1181,9 @@ discard block |
||
1107 | 1181 | require_once($sourcedir . '/Subs-Admin.php'); |
1108 | 1182 | updateSettingsFile($changes); |
1109 | 1183 | |
1110 | - if ($command_line) |
|
1111 | - echo ' Successful.' . "\n"; |
|
1184 | + if ($command_line) { |
|
1185 | + echo ' Successful.' . "\n"; |
|
1186 | + } |
|
1112 | 1187 | |
1113 | 1188 | // Are we doing debug? |
1114 | 1189 | if (isset($_POST['debug'])) |
@@ -1118,8 +1193,9 @@ discard block |
||
1118 | 1193 | } |
1119 | 1194 | |
1120 | 1195 | // If we're not backing up then jump one. |
1121 | - if (empty($_POST['backup'])) |
|
1122 | - $upcontext['current_step']++; |
|
1196 | + if (empty($_POST['backup'])) { |
|
1197 | + $upcontext['current_step']++; |
|
1198 | + } |
|
1123 | 1199 | |
1124 | 1200 | // If we've got here then let's proceed to the next step! |
1125 | 1201 | return true; |
@@ -1134,8 +1210,9 @@ discard block |
||
1134 | 1210 | $upcontext['page_title'] = 'Backup Database'; |
1135 | 1211 | |
1136 | 1212 | // Done it already - js wise? |
1137 | - if (!empty($_POST['backup_done'])) |
|
1138 | - return true; |
|
1213 | + if (!empty($_POST['backup_done'])) { |
|
1214 | + return true; |
|
1215 | + } |
|
1139 | 1216 | |
1140 | 1217 | // Some useful stuff here. |
1141 | 1218 | db_extend(); |
@@ -1149,9 +1226,10 @@ discard block |
||
1149 | 1226 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1150 | 1227 | |
1151 | 1228 | $table_names = array(); |
1152 | - foreach ($tables as $table) |
|
1153 | - if (substr($table, 0, 7) !== 'backup_') |
|
1229 | + foreach ($tables as $table) { |
|
1230 | + if (substr($table, 0, 7) !== 'backup_') |
|
1154 | 1231 | $table_names[] = $table; |
1232 | + } |
|
1155 | 1233 | |
1156 | 1234 | $upcontext['table_count'] = count($table_names); |
1157 | 1235 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1161,12 +1239,14 @@ discard block |
||
1161 | 1239 | $file_steps = $upcontext['table_count']; |
1162 | 1240 | |
1163 | 1241 | // What ones have we already done? |
1164 | - foreach ($table_names as $id => $table) |
|
1165 | - if ($id < $_GET['substep']) |
|
1242 | + foreach ($table_names as $id => $table) { |
|
1243 | + if ($id < $_GET['substep']) |
|
1166 | 1244 | $upcontext['previous_tables'][] = $table; |
1245 | + } |
|
1167 | 1246 | |
1168 | - if ($command_line) |
|
1169 | - echo 'Backing Up Tables.'; |
|
1247 | + if ($command_line) { |
|
1248 | + echo 'Backing Up Tables.'; |
|
1249 | + } |
|
1170 | 1250 | |
1171 | 1251 | // If we don't support javascript we backup here. |
1172 | 1252 | if (!$support_js || isset($_GET['xml'])) |
@@ -1185,8 +1265,9 @@ discard block |
||
1185 | 1265 | backupTable($table_names[$substep]); |
1186 | 1266 | |
1187 | 1267 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1188 | - if (isset($_GET['xml'])) |
|
1189 | - return upgradeExit(); |
|
1268 | + if (isset($_GET['xml'])) { |
|
1269 | + return upgradeExit(); |
|
1270 | + } |
|
1190 | 1271 | } |
1191 | 1272 | |
1192 | 1273 | if ($command_line) |
@@ -1219,9 +1300,10 @@ discard block |
||
1219 | 1300 | |
1220 | 1301 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1221 | 1302 | |
1222 | - if ($command_line) |
|
1223 | - echo ' done.'; |
|
1224 | -} |
|
1303 | + if ($command_line) { |
|
1304 | + echo ' done.'; |
|
1305 | + } |
|
1306 | + } |
|
1225 | 1307 | |
1226 | 1308 | // Step 2: Everything. |
1227 | 1309 | function DatabaseChanges() |
@@ -1230,8 +1312,9 @@ discard block |
||
1230 | 1312 | global $upcontext, $support_js, $db_type; |
1231 | 1313 | |
1232 | 1314 | // Have we just completed this? |
1233 | - if (!empty($_POST['database_done'])) |
|
1234 | - return true; |
|
1315 | + if (!empty($_POST['database_done'])) { |
|
1316 | + return true; |
|
1317 | + } |
|
1235 | 1318 | |
1236 | 1319 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1237 | 1320 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1246,15 +1329,16 @@ discard block |
||
1246 | 1329 | ); |
1247 | 1330 | |
1248 | 1331 | // How many files are there in total? |
1249 | - if (isset($_GET['filecount'])) |
|
1250 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1251 | - else |
|
1332 | + if (isset($_GET['filecount'])) { |
|
1333 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1334 | + } else |
|
1252 | 1335 | { |
1253 | 1336 | $upcontext['file_count'] = 0; |
1254 | 1337 | foreach ($files as $file) |
1255 | 1338 | { |
1256 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1257 | - $upcontext['file_count']++; |
|
1339 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1340 | + $upcontext['file_count']++; |
|
1341 | + } |
|
1258 | 1342 | } |
1259 | 1343 | } |
1260 | 1344 | |
@@ -1264,9 +1348,9 @@ discard block |
||
1264 | 1348 | $upcontext['cur_file_num'] = 0; |
1265 | 1349 | foreach ($files as $file) |
1266 | 1350 | { |
1267 | - if ($did_not_do) |
|
1268 | - $did_not_do--; |
|
1269 | - else |
|
1351 | + if ($did_not_do) { |
|
1352 | + $did_not_do--; |
|
1353 | + } else |
|
1270 | 1354 | { |
1271 | 1355 | $upcontext['cur_file_num']++; |
1272 | 1356 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1293,12 +1377,13 @@ discard block |
||
1293 | 1377 | // Flag to move on to the next. |
1294 | 1378 | $upcontext['completed_step'] = true; |
1295 | 1379 | // Did we complete the whole file? |
1296 | - if ($nextFile) |
|
1297 | - $upcontext['current_debug_item_num'] = -1; |
|
1380 | + if ($nextFile) { |
|
1381 | + $upcontext['current_debug_item_num'] = -1; |
|
1382 | + } |
|
1298 | 1383 | return upgradeExit(); |
1384 | + } elseif ($support_js) { |
|
1385 | + break; |
|
1299 | 1386 | } |
1300 | - elseif ($support_js) |
|
1301 | - break; |
|
1302 | 1387 | } |
1303 | 1388 | // Set the progress bar to be right as if we had - even if we hadn't... |
1304 | 1389 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1323,8 +1408,9 @@ discard block |
||
1323 | 1408 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1324 | 1409 | |
1325 | 1410 | // Now it's nice to have some of the basic SMF source files. |
1326 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1327 | - redirectLocation('&ssi=1'); |
|
1411 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1412 | + redirectLocation('&ssi=1'); |
|
1413 | + } |
|
1328 | 1414 | |
1329 | 1415 | $upcontext['sub_template'] = 'upgrade_complete'; |
1330 | 1416 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1340,14 +1426,16 @@ discard block |
||
1340 | 1426 | // Are we in maintenance mode? |
1341 | 1427 | if (isset($upcontext['user']['main'])) |
1342 | 1428 | { |
1343 | - if ($command_line) |
|
1344 | - echo ' * '; |
|
1429 | + if ($command_line) { |
|
1430 | + echo ' * '; |
|
1431 | + } |
|
1345 | 1432 | $upcontext['removed_maintenance'] = true; |
1346 | 1433 | $changes['maintenance'] = $upcontext['user']['main']; |
1347 | 1434 | } |
1348 | 1435 | // Otherwise if somehow we are in 2 let's go to 1. |
1349 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1350 | - $changes['maintenance'] = 1; |
|
1436 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1437 | + $changes['maintenance'] = 1; |
|
1438 | + } |
|
1351 | 1439 | |
1352 | 1440 | // Wipe this out... |
1353 | 1441 | $upcontext['user'] = array(); |
@@ -1362,9 +1450,9 @@ discard block |
||
1362 | 1450 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1363 | 1451 | |
1364 | 1452 | // Now is the perfect time to fetch the SM files. |
1365 | - if ($command_line) |
|
1366 | - cli_scheduled_fetchSMfiles(); |
|
1367 | - else |
|
1453 | + if ($command_line) { |
|
1454 | + cli_scheduled_fetchSMfiles(); |
|
1455 | + } else |
|
1368 | 1456 | { |
1369 | 1457 | require_once($sourcedir . '/ScheduledTasks.php'); |
1370 | 1458 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1372,8 +1460,9 @@ discard block |
||
1372 | 1460 | } |
1373 | 1461 | |
1374 | 1462 | // Log what we've done. |
1375 | - if (empty($user_info['id'])) |
|
1376 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1463 | + if (empty($user_info['id'])) { |
|
1464 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1465 | + } |
|
1377 | 1466 | |
1378 | 1467 | // Log the action manually, so CLI still works. |
1379 | 1468 | $smcFunc['db_insert']('', |
@@ -1392,8 +1481,9 @@ discard block |
||
1392 | 1481 | |
1393 | 1482 | // Save the current database version. |
1394 | 1483 | $server_version = $smcFunc['db_server_info'](); |
1395 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1396 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1484 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1485 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1486 | + } |
|
1397 | 1487 | |
1398 | 1488 | if ($command_line) |
1399 | 1489 | { |
@@ -1405,8 +1495,9 @@ discard block |
||
1405 | 1495 | |
1406 | 1496 | // Make sure it says we're done. |
1407 | 1497 | $upcontext['overall_percent'] = 100; |
1408 | - if (isset($upcontext['step_progress'])) |
|
1409 | - unset($upcontext['step_progress']); |
|
1498 | + if (isset($upcontext['step_progress'])) { |
|
1499 | + unset($upcontext['step_progress']); |
|
1500 | + } |
|
1410 | 1501 | |
1411 | 1502 | $_GET['substep'] = 0; |
1412 | 1503 | return false; |
@@ -1417,8 +1508,9 @@ discard block |
||
1417 | 1508 | { |
1418 | 1509 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1419 | 1510 | |
1420 | - if (empty($modSettings['time_format'])) |
|
1421 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1511 | + if (empty($modSettings['time_format'])) { |
|
1512 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1513 | + } |
|
1422 | 1514 | |
1423 | 1515 | // What files do we want to get |
1424 | 1516 | $request = $smcFunc['db_query']('', ' |
@@ -1452,8 +1544,9 @@ discard block |
||
1452 | 1544 | $file_data = fetch_web_data($url); |
1453 | 1545 | |
1454 | 1546 | // If we got an error - give up - the site might be down. |
1455 | - if ($file_data === false) |
|
1456 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1547 | + if ($file_data === false) { |
|
1548 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1549 | + } |
|
1457 | 1550 | |
1458 | 1551 | // Save the file to the database. |
1459 | 1552 | $smcFunc['db_query']('substring', ' |
@@ -1495,8 +1588,9 @@ discard block |
||
1495 | 1588 | $themeData = array(); |
1496 | 1589 | foreach ($values as $variable => $value) |
1497 | 1590 | { |
1498 | - if (!isset($value) || $value === null) |
|
1499 | - $value = 0; |
|
1591 | + if (!isset($value) || $value === null) { |
|
1592 | + $value = 0; |
|
1593 | + } |
|
1500 | 1594 | |
1501 | 1595 | $themeData[] = array(0, 1, $variable, $value); |
1502 | 1596 | } |
@@ -1525,8 +1619,9 @@ discard block |
||
1525 | 1619 | |
1526 | 1620 | foreach ($values as $variable => $value) |
1527 | 1621 | { |
1528 | - if (empty($modSettings[$value[0]])) |
|
1529 | - continue; |
|
1622 | + if (empty($modSettings[$value[0]])) { |
|
1623 | + continue; |
|
1624 | + } |
|
1530 | 1625 | |
1531 | 1626 | $smcFunc['db_query']('', ' |
1532 | 1627 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1612,19 +1707,21 @@ discard block |
||
1612 | 1707 | set_error_handler( |
1613 | 1708 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1614 | 1709 | { |
1615 | - if ($support_js) |
|
1616 | - return true; |
|
1617 | - else |
|
1618 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1710 | + if ($support_js) { |
|
1711 | + return true; |
|
1712 | + } else { |
|
1713 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1714 | + } |
|
1619 | 1715 | } |
1620 | 1716 | ); |
1621 | 1717 | |
1622 | 1718 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1623 | 1719 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1624 | - if ($db_type == 'mysql') |
|
1625 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1626 | - else |
|
1627 | - $db_collation = ''; |
|
1720 | + if ($db_type == 'mysql') { |
|
1721 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1722 | + } else { |
|
1723 | + $db_collation = ''; |
|
1724 | + } |
|
1628 | 1725 | |
1629 | 1726 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1630 | 1727 | |
@@ -1636,8 +1733,9 @@ discard block |
||
1636 | 1733 | $last_step = ''; |
1637 | 1734 | |
1638 | 1735 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1639 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1640 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1736 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1737 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1738 | + } |
|
1641 | 1739 | |
1642 | 1740 | // Count the total number of steps within this file - for progress. |
1643 | 1741 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1657,15 +1755,18 @@ discard block |
||
1657 | 1755 | $do_current = $substep >= $_GET['substep']; |
1658 | 1756 | |
1659 | 1757 | // Get rid of any comments in the beginning of the line... |
1660 | - if (substr(trim($line), 0, 2) === '/*') |
|
1661 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1758 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1759 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1760 | + } |
|
1662 | 1761 | |
1663 | 1762 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1664 | - if ($is_debug && !$support_js && $command_line) |
|
1665 | - flush(); |
|
1763 | + if ($is_debug && !$support_js && $command_line) { |
|
1764 | + flush(); |
|
1765 | + } |
|
1666 | 1766 | |
1667 | - if (trim($line) === '') |
|
1668 | - continue; |
|
1767 | + if (trim($line) === '') { |
|
1768 | + continue; |
|
1769 | + } |
|
1669 | 1770 | |
1670 | 1771 | if (trim(substr($line, 0, 3)) === '---') |
1671 | 1772 | { |
@@ -1675,8 +1776,9 @@ discard block |
||
1675 | 1776 | if (trim($current_data) != '' && $type !== '}') |
1676 | 1777 | { |
1677 | 1778 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1678 | - if ($command_line) |
|
1679 | - echo $upcontext['error_message']; |
|
1779 | + if ($command_line) { |
|
1780 | + echo $upcontext['error_message']; |
|
1781 | + } |
|
1680 | 1782 | } |
1681 | 1783 | |
1682 | 1784 | if ($type == ' ') |
@@ -1694,17 +1796,18 @@ discard block |
||
1694 | 1796 | if ($do_current) |
1695 | 1797 | { |
1696 | 1798 | $upcontext['actioned_items'][] = $last_step; |
1697 | - if ($command_line) |
|
1698 | - echo ' * '; |
|
1799 | + if ($command_line) { |
|
1800 | + echo ' * '; |
|
1801 | + } |
|
1699 | 1802 | } |
1700 | - } |
|
1701 | - elseif ($type == '#') |
|
1803 | + } elseif ($type == '#') |
|
1702 | 1804 | { |
1703 | 1805 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1704 | 1806 | |
1705 | 1807 | $upcontext['current_debug_item_num']++; |
1706 | - if (trim($line) != '---#') |
|
1707 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1808 | + if (trim($line) != '---#') { |
|
1809 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1810 | + } |
|
1708 | 1811 | |
1709 | 1812 | // Have we already done something? |
1710 | 1813 | if (isset($_GET['xml']) && $done_something) |
@@ -1715,34 +1818,36 @@ discard block |
||
1715 | 1818 | |
1716 | 1819 | if ($do_current) |
1717 | 1820 | { |
1718 | - if (trim($line) == '---#' && $command_line) |
|
1719 | - echo ' done.', $endl; |
|
1720 | - elseif ($command_line) |
|
1721 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1722 | - elseif (trim($line) != '---#') |
|
1821 | + if (trim($line) == '---#' && $command_line) { |
|
1822 | + echo ' done.', $endl; |
|
1823 | + } elseif ($command_line) { |
|
1824 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1825 | + } elseif (trim($line) != '---#') |
|
1723 | 1826 | { |
1724 | - if ($is_debug) |
|
1725 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1827 | + if ($is_debug) { |
|
1828 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1829 | + } |
|
1726 | 1830 | } |
1727 | 1831 | } |
1728 | 1832 | |
1729 | 1833 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1730 | 1834 | { |
1731 | - if ($command_line) |
|
1732 | - echo ' * '; |
|
1733 | - else |
|
1734 | - $upcontext['actioned_items'][] = $last_step; |
|
1835 | + if ($command_line) { |
|
1836 | + echo ' * '; |
|
1837 | + } else { |
|
1838 | + $upcontext['actioned_items'][] = $last_step; |
|
1839 | + } |
|
1735 | 1840 | } |
1736 | 1841 | |
1737 | 1842 | // Small step - only if we're actually doing stuff. |
1738 | - if ($do_current) |
|
1739 | - nextSubstep(++$substep); |
|
1740 | - else |
|
1741 | - $substep++; |
|
1742 | - } |
|
1743 | - elseif ($type == '{') |
|
1744 | - $current_type = 'code'; |
|
1745 | - elseif ($type == '}') |
|
1843 | + if ($do_current) { |
|
1844 | + nextSubstep(++$substep); |
|
1845 | + } else { |
|
1846 | + $substep++; |
|
1847 | + } |
|
1848 | + } elseif ($type == '{') { |
|
1849 | + $current_type = 'code'; |
|
1850 | + } elseif ($type == '}') |
|
1746 | 1851 | { |
1747 | 1852 | $current_type = 'sql'; |
1748 | 1853 | |
@@ -1755,8 +1860,9 @@ discard block |
||
1755 | 1860 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1756 | 1861 | { |
1757 | 1862 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1758 | - if ($command_line) |
|
1759 | - echo $upcontext['error_message']; |
|
1863 | + if ($command_line) { |
|
1864 | + echo $upcontext['error_message']; |
|
1865 | + } |
|
1760 | 1866 | } |
1761 | 1867 | |
1762 | 1868 | // Done with code! |
@@ -1836,8 +1942,9 @@ discard block |
||
1836 | 1942 | $db_unbuffered = false; |
1837 | 1943 | |
1838 | 1944 | // Failure?! |
1839 | - if ($result !== false) |
|
1840 | - return $result; |
|
1945 | + if ($result !== false) { |
|
1946 | + return $result; |
|
1947 | + } |
|
1841 | 1948 | |
1842 | 1949 | $db_error_message = $smcFunc['db_error']($db_connection); |
1843 | 1950 | // If MySQL we do something more clever. |
@@ -1865,54 +1972,61 @@ discard block |
||
1865 | 1972 | { |
1866 | 1973 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1867 | 1974 | $result = mysqli_query($db_connection, $string); |
1868 | - if ($result !== false) |
|
1869 | - return $result; |
|
1975 | + if ($result !== false) { |
|
1976 | + return $result; |
|
1977 | + } |
|
1870 | 1978 | } |
1871 | - } |
|
1872 | - elseif ($mysqli_errno == 2013) |
|
1979 | + } elseif ($mysqli_errno == 2013) |
|
1873 | 1980 | { |
1874 | 1981 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1875 | 1982 | mysqli_select_db($db_connection, $db_name); |
1876 | 1983 | if ($db_connection) |
1877 | 1984 | { |
1878 | 1985 | $result = mysqli_query($db_connection, $string); |
1879 | - if ($result !== false) |
|
1880 | - return $result; |
|
1986 | + if ($result !== false) { |
|
1987 | + return $result; |
|
1988 | + } |
|
1881 | 1989 | } |
1882 | 1990 | } |
1883 | 1991 | // Duplicate column name... should be okay ;). |
1884 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1885 | - return false; |
|
1992 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
1993 | + return false; |
|
1994 | + } |
|
1886 | 1995 | // Duplicate insert... make sure it's the proper type of query ;). |
1887 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1888 | - return false; |
|
1996 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
1997 | + return false; |
|
1998 | + } |
|
1889 | 1999 | // Creating an index on a non-existent column. |
1890 | - elseif ($mysqli_errno == 1072) |
|
1891 | - return false; |
|
1892 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1893 | - return false; |
|
2000 | + elseif ($mysqli_errno == 1072) { |
|
2001 | + return false; |
|
2002 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2003 | + return false; |
|
2004 | + } |
|
1894 | 2005 | } |
1895 | 2006 | // If a table already exists don't go potty. |
1896 | 2007 | else |
1897 | 2008 | { |
1898 | 2009 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1899 | 2010 | { |
1900 | - if (strpos($db_error_message, 'exist') !== false) |
|
1901 | - return true; |
|
1902 | - } |
|
1903 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2011 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2012 | + return true; |
|
2013 | + } |
|
2014 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1904 | 2015 | { |
1905 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1906 | - return true; |
|
2016 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2017 | + return true; |
|
2018 | + } |
|
1907 | 2019 | } |
1908 | 2020 | } |
1909 | 2021 | |
1910 | 2022 | // Get the query string so we pass everything. |
1911 | 2023 | $query_string = ''; |
1912 | - foreach ($_GET as $k => $v) |
|
1913 | - $query_string .= ';' . $k . '=' . $v; |
|
1914 | - if (strlen($query_string) != 0) |
|
1915 | - $query_string = '?' . substr($query_string, 1); |
|
2024 | + foreach ($_GET as $k => $v) { |
|
2025 | + $query_string .= ';' . $k . '=' . $v; |
|
2026 | + } |
|
2027 | + if (strlen($query_string) != 0) { |
|
2028 | + $query_string = '?' . substr($query_string, 1); |
|
2029 | + } |
|
1916 | 2030 | |
1917 | 2031 | if ($command_line) |
1918 | 2032 | { |
@@ -1967,16 +2081,18 @@ discard block |
||
1967 | 2081 | { |
1968 | 2082 | $found |= 1; |
1969 | 2083 | // Do some checks on the data if we have it set. |
1970 | - if (isset($change['col_type'])) |
|
1971 | - $found &= $change['col_type'] === $column['type']; |
|
1972 | - if (isset($change['null_allowed'])) |
|
1973 | - $found &= $column['null'] == $change['null_allowed']; |
|
1974 | - if (isset($change['default'])) |
|
1975 | - $found &= $change['default'] === $column['default']; |
|
2084 | + if (isset($change['col_type'])) { |
|
2085 | + $found &= $change['col_type'] === $column['type']; |
|
2086 | + } |
|
2087 | + if (isset($change['null_allowed'])) { |
|
2088 | + $found &= $column['null'] == $change['null_allowed']; |
|
2089 | + } |
|
2090 | + if (isset($change['default'])) { |
|
2091 | + $found &= $change['default'] === $column['default']; |
|
2092 | + } |
|
1976 | 2093 | } |
1977 | 2094 | } |
1978 | - } |
|
1979 | - elseif ($change['type'] === 'index') |
|
2095 | + } elseif ($change['type'] === 'index') |
|
1980 | 2096 | { |
1981 | 2097 | $request = upgrade_query(' |
1982 | 2098 | SHOW INDEX |
@@ -1985,9 +2101,10 @@ discard block |
||
1985 | 2101 | { |
1986 | 2102 | $cur_index = array(); |
1987 | 2103 | |
1988 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1989 | - if ($row['Key_name'] === $change['name']) |
|
2104 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2105 | + if ($row['Key_name'] === $change['name']) |
|
1990 | 2106 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2107 | + } |
|
1991 | 2108 | |
1992 | 2109 | ksort($cur_index, SORT_NUMERIC); |
1993 | 2110 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -1997,14 +2114,17 @@ discard block |
||
1997 | 2114 | } |
1998 | 2115 | |
1999 | 2116 | // If we're trying to add and it's added, we're done. |
2000 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2001 | - return true; |
|
2117 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2118 | + return true; |
|
2119 | + } |
|
2002 | 2120 | // Otherwise if we're removing and it wasn't found we're also done. |
2003 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2004 | - return true; |
|
2121 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2122 | + return true; |
|
2123 | + } |
|
2005 | 2124 | // Otherwise is it just a test? |
2006 | - elseif ($is_test) |
|
2007 | - return false; |
|
2125 | + elseif ($is_test) { |
|
2126 | + return false; |
|
2127 | + } |
|
2008 | 2128 | |
2009 | 2129 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2010 | 2130 | $running = false; |
@@ -2015,8 +2135,9 @@ discard block |
||
2015 | 2135 | SHOW FULL PROCESSLIST'); |
2016 | 2136 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2017 | 2137 | { |
2018 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2019 | - $found = true; |
|
2138 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2139 | + $found = true; |
|
2140 | + } |
|
2020 | 2141 | } |
2021 | 2142 | |
2022 | 2143 | // Can't find it? Then we need to run it fools! |
@@ -2028,8 +2149,9 @@ discard block |
||
2028 | 2149 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2029 | 2150 | ' . $change['text'], true) !== false; |
2030 | 2151 | |
2031 | - if (!$success) |
|
2032 | - return false; |
|
2152 | + if (!$success) { |
|
2153 | + return false; |
|
2154 | + } |
|
2033 | 2155 | |
2034 | 2156 | // Return |
2035 | 2157 | $running = true; |
@@ -2071,8 +2193,9 @@ discard block |
||
2071 | 2193 | 'db_error_skip' => true, |
2072 | 2194 | ) |
2073 | 2195 | ); |
2074 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2075 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2196 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2197 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2198 | + } |
|
2076 | 2199 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2077 | 2200 | $smcFunc['db_free_result']($request); |
2078 | 2201 | |
@@ -2094,18 +2217,19 @@ discard block |
||
2094 | 2217 | ) |
2095 | 2218 | ); |
2096 | 2219 | // No results? Just forget it all together. |
2097 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2098 | - unset($table_row['Collation']); |
|
2099 | - else |
|
2100 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2220 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2221 | + unset($table_row['Collation']); |
|
2222 | + } else { |
|
2223 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2224 | + } |
|
2101 | 2225 | $smcFunc['db_free_result']($request); |
2102 | 2226 | } |
2103 | 2227 | |
2104 | 2228 | if ($column_fix) |
2105 | 2229 | { |
2106 | 2230 | // Make sure there are no NULL's left. |
2107 | - if ($null_fix) |
|
2108 | - $smcFunc['db_query']('', ' |
|
2231 | + if ($null_fix) { |
|
2232 | + $smcFunc['db_query']('', ' |
|
2109 | 2233 | UPDATE {db_prefix}' . $change['table'] . ' |
2110 | 2234 | SET ' . $change['column'] . ' = {string:default} |
2111 | 2235 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2114,6 +2238,7 @@ discard block |
||
2114 | 2238 | 'db_error_skip' => true, |
2115 | 2239 | ) |
2116 | 2240 | ); |
2241 | + } |
|
2117 | 2242 | |
2118 | 2243 | // Do the actual alteration. |
2119 | 2244 | $smcFunc['db_query']('', ' |
@@ -2142,8 +2267,9 @@ discard block |
||
2142 | 2267 | } |
2143 | 2268 | |
2144 | 2269 | // Not a column we need to check on? |
2145 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2146 | - return; |
|
2270 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2271 | + return; |
|
2272 | + } |
|
2147 | 2273 | |
2148 | 2274 | // Break it up you (six|seven). |
2149 | 2275 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2162,13 +2288,13 @@ discard block |
||
2162 | 2288 | 'new_name' => $temp[2], |
2163 | 2289 | )); |
2164 | 2290 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2165 | - if ($smcFunc['db_num_rows'] != 1) |
|
2166 | - return; |
|
2291 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2292 | + return; |
|
2293 | + } |
|
2167 | 2294 | |
2168 | 2295 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2169 | 2296 | $smcFunc['db_free_result']($request); |
2170 | - } |
|
2171 | - else |
|
2297 | + } else |
|
2172 | 2298 | { |
2173 | 2299 | // Do this the old fashion, sure method way. |
2174 | 2300 | $request = $smcFunc['db_query']('', ' |
@@ -2179,21 +2305,24 @@ discard block |
||
2179 | 2305 | )); |
2180 | 2306 | // Mayday! |
2181 | 2307 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2182 | - if ($smcFunc['db_num_rows'] == 0) |
|
2183 | - return; |
|
2308 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2309 | + return; |
|
2310 | + } |
|
2184 | 2311 | |
2185 | 2312 | // Oh where, oh where has my little field gone. Oh where can it be... |
2186 | - while ($row = $smcFunc['db_query']($request)) |
|
2187 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2313 | + while ($row = $smcFunc['db_query']($request)) { |
|
2314 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2188 | 2315 | { |
2189 | 2316 | $current_type = $row['Type']; |
2317 | + } |
|
2190 | 2318 | break; |
2191 | 2319 | } |
2192 | 2320 | } |
2193 | 2321 | |
2194 | 2322 | // If this doesn't match, the column may of been altered for a reason. |
2195 | - if (trim($current_type) != trim($temp[3])) |
|
2196 | - $temp[3] = $current_type; |
|
2323 | + if (trim($current_type) != trim($temp[3])) { |
|
2324 | + $temp[3] = $current_type; |
|
2325 | + } |
|
2197 | 2326 | |
2198 | 2327 | // Piece this back together. |
2199 | 2328 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2205,8 +2334,9 @@ discard block |
||
2205 | 2334 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2206 | 2335 | global $step_progress, $is_debug, $upcontext; |
2207 | 2336 | |
2208 | - if ($_GET['substep'] < $substep) |
|
2209 | - $_GET['substep'] = $substep; |
|
2337 | + if ($_GET['substep'] < $substep) { |
|
2338 | + $_GET['substep'] = $substep; |
|
2339 | + } |
|
2210 | 2340 | |
2211 | 2341 | if ($command_line) |
2212 | 2342 | { |
@@ -2219,29 +2349,33 @@ discard block |
||
2219 | 2349 | } |
2220 | 2350 | |
2221 | 2351 | @set_time_limit(300); |
2222 | - if (function_exists('apache_reset_timeout')) |
|
2223 | - @apache_reset_timeout(); |
|
2352 | + if (function_exists('apache_reset_timeout')) { |
|
2353 | + @apache_reset_timeout(); |
|
2354 | + } |
|
2224 | 2355 | |
2225 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2226 | - return; |
|
2356 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2357 | + return; |
|
2358 | + } |
|
2227 | 2359 | |
2228 | 2360 | // Do we have some custom step progress stuff? |
2229 | 2361 | if (!empty($step_progress)) |
2230 | 2362 | { |
2231 | 2363 | $upcontext['substep_progress'] = 0; |
2232 | 2364 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2233 | - if ($step_progress['current'] > $step_progress['total']) |
|
2234 | - $upcontext['substep_progress'] = 99.9; |
|
2235 | - else |
|
2236 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2365 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2366 | + $upcontext['substep_progress'] = 99.9; |
|
2367 | + } else { |
|
2368 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2369 | + } |
|
2237 | 2370 | |
2238 | 2371 | // Make it nicely rounded. |
2239 | 2372 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2240 | 2373 | } |
2241 | 2374 | |
2242 | 2375 | // If this is XML we just exit right away! |
2243 | - if (isset($_GET['xml'])) |
|
2244 | - return upgradeExit(); |
|
2376 | + if (isset($_GET['xml'])) { |
|
2377 | + return upgradeExit(); |
|
2378 | + } |
|
2245 | 2379 | |
2246 | 2380 | // We're going to pause after this! |
2247 | 2381 | $upcontext['pause'] = true; |
@@ -2249,13 +2383,15 @@ discard block |
||
2249 | 2383 | $upcontext['query_string'] = ''; |
2250 | 2384 | foreach ($_GET as $k => $v) |
2251 | 2385 | { |
2252 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2253 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2386 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2387 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2388 | + } |
|
2254 | 2389 | } |
2255 | 2390 | |
2256 | 2391 | // Custom warning? |
2257 | - if (!empty($custom_warning)) |
|
2258 | - $upcontext['custom_warning'] = $custom_warning; |
|
2392 | + if (!empty($custom_warning)) { |
|
2393 | + $upcontext['custom_warning'] = $custom_warning; |
|
2394 | + } |
|
2259 | 2395 | |
2260 | 2396 | upgradeExit(); |
2261 | 2397 | } |
@@ -2270,25 +2406,26 @@ discard block |
||
2270 | 2406 | ob_implicit_flush(true); |
2271 | 2407 | @set_time_limit(600); |
2272 | 2408 | |
2273 | - if (!isset($_SERVER['argv'])) |
|
2274 | - $_SERVER['argv'] = array(); |
|
2409 | + if (!isset($_SERVER['argv'])) { |
|
2410 | + $_SERVER['argv'] = array(); |
|
2411 | + } |
|
2275 | 2412 | $_GET['maint'] = 1; |
2276 | 2413 | |
2277 | 2414 | foreach ($_SERVER['argv'] as $i => $arg) |
2278 | 2415 | { |
2279 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2280 | - $_GET['lang'] = $match[1]; |
|
2281 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2282 | - continue; |
|
2283 | - elseif ($arg == '--no-maintenance') |
|
2284 | - $_GET['maint'] = 0; |
|
2285 | - elseif ($arg == '--debug') |
|
2286 | - $is_debug = true; |
|
2287 | - elseif ($arg == '--backup') |
|
2288 | - $_POST['backup'] = 1; |
|
2289 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2290 | - $_GET['conv'] = 1; |
|
2291 | - elseif ($i != 0) |
|
2416 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2417 | + $_GET['lang'] = $match[1]; |
|
2418 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2419 | + continue; |
|
2420 | + } elseif ($arg == '--no-maintenance') { |
|
2421 | + $_GET['maint'] = 0; |
|
2422 | + } elseif ($arg == '--debug') { |
|
2423 | + $is_debug = true; |
|
2424 | + } elseif ($arg == '--backup') { |
|
2425 | + $_POST['backup'] = 1; |
|
2426 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2427 | + $_GET['conv'] = 1; |
|
2428 | + } elseif ($i != 0) |
|
2292 | 2429 | { |
2293 | 2430 | echo 'SMF Command-line Upgrader |
2294 | 2431 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2302,10 +2439,12 @@ discard block |
||
2302 | 2439 | } |
2303 | 2440 | } |
2304 | 2441 | |
2305 | - if (!php_version_check()) |
|
2306 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2307 | - if (!db_version_check()) |
|
2308 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2442 | + if (!php_version_check()) { |
|
2443 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2444 | + } |
|
2445 | + if (!db_version_check()) { |
|
2446 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2447 | + } |
|
2309 | 2448 | |
2310 | 2449 | // Do some checks to make sure they have proper privileges |
2311 | 2450 | db_extend('packages'); |
@@ -2320,34 +2459,39 @@ discard block |
||
2320 | 2459 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2321 | 2460 | |
2322 | 2461 | // Sorry... we need CREATE, ALTER and DROP |
2323 | - if (!$create || !$alter || !$drop) |
|
2324 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2462 | + if (!$create || !$alter || !$drop) { |
|
2463 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2464 | + } |
|
2325 | 2465 | |
2326 | 2466 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2327 | 2467 | && @file_exists($sourcedir . '/QueryString.php') |
2328 | 2468 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2329 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2330 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2469 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2470 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2471 | + } |
|
2331 | 2472 | |
2332 | 2473 | // Do a quick version spot check. |
2333 | 2474 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2334 | 2475 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2335 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2336 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2476 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2477 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2478 | + } |
|
2337 | 2479 | |
2338 | 2480 | // Make sure Settings.php is writable. |
2339 | 2481 | quickFileWritable($boarddir . '/Settings.php'); |
2340 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2341 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2482 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2483 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2484 | + } |
|
2342 | 2485 | |
2343 | 2486 | // Make sure Settings_bak.php is writable. |
2344 | 2487 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2345 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2346 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2488 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2489 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2490 | + } |
|
2347 | 2491 | |
2348 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2349 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2350 | - elseif (isset($modSettings['agreement'])) |
|
2492 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2493 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2494 | + } elseif (isset($modSettings['agreement'])) |
|
2351 | 2495 | { |
2352 | 2496 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2353 | 2497 | fwrite($fp, $modSettings['agreement']); |
@@ -2357,31 +2501,36 @@ discard block |
||
2357 | 2501 | // Make sure Themes is writable. |
2358 | 2502 | quickFileWritable($modSettings['theme_dir']); |
2359 | 2503 | |
2360 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2361 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2504 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2505 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2506 | + } |
|
2362 | 2507 | |
2363 | 2508 | // Make sure cache directory exists and is writable! |
2364 | 2509 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2365 | - if (!file_exists($cachedir_temp)) |
|
2366 | - @mkdir($cachedir_temp); |
|
2510 | + if (!file_exists($cachedir_temp)) { |
|
2511 | + @mkdir($cachedir_temp); |
|
2512 | + } |
|
2367 | 2513 | |
2368 | 2514 | // Make sure the cache temp dir is writable. |
2369 | 2515 | quickFileWritable($cachedir_temp); |
2370 | 2516 | |
2371 | - if (!is_writable($cachedir_temp)) |
|
2372 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2517 | + if (!is_writable($cachedir_temp)) { |
|
2518 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2519 | + } |
|
2373 | 2520 | |
2374 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2375 | - print_error('Error: Unable to find language files!', true); |
|
2376 | - else |
|
2521 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2522 | + print_error('Error: Unable to find language files!', true); |
|
2523 | + } else |
|
2377 | 2524 | { |
2378 | 2525 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2379 | 2526 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2380 | 2527 | |
2381 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2382 | - print_error('Error: Language files out of date.', true); |
|
2383 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2384 | - print_error('Error: Install language is missing for selected language.', true); |
|
2528 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2529 | + print_error('Error: Language files out of date.', true); |
|
2530 | + } |
|
2531 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2532 | + print_error('Error: Install language is missing for selected language.', true); |
|
2533 | + } |
|
2385 | 2534 | |
2386 | 2535 | // Otherwise include it! |
2387 | 2536 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2400,8 +2549,9 @@ discard block |
||
2400 | 2549 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
2401 | 2550 | |
2402 | 2551 | // Done it already? |
2403 | - if (!empty($_POST['utf8_done'])) |
|
2404 | - return true; |
|
2552 | + if (!empty($_POST['utf8_done'])) { |
|
2553 | + return true; |
|
2554 | + } |
|
2405 | 2555 | |
2406 | 2556 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2407 | 2557 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2414,8 +2564,7 @@ discard block |
||
2414 | 2564 | ); |
2415 | 2565 | |
2416 | 2566 | return true; |
2417 | - } |
|
2418 | - else |
|
2567 | + } else |
|
2419 | 2568 | { |
2420 | 2569 | $upcontext['page_title'] = 'Converting to UTF8'; |
2421 | 2570 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2459,8 +2608,9 @@ discard block |
||
2459 | 2608 | ) |
2460 | 2609 | ); |
2461 | 2610 | $db_charsets = array(); |
2462 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2463 | - $db_charsets[] = $row['Charset']; |
|
2611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2612 | + $db_charsets[] = $row['Charset']; |
|
2613 | + } |
|
2464 | 2614 | |
2465 | 2615 | $smcFunc['db_free_result']($request); |
2466 | 2616 | |
@@ -2496,13 +2646,15 @@ discard block |
||
2496 | 2646 | // If there's a fulltext index, we need to drop it first... |
2497 | 2647 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2498 | 2648 | { |
2499 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2500 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2649 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2650 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2501 | 2651 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2652 | + } |
|
2502 | 2653 | $smcFunc['db_free_result']($request); |
2503 | 2654 | |
2504 | - if (isset($upcontext['fulltext_index'])) |
|
2505 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2655 | + if (isset($upcontext['fulltext_index'])) { |
|
2656 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2657 | + } |
|
2506 | 2658 | } |
2507 | 2659 | |
2508 | 2660 | // Drop it and make a note... |
@@ -2692,8 +2844,9 @@ discard block |
||
2692 | 2844 | $replace = '%field%'; |
2693 | 2845 | |
2694 | 2846 | // Build a huge REPLACE statement... |
2695 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2696 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2847 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2848 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2849 | + } |
|
2697 | 2850 | } |
2698 | 2851 | |
2699 | 2852 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2703,9 +2856,10 @@ discard block |
||
2703 | 2856 | $upcontext['table_count'] = count($queryTables); |
2704 | 2857 | |
2705 | 2858 | // What ones have we already done? |
2706 | - foreach ($queryTables as $id => $table) |
|
2707 | - if ($id < $_GET['substep']) |
|
2859 | + foreach ($queryTables as $id => $table) { |
|
2860 | + if ($id < $_GET['substep']) |
|
2708 | 2861 | $upcontext['previous_tables'][] = $table; |
2862 | + } |
|
2709 | 2863 | |
2710 | 2864 | $upcontext['cur_table_num'] = $_GET['substep']; |
2711 | 2865 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2742,8 +2896,9 @@ discard block |
||
2742 | 2896 | nextSubstep($substep); |
2743 | 2897 | |
2744 | 2898 | // Just to make sure it doesn't time out. |
2745 | - if (function_exists('apache_reset_timeout')) |
|
2746 | - @apache_reset_timeout(); |
|
2899 | + if (function_exists('apache_reset_timeout')) { |
|
2900 | + @apache_reset_timeout(); |
|
2901 | + } |
|
2747 | 2902 | |
2748 | 2903 | $table_charsets = array(); |
2749 | 2904 | |
@@ -2764,8 +2919,9 @@ discard block |
||
2764 | 2919 | { |
2765 | 2920 | list($charset) = explode('_', $collation); |
2766 | 2921 | |
2767 | - if (!isset($table_charsets[$charset])) |
|
2768 | - $table_charsets[$charset] = array(); |
|
2922 | + if (!isset($table_charsets[$charset])) { |
|
2923 | + $table_charsets[$charset] = array(); |
|
2924 | + } |
|
2769 | 2925 | |
2770 | 2926 | $table_charsets[$charset][] = $column_info; |
2771 | 2927 | } |
@@ -2805,10 +2961,11 @@ discard block |
||
2805 | 2961 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2806 | 2962 | { |
2807 | 2963 | $update = ''; |
2808 | - foreach ($table_charsets as $charset => $columns) |
|
2809 | - foreach ($columns as $column) |
|
2964 | + foreach ($table_charsets as $charset => $columns) { |
|
2965 | + foreach ($columns as $column) |
|
2810 | 2966 | $update .= ' |
2811 | 2967 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
2968 | + } |
|
2812 | 2969 | |
2813 | 2970 | $smcFunc['db_query']('', ' |
2814 | 2971 | UPDATE {raw:table_name} |
@@ -2833,8 +2990,9 @@ discard block |
||
2833 | 2990 | // Now do the actual conversion (if still needed). |
2834 | 2991 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2835 | 2992 | { |
2836 | - if ($command_line) |
|
2837 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2993 | + if ($command_line) { |
|
2994 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2995 | + } |
|
2838 | 2996 | |
2839 | 2997 | $smcFunc['db_query']('', ' |
2840 | 2998 | ALTER TABLE {raw:table_name} |
@@ -2844,12 +3002,14 @@ discard block |
||
2844 | 3002 | ) |
2845 | 3003 | ); |
2846 | 3004 | |
2847 | - if ($command_line) |
|
2848 | - echo " done.\n"; |
|
3005 | + if ($command_line) { |
|
3006 | + echo " done.\n"; |
|
3007 | + } |
|
2849 | 3008 | } |
2850 | 3009 | // If this is XML to keep it nice for the user do one table at a time anyway! |
2851 | - if (isset($_GET['xml'])) |
|
2852 | - return upgradeExit(); |
|
3010 | + if (isset($_GET['xml'])) { |
|
3011 | + return upgradeExit(); |
|
3012 | + } |
|
2853 | 3013 | } |
2854 | 3014 | |
2855 | 3015 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2878,8 +3038,8 @@ discard block |
||
2878 | 3038 | ); |
2879 | 3039 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2880 | 3040 | { |
2881 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
2882 | - $smcFunc['db_query']('', ' |
|
3041 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
3042 | + $smcFunc['db_query']('', ' |
|
2883 | 3043 | UPDATE {db_prefix}log_actions |
2884 | 3044 | SET extra = {string:extra} |
2885 | 3045 | WHERE id_action = {int:current_action}', |
@@ -2888,6 +3048,7 @@ discard block |
||
2888 | 3048 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2889 | 3049 | ) |
2890 | 3050 | ); |
3051 | + } |
|
2891 | 3052 | } |
2892 | 3053 | $smcFunc['db_free_result']($request); |
2893 | 3054 | |
@@ -2909,15 +3070,17 @@ discard block |
||
2909 | 3070 | // First thing's first - did we already do this? |
2910 | 3071 | if (!empty($modSettings['json_done'])) |
2911 | 3072 | { |
2912 | - if ($command_line) |
|
2913 | - return DeleteUpgrade(); |
|
2914 | - else |
|
2915 | - return true; |
|
3073 | + if ($command_line) { |
|
3074 | + return DeleteUpgrade(); |
|
3075 | + } else { |
|
3076 | + return true; |
|
3077 | + } |
|
2916 | 3078 | } |
2917 | 3079 | |
2918 | 3080 | // Done it already - js wise? |
2919 | - if (!empty($_POST['json_done'])) |
|
2920 | - return true; |
|
3081 | + if (!empty($_POST['json_done'])) { |
|
3082 | + return true; |
|
3083 | + } |
|
2921 | 3084 | |
2922 | 3085 | // List of tables affected by this function |
2923 | 3086 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2949,12 +3112,14 @@ discard block |
||
2949 | 3112 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
2950 | 3113 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2951 | 3114 | |
2952 | - foreach ($keys as $id => $table) |
|
2953 | - if ($id < $_GET['substep']) |
|
3115 | + foreach ($keys as $id => $table) { |
|
3116 | + if ($id < $_GET['substep']) |
|
2954 | 3117 | $upcontext['previous_tables'][] = $table; |
3118 | + } |
|
2955 | 3119 | |
2956 | - if ($command_line) |
|
2957 | - echo 'Converting data from serialize() to json_encode().'; |
|
3120 | + if ($command_line) { |
|
3121 | + echo 'Converting data from serialize() to json_encode().'; |
|
3122 | + } |
|
2958 | 3123 | |
2959 | 3124 | if (!$support_js || isset($_GET['xml'])) |
2960 | 3125 | { |
@@ -2994,8 +3159,9 @@ discard block |
||
2994 | 3159 | |
2995 | 3160 | // Loop through and fix these... |
2996 | 3161 | $new_settings = array(); |
2997 | - if ($command_line) |
|
2998 | - echo "\n" . 'Fixing some settings...'; |
|
3162 | + if ($command_line) { |
|
3163 | + echo "\n" . 'Fixing some settings...'; |
|
3164 | + } |
|
2999 | 3165 | |
3000 | 3166 | foreach ($serialized_settings as $var) |
3001 | 3167 | { |
@@ -3003,22 +3169,24 @@ discard block |
||
3003 | 3169 | { |
3004 | 3170 | // Attempt to unserialize the setting |
3005 | 3171 | $temp = @safe_unserialize($modSettings[$var]); |
3006 | - if (!$temp && $command_line) |
|
3007 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3008 | - elseif ($temp !== false) |
|
3009 | - $new_settings[$var] = json_encode($temp); |
|
3172 | + if (!$temp && $command_line) { |
|
3173 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3174 | + } elseif ($temp !== false) { |
|
3175 | + $new_settings[$var] = json_encode($temp); |
|
3176 | + } |
|
3010 | 3177 | } |
3011 | 3178 | } |
3012 | 3179 | |
3013 | 3180 | // Update everything at once |
3014 | - if (!function_exists('cache_put_data')) |
|
3015 | - require_once($sourcedir . '/Load.php'); |
|
3181 | + if (!function_exists('cache_put_data')) { |
|
3182 | + require_once($sourcedir . '/Load.php'); |
|
3183 | + } |
|
3016 | 3184 | updateSettings($new_settings, true); |
3017 | 3185 | |
3018 | - if ($command_line) |
|
3019 | - echo ' done.'; |
|
3020 | - } |
|
3021 | - elseif ($table == 'themes') |
|
3186 | + if ($command_line) { |
|
3187 | + echo ' done.'; |
|
3188 | + } |
|
3189 | + } elseif ($table == 'themes') |
|
3022 | 3190 | { |
3023 | 3191 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3024 | 3192 | $query = $smcFunc['db_query']('', ' |
@@ -3037,10 +3205,11 @@ discard block |
||
3037 | 3205 | |
3038 | 3206 | if ($command_line) |
3039 | 3207 | { |
3040 | - if ($temp === false) |
|
3041 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3042 | - else |
|
3043 | - echo "\n" . 'Fixing admin preferences...'; |
|
3208 | + if ($temp === false) { |
|
3209 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3210 | + } else { |
|
3211 | + echo "\n" . 'Fixing admin preferences...'; |
|
3212 | + } |
|
3044 | 3213 | } |
3045 | 3214 | |
3046 | 3215 | if ($temp !== false) |
@@ -3062,15 +3231,15 @@ discard block |
||
3062 | 3231 | ) |
3063 | 3232 | ); |
3064 | 3233 | |
3065 | - if ($command_line) |
|
3066 | - echo ' done.'; |
|
3234 | + if ($command_line) { |
|
3235 | + echo ' done.'; |
|
3236 | + } |
|
3067 | 3237 | } |
3068 | 3238 | } |
3069 | 3239 | |
3070 | 3240 | $smcFunc['db_free_result']($query); |
3071 | 3241 | } |
3072 | - } |
|
3073 | - else |
|
3242 | + } else |
|
3074 | 3243 | { |
3075 | 3244 | // First item is always the key... |
3076 | 3245 | $key = $info[0]; |
@@ -3081,8 +3250,7 @@ discard block |
||
3081 | 3250 | { |
3082 | 3251 | $col_select = $info[1]; |
3083 | 3252 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3084 | - } |
|
3085 | - else |
|
3253 | + } else |
|
3086 | 3254 | { |
3087 | 3255 | $col_select = implode(', ', $info); |
3088 | 3256 | } |
@@ -3115,8 +3283,7 @@ discard block |
||
3115 | 3283 | if ($temp === false && $command_line) |
3116 | 3284 | { |
3117 | 3285 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3118 | - } |
|
3119 | - else |
|
3286 | + } else |
|
3120 | 3287 | { |
3121 | 3288 | $row[$col] = json_encode($temp); |
3122 | 3289 | |
@@ -3141,16 +3308,18 @@ discard block |
||
3141 | 3308 | } |
3142 | 3309 | } |
3143 | 3310 | |
3144 | - if ($command_line) |
|
3145 | - echo ' done.'; |
|
3311 | + if ($command_line) { |
|
3312 | + echo ' done.'; |
|
3313 | + } |
|
3146 | 3314 | |
3147 | 3315 | // Free up some memory... |
3148 | 3316 | $smcFunc['db_free_result']($query); |
3149 | 3317 | } |
3150 | 3318 | } |
3151 | 3319 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3152 | - if (isset($_GET['xml'])) |
|
3153 | - return upgradeExit(); |
|
3320 | + if (isset($_GET['xml'])) { |
|
3321 | + return upgradeExit(); |
|
3322 | + } |
|
3154 | 3323 | } |
3155 | 3324 | |
3156 | 3325 | if ($command_line) |
@@ -3165,8 +3334,9 @@ discard block |
||
3165 | 3334 | |
3166 | 3335 | $_GET['substep'] = 0; |
3167 | 3336 | // Make sure we move on! |
3168 | - if ($command_line) |
|
3169 | - return DeleteUpgrade(); |
|
3337 | + if ($command_line) { |
|
3338 | + return DeleteUpgrade(); |
|
3339 | + } |
|
3170 | 3340 | |
3171 | 3341 | return true; |
3172 | 3342 | } |
@@ -3186,14 +3356,16 @@ discard block |
||
3186 | 3356 | global $upcontext, $txt, $settings; |
3187 | 3357 | |
3188 | 3358 | // Don't call me twice! |
3189 | - if (!empty($upcontext['chmod_called'])) |
|
3190 | - return; |
|
3359 | + if (!empty($upcontext['chmod_called'])) { |
|
3360 | + return; |
|
3361 | + } |
|
3191 | 3362 | |
3192 | 3363 | $upcontext['chmod_called'] = true; |
3193 | 3364 | |
3194 | 3365 | // Nothing? |
3195 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3196 | - return; |
|
3366 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3367 | + return; |
|
3368 | + } |
|
3197 | 3369 | |
3198 | 3370 | // Was it a problem with Windows? |
3199 | 3371 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3225,11 +3397,12 @@ discard block |
||
3225 | 3397 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
3226 | 3398 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3227 | 3399 | |
3228 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3229 | - echo ' |
|
3400 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3401 | + echo ' |
|
3230 | 3402 | content.write(\'<hr>\n\t\t\t\'); |
3231 | 3403 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
3232 | 3404 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3405 | + } |
|
3233 | 3406 | |
3234 | 3407 | echo ' |
3235 | 3408 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3237,17 +3410,19 @@ discard block |
||
3237 | 3410 | } |
3238 | 3411 | </script>'; |
3239 | 3412 | |
3240 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3241 | - echo ' |
|
3413 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3414 | + echo ' |
|
3242 | 3415 | <div class="error_message red"> |
3243 | 3416 | The following error was encountered when trying to connect:<br><br> |
3244 | 3417 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3245 | 3418 | </div> |
3246 | 3419 | <br>'; |
3420 | + } |
|
3247 | 3421 | |
3248 | - if (empty($upcontext['chmod_in_form'])) |
|
3249 | - echo ' |
|
3422 | + if (empty($upcontext['chmod_in_form'])) { |
|
3423 | + echo ' |
|
3250 | 3424 | <form action="', $upcontext['form_url'], '" method="post">'; |
3425 | + } |
|
3251 | 3426 | |
3252 | 3427 | echo ' |
3253 | 3428 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3282,10 +3457,11 @@ discard block |
||
3282 | 3457 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
3283 | 3458 | </div>'; |
3284 | 3459 | |
3285 | - if (empty($upcontext['chmod_in_form'])) |
|
3286 | - echo ' |
|
3460 | + if (empty($upcontext['chmod_in_form'])) { |
|
3461 | + echo ' |
|
3287 | 3462 | </form>'; |
3288 | -} |
|
3463 | + } |
|
3464 | + } |
|
3289 | 3465 | |
3290 | 3466 | function template_upgrade_above() |
3291 | 3467 | { |
@@ -3345,9 +3521,10 @@ discard block |
||
3345 | 3521 | <h2>', $txt['upgrade_progress'], '</h2> |
3346 | 3522 | <ul>'; |
3347 | 3523 | |
3348 | - foreach ($upcontext['steps'] as $num => $step) |
|
3349 | - echo ' |
|
3524 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3525 | + echo ' |
|
3350 | 3526 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3527 | + } |
|
3351 | 3528 | |
3352 | 3529 | echo ' |
3353 | 3530 | </ul> |
@@ -3360,8 +3537,8 @@ discard block |
||
3360 | 3537 | </div> |
3361 | 3538 | </div>'; |
3362 | 3539 | |
3363 | - if (isset($upcontext['step_progress'])) |
|
3364 | - echo ' |
|
3540 | + if (isset($upcontext['step_progress'])) { |
|
3541 | + echo ' |
|
3365 | 3542 | <br> |
3366 | 3543 | <br> |
3367 | 3544 | <div id="progress_bar_step"> |
@@ -3370,6 +3547,7 @@ discard block |
||
3370 | 3547 | <span>', $txt['upgrade_step_progress'], '</span> |
3371 | 3548 | </div> |
3372 | 3549 | </div>'; |
3550 | + } |
|
3373 | 3551 | |
3374 | 3552 | echo ' |
3375 | 3553 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3400,32 +3578,36 @@ discard block |
||
3400 | 3578 | { |
3401 | 3579 | global $upcontext, $txt; |
3402 | 3580 | |
3403 | - if (!empty($upcontext['pause'])) |
|
3404 | - echo ' |
|
3581 | + if (!empty($upcontext['pause'])) { |
|
3582 | + echo ' |
|
3405 | 3583 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3406 | 3584 | |
3407 | 3585 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3408 | 3586 | <h3> |
3409 | 3587 | ', $txt['upgrade_paused_overload'], ' |
3410 | 3588 | </h3>'; |
3589 | + } |
|
3411 | 3590 | |
3412 | - if (!empty($upcontext['custom_warning'])) |
|
3413 | - echo ' |
|
3591 | + if (!empty($upcontext['custom_warning'])) { |
|
3592 | + echo ' |
|
3414 | 3593 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3415 | 3594 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3416 | 3595 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3417 | 3596 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3418 | 3597 | </div>'; |
3598 | + } |
|
3419 | 3599 | |
3420 | 3600 | echo ' |
3421 | 3601 | <div class="righttext" style="margin: 1ex;">'; |
3422 | 3602 | |
3423 | - if (!empty($upcontext['continue'])) |
|
3424 | - echo ' |
|
3603 | + if (!empty($upcontext['continue'])) { |
|
3604 | + echo ' |
|
3425 | 3605 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
3426 | - if (!empty($upcontext['skip'])) |
|
3427 | - echo ' |
|
3606 | + } |
|
3607 | + if (!empty($upcontext['skip'])) { |
|
3608 | + echo ' |
|
3428 | 3609 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
3610 | + } |
|
3429 | 3611 | |
3430 | 3612 | echo ' |
3431 | 3613 | </div> |
@@ -3475,11 +3657,12 @@ discard block |
||
3475 | 3657 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3476 | 3658 | <smf>'; |
3477 | 3659 | |
3478 | - if (!empty($upcontext['get_data'])) |
|
3479 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3660 | + if (!empty($upcontext['get_data'])) { |
|
3661 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3480 | 3662 | echo ' |
3481 | 3663 | <get key="', $k, '">', $v, '</get>'; |
3482 | -} |
|
3664 | + } |
|
3665 | + } |
|
3483 | 3666 | |
3484 | 3667 | function template_xml_below() |
3485 | 3668 | { |
@@ -3520,8 +3703,8 @@ discard block |
||
3520 | 3703 | template_chmod(); |
3521 | 3704 | |
3522 | 3705 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3523 | - if ($upcontext['is_large_forum']) |
|
3524 | - echo ' |
|
3706 | + if ($upcontext['is_large_forum']) { |
|
3707 | + echo ' |
|
3525 | 3708 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3526 | 3709 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3527 | 3710 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3529,10 +3712,11 @@ discard block |
||
3529 | 3712 | ', $txt['upgrade_warning_lots_data'], ' |
3530 | 3713 | </div> |
3531 | 3714 | </div>'; |
3715 | + } |
|
3532 | 3716 | |
3533 | 3717 | // A warning message? |
3534 | - if (!empty($upcontext['warning'])) |
|
3535 | - echo ' |
|
3718 | + if (!empty($upcontext['warning'])) { |
|
3719 | + echo ' |
|
3536 | 3720 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3537 | 3721 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3538 | 3722 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3540,6 +3724,7 @@ discard block |
||
3540 | 3724 | ', $upcontext['warning'], ' |
3541 | 3725 | </div> |
3542 | 3726 | </div>'; |
3727 | + } |
|
3543 | 3728 | |
3544 | 3729 | // Paths are incorrect? |
3545 | 3730 | echo ' |
@@ -3555,20 +3740,22 @@ discard block |
||
3555 | 3740 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3556 | 3741 | { |
3557 | 3742 | $ago = time() - $upcontext['started']; |
3558 | - if ($ago < 60) |
|
3559 | - $ago = $ago . ' seconds'; |
|
3560 | - elseif ($ago < 3600) |
|
3561 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3562 | - else |
|
3563 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3743 | + if ($ago < 60) { |
|
3744 | + $ago = $ago . ' seconds'; |
|
3745 | + } elseif ($ago < 3600) { |
|
3746 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3747 | + } else { |
|
3748 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3749 | + } |
|
3564 | 3750 | |
3565 | 3751 | $active = time() - $upcontext['updated']; |
3566 | - if ($active < 60) |
|
3567 | - $updated = $active . ' seconds'; |
|
3568 | - elseif ($active < 3600) |
|
3569 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3570 | - else |
|
3571 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3752 | + if ($active < 60) { |
|
3753 | + $updated = $active . ' seconds'; |
|
3754 | + } elseif ($active < 3600) { |
|
3755 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3756 | + } else { |
|
3757 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3758 | + } |
|
3572 | 3759 | |
3573 | 3760 | echo ' |
3574 | 3761 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3577,16 +3764,18 @@ discard block |
||
3577 | 3764 | <div style="padding-left: 6ex;"> |
3578 | 3765 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3579 | 3766 | |
3580 | - if ($active < 600) |
|
3581 | - echo ' |
|
3767 | + if ($active < 600) { |
|
3768 | + echo ' |
|
3582 | 3769 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3770 | + } |
|
3583 | 3771 | |
3584 | - if ($active > $upcontext['inactive_timeout']) |
|
3585 | - echo ' |
|
3772 | + if ($active > $upcontext['inactive_timeout']) { |
|
3773 | + echo ' |
|
3586 | 3774 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
3587 | - else |
|
3588 | - echo ' |
|
3775 | + } else { |
|
3776 | + echo ' |
|
3589 | 3777 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
3778 | + } |
|
3590 | 3779 | |
3591 | 3780 | echo ' |
3592 | 3781 | </div> |
@@ -3602,9 +3791,10 @@ discard block |
||
3602 | 3791 | <td> |
3603 | 3792 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
3604 | 3793 | |
3605 | - if (!empty($upcontext['username_incorrect'])) |
|
3606 | - echo ' |
|
3794 | + if (!empty($upcontext['username_incorrect'])) { |
|
3795 | + echo ' |
|
3607 | 3796 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3797 | + } |
|
3608 | 3798 | |
3609 | 3799 | echo ' |
3610 | 3800 | </td> |
@@ -3615,9 +3805,10 @@ discard block |
||
3615 | 3805 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
3616 | 3806 | <input type="hidden" name="hash_passwrd" value="">'; |
3617 | 3807 | |
3618 | - if (!empty($upcontext['password_failed'])) |
|
3619 | - echo ' |
|
3808 | + if (!empty($upcontext['password_failed'])) { |
|
3809 | + echo ' |
|
3620 | 3810 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3811 | + } |
|
3621 | 3812 | |
3622 | 3813 | echo ' |
3623 | 3814 | </td> |
@@ -3688,8 +3879,8 @@ discard block |
||
3688 | 3879 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3689 | 3880 | |
3690 | 3881 | // Warning message? |
3691 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3692 | - echo ' |
|
3882 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3883 | + echo ' |
|
3693 | 3884 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3694 | 3885 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3695 | 3886 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3697,6 +3888,7 @@ discard block |
||
3697 | 3888 | ', $upcontext['upgrade_options_warning'], ' |
3698 | 3889 | </div> |
3699 | 3890 | </div>'; |
3891 | + } |
|
3700 | 3892 | |
3701 | 3893 | echo ' |
3702 | 3894 | <table> |
@@ -3739,8 +3931,8 @@ discard block |
||
3739 | 3931 | </td> |
3740 | 3932 | </tr>'; |
3741 | 3933 | |
3742 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3743 | - echo ' |
|
3934 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3935 | + echo ' |
|
3744 | 3936 | <tr valign="top"> |
3745 | 3937 | <td width="2%"> |
3746 | 3938 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3749,6 +3941,7 @@ discard block |
||
3749 | 3941 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3750 | 3942 | </td> |
3751 | 3943 | </tr>'; |
3944 | + } |
|
3752 | 3945 | |
3753 | 3946 | echo ' |
3754 | 3947 | <tr valign="top"> |
@@ -3786,10 +3979,11 @@ discard block |
||
3786 | 3979 | </div>'; |
3787 | 3980 | |
3788 | 3981 | // Dont any tables so far? |
3789 | - if (!empty($upcontext['previous_tables'])) |
|
3790 | - foreach ($upcontext['previous_tables'] as $table) |
|
3982 | + if (!empty($upcontext['previous_tables'])) { |
|
3983 | + foreach ($upcontext['previous_tables'] as $table) |
|
3791 | 3984 | echo ' |
3792 | 3985 | <br>Completed Table: "', $table, '".'; |
3986 | + } |
|
3793 | 3987 | |
3794 | 3988 | echo ' |
3795 | 3989 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3826,12 +4020,13 @@ discard block |
||
3826 | 4020 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3827 | 4021 | |
3828 | 4022 | // If debug flood the screen. |
3829 | - if ($is_debug) |
|
3830 | - echo ' |
|
4023 | + if ($is_debug) { |
|
4024 | + echo ' |
|
3831 | 4025 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3832 | 4026 | |
3833 | 4027 | if (document.getElementById(\'debug_section\').scrollHeight) |
3834 | 4028 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4029 | + } |
|
3835 | 4030 | |
3836 | 4031 | echo ' |
3837 | 4032 | // Get the next update... |
@@ -3864,8 +4059,9 @@ discard block |
||
3864 | 4059 | { |
3865 | 4060 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3866 | 4061 | |
3867 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3868 | - $is_debug = true; |
|
4062 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4063 | + $is_debug = true; |
|
4064 | + } |
|
3869 | 4065 | |
3870 | 4066 | echo ' |
3871 | 4067 | <h3>Executing database changes</h3> |
@@ -3880,8 +4076,9 @@ discard block |
||
3880 | 4076 | { |
3881 | 4077 | foreach ($upcontext['actioned_items'] as $num => $item) |
3882 | 4078 | { |
3883 | - if ($num != 0) |
|
3884 | - echo ' Successful!'; |
|
4079 | + if ($num != 0) { |
|
4080 | + echo ' Successful!'; |
|
4081 | + } |
|
3885 | 4082 | echo '<br>' . $item; |
3886 | 4083 | } |
3887 | 4084 | if (!empty($upcontext['changes_complete'])) |
@@ -3894,28 +4091,32 @@ discard block |
||
3894 | 4091 | $seconds = intval($active % 60); |
3895 | 4092 | |
3896 | 4093 | $totalTime = ''; |
3897 | - if ($hours > 0) |
|
3898 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3899 | - if ($minutes > 0) |
|
3900 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3901 | - if ($seconds > 0) |
|
3902 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4094 | + if ($hours > 0) { |
|
4095 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4096 | + } |
|
4097 | + if ($minutes > 0) { |
|
4098 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4099 | + } |
|
4100 | + if ($seconds > 0) { |
|
4101 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4102 | + } |
|
3903 | 4103 | } |
3904 | 4104 | |
3905 | - if ($is_debug && !empty($totalTime)) |
|
3906 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3907 | - else |
|
3908 | - echo ' Successful!<br><br>'; |
|
4105 | + if ($is_debug && !empty($totalTime)) { |
|
4106 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4107 | + } else { |
|
4108 | + echo ' Successful!<br><br>'; |
|
4109 | + } |
|
3909 | 4110 | |
3910 | 4111 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3911 | 4112 | } |
3912 | - } |
|
3913 | - else |
|
4113 | + } else |
|
3914 | 4114 | { |
3915 | 4115 | // Tell them how many files we have in total. |
3916 | - if ($upcontext['file_count'] > 1) |
|
3917 | - echo ' |
|
4116 | + if ($upcontext['file_count'] > 1) { |
|
4117 | + echo ' |
|
3918 | 4118 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4119 | + } |
|
3919 | 4120 | |
3920 | 4121 | echo ' |
3921 | 4122 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3931,19 +4132,23 @@ discard block |
||
3931 | 4132 | $seconds = intval($active % 60); |
3932 | 4133 | |
3933 | 4134 | $totalTime = ''; |
3934 | - if ($hours > 0) |
|
3935 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3936 | - if ($minutes > 0) |
|
3937 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3938 | - if ($seconds > 0) |
|
3939 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4135 | + if ($hours > 0) { |
|
4136 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4137 | + } |
|
4138 | + if ($minutes > 0) { |
|
4139 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4140 | + } |
|
4141 | + if ($seconds > 0) { |
|
4142 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4143 | + } |
|
3940 | 4144 | } |
3941 | 4145 | |
3942 | 4146 | echo ' |
3943 | 4147 | <br><span id="upgradeCompleted">'; |
3944 | 4148 | |
3945 | - if (!empty($totalTime)) |
|
3946 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4149 | + if (!empty($totalTime)) { |
|
4150 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4151 | + } |
|
3947 | 4152 | |
3948 | 4153 | echo '</span> |
3949 | 4154 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -3980,9 +4185,10 @@ discard block |
||
3980 | 4185 | var getData = ""; |
3981 | 4186 | var debugItems = ', $upcontext['debug_items'], ';'; |
3982 | 4187 | |
3983 | - if ($is_debug) |
|
3984 | - echo ' |
|
4188 | + if ($is_debug) { |
|
4189 | + echo ' |
|
3985 | 4190 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4191 | + } |
|
3986 | 4192 | |
3987 | 4193 | echo ' |
3988 | 4194 | function getNextItem() |
@@ -4022,9 +4228,10 @@ discard block |
||
4022 | 4228 | document.getElementById("error_block").style.display = ""; |
4023 | 4229 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4024 | 4230 | |
4025 | - if ($is_debug) |
|
4026 | - echo ' |
|
4231 | + if ($is_debug) { |
|
4232 | + echo ' |
|
4027 | 4233 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4234 | + } |
|
4028 | 4235 | |
4029 | 4236 | echo ' |
4030 | 4237 | } |
@@ -4045,9 +4252,10 @@ discard block |
||
4045 | 4252 | document.getElementById("error_block").style.display = ""; |
4046 | 4253 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4047 | 4254 | |
4048 | - if ($is_debug) |
|
4049 | - echo ' |
|
4255 | + if ($is_debug) { |
|
4256 | + echo ' |
|
4050 | 4257 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4258 | + } |
|
4051 | 4259 | |
4052 | 4260 | echo ' |
4053 | 4261 | } |
@@ -4106,8 +4314,8 @@ discard block |
||
4106 | 4314 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4107 | 4315 | {'; |
4108 | 4316 | |
4109 | - if ($is_debug) |
|
4110 | - echo ' |
|
4317 | + if ($is_debug) { |
|
4318 | + echo ' |
|
4111 | 4319 | document.getElementById(\'debug_section\').style.display = "none"; |
4112 | 4320 | |
4113 | 4321 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4125,6 +4333,7 @@ discard block |
||
4125 | 4333 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4126 | 4334 | |
4127 | 4335 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4336 | + } |
|
4128 | 4337 | |
4129 | 4338 | echo ' |
4130 | 4339 | |
@@ -4132,9 +4341,10 @@ discard block |
||
4132 | 4341 | document.getElementById(\'contbutt\').disabled = 0; |
4133 | 4342 | document.getElementById(\'database_done\').value = 1;'; |
4134 | 4343 | |
4135 | - if ($upcontext['file_count'] > 1) |
|
4136 | - echo ' |
|
4344 | + if ($upcontext['file_count'] > 1) { |
|
4345 | + echo ' |
|
4137 | 4346 | document.getElementById(\'info1\').style.display = "none";'; |
4347 | + } |
|
4138 | 4348 | |
4139 | 4349 | echo ' |
4140 | 4350 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4147,9 +4357,10 @@ discard block |
||
4147 | 4357 | lastItem = 0; |
4148 | 4358 | prevFile = curFile;'; |
4149 | 4359 | |
4150 | - if ($is_debug) |
|
4151 | - echo ' |
|
4360 | + if ($is_debug) { |
|
4361 | + echo ' |
|
4152 | 4362 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4363 | + } |
|
4153 | 4364 | |
4154 | 4365 | echo ' |
4155 | 4366 | getNextItem(); |
@@ -4157,8 +4368,8 @@ discard block |
||
4157 | 4368 | }'; |
4158 | 4369 | |
4159 | 4370 | // If debug scroll the screen. |
4160 | - if ($is_debug) |
|
4161 | - echo ' |
|
4371 | + if ($is_debug) { |
|
4372 | + echo ' |
|
4162 | 4373 | if (iLastSubStepProgress == -1) |
4163 | 4374 | { |
4164 | 4375 | // Give it consistent dots. |
@@ -4177,6 +4388,7 @@ discard block |
||
4177 | 4388 | |
4178 | 4389 | if (document.getElementById(\'debug_section\').scrollHeight) |
4179 | 4390 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4391 | + } |
|
4180 | 4392 | |
4181 | 4393 | echo ' |
4182 | 4394 | // Update the page. |
@@ -4237,9 +4449,10 @@ discard block |
||
4237 | 4449 | }'; |
4238 | 4450 | |
4239 | 4451 | // Start things off assuming we've not errored. |
4240 | - if (empty($upcontext['error_message'])) |
|
4241 | - echo ' |
|
4452 | + if (empty($upcontext['error_message'])) { |
|
4453 | + echo ' |
|
4242 | 4454 | getNextItem();'; |
4455 | + } |
|
4243 | 4456 | |
4244 | 4457 | echo ' |
4245 | 4458 | //# sourceURL=dynamicScript-dbch.js |
@@ -4257,18 +4470,21 @@ discard block |
||
4257 | 4470 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4258 | 4471 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
4259 | 4472 | |
4260 | - if (!empty($upcontext['error_message'])) |
|
4261 | - echo ' |
|
4473 | + if (!empty($upcontext['error_message'])) { |
|
4474 | + echo ' |
|
4262 | 4475 | <error>', $upcontext['error_message'], '</error>'; |
4476 | + } |
|
4263 | 4477 | |
4264 | - if (!empty($upcontext['error_string'])) |
|
4265 | - echo ' |
|
4478 | + if (!empty($upcontext['error_string'])) { |
|
4479 | + echo ' |
|
4266 | 4480 | <sql>', $upcontext['error_string'], '</sql>'; |
4481 | + } |
|
4267 | 4482 | |
4268 | - if ($is_debug) |
|
4269 | - echo ' |
|
4483 | + if ($is_debug) { |
|
4484 | + echo ' |
|
4270 | 4485 | <curtime>', time(), '</curtime>'; |
4271 | -} |
|
4486 | + } |
|
4487 | + } |
|
4272 | 4488 | |
4273 | 4489 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4274 | 4490 | function template_convert_utf8() |
@@ -4287,18 +4503,20 @@ discard block |
||
4287 | 4503 | </div>'; |
4288 | 4504 | |
4289 | 4505 | // Done any tables so far? |
4290 | - if (!empty($upcontext['previous_tables'])) |
|
4291 | - foreach ($upcontext['previous_tables'] as $table) |
|
4506 | + if (!empty($upcontext['previous_tables'])) { |
|
4507 | + foreach ($upcontext['previous_tables'] as $table) |
|
4292 | 4508 | echo ' |
4293 | 4509 | <br>Completed Table: "', $table, '".'; |
4510 | + } |
|
4294 | 4511 | |
4295 | 4512 | echo ' |
4296 | 4513 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4297 | 4514 | |
4298 | 4515 | // If we dropped their index, let's let them know |
4299 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
4300 | - echo ' |
|
4516 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
4517 | + echo ' |
|
4301 | 4518 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
4519 | + } |
|
4302 | 4520 | |
4303 | 4521 | echo ' |
4304 | 4522 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4334,12 +4552,13 @@ discard block |
||
4334 | 4552 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4335 | 4553 | |
4336 | 4554 | // If debug flood the screen. |
4337 | - if ($is_debug) |
|
4338 | - echo ' |
|
4555 | + if ($is_debug) { |
|
4556 | + echo ' |
|
4339 | 4557 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4340 | 4558 | |
4341 | 4559 | if (document.getElementById(\'debug_section\').scrollHeight) |
4342 | 4560 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4561 | + } |
|
4343 | 4562 | |
4344 | 4563 | echo ' |
4345 | 4564 | // Get the next update... |
@@ -4384,19 +4603,21 @@ discard block |
||
4384 | 4603 | </div>'; |
4385 | 4604 | |
4386 | 4605 | // Dont any tables so far? |
4387 | - if (!empty($upcontext['previous_tables'])) |
|
4388 | - foreach ($upcontext['previous_tables'] as $table) |
|
4606 | + if (!empty($upcontext['previous_tables'])) { |
|
4607 | + foreach ($upcontext['previous_tables'] as $table) |
|
4389 | 4608 | echo ' |
4390 | 4609 | <br>Completed Table: "', $table, '".'; |
4610 | + } |
|
4391 | 4611 | |
4392 | 4612 | echo ' |
4393 | 4613 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4394 | 4614 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
4395 | 4615 | |
4396 | 4616 | // Try to make sure substep was reset. |
4397 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4398 | - echo ' |
|
4617 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4618 | + echo ' |
|
4399 | 4619 | <input type="hidden" name="substep" id="substep" value="0">'; |
4620 | + } |
|
4400 | 4621 | |
4401 | 4622 | // Continue please! |
4402 | 4623 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4429,12 +4650,13 @@ discard block |
||
4429 | 4650 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4430 | 4651 | |
4431 | 4652 | // If debug flood the screen. |
4432 | - if ($is_debug) |
|
4433 | - echo ' |
|
4653 | + if ($is_debug) { |
|
4654 | + echo ' |
|
4434 | 4655 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4435 | 4656 | |
4436 | 4657 | if (document.getElementById(\'debug_section\').scrollHeight) |
4437 | 4658 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4659 | + } |
|
4438 | 4660 | |
4439 | 4661 | echo ' |
4440 | 4662 | // Get the next update... |
@@ -4470,8 +4692,8 @@ discard block |
||
4470 | 4692 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
4471 | 4693 | <form action="', $boardurl, '/index.php">'; |
4472 | 4694 | |
4473 | - if (!empty($upcontext['can_delete_script'])) |
|
4474 | - echo ' |
|
4695 | + if (!empty($upcontext['can_delete_script'])) { |
|
4696 | + echo ' |
|
4475 | 4697 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
4476 | 4698 | <script> |
4477 | 4699 | function doTheDelete(theCheck) |
@@ -4483,6 +4705,7 @@ discard block |
||
4483 | 4705 | } |
4484 | 4706 | </script> |
4485 | 4707 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4708 | + } |
|
4486 | 4709 | |
4487 | 4710 | $active = time() - $upcontext['started']; |
4488 | 4711 | $hours = floor($active / 3600); |
@@ -4492,16 +4715,20 @@ discard block |
||
4492 | 4715 | if ($is_debug) |
4493 | 4716 | { |
4494 | 4717 | $totalTime = ''; |
4495 | - if ($hours > 0) |
|
4496 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4497 | - if ($minutes > 0) |
|
4498 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4499 | - if ($seconds > 0) |
|
4500 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4718 | + if ($hours > 0) { |
|
4719 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4720 | + } |
|
4721 | + if ($minutes > 0) { |
|
4722 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4723 | + } |
|
4724 | + if ($seconds > 0) { |
|
4725 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4726 | + } |
|
4501 | 4727 | } |
4502 | 4728 | |
4503 | - if ($is_debug && !empty($totalTime)) |
|
4504 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4729 | + if ($is_debug && !empty($totalTime)) { |
|
4730 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4731 | + } |
|
4505 | 4732 | |
4506 | 4733 | echo '<br> |
4507 | 4734 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4528,8 +4755,9 @@ discard block |
||
4528 | 4755 | |
4529 | 4756 | $current_substep = $_GET['substep']; |
4530 | 4757 | |
4531 | - if (empty($_GET['a'])) |
|
4532 | - $_GET['a'] = 0; |
|
4758 | + if (empty($_GET['a'])) { |
|
4759 | + $_GET['a'] = 0; |
|
4760 | + } |
|
4533 | 4761 | $step_progress['name'] = 'Converting ips'; |
4534 | 4762 | $step_progress['current'] = $_GET['a']; |
4535 | 4763 | |
@@ -4572,16 +4800,19 @@ discard block |
||
4572 | 4800 | 'empty' => '', |
4573 | 4801 | 'limit' => $limit, |
4574 | 4802 | )); |
4575 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4576 | - $arIp[] = $row[$oldCol]; |
|
4803 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4804 | + $arIp[] = $row[$oldCol]; |
|
4805 | + } |
|
4577 | 4806 | $smcFunc['db_free_result']($request); |
4578 | 4807 | |
4579 | 4808 | // Special case, null ip could keep us in a loop. |
4580 | - if (is_null($arIp[0])) |
|
4581 | - unset($arIp[0]); |
|
4809 | + if (is_null($arIp[0])) { |
|
4810 | + unset($arIp[0]); |
|
4811 | + } |
|
4582 | 4812 | |
4583 | - if (empty($arIp)) |
|
4584 | - $is_done = true; |
|
4813 | + if (empty($arIp)) { |
|
4814 | + $is_done = true; |
|
4815 | + } |
|
4585 | 4816 | |
4586 | 4817 | $updates = array(); |
4587 | 4818 | $cases = array(); |
@@ -4590,16 +4821,18 @@ discard block |
||
4590 | 4821 | { |
4591 | 4822 | $arIp[$i] = trim($arIp[$i]); |
4592 | 4823 | |
4593 | - if (empty($arIp[$i])) |
|
4594 | - continue; |
|
4824 | + if (empty($arIp[$i])) { |
|
4825 | + continue; |
|
4826 | + } |
|
4595 | 4827 | |
4596 | 4828 | $updates['ip' . $i] = $arIp[$i]; |
4597 | 4829 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4598 | 4830 | |
4599 | 4831 | if ($setSize > 0 && $i % $setSize === 0) |
4600 | 4832 | { |
4601 | - if (count($updates) == 1) |
|
4602 | - continue; |
|
4833 | + if (count($updates) == 1) { |
|
4834 | + continue; |
|
4835 | + } |
|
4603 | 4836 | |
4604 | 4837 | $updates['whereSet'] = array_values($updates); |
4605 | 4838 | $smcFunc['db_query']('', ' |
@@ -4633,8 +4866,7 @@ discard block |
||
4633 | 4866 | 'ip' => $ip |
4634 | 4867 | )); |
4635 | 4868 | } |
4636 | - } |
|
4637 | - else |
|
4869 | + } else |
|
4638 | 4870 | { |
4639 | 4871 | $updates['whereSet'] = array_values($updates); |
4640 | 4872 | $smcFunc['db_query']('', ' |
@@ -4648,9 +4880,9 @@ discard block |
||
4648 | 4880 | $updates |
4649 | 4881 | ); |
4650 | 4882 | } |
4883 | + } else { |
|
4884 | + $is_done = true; |
|
4651 | 4885 | } |
4652 | - else |
|
4653 | - $is_done = true; |
|
4654 | 4886 | |
4655 | 4887 | $_GET['a'] += $limit; |
4656 | 4888 | $step_progress['current'] = $_GET['a']; |
@@ -4676,10 +4908,11 @@ discard block |
||
4676 | 4908 | |
4677 | 4909 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4678 | 4910 | |
4679 | - if (isset($columns[$column])) |
|
4680 | - return $columns[$column]; |
|
4681 | - else |
|
4682 | - return null; |
|
4683 | -} |
|
4911 | + if (isset($columns[$column])) { |
|
4912 | + return $columns[$column]; |
|
4913 | + } else { |
|
4914 | + return null; |
|
4915 | + } |
|
4916 | + } |
|
4684 | 4917 | |
4685 | 4918 | ?> |
4686 | 4919 | \ No newline at end of file |
@@ -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;', |
@@ -74,12 +76,14 @@ discard block |
||
74 | 76 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
75 | 77 | |
76 | 78 | // Is it reserved? |
77 | - if ($value == 'pg_') |
|
78 | - return $txt['error_db_prefix_reserved']; |
|
79 | + if ($value == 'pg_') { |
|
80 | + return $txt['error_db_prefix_reserved']; |
|
81 | + } |
|
79 | 82 | |
80 | 83 | // Is the prefix numeric? |
81 | - if (preg_match('~^\d~', $value)) |
|
82 | - return $txt['error_db_prefix_numeric']; |
|
84 | + if (preg_match('~^\d~', $value)) { |
|
85 | + return $txt['error_db_prefix_numeric']; |
|
86 | + } |
|
83 | 87 | |
84 | 88 | return true; |
85 | 89 | }, |
@@ -124,10 +128,11 @@ discard block |
||
124 | 128 | $incontext['skip'] = false; |
125 | 129 | |
126 | 130 | // Call the step and if it returns false that means pause! |
127 | - if (function_exists($step[2]) && $step[2]() === false) |
|
128 | - break; |
|
129 | - elseif (function_exists($step[2])) |
|
130 | - $incontext['current_step']++; |
|
131 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
132 | + break; |
|
133 | + } elseif (function_exists($step[2])) { |
|
134 | + $incontext['current_step']++; |
|
135 | + } |
|
131 | 136 | |
132 | 137 | // No warnings pass on. |
133 | 138 | $incontext['warning'] = ''; |
@@ -143,12 +148,14 @@ discard block |
||
143 | 148 | global $databases, $incontext; |
144 | 149 | |
145 | 150 | // Just so people using older versions of PHP aren't left in the cold. |
146 | - if (!isset($_SERVER['PHP_SELF'])) |
|
147 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
151 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
152 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
153 | + } |
|
148 | 154 | |
149 | 155 | // Turn off magic quotes runtime and enable error reporting. |
150 | - if (function_exists('set_magic_quotes_runtime')) |
|
151 | - @set_magic_quotes_runtime(0); |
|
156 | + if (function_exists('set_magic_quotes_runtime')) { |
|
157 | + @set_magic_quotes_runtime(0); |
|
158 | + } |
|
152 | 159 | error_reporting(E_ALL); |
153 | 160 | |
154 | 161 | // Fun. Low PHP version... |
@@ -162,21 +169,23 @@ discard block |
||
162 | 169 | { |
163 | 170 | ob_start(); |
164 | 171 | |
165 | - if (ini_get('session.save_handler') == 'user') |
|
166 | - @ini_set('session.save_handler', 'files'); |
|
167 | - if (function_exists('session_start')) |
|
168 | - @session_start(); |
|
169 | - } |
|
170 | - else |
|
172 | + if (ini_get('session.save_handler') == 'user') { |
|
173 | + @ini_set('session.save_handler', 'files'); |
|
174 | + } |
|
175 | + if (function_exists('session_start')) { |
|
176 | + @session_start(); |
|
177 | + } |
|
178 | + } else |
|
171 | 179 | { |
172 | 180 | ob_start('ob_gzhandler'); |
173 | 181 | |
174 | - if (ini_get('session.save_handler') == 'user') |
|
175 | - @ini_set('session.save_handler', 'files'); |
|
182 | + if (ini_get('session.save_handler') == 'user') { |
|
183 | + @ini_set('session.save_handler', 'files'); |
|
184 | + } |
|
176 | 185 | session_start(); |
177 | 186 | |
178 | - if (!headers_sent()) |
|
179 | - echo '<!DOCTYPE html> |
|
187 | + if (!headers_sent()) { |
|
188 | + echo '<!DOCTYPE html> |
|
180 | 189 | <html> |
181 | 190 | <head> |
182 | 191 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -185,14 +194,16 @@ discard block |
||
185 | 194 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
186 | 195 | </body> |
187 | 196 | </html>'; |
197 | + } |
|
188 | 198 | exit; |
189 | 199 | } |
190 | 200 | |
191 | 201 | // Add slashes, as long as they aren't already being added. |
192 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
193 | - foreach ($_POST as $k => $v) |
|
202 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
203 | + foreach ($_POST as $k => $v) |
|
194 | 204 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
195 | 205 | $_POST[$k] = addslashes($v); |
206 | + } |
|
196 | 207 | |
197 | 208 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
198 | 209 | if (isset($_GET['delete'])) |
@@ -213,8 +224,7 @@ discard block |
||
213 | 224 | $ftp->close(); |
214 | 225 | |
215 | 226 | unset($_SESSION['installer_temp_ftp']); |
216 | - } |
|
217 | - else |
|
227 | + } else |
|
218 | 228 | { |
219 | 229 | @unlink(__FILE__); |
220 | 230 | |
@@ -235,10 +245,11 @@ discard block |
||
235 | 245 | { |
236 | 246 | // Get PHP's default timezone, if set |
237 | 247 | $ini_tz = ini_get('date.timezone'); |
238 | - if (!empty($ini_tz)) |
|
239 | - $timezone_id = $ini_tz; |
|
240 | - else |
|
241 | - $timezone_id = ''; |
|
248 | + if (!empty($ini_tz)) { |
|
249 | + $timezone_id = $ini_tz; |
|
250 | + } else { |
|
251 | + $timezone_id = ''; |
|
252 | + } |
|
242 | 253 | |
243 | 254 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
244 | 255 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -268,8 +279,9 @@ discard block |
||
268 | 279 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
269 | 280 | while ($entry = $dir->read()) |
270 | 281 | { |
271 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
272 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
282 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
283 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
284 | + } |
|
273 | 285 | } |
274 | 286 | $dir->close(); |
275 | 287 | } |
@@ -304,10 +316,11 @@ discard block |
||
304 | 316 | } |
305 | 317 | |
306 | 318 | // Override the language file? |
307 | - if (isset($_GET['lang_file'])) |
|
308 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
309 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
310 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
319 | + if (isset($_GET['lang_file'])) { |
|
320 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
321 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
322 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
323 | + } |
|
311 | 324 | |
312 | 325 | // Make sure it exists, if it doesn't reset it. |
313 | 326 | 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'])) |
@@ -316,8 +329,9 @@ discard block |
||
316 | 329 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
317 | 330 | |
318 | 331 | // If we have english and some other language, use the other language. We Americans hate english :P. |
319 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
320 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
332 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
333 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
334 | + } |
|
321 | 335 | } |
322 | 336 | |
323 | 337 | // And now include the actual language file itself. |
@@ -330,15 +344,18 @@ discard block |
||
330 | 344 | global $db_prefix, $db_connection, $sourcedir; |
331 | 345 | global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist; |
332 | 346 | |
333 | - if (empty($sourcedir)) |
|
334 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
347 | + if (empty($sourcedir)) { |
|
348 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
349 | + } |
|
335 | 350 | |
336 | 351 | // Need this to check whether we need the database password. |
337 | 352 | require(dirname(__FILE__) . '/Settings.php'); |
338 | - if (!defined('SMF')) |
|
339 | - define('SMF', 1); |
|
340 | - if (empty($smcFunc)) |
|
341 | - $smcFunc = array(); |
|
353 | + if (!defined('SMF')) { |
|
354 | + define('SMF', 1); |
|
355 | + } |
|
356 | + if (empty($smcFunc)) { |
|
357 | + $smcFunc = array(); |
|
358 | + } |
|
342 | 359 | |
343 | 360 | $modSettings['disableQueryCheck'] = true; |
344 | 361 | |
@@ -346,8 +363,9 @@ discard block |
||
346 | 363 | if (!$db_connection) |
347 | 364 | { |
348 | 365 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
349 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
350 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
366 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
367 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
368 | + } |
|
351 | 369 | |
352 | 370 | $db_options = array('persist' => $db_persist); |
353 | 371 | $port = ''; |
@@ -358,19 +376,20 @@ discard block |
||
358 | 376 | if ($db_type == 'mysql') |
359 | 377 | { |
360 | 378 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
361 | - } |
|
362 | - elseif ($db_type == 'postgresql') |
|
379 | + } elseif ($db_type == 'postgresql') |
|
363 | 380 | { |
364 | 381 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
365 | 382 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
366 | 383 | } |
367 | 384 | } |
368 | 385 | |
369 | - if (!empty($port)) |
|
370 | - $db_options['port'] = $port; |
|
386 | + if (!empty($port)) { |
|
387 | + $db_options['port'] = $port; |
|
388 | + } |
|
371 | 389 | |
372 | - if (!$db_connection) |
|
373 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
390 | + if (!$db_connection) { |
|
391 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
392 | + } |
|
374 | 393 | } |
375 | 394 | } |
376 | 395 | |
@@ -398,8 +417,9 @@ discard block |
||
398 | 417 | // @todo REMOVE THIS!! |
399 | 418 | else |
400 | 419 | { |
401 | - if (function_exists('doStep' . $_GET['step'])) |
|
402 | - call_user_func('doStep' . $_GET['step']); |
|
420 | + if (function_exists('doStep' . $_GET['step'])) { |
|
421 | + call_user_func('doStep' . $_GET['step']); |
|
422 | + } |
|
403 | 423 | } |
404 | 424 | // Show the footer. |
405 | 425 | template_install_below(); |
@@ -417,8 +437,9 @@ discard block |
||
417 | 437 | $incontext['sub_template'] = 'welcome_message'; |
418 | 438 | |
419 | 439 | // Done the submission? |
420 | - if (isset($_POST['contbutt'])) |
|
421 | - return true; |
|
440 | + if (isset($_POST['contbutt'])) { |
|
441 | + return true; |
|
442 | + } |
|
422 | 443 | |
423 | 444 | // See if we think they have already installed it? |
424 | 445 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -426,14 +447,17 @@ discard block |
||
426 | 447 | $probably_installed = 0; |
427 | 448 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
428 | 449 | { |
429 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
430 | - $probably_installed++; |
|
431 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
432 | - $probably_installed++; |
|
450 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
451 | + $probably_installed++; |
|
452 | + } |
|
453 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
454 | + $probably_installed++; |
|
455 | + } |
|
433 | 456 | } |
434 | 457 | |
435 | - if ($probably_installed == 2) |
|
436 | - $incontext['warning'] = $txt['error_already_installed']; |
|
458 | + if ($probably_installed == 2) { |
|
459 | + $incontext['warning'] = $txt['error_already_installed']; |
|
460 | + } |
|
437 | 461 | } |
438 | 462 | |
439 | 463 | // Is some database support even compiled in? |
@@ -448,36 +472,43 @@ discard block |
||
448 | 472 | $databases[$key]['supported'] = false; |
449 | 473 | $notFoundSQLFile = true; |
450 | 474 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
475 | + } else { |
|
476 | + $incontext['supported_databases'][] = $db; |
|
451 | 477 | } |
452 | - else |
|
453 | - $incontext['supported_databases'][] = $db; |
|
454 | 478 | } |
455 | 479 | } |
456 | 480 | |
457 | 481 | // Check the PHP version. |
458 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
459 | - $error = 'error_php_too_low'; |
|
482 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) { |
|
483 | + $error = 'error_php_too_low'; |
|
484 | + } |
|
460 | 485 | // Make sure we have a supported database |
461 | - elseif (empty($incontext['supported_databases'])) |
|
462 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
486 | + elseif (empty($incontext['supported_databases'])) { |
|
487 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
488 | + } |
|
463 | 489 | // How about session support? Some crazy sysadmin remove it? |
464 | - elseif (!function_exists('session_start')) |
|
465 | - $error = 'error_session_missing'; |
|
490 | + elseif (!function_exists('session_start')) { |
|
491 | + $error = 'error_session_missing'; |
|
492 | + } |
|
466 | 493 | // Make sure they uploaded all the files. |
467 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
468 | - $error = 'error_missing_files'; |
|
494 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
495 | + $error = 'error_missing_files'; |
|
496 | + } |
|
469 | 497 | // Very simple check on the session.save_path for Windows. |
470 | 498 | // @todo Move this down later if they don't use database-driven sessions? |
471 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
472 | - $error = 'error_session_save_path'; |
|
499 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
500 | + $error = 'error_session_save_path'; |
|
501 | + } |
|
473 | 502 | |
474 | 503 | // Since each of the three messages would look the same, anyway... |
475 | - if (isset($error)) |
|
476 | - $incontext['error'] = $txt[$error]; |
|
504 | + if (isset($error)) { |
|
505 | + $incontext['error'] = $txt[$error]; |
|
506 | + } |
|
477 | 507 | |
478 | 508 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
479 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
480 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
509 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
510 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
511 | + } |
|
481 | 512 | |
482 | 513 | return false; |
483 | 514 | } |
@@ -503,12 +534,14 @@ discard block |
||
503 | 534 | 'db_last_error.php', |
504 | 535 | ); |
505 | 536 | |
506 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
507 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
537 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
538 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
539 | + } |
|
508 | 540 | |
509 | 541 | // With mod_security installed, we could attempt to fix it with .htaccess. |
510 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
511 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
542 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
543 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
544 | + } |
|
512 | 545 | |
513 | 546 | $failed_files = array(); |
514 | 547 | |
@@ -524,12 +557,14 @@ discard block |
||
524 | 557 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
525 | 558 | |
526 | 559 | // Well, 755 hopefully worked... if not, try 777. |
527 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
528 | - $failed_files[] = $file; |
|
560 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
561 | + $failed_files[] = $file; |
|
562 | + } |
|
529 | 563 | } |
530 | 564 | } |
531 | - foreach ($extra_files as $file) |
|
532 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
565 | + foreach ($extra_files as $file) { |
|
566 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
567 | + } |
|
533 | 568 | } |
534 | 569 | // Windows is trickier. Let's try opening for r+... |
535 | 570 | else |
@@ -539,30 +574,35 @@ discard block |
||
539 | 574 | foreach ($writable_files as $file) |
540 | 575 | { |
541 | 576 | // Folders can't be opened for write... but the index.php in them can ;) |
542 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
543 | - $file .= '/index.php'; |
|
577 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
578 | + $file .= '/index.php'; |
|
579 | + } |
|
544 | 580 | |
545 | 581 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
546 | 582 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
547 | 583 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
548 | 584 | |
549 | 585 | // Hmm, okay, try just for write in that case... |
550 | - if (!is_resource($fp)) |
|
551 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
586 | + if (!is_resource($fp)) { |
|
587 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
588 | + } |
|
552 | 589 | |
553 | - if (!is_resource($fp)) |
|
554 | - $failed_files[] = $file; |
|
590 | + if (!is_resource($fp)) { |
|
591 | + $failed_files[] = $file; |
|
592 | + } |
|
555 | 593 | |
556 | 594 | @fclose($fp); |
557 | 595 | } |
558 | - foreach ($extra_files as $file) |
|
559 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
596 | + foreach ($extra_files as $file) { |
|
597 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
598 | + } |
|
560 | 599 | } |
561 | 600 | |
562 | 601 | $failure = count($failed_files) >= 1; |
563 | 602 | |
564 | - if (!isset($_SERVER)) |
|
565 | - return !$failure; |
|
603 | + if (!isset($_SERVER)) { |
|
604 | + return !$failure; |
|
605 | + } |
|
566 | 606 | |
567 | 607 | // Put the list into context. |
568 | 608 | $incontext['failed_files'] = $failed_files; |
@@ -610,19 +650,23 @@ discard block |
||
610 | 650 | |
611 | 651 | if (!isset($ftp) || $ftp->error !== false) |
612 | 652 | { |
613 | - if (!isset($ftp)) |
|
614 | - $ftp = new ftp_connection(null); |
|
653 | + if (!isset($ftp)) { |
|
654 | + $ftp = new ftp_connection(null); |
|
655 | + } |
|
615 | 656 | // Save the error so we can mess with listing... |
616 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
617 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
657 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
658 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
659 | + } |
|
618 | 660 | |
619 | 661 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
620 | 662 | |
621 | - if (empty($_POST['ftp_path']) && $found_path) |
|
622 | - $_POST['ftp_path'] = $detect_path; |
|
663 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
664 | + $_POST['ftp_path'] = $detect_path; |
|
665 | + } |
|
623 | 666 | |
624 | - if (!isset($_POST['ftp_username'])) |
|
625 | - $_POST['ftp_username'] = $username; |
|
667 | + if (!isset($_POST['ftp_username'])) { |
|
668 | + $_POST['ftp_username'] = $username; |
|
669 | + } |
|
626 | 670 | |
627 | 671 | // Set the username etc, into context. |
628 | 672 | $incontext['ftp'] = array( |
@@ -634,8 +678,7 @@ discard block |
||
634 | 678 | ); |
635 | 679 | |
636 | 680 | return false; |
637 | - } |
|
638 | - else |
|
681 | + } else |
|
639 | 682 | { |
640 | 683 | $_SESSION['installer_temp_ftp'] = array( |
641 | 684 | 'server' => $_POST['ftp_server'], |
@@ -649,10 +692,12 @@ discard block |
||
649 | 692 | |
650 | 693 | foreach ($failed_files as $file) |
651 | 694 | { |
652 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
653 | - $ftp->chmod($file, 0755); |
|
654 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
655 | - $ftp->chmod($file, 0777); |
|
695 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
696 | + $ftp->chmod($file, 0755); |
|
697 | + } |
|
698 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
699 | + $ftp->chmod($file, 0777); |
|
700 | + } |
|
656 | 701 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
657 | 702 | { |
658 | 703 | $failed_files_updated[] = $file; |
@@ -707,15 +752,17 @@ discard block |
||
707 | 752 | |
708 | 753 | if (!$foundOne) |
709 | 754 | { |
710 | - if (isset($db['default_host'])) |
|
711 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
755 | + if (isset($db['default_host'])) { |
|
756 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
757 | + } |
|
712 | 758 | if (isset($db['default_user'])) |
713 | 759 | { |
714 | 760 | $incontext['db']['user'] = ini_get($db['default_user']); |
715 | 761 | $incontext['db']['name'] = ini_get($db['default_user']); |
716 | 762 | } |
717 | - if (isset($db['default_password'])) |
|
718 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
763 | + if (isset($db['default_password'])) { |
|
764 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
765 | + } |
|
719 | 766 | |
720 | 767 | // For simplicity and less confusion, leave the port blank by default |
721 | 768 | $incontext['db']['port'] = ''; |
@@ -734,10 +781,10 @@ discard block |
||
734 | 781 | $incontext['db']['server'] = $_POST['db_server']; |
735 | 782 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
736 | 783 | |
737 | - if (!empty($_POST['db_port'])) |
|
738 | - $incontext['db']['port'] = $_POST['db_port']; |
|
739 | - } |
|
740 | - else |
|
784 | + if (!empty($_POST['db_port'])) { |
|
785 | + $incontext['db']['port'] = $_POST['db_port']; |
|
786 | + } |
|
787 | + } else |
|
741 | 788 | { |
742 | 789 | $incontext['db']['prefix'] = 'smf_'; |
743 | 790 | } |
@@ -773,10 +820,11 @@ discard block |
||
773 | 820 | if (!empty($_POST['db_port'])) |
774 | 821 | { |
775 | 822 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
776 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
777 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
778 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
779 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
823 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
824 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
825 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
826 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
827 | + } |
|
780 | 828 | } |
781 | 829 | |
782 | 830 | // God I hope it saved! |
@@ -789,8 +837,9 @@ discard block |
||
789 | 837 | // Make sure it works. |
790 | 838 | require(dirname(__FILE__) . '/Settings.php'); |
791 | 839 | |
792 | - if (empty($sourcedir)) |
|
793 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
840 | + if (empty($sourcedir)) { |
|
841 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
842 | + } |
|
794 | 843 | |
795 | 844 | // Better find the database file! |
796 | 845 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -800,18 +849,21 @@ discard block |
||
800 | 849 | } |
801 | 850 | |
802 | 851 | // Now include it for database functions! |
803 | - if (!defined('SMF')) |
|
804 | - define('SMF', 1); |
|
852 | + if (!defined('SMF')) { |
|
853 | + define('SMF', 1); |
|
854 | + } |
|
805 | 855 | |
806 | 856 | $modSettings['disableQueryCheck'] = true; |
807 | - if (empty($smcFunc)) |
|
808 | - $smcFunc = array(); |
|
857 | + if (empty($smcFunc)) { |
|
858 | + $smcFunc = array(); |
|
859 | + } |
|
809 | 860 | |
810 | 861 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
811 | 862 | |
812 | 863 | // What - running PHP4? The shame! |
813 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
814 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
864 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
865 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
866 | + } |
|
815 | 867 | |
816 | 868 | // Attempt a connection. |
817 | 869 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -899,12 +951,14 @@ discard block |
||
899 | 951 | $incontext['page_title'] = $txt['install_settings']; |
900 | 952 | |
901 | 953 | // Let's see if we got the database type correct. |
902 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
903 | - $db_type = $_POST['db_type']; |
|
954 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
955 | + $db_type = $_POST['db_type']; |
|
956 | + } |
|
904 | 957 | |
905 | 958 | // Else we'd better be able to get the connection. |
906 | - else |
|
907 | - load_database(); |
|
959 | + else { |
|
960 | + load_database(); |
|
961 | + } |
|
908 | 962 | |
909 | 963 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
910 | 964 | |
@@ -924,12 +978,14 @@ discard block |
||
924 | 978 | // Submitting? |
925 | 979 | if (isset($_POST['boardurl'])) |
926 | 980 | { |
927 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
928 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
929 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
930 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
931 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
932 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
981 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
982 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
983 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
984 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
985 | + } |
|
986 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
987 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
988 | + } |
|
933 | 989 | |
934 | 990 | // Save these variables. |
935 | 991 | $vars = array( |
@@ -966,10 +1022,10 @@ discard block |
||
966 | 1022 | { |
967 | 1023 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
968 | 1024 | return false; |
969 | - } |
|
970 | - else |
|
971 | - // Set the character set here. |
|
1025 | + } else { |
|
1026 | + // Set the character set here. |
|
972 | 1027 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1028 | + } |
|
973 | 1029 | } |
974 | 1030 | |
975 | 1031 | // Good, skip on. |
@@ -989,8 +1045,9 @@ discard block |
||
989 | 1045 | $incontext['continue'] = 1; |
990 | 1046 | |
991 | 1047 | // Already done? |
992 | - if (isset($_POST['pop_done'])) |
|
993 | - return true; |
|
1048 | + if (isset($_POST['pop_done'])) { |
|
1049 | + return true; |
|
1050 | + } |
|
994 | 1051 | |
995 | 1052 | // Reload settings. |
996 | 1053 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1008,8 +1065,9 @@ discard block |
||
1008 | 1065 | $modSettings = array(); |
1009 | 1066 | if ($result !== false) |
1010 | 1067 | { |
1011 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1012 | - $modSettings[$row['variable']] = $row['value']; |
|
1068 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1069 | + $modSettings[$row['variable']] = $row['value']; |
|
1070 | + } |
|
1013 | 1071 | $smcFunc['db_free_result']($result); |
1014 | 1072 | |
1015 | 1073 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1022,20 +1080,22 @@ discard block |
||
1022 | 1080 | $modSettings['disableQueryCheck'] = true; |
1023 | 1081 | |
1024 | 1082 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1025 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1026 | - $smcFunc['db_query']('', ' |
|
1083 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1084 | + $smcFunc['db_query']('', ' |
|
1027 | 1085 | SET NAMES {string:utf8}', |
1028 | 1086 | array( |
1029 | 1087 | 'db_error_skip' => true, |
1030 | 1088 | 'utf8' => 'utf8', |
1031 | 1089 | ) |
1032 | 1090 | ); |
1091 | + } |
|
1033 | 1092 | |
1034 | 1093 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1035 | - if (substr(__DIR__, -1) == '\\') |
|
1036 | - $attachdir = __DIR__ . 'attachments'; |
|
1037 | - else |
|
1038 | - $attachdir = __DIR__ . '/attachments'; |
|
1094 | + if (substr(__DIR__, -1) == '\\') { |
|
1095 | + $attachdir = __DIR__ . 'attachments'; |
|
1096 | + } else { |
|
1097 | + $attachdir = __DIR__ . '/attachments'; |
|
1098 | + } |
|
1039 | 1099 | |
1040 | 1100 | $replaces = array( |
1041 | 1101 | '{$db_prefix}' => $db_prefix, |
@@ -1052,8 +1112,9 @@ discard block |
||
1052 | 1112 | |
1053 | 1113 | foreach ($txt as $key => $value) |
1054 | 1114 | { |
1055 | - if (substr($key, 0, 8) == 'default_') |
|
1056 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1115 | + if (substr($key, 0, 8) == 'default_') { |
|
1116 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1117 | + } |
|
1057 | 1118 | } |
1058 | 1119 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1059 | 1120 | |
@@ -1068,8 +1129,9 @@ discard block |
||
1068 | 1129 | |
1069 | 1130 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1070 | 1131 | { |
1071 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1072 | - $engines[] = $row['Engine']; |
|
1132 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1133 | + $engines[] = $row['Engine']; |
|
1134 | + } |
|
1073 | 1135 | } |
1074 | 1136 | |
1075 | 1137 | // Done with this now |
@@ -1093,8 +1155,7 @@ discard block |
||
1093 | 1155 | $replaces['START TRANSACTION;'] = ''; |
1094 | 1156 | $replaces['COMMIT;'] = ''; |
1095 | 1157 | } |
1096 | - } |
|
1097 | - else |
|
1158 | + } else |
|
1098 | 1159 | { |
1099 | 1160 | $has_innodb = false; |
1100 | 1161 | } |
@@ -1116,21 +1177,24 @@ discard block |
||
1116 | 1177 | foreach ($sql_lines as $count => $line) |
1117 | 1178 | { |
1118 | 1179 | // No comments allowed! |
1119 | - if (substr(trim($line), 0, 1) != '#') |
|
1120 | - $current_statement .= "\n" . rtrim($line); |
|
1180 | + if (substr(trim($line), 0, 1) != '#') { |
|
1181 | + $current_statement .= "\n" . rtrim($line); |
|
1182 | + } |
|
1121 | 1183 | |
1122 | 1184 | // Is this the end of the query string? |
1123 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1124 | - continue; |
|
1185 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1186 | + continue; |
|
1187 | + } |
|
1125 | 1188 | |
1126 | 1189 | // Does this table already exist? If so, don't insert more data into it! |
1127 | 1190 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1128 | 1191 | { |
1129 | 1192 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1130 | - if (!empty($matches[0])) |
|
1131 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1132 | - else |
|
1133 | - $incontext['sql_results']['insert_dups']++; |
|
1193 | + if (!empty($matches[0])) { |
|
1194 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1195 | + } else { |
|
1196 | + $incontext['sql_results']['insert_dups']++; |
|
1197 | + } |
|
1134 | 1198 | |
1135 | 1199 | $current_statement = ''; |
1136 | 1200 | continue; |
@@ -1139,8 +1203,9 @@ discard block |
||
1139 | 1203 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1140 | 1204 | { |
1141 | 1205 | // Use the appropriate function based on the DB type |
1142 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1143 | - $db_errorno = $db_type . '_errno'; |
|
1206 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1207 | + $db_errorno = $db_type . '_errno'; |
|
1208 | + } |
|
1144 | 1209 | |
1145 | 1210 | // Error 1050: Table already exists! |
1146 | 1211 | // @todo Needs to be made better! |
@@ -1155,18 +1220,18 @@ discard block |
||
1155 | 1220 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1156 | 1221 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1157 | 1222 | } |
1158 | - } |
|
1159 | - else |
|
1223 | + } else |
|
1160 | 1224 | { |
1161 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1162 | - $incontext['sql_results']['tables']++; |
|
1163 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1225 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1226 | + $incontext['sql_results']['tables']++; |
|
1227 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1164 | 1228 | { |
1165 | 1229 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1166 | - if (!empty($matches[0])) |
|
1167 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1168 | - else |
|
1169 | - $incontext['sql_results']['inserts']++; |
|
1230 | + if (!empty($matches[0])) { |
|
1231 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1232 | + } else { |
|
1233 | + $incontext['sql_results']['inserts']++; |
|
1234 | + } |
|
1170 | 1235 | } |
1171 | 1236 | } |
1172 | 1237 | |
@@ -1179,15 +1244,17 @@ discard block |
||
1179 | 1244 | // Sort out the context for the SQL. |
1180 | 1245 | foreach ($incontext['sql_results'] as $key => $number) |
1181 | 1246 | { |
1182 | - if ($number == 0) |
|
1183 | - unset($incontext['sql_results'][$key]); |
|
1184 | - else |
|
1185 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1247 | + if ($number == 0) { |
|
1248 | + unset($incontext['sql_results'][$key]); |
|
1249 | + } else { |
|
1250 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1251 | + } |
|
1186 | 1252 | } |
1187 | 1253 | |
1188 | 1254 | // Make sure UTF will be used globally. |
1189 | - 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']))) |
|
1190 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1255 | + 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']))) { |
|
1256 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1257 | + } |
|
1191 | 1258 | |
1192 | 1259 | // Maybe we can auto-detect better cookie settings? |
1193 | 1260 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1198,16 +1265,20 @@ discard block |
||
1198 | 1265 | $globalCookies = false; |
1199 | 1266 | |
1200 | 1267 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1201 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1202 | - $globalCookies = true; |
|
1268 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1269 | + $globalCookies = true; |
|
1270 | + } |
|
1203 | 1271 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1204 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1205 | - $localCookies = true; |
|
1272 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1273 | + $localCookies = true; |
|
1274 | + } |
|
1206 | 1275 | |
1207 | - if ($globalCookies) |
|
1208 | - $newSettings[] = array('globalCookies', '1'); |
|
1209 | - if ($localCookies) |
|
1210 | - $newSettings[] = array('localCookies', '1'); |
|
1276 | + if ($globalCookies) { |
|
1277 | + $newSettings[] = array('globalCookies', '1'); |
|
1278 | + } |
|
1279 | + if ($localCookies) { |
|
1280 | + $newSettings[] = array('localCookies', '1'); |
|
1281 | + } |
|
1211 | 1282 | } |
1212 | 1283 | |
1213 | 1284 | // Are we allowing stat collection? |
@@ -1223,32 +1294,36 @@ discard block |
||
1223 | 1294 | fwrite($fp, $out); |
1224 | 1295 | |
1225 | 1296 | $return_data = ''; |
1226 | - while (!feof($fp)) |
|
1227 | - $return_data .= fgets($fp, 128); |
|
1297 | + while (!feof($fp)) { |
|
1298 | + $return_data .= fgets($fp, 128); |
|
1299 | + } |
|
1228 | 1300 | |
1229 | 1301 | fclose($fp); |
1230 | 1302 | |
1231 | 1303 | // Get the unique site ID. |
1232 | 1304 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1233 | 1305 | |
1234 | - if (!empty($ID[1])) |
|
1235 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1306 | + if (!empty($ID[1])) { |
|
1307 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1308 | + } |
|
1236 | 1309 | } |
1237 | 1310 | } |
1238 | 1311 | |
1239 | 1312 | // Are we enabling SSL? |
1240 | - if (!empty($_POST['force_ssl'])) |
|
1241 | - $newSettings[] = array('force_ssl', 2); |
|
1313 | + if (!empty($_POST['force_ssl'])) { |
|
1314 | + $newSettings[] = array('force_ssl', 2); |
|
1315 | + } |
|
1242 | 1316 | |
1243 | 1317 | // Setting a timezone is required. |
1244 | 1318 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1245 | 1319 | { |
1246 | 1320 | // Get PHP's default timezone, if set |
1247 | 1321 | $ini_tz = ini_get('date.timezone'); |
1248 | - if (!empty($ini_tz)) |
|
1249 | - $timezone_id = $ini_tz; |
|
1250 | - else |
|
1251 | - $timezone_id = ''; |
|
1322 | + if (!empty($ini_tz)) { |
|
1323 | + $timezone_id = $ini_tz; |
|
1324 | + } else { |
|
1325 | + $timezone_id = ''; |
|
1326 | + } |
|
1252 | 1327 | |
1253 | 1328 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1254 | 1329 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1257,8 +1332,9 @@ discard block |
||
1257 | 1332 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1258 | 1333 | } |
1259 | 1334 | |
1260 | - if (date_default_timezone_set($timezone_id)) |
|
1261 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1335 | + if (date_default_timezone_set($timezone_id)) { |
|
1336 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1337 | + } |
|
1262 | 1338 | } |
1263 | 1339 | |
1264 | 1340 | if (!empty($newSettings)) |
@@ -1289,16 +1365,18 @@ discard block |
||
1289 | 1365 | } |
1290 | 1366 | |
1291 | 1367 | // MySQL specific stuff |
1292 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1293 | - return false; |
|
1368 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1369 | + return false; |
|
1370 | + } |
|
1294 | 1371 | |
1295 | 1372 | // Find database user privileges. |
1296 | 1373 | $privs = array(); |
1297 | 1374 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1298 | 1375 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1299 | 1376 | { |
1300 | - if ($row['Privilege'] == 'Alter') |
|
1301 | - $privs[] = $row['Privilege']; |
|
1377 | + if ($row['Privilege'] == 'Alter') { |
|
1378 | + $privs[] = $row['Privilege']; |
|
1379 | + } |
|
1302 | 1380 | } |
1303 | 1381 | $smcFunc['db_free_result']($get_privs); |
1304 | 1382 | |
@@ -1328,8 +1406,9 @@ discard block |
||
1328 | 1406 | $incontext['continue'] = 1; |
1329 | 1407 | |
1330 | 1408 | // Skipping? |
1331 | - if (!empty($_POST['skip'])) |
|
1332 | - return true; |
|
1409 | + if (!empty($_POST['skip'])) { |
|
1410 | + return true; |
|
1411 | + } |
|
1333 | 1412 | |
1334 | 1413 | // Need this to check whether we need the database password. |
1335 | 1414 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1342,18 +1421,22 @@ discard block |
||
1342 | 1421 | // We need this to properly hash the password for Admin |
1343 | 1422 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1344 | 1423 | global $sourcedir; |
1345 | - if (function_exists('mb_strtolower')) |
|
1346 | - return mb_strtolower($string, 'UTF-8'); |
|
1424 | + if (function_exists('mb_strtolower')) { |
|
1425 | + return mb_strtolower($string, 'UTF-8'); |
|
1426 | + } |
|
1347 | 1427 | require_once($sourcedir . '/Subs-Charset.php'); |
1348 | 1428 | return utf8_strtolower($string); |
1349 | 1429 | }; |
1350 | 1430 | |
1351 | - if (!isset($_POST['username'])) |
|
1352 | - $_POST['username'] = ''; |
|
1353 | - if (!isset($_POST['email'])) |
|
1354 | - $_POST['email'] = ''; |
|
1355 | - if (!isset($_POST['server_email'])) |
|
1356 | - $_POST['server_email'] = ''; |
|
1431 | + if (!isset($_POST['username'])) { |
|
1432 | + $_POST['username'] = ''; |
|
1433 | + } |
|
1434 | + if (!isset($_POST['email'])) { |
|
1435 | + $_POST['email'] = ''; |
|
1436 | + } |
|
1437 | + if (!isset($_POST['server_email'])) { |
|
1438 | + $_POST['server_email'] = ''; |
|
1439 | + } |
|
1357 | 1440 | |
1358 | 1441 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1359 | 1442 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1372,8 +1455,9 @@ discard block |
||
1372 | 1455 | 'admin_group' => 1, |
1373 | 1456 | ) |
1374 | 1457 | ); |
1375 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1376 | - $incontext['skip'] = 1; |
|
1458 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1459 | + $incontext['skip'] = 1; |
|
1460 | + } |
|
1377 | 1461 | $smcFunc['db_free_result']($request); |
1378 | 1462 | |
1379 | 1463 | // Trying to create an account? |
@@ -1404,8 +1488,9 @@ discard block |
||
1404 | 1488 | } |
1405 | 1489 | |
1406 | 1490 | // Update the webmaster's email? |
1407 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1408 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1491 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1492 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1493 | + } |
|
1409 | 1494 | |
1410 | 1495 | // Work out whether we're going to have dodgy characters and remove them. |
1411 | 1496 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1428,32 +1513,27 @@ discard block |
||
1428 | 1513 | $smcFunc['db_free_result']($result); |
1429 | 1514 | |
1430 | 1515 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1431 | - } |
|
1432 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1516 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1433 | 1517 | { |
1434 | 1518 | // Try the previous step again. |
1435 | 1519 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1436 | 1520 | return false; |
1437 | - } |
|
1438 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1521 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1439 | 1522 | { |
1440 | 1523 | // Try the previous step again. |
1441 | 1524 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1442 | 1525 | return false; |
1443 | - } |
|
1444 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1526 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1445 | 1527 | { |
1446 | 1528 | // One step back, this time fill out a proper admin email address. |
1447 | 1529 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1448 | 1530 | return false; |
1449 | - } |
|
1450 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1531 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1451 | 1532 | { |
1452 | 1533 | // One step back, this time fill out a proper admin email address. |
1453 | 1534 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1454 | 1535 | return false; |
1455 | - } |
|
1456 | - elseif ($_POST['username'] != '') |
|
1536 | + } elseif ($_POST['username'] != '') |
|
1457 | 1537 | { |
1458 | 1538 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1459 | 1539 | |
@@ -1519,17 +1599,19 @@ discard block |
||
1519 | 1599 | require_once($sourcedir . '/Subs-Auth.php'); |
1520 | 1600 | |
1521 | 1601 | // Bring a warning over. |
1522 | - if (!empty($incontext['account_existed'])) |
|
1523 | - $incontext['warning'] = $incontext['account_existed']; |
|
1602 | + if (!empty($incontext['account_existed'])) { |
|
1603 | + $incontext['warning'] = $incontext['account_existed']; |
|
1604 | + } |
|
1524 | 1605 | |
1525 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1526 | - $smcFunc['db_query']('', ' |
|
1606 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1607 | + $smcFunc['db_query']('', ' |
|
1527 | 1608 | SET NAMES {string:db_character_set}', |
1528 | 1609 | array( |
1529 | 1610 | 'db_character_set' => $db_character_set, |
1530 | 1611 | 'db_error_skip' => true, |
1531 | 1612 | ) |
1532 | 1613 | ); |
1614 | + } |
|
1533 | 1615 | |
1534 | 1616 | // As track stats is by default enabled let's add some activity. |
1535 | 1617 | $smcFunc['db_insert']('ignore', |
@@ -1550,14 +1632,16 @@ discard block |
||
1550 | 1632 | // Only proceed if we can load the data. |
1551 | 1633 | if ($request) |
1552 | 1634 | { |
1553 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1554 | - $modSettings[$row[0]] = $row[1]; |
|
1635 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1636 | + $modSettings[$row[0]] = $row[1]; |
|
1637 | + } |
|
1555 | 1638 | $smcFunc['db_free_result']($request); |
1556 | 1639 | } |
1557 | 1640 | |
1558 | 1641 | // Automatically log them in ;) |
1559 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1560 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1642 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1643 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1644 | + } |
|
1561 | 1645 | |
1562 | 1646 | $result = $smcFunc['db_query']('', ' |
1563 | 1647 | SELECT value |
@@ -1568,13 +1652,14 @@ discard block |
||
1568 | 1652 | 'db_error_skip' => true, |
1569 | 1653 | ) |
1570 | 1654 | ); |
1571 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1572 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1655 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1656 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1657 | + } |
|
1573 | 1658 | $smcFunc['db_free_result']($result); |
1574 | 1659 | |
1575 | - if (empty($db_sessions)) |
|
1576 | - $_SESSION['admin_time'] = time(); |
|
1577 | - else |
|
1660 | + if (empty($db_sessions)) { |
|
1661 | + $_SESSION['admin_time'] = time(); |
|
1662 | + } else |
|
1578 | 1663 | { |
1579 | 1664 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1580 | 1665 | |
@@ -1598,8 +1683,9 @@ discard block |
||
1598 | 1683 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1599 | 1684 | function($string){ |
1600 | 1685 | global $sourcedir; |
1601 | - if (function_exists('mb_strtolower')) |
|
1602 | - return mb_strtolower($string, 'UTF-8'); |
|
1686 | + if (function_exists('mb_strtolower')) { |
|
1687 | + return mb_strtolower($string, 'UTF-8'); |
|
1688 | + } |
|
1603 | 1689 | require_once($sourcedir . '/Subs-Charset.php'); |
1604 | 1690 | return utf8_strtolower($string); |
1605 | 1691 | }; |
@@ -1615,8 +1701,9 @@ discard block |
||
1615 | 1701 | ) |
1616 | 1702 | ); |
1617 | 1703 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1618 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1619 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1704 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1705 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1706 | + } |
|
1620 | 1707 | $smcFunc['db_free_result']($request); |
1621 | 1708 | |
1622 | 1709 | // Now is the perfect time to fetch the SM files. |
@@ -1635,8 +1722,9 @@ discard block |
||
1635 | 1722 | |
1636 | 1723 | // Check if we need some stupid MySQL fix. |
1637 | 1724 | $server_version = $smcFunc['db_server_info'](); |
1638 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1639 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1725 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1726 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1727 | + } |
|
1640 | 1728 | |
1641 | 1729 | // Some final context for the template. |
1642 | 1730 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1656,8 +1744,9 @@ discard block |
||
1656 | 1744 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1657 | 1745 | |
1658 | 1746 | // @todo Do we just want to read the file in clean, and split it this way always? |
1659 | - if (count($settingsArray) == 1) |
|
1660 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1747 | + if (count($settingsArray) == 1) { |
|
1748 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1749 | + } |
|
1661 | 1750 | |
1662 | 1751 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1663 | 1752 | { |
@@ -1672,19 +1761,22 @@ discard block |
||
1672 | 1761 | continue; |
1673 | 1762 | } |
1674 | 1763 | |
1675 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1676 | - $settingsArray[$i] = ''; |
|
1764 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1765 | + $settingsArray[$i] = ''; |
|
1766 | + } |
|
1677 | 1767 | |
1678 | 1768 | // Don't trim or bother with it if it's not a variable. |
1679 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1680 | - continue; |
|
1769 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1770 | + continue; |
|
1771 | + } |
|
1681 | 1772 | |
1682 | 1773 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1683 | 1774 | |
1684 | - foreach ($vars as $var => $val) |
|
1685 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1775 | + foreach ($vars as $var => $val) { |
|
1776 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1686 | 1777 | { |
1687 | 1778 | $comment = strstr($settingsArray[$i], '#'); |
1779 | + } |
|
1688 | 1780 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1689 | 1781 | unset($vars[$var]); |
1690 | 1782 | } |
@@ -1694,36 +1786,41 @@ discard block |
||
1694 | 1786 | if (!empty($vars)) |
1695 | 1787 | { |
1696 | 1788 | $settingsArray[$i++] = ''; |
1697 | - foreach ($vars as $var => $val) |
|
1698 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1789 | + foreach ($vars as $var => $val) { |
|
1790 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1791 | + } |
|
1699 | 1792 | } |
1700 | 1793 | |
1701 | 1794 | // Blank out the file - done to fix a oddity with some servers. |
1702 | 1795 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1703 | - if (!$fp) |
|
1704 | - return false; |
|
1796 | + if (!$fp) { |
|
1797 | + return false; |
|
1798 | + } |
|
1705 | 1799 | fclose($fp); |
1706 | 1800 | |
1707 | 1801 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1708 | 1802 | |
1709 | 1803 | // Gotta have one of these ;) |
1710 | - if (trim($settingsArray[0]) != '<?php') |
|
1711 | - fwrite($fp, "<?php\n"); |
|
1804 | + if (trim($settingsArray[0]) != '<?php') { |
|
1805 | + fwrite($fp, "<?php\n"); |
|
1806 | + } |
|
1712 | 1807 | |
1713 | 1808 | $lines = count($settingsArray); |
1714 | 1809 | for ($i = 0; $i < $lines - 1; $i++) |
1715 | 1810 | { |
1716 | 1811 | // Don't just write a bunch of blank lines. |
1717 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1718 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1812 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1813 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1814 | + } |
|
1719 | 1815 | } |
1720 | 1816 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1721 | 1817 | fclose($fp); |
1722 | 1818 | |
1723 | 1819 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1724 | 1820 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1725 | - if (function_exists('opcache_invalidate')) |
|
1726 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1821 | + if (function_exists('opcache_invalidate')) { |
|
1822 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1823 | + } |
|
1727 | 1824 | |
1728 | 1825 | return true; |
1729 | 1826 | } |
@@ -1748,9 +1845,9 @@ discard block |
||
1748 | 1845 | SecFilterScanPOST Off |
1749 | 1846 | </IfModule>'; |
1750 | 1847 | |
1751 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1752 | - return true; |
|
1753 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1848 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1849 | + return true; |
|
1850 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1754 | 1851 | { |
1755 | 1852 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1756 | 1853 | |
@@ -1762,29 +1859,28 @@ discard block |
||
1762 | 1859 | fwrite($ht_handle, $htaccess_addition); |
1763 | 1860 | fclose($ht_handle); |
1764 | 1861 | return true; |
1862 | + } else { |
|
1863 | + return false; |
|
1765 | 1864 | } |
1766 | - else |
|
1767 | - return false; |
|
1865 | + } else { |
|
1866 | + return true; |
|
1768 | 1867 | } |
1769 | - else |
|
1770 | - return true; |
|
1771 | - } |
|
1772 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1773 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1774 | - elseif (is_writable(dirname(__FILE__))) |
|
1868 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1869 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1870 | + } elseif (is_writable(dirname(__FILE__))) |
|
1775 | 1871 | { |
1776 | 1872 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1777 | 1873 | { |
1778 | 1874 | fwrite($ht_handle, $htaccess_addition); |
1779 | 1875 | fclose($ht_handle); |
1780 | 1876 | return true; |
1877 | + } else { |
|
1878 | + return false; |
|
1781 | 1879 | } |
1782 | - else |
|
1880 | + } else { |
|
1783 | 1881 | return false; |
1784 | 1882 | } |
1785 | - else |
|
1786 | - return false; |
|
1787 | -} |
|
1883 | + } |
|
1788 | 1884 | |
1789 | 1885 | function template_install_above() |
1790 | 1886 | { |
@@ -1822,9 +1918,10 @@ discard block |
||
1822 | 1918 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1823 | 1919 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1824 | 1920 | |
1825 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1826 | - echo ' |
|
1921 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1922 | + echo ' |
|
1827 | 1923 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1924 | + } |
|
1828 | 1925 | |
1829 | 1926 | echo ' |
1830 | 1927 | </select> |
@@ -1844,9 +1941,10 @@ discard block |
||
1844 | 1941 | <h2>', $txt['upgrade_progress'], '</h2> |
1845 | 1942 | <ul>'; |
1846 | 1943 | |
1847 | - foreach ($incontext['steps'] as $num => $step) |
|
1848 | - echo ' |
|
1944 | + foreach ($incontext['steps'] as $num => $step) { |
|
1945 | + echo ' |
|
1849 | 1946 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
1947 | + } |
|
1850 | 1948 | |
1851 | 1949 | echo ' |
1852 | 1950 | </ul> |
@@ -1871,20 +1969,23 @@ discard block |
||
1871 | 1969 | echo ' |
1872 | 1970 | <div>'; |
1873 | 1971 | |
1874 | - if (!empty($incontext['continue'])) |
|
1875 | - echo ' |
|
1972 | + if (!empty($incontext['continue'])) { |
|
1973 | + echo ' |
|
1876 | 1974 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1877 | - if (!empty($incontext['skip'])) |
|
1878 | - echo ' |
|
1975 | + } |
|
1976 | + if (!empty($incontext['skip'])) { |
|
1977 | + echo ' |
|
1879 | 1978 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1979 | + } |
|
1880 | 1980 | echo ' |
1881 | 1981 | </div>'; |
1882 | 1982 | } |
1883 | 1983 | |
1884 | 1984 | // Show the closing form tag and other data only if not in the last step |
1885 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1886 | - echo ' |
|
1985 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
1986 | + echo ' |
|
1887 | 1987 | </form>'; |
1988 | + } |
|
1888 | 1989 | |
1889 | 1990 | echo ' |
1890 | 1991 | </div> |
@@ -1919,13 +2020,15 @@ discard block |
||
1919 | 2020 | </div>'; |
1920 | 2021 | |
1921 | 2022 | // Show the warnings, or not. |
1922 | - if (template_warning_divs()) |
|
1923 | - echo ' |
|
2023 | + if (template_warning_divs()) { |
|
2024 | + echo ' |
|
1924 | 2025 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2026 | + } |
|
1925 | 2027 | |
1926 | 2028 | // Say we want the continue button! |
1927 | - if (empty($incontext['error'])) |
|
1928 | - $incontext['continue'] = 1; |
|
2029 | + if (empty($incontext['error'])) { |
|
2030 | + $incontext['continue'] = 1; |
|
2031 | + } |
|
1929 | 2032 | |
1930 | 2033 | // For the latest version stuff. |
1931 | 2034 | echo ' |
@@ -1959,8 +2062,8 @@ discard block |
||
1959 | 2062 | global $txt, $incontext; |
1960 | 2063 | |
1961 | 2064 | // Errors are very serious.. |
1962 | - if (!empty($incontext['error'])) |
|
1963 | - echo ' |
|
2065 | + if (!empty($incontext['error'])) { |
|
2066 | + echo ' |
|
1964 | 2067 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1965 | 2068 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1966 | 2069 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1968,9 +2071,10 @@ discard block |
||
1968 | 2071 | ', $incontext['error'], ' |
1969 | 2072 | </div> |
1970 | 2073 | </div>'; |
2074 | + } |
|
1971 | 2075 | // A warning message? |
1972 | - elseif (!empty($incontext['warning'])) |
|
1973 | - echo ' |
|
2076 | + elseif (!empty($incontext['warning'])) { |
|
2077 | + echo ' |
|
1974 | 2078 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1975 | 2079 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1976 | 2080 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1978,6 +2082,7 @@ discard block |
||
1978 | 2082 | ', $incontext['warning'], ' |
1979 | 2083 | </div> |
1980 | 2084 | </div>'; |
2085 | + } |
|
1981 | 2086 | |
1982 | 2087 | return empty($incontext['error']) && empty($incontext['warning']); |
1983 | 2088 | } |
@@ -1993,27 +2098,30 @@ discard block |
||
1993 | 2098 | <li>', $incontext['failed_files']), '</li> |
1994 | 2099 | </ul>'; |
1995 | 2100 | |
1996 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
1997 | - echo ' |
|
2101 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2102 | + echo ' |
|
1998 | 2103 | <hr> |
1999 | 2104 | <p>', $txt['chmod_linux_info'], '</p> |
2000 | 2105 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2106 | + } |
|
2001 | 2107 | |
2002 | 2108 | // This is serious! |
2003 | - if (!template_warning_divs()) |
|
2004 | - return; |
|
2109 | + if (!template_warning_divs()) { |
|
2110 | + return; |
|
2111 | + } |
|
2005 | 2112 | |
2006 | 2113 | echo ' |
2007 | 2114 | <hr> |
2008 | 2115 | <p>', $txt['ftp_setup_info'], '</p>'; |
2009 | 2116 | |
2010 | - if (!empty($incontext['ftp_errors'])) |
|
2011 | - echo ' |
|
2117 | + if (!empty($incontext['ftp_errors'])) { |
|
2118 | + echo ' |
|
2012 | 2119 | <div class="error_message"> |
2013 | 2120 | ', $txt['error_ftp_no_connect'], '<br><br> |
2014 | 2121 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2015 | 2122 | </div> |
2016 | 2123 | <br>'; |
2124 | + } |
|
2017 | 2125 | |
2018 | 2126 | echo ' |
2019 | 2127 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2073,17 +2181,17 @@ discard block |
||
2073 | 2181 | <td> |
2074 | 2182 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2075 | 2183 | |
2076 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2077 | - echo ' |
|
2184 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2185 | + echo ' |
|
2078 | 2186 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2187 | + } |
|
2079 | 2188 | |
2080 | 2189 | echo ' |
2081 | 2190 | </select> |
2082 | 2191 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2083 | 2192 | </td> |
2084 | 2193 | </tr>'; |
2085 | - } |
|
2086 | - else |
|
2194 | + } else |
|
2087 | 2195 | { |
2088 | 2196 | echo ' |
2089 | 2197 | <tr style="display: none;"> |
@@ -2275,9 +2383,10 @@ discard block |
||
2275 | 2383 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2276 | 2384 | <ul>'; |
2277 | 2385 | |
2278 | - foreach ($incontext['failures'] as $line => $fail) |
|
2279 | - echo ' |
|
2386 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2387 | + echo ' |
|
2280 | 2388 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2389 | + } |
|
2281 | 2390 | |
2282 | 2391 | echo ' |
2283 | 2392 | </ul>'; |
@@ -2338,15 +2447,16 @@ discard block |
||
2338 | 2447 | </tr> |
2339 | 2448 | </table>'; |
2340 | 2449 | |
2341 | - if ($incontext['require_db_confirm']) |
|
2342 | - echo ' |
|
2450 | + if ($incontext['require_db_confirm']) { |
|
2451 | + echo ' |
|
2343 | 2452 | <h2>', $txt['user_settings_database'], '</h2> |
2344 | 2453 | <p>', $txt['user_settings_database_info'], '</p> |
2345 | 2454 | |
2346 | 2455 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2347 | 2456 | <input type="password" name="password3" size="30" class="input_password" /> |
2348 | 2457 | </div>'; |
2349 | -} |
|
2458 | + } |
|
2459 | + } |
|
2350 | 2460 | |
2351 | 2461 | // Tell them it's done, and to delete. |
2352 | 2462 | function template_delete_install() |
@@ -2359,14 +2469,15 @@ discard block |
||
2359 | 2469 | template_warning_divs(); |
2360 | 2470 | |
2361 | 2471 | // Install directory still writable? |
2362 | - if ($incontext['dir_still_writable']) |
|
2363 | - echo ' |
|
2472 | + if ($incontext['dir_still_writable']) { |
|
2473 | + echo ' |
|
2364 | 2474 | <em>', $txt['still_writable'], '</em><br> |
2365 | 2475 | <br>'; |
2476 | + } |
|
2366 | 2477 | |
2367 | 2478 | // Don't show the box if it's like 99% sure it won't work :P. |
2368 | - if ($incontext['probably_delete_install']) |
|
2369 | - echo ' |
|
2479 | + if ($incontext['probably_delete_install']) { |
|
2480 | + echo ' |
|
2370 | 2481 | <div style="margin: 1ex; font-weight: bold;"> |
2371 | 2482 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2372 | 2483 | </div> |
@@ -2382,6 +2493,7 @@ discard block |
||
2382 | 2493 | } |
2383 | 2494 | </script> |
2384 | 2495 | <br>'; |
2496 | + } |
|
2385 | 2497 | |
2386 | 2498 | echo ' |
2387 | 2499 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -34,8 +35,8 @@ discard block |
||
34 | 35 | global $smcFunc; |
35 | 36 | |
36 | 37 | // Map some database specific functions, only do this once. |
37 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
38 | - $smcFunc += array( |
|
38 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
39 | + $smcFunc += array( |
|
39 | 40 | 'db_query' => 'smf_db_query', |
40 | 41 | 'db_quote' => 'smf_db_quote', |
41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -61,11 +62,13 @@ discard block |
||
61 | 62 | 'db_mb4' => true, |
62 | 63 | 'db_ping' => 'pg_ping', |
63 | 64 | ); |
65 | + } |
|
64 | 66 | |
65 | - if (!empty($db_options['persist'])) |
|
66 | - $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
67 | - else |
|
68 | - $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
67 | + if (!empty($db_options['persist'])) { |
|
68 | + $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
69 | + } else { |
|
70 | + $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
71 | + } |
|
69 | 72 | |
70 | 73 | // Something's wrong, show an error if its fatal (which we assume it is) |
71 | 74 | if (!$connection) |
@@ -73,8 +76,7 @@ discard block |
||
73 | 76 | if (!empty($db_options['non_fatal'])) |
74 | 77 | { |
75 | 78 | return null; |
76 | - } |
|
77 | - else |
|
79 | + } else |
|
78 | 80 | { |
79 | 81 | display_db_error(); |
80 | 82 | } |
@@ -125,34 +127,42 @@ discard block |
||
125 | 127 | |
126 | 128 | list ($values, $connection) = $db_callback; |
127 | 129 | |
128 | - if ($matches[1] === 'db_prefix') |
|
129 | - return $db_prefix; |
|
130 | + if ($matches[1] === 'db_prefix') { |
|
131 | + return $db_prefix; |
|
132 | + } |
|
130 | 133 | |
131 | - if ($matches[1] === 'query_see_board') |
|
132 | - return $user_info['query_see_board']; |
|
134 | + if ($matches[1] === 'query_see_board') { |
|
135 | + return $user_info['query_see_board']; |
|
136 | + } |
|
133 | 137 | |
134 | - if ($matches[1] === 'query_wanna_see_board') |
|
135 | - return $user_info['query_wanna_see_board']; |
|
138 | + if ($matches[1] === 'query_wanna_see_board') { |
|
139 | + return $user_info['query_wanna_see_board']; |
|
140 | + } |
|
136 | 141 | |
137 | - if ($matches[1] === 'empty') |
|
138 | - return '\'\''; |
|
142 | + if ($matches[1] === 'empty') { |
|
143 | + return '\'\''; |
|
144 | + } |
|
139 | 145 | |
140 | - if (!isset($matches[2])) |
|
141 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
146 | + if (!isset($matches[2])) { |
|
147 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
148 | + } |
|
142 | 149 | |
143 | - if ($matches[1] === 'literal') |
|
144 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
150 | + if ($matches[1] === 'literal') { |
|
151 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
152 | + } |
|
145 | 153 | |
146 | - if (!isset($values[$matches[2]])) |
|
147 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
154 | + if (!isset($values[$matches[2]])) { |
|
155 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
156 | + } |
|
148 | 157 | |
149 | 158 | $replacement = $values[$matches[2]]; |
150 | 159 | |
151 | 160 | switch ($matches[1]) |
152 | 161 | { |
153 | 162 | case 'int': |
154 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
155 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
163 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
164 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
165 | + } |
|
156 | 166 | return (string) (int) $replacement; |
157 | 167 | break; |
158 | 168 | |
@@ -164,65 +174,73 @@ discard block |
||
164 | 174 | case 'array_int': |
165 | 175 | if (is_array($replacement)) |
166 | 176 | { |
167 | - if (empty($replacement)) |
|
168 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
177 | + if (empty($replacement)) { |
|
178 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
179 | + } |
|
169 | 180 | |
170 | 181 | foreach ($replacement as $key => $value) |
171 | 182 | { |
172 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
173 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
183 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
184 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
185 | + } |
|
174 | 186 | |
175 | 187 | $replacement[$key] = (string) (int) $value; |
176 | 188 | } |
177 | 189 | |
178 | 190 | return implode(', ', $replacement); |
191 | + } else { |
|
192 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
179 | 193 | } |
180 | - else |
|
181 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
182 | 194 | |
183 | 195 | break; |
184 | 196 | |
185 | 197 | case 'array_string': |
186 | 198 | if (is_array($replacement)) |
187 | 199 | { |
188 | - if (empty($replacement)) |
|
189 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
200 | + if (empty($replacement)) { |
|
201 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
202 | + } |
|
190 | 203 | |
191 | - foreach ($replacement as $key => $value) |
|
192 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
204 | + foreach ($replacement as $key => $value) { |
|
205 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
206 | + } |
|
193 | 207 | |
194 | 208 | return implode(', ', $replacement); |
209 | + } else { |
|
210 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
195 | 211 | } |
196 | - else |
|
197 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
198 | 212 | break; |
199 | 213 | |
200 | 214 | case 'date': |
201 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
202 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
203 | - else |
|
204 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
215 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
216 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
217 | + } else { |
|
218 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
219 | + } |
|
205 | 220 | break; |
206 | 221 | |
207 | 222 | case 'time': |
208 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
209 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
210 | - else |
|
211 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
223 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
224 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
225 | + } else { |
|
226 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
227 | + } |
|
212 | 228 | break; |
213 | 229 | |
214 | 230 | case 'datetime': |
215 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
216 | - return 'to_timestamp('. |
|
231 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
232 | + return 'to_timestamp('. |
|
217 | 233 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
218 | 234 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
219 | - else |
|
220 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
235 | + } else { |
|
236 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
237 | + } |
|
221 | 238 | break; |
222 | 239 | |
223 | 240 | case 'float': |
224 | - if (!is_numeric($replacement)) |
|
225 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
241 | + if (!is_numeric($replacement)) { |
|
242 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
243 | + } |
|
226 | 244 | return (string) (float) $replacement; |
227 | 245 | break; |
228 | 246 | |
@@ -235,31 +253,36 @@ discard block |
||
235 | 253 | break; |
236 | 254 | |
237 | 255 | case 'inet': |
238 | - if ($replacement == 'null' || $replacement == '') |
|
239 | - return 'null'; |
|
240 | - if (inet_pton($replacement) === false) |
|
241 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
256 | + if ($replacement == 'null' || $replacement == '') { |
|
257 | + return 'null'; |
|
258 | + } |
|
259 | + if (inet_pton($replacement) === false) { |
|
260 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
261 | + } |
|
242 | 262 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
243 | 263 | |
244 | 264 | case 'array_inet': |
245 | 265 | if (is_array($replacement)) |
246 | 266 | { |
247 | - if (empty($replacement)) |
|
248 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
267 | + if (empty($replacement)) { |
|
268 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
269 | + } |
|
249 | 270 | |
250 | 271 | foreach ($replacement as $key => $value) |
251 | 272 | { |
252 | - if ($replacement == 'null' || $replacement == '') |
|
253 | - $replacement[$key] = 'null'; |
|
254 | - if (!isValidIP($value)) |
|
255 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
273 | + if ($replacement == 'null' || $replacement == '') { |
|
274 | + $replacement[$key] = 'null'; |
|
275 | + } |
|
276 | + if (!isValidIP($value)) { |
|
277 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
278 | + } |
|
256 | 279 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
257 | 280 | } |
258 | 281 | |
259 | 282 | return implode(', ', $replacement); |
283 | + } else { |
|
284 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
260 | 285 | } |
261 | - else |
|
262 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
263 | 286 | break; |
264 | 287 | |
265 | 288 | default: |
@@ -343,14 +366,16 @@ discard block |
||
343 | 366 | ), |
344 | 367 | ); |
345 | 368 | |
346 | - if (isset($replacements[$identifier])) |
|
347 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
369 | + if (isset($replacements[$identifier])) { |
|
370 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
371 | + } |
|
348 | 372 | |
349 | 373 | // Limits need to be a little different. |
350 | 374 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
351 | 375 | |
352 | - if (trim($db_string) == '') |
|
353 | - return false; |
|
376 | + if (trim($db_string) == '') { |
|
377 | + return false; |
|
378 | + } |
|
354 | 379 | |
355 | 380 | // Comments that are allowed in a query are preg_removed. |
356 | 381 | static $allowed_comments_from = array( |
@@ -370,8 +395,9 @@ discard block |
||
370 | 395 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
371 | 396 | $db_replace_result = 0; |
372 | 397 | |
373 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
374 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
398 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
399 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
400 | + } |
|
375 | 401 | |
376 | 402 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
377 | 403 | { |
@@ -392,8 +418,9 @@ discard block |
||
392 | 418 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
393 | 419 | |
394 | 420 | // Initialize $db_cache if not already initialized. |
395 | - if (!isset($db_cache)) |
|
396 | - $db_cache = array(); |
|
421 | + if (!isset($db_cache)) { |
|
422 | + $db_cache = array(); |
|
423 | + } |
|
397 | 424 | |
398 | 425 | if (!empty($_SESSION['debug_redirect'])) |
399 | 426 | { |
@@ -419,17 +446,18 @@ discard block |
||
419 | 446 | while (true) |
420 | 447 | { |
421 | 448 | $pos = strpos($db_string, '\'', $pos + 1); |
422 | - if ($pos === false) |
|
423 | - break; |
|
449 | + if ($pos === false) { |
|
450 | + break; |
|
451 | + } |
|
424 | 452 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
425 | 453 | |
426 | 454 | while (true) |
427 | 455 | { |
428 | 456 | $pos1 = strpos($db_string, '\'', $pos + 1); |
429 | 457 | $pos2 = strpos($db_string, '\\', $pos + 1); |
430 | - if ($pos1 === false) |
|
431 | - break; |
|
432 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
458 | + if ($pos1 === false) { |
|
459 | + break; |
|
460 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
433 | 461 | { |
434 | 462 | $pos = $pos1; |
435 | 463 | break; |
@@ -445,26 +473,31 @@ discard block |
||
445 | 473 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
446 | 474 | |
447 | 475 | // Comments? We don't use comments in our queries, we leave 'em outside! |
448 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
449 | - $fail = true; |
|
476 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
477 | + $fail = true; |
|
478 | + } |
|
450 | 479 | // Trying to change passwords, slow us down, or something? |
451 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
452 | - $fail = true; |
|
453 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
454 | - $fail = true; |
|
480 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
481 | + $fail = true; |
|
482 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
483 | + $fail = true; |
|
484 | + } |
|
455 | 485 | |
456 | - if (!empty($fail) && function_exists('log_error')) |
|
457 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
486 | + if (!empty($fail) && function_exists('log_error')) { |
|
487 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
488 | + } |
|
458 | 489 | } |
459 | 490 | |
460 | 491 | $db_last_result = @pg_query($connection, $db_string); |
461 | 492 | |
462 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
463 | - $db_last_result = smf_db_error($db_string, $connection); |
|
493 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
494 | + $db_last_result = smf_db_error($db_string, $connection); |
|
495 | + } |
|
464 | 496 | |
465 | 497 | // Debugging. |
466 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
467 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
498 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
499 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
500 | + } |
|
468 | 501 | |
469 | 502 | return $db_last_result; |
470 | 503 | } |
@@ -477,10 +510,11 @@ discard block |
||
477 | 510 | { |
478 | 511 | global $db_last_result, $db_replace_result; |
479 | 512 | |
480 | - if ($db_replace_result) |
|
481 | - return $db_replace_result; |
|
482 | - elseif ($result === null && !$db_last_result) |
|
483 | - return 0; |
|
513 | + if ($db_replace_result) { |
|
514 | + return $db_replace_result; |
|
515 | + } elseif ($result === null && !$db_last_result) { |
|
516 | + return 0; |
|
517 | + } |
|
484 | 518 | |
485 | 519 | return pg_affected_rows($result === null ? $db_last_result : $result); |
486 | 520 | } |
@@ -504,8 +538,9 @@ discard block |
||
504 | 538 | array( |
505 | 539 | ) |
506 | 540 | ); |
507 | - if (!$request) |
|
508 | - return false; |
|
541 | + if (!$request) { |
|
542 | + return false; |
|
543 | + } |
|
509 | 544 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
510 | 545 | $smcFunc['db_free_result']($request); |
511 | 546 | |
@@ -526,12 +561,13 @@ discard block |
||
526 | 561 | // Decide which connection to use |
527 | 562 | $connection = $connection === null ? $db_connection : $connection; |
528 | 563 | |
529 | - if ($type == 'begin') |
|
530 | - return @pg_query($connection, 'BEGIN'); |
|
531 | - elseif ($type == 'rollback') |
|
532 | - return @pg_query($connection, 'ROLLBACK'); |
|
533 | - elseif ($type == 'commit') |
|
534 | - return @pg_query($connection, 'COMMIT'); |
|
564 | + if ($type == 'begin') { |
|
565 | + return @pg_query($connection, 'BEGIN'); |
|
566 | + } elseif ($type == 'rollback') { |
|
567 | + return @pg_query($connection, 'ROLLBACK'); |
|
568 | + } elseif ($type == 'commit') { |
|
569 | + return @pg_query($connection, 'COMMIT'); |
|
570 | + } |
|
535 | 571 | |
536 | 572 | return false; |
537 | 573 | } |
@@ -559,19 +595,22 @@ discard block |
||
559 | 595 | $query_error = @pg_last_error($connection); |
560 | 596 | |
561 | 597 | // Log the error. |
562 | - if (function_exists('log_error')) |
|
563 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
598 | + if (function_exists('log_error')) { |
|
599 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
600 | + } |
|
564 | 601 | |
565 | 602 | // Nothing's defined yet... just die with it. |
566 | - if (empty($context) || empty($txt)) |
|
567 | - die($query_error); |
|
603 | + if (empty($context) || empty($txt)) { |
|
604 | + die($query_error); |
|
605 | + } |
|
568 | 606 | |
569 | 607 | // Show an error message, if possible. |
570 | 608 | $context['error_title'] = $txt['database_error']; |
571 | - if (allowedTo('admin_forum')) |
|
572 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
573 | - else |
|
574 | - $context['error_message'] = $txt['try_again']; |
|
609 | + if (allowedTo('admin_forum')) { |
|
610 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
611 | + } else { |
|
612 | + $context['error_message'] = $txt['try_again']; |
|
613 | + } |
|
575 | 614 | |
576 | 615 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
577 | 616 | { |
@@ -593,12 +632,14 @@ discard block |
||
593 | 632 | { |
594 | 633 | global $db_row_count; |
595 | 634 | |
596 | - if ($counter !== false) |
|
597 | - return pg_fetch_row($request, $counter); |
|
635 | + if ($counter !== false) { |
|
636 | + return pg_fetch_row($request, $counter); |
|
637 | + } |
|
598 | 638 | |
599 | 639 | // Reset the row counter... |
600 | - if (!isset($db_row_count[(int) $request])) |
|
601 | - $db_row_count[(int) $request] = 0; |
|
640 | + if (!isset($db_row_count[(int) $request])) { |
|
641 | + $db_row_count[(int) $request] = 0; |
|
642 | + } |
|
602 | 643 | |
603 | 644 | // Return the right row. |
604 | 645 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -615,12 +656,14 @@ discard block |
||
615 | 656 | { |
616 | 657 | global $db_row_count; |
617 | 658 | |
618 | - if ($counter !== false) |
|
619 | - return pg_fetch_assoc($request, $counter); |
|
659 | + if ($counter !== false) { |
|
660 | + return pg_fetch_assoc($request, $counter); |
|
661 | + } |
|
620 | 662 | |
621 | 663 | // Reset the row counter... |
622 | - if (!isset($db_row_count[(int) $request])) |
|
623 | - $db_row_count[(int) $request] = 0; |
|
664 | + if (!isset($db_row_count[(int) $request])) { |
|
665 | + $db_row_count[(int) $request] = 0; |
|
666 | + } |
|
624 | 667 | |
625 | 668 | // Return the right row. |
626 | 669 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -673,11 +716,13 @@ discard block |
||
673 | 716 | |
674 | 717 | $replace = ''; |
675 | 718 | |
676 | - if (empty($data)) |
|
677 | - return; |
|
719 | + if (empty($data)) { |
|
720 | + return; |
|
721 | + } |
|
678 | 722 | |
679 | - if (!is_array($data[array_rand($data)])) |
|
680 | - $data = array($data); |
|
723 | + if (!is_array($data[array_rand($data)])) { |
|
724 | + $data = array($data); |
|
725 | + } |
|
681 | 726 | |
682 | 727 | // Replace the prefix holder with the actual prefix. |
683 | 728 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -696,11 +741,13 @@ discard block |
||
696 | 741 | //pg 9.5 got replace support |
697 | 742 | $pg_version = $smcFunc['db_get_version'](); |
698 | 743 | // if we got a Beta Version |
699 | - if (stripos($pg_version, 'beta') !== false) |
|
700 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
744 | + if (stripos($pg_version, 'beta') !== false) { |
|
745 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
746 | + } |
|
701 | 747 | // or RC |
702 | - if (stripos($pg_version, 'rc') !== false) |
|
703 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
748 | + if (stripos($pg_version, 'rc') !== false) { |
|
749 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
750 | + } |
|
704 | 751 | |
705 | 752 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
706 | 753 | } |
@@ -719,8 +766,7 @@ discard block |
||
719 | 766 | $key_str .= ($count_pk > 0 ? ',' : ''); |
720 | 767 | $key_str .= $columnName; |
721 | 768 | $count_pk++; |
722 | - } |
|
723 | - else //normal field |
|
769 | + } else //normal field |
|
724 | 770 | { |
725 | 771 | $col_str .= ($count > 0 ? ',' : ''); |
726 | 772 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
@@ -728,20 +774,21 @@ discard block |
||
728 | 774 | } |
729 | 775 | } |
730 | 776 | $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
731 | - } |
|
732 | - else |
|
777 | + } else |
|
733 | 778 | { |
734 | 779 | foreach ($columns as $columnName => $type) |
735 | 780 | { |
736 | 781 | // Are we restricting the length? |
737 | - if (strpos($type, 'string-') !== false) |
|
738 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
739 | - else |
|
740 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
782 | + if (strpos($type, 'string-') !== false) { |
|
783 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
784 | + } else { |
|
785 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
786 | + } |
|
741 | 787 | |
742 | 788 | // A key? That's what we were looking for. |
743 | - if (in_array($columnName, $keys)) |
|
744 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
789 | + if (in_array($columnName, $keys)) { |
|
790 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
791 | + } |
|
745 | 792 | $count++; |
746 | 793 | } |
747 | 794 | |
@@ -777,10 +824,11 @@ discard block |
||
777 | 824 | foreach ($columns as $columnName => $type) |
778 | 825 | { |
779 | 826 | // Are we restricting the length? |
780 | - if (strpos($type, 'string-') !== false) |
|
781 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
782 | - else |
|
783 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
827 | + if (strpos($type, 'string-') !== false) { |
|
828 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
829 | + } else { |
|
830 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
831 | + } |
|
784 | 832 | } |
785 | 833 | $insertData = substr($insertData, 0, -2) . ')'; |
786 | 834 | |
@@ -789,8 +837,9 @@ discard block |
||
789 | 837 | |
790 | 838 | // Here's where the variables are injected to the query. |
791 | 839 | $insertRows = array(); |
792 | - foreach ($data as $dataRow) |
|
793 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
840 | + foreach ($data as $dataRow) { |
|
841 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
842 | + } |
|
794 | 843 | |
795 | 844 | // Do the insert. |
796 | 845 | $request = $smcFunc['db_query']('', ' |
@@ -807,19 +856,21 @@ discard block |
||
807 | 856 | |
808 | 857 | if ($with_returning && $request !== false) |
809 | 858 | { |
810 | - if ($returnmode === 2) |
|
811 | - $return_var = array(); |
|
859 | + if ($returnmode === 2) { |
|
860 | + $return_var = array(); |
|
861 | + } |
|
812 | 862 | |
813 | 863 | while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
814 | 864 | { |
815 | - if (is_numeric($row[0])) // try to emulate mysql limitation |
|
865 | + if (is_numeric($row[0])) { |
|
866 | + // try to emulate mysql limitation |
|
816 | 867 | { |
817 | 868 | if ($returnmode === 1) |
818 | 869 | $return_var = $row[0]; |
819 | - elseif ($returnmode === 2) |
|
820 | - $return_var[] = $row[0]; |
|
821 | - } |
|
822 | - else |
|
870 | + } elseif ($returnmode === 2) { |
|
871 | + $return_var[] = $row[0]; |
|
872 | + } |
|
873 | + } else |
|
823 | 874 | { |
824 | 875 | $with_returning = false; |
825 | 876 | trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR); |
@@ -828,9 +879,10 @@ discard block |
||
828 | 879 | } |
829 | 880 | } |
830 | 881 | |
831 | - if ($with_returning && !empty($return_var)) |
|
832 | - return $return_var; |
|
833 | -} |
|
882 | + if ($with_returning && !empty($return_var)) { |
|
883 | + return $return_var; |
|
884 | + } |
|
885 | + } |
|
834 | 886 | |
835 | 887 | /** |
836 | 888 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -867,8 +919,9 @@ discard block |
||
867 | 919 | */ |
868 | 920 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
869 | 921 | { |
870 | - if (empty($log_message)) |
|
871 | - $log_message = $error_message; |
|
922 | + if (empty($log_message)) { |
|
923 | + $log_message = $error_message; |
|
924 | + } |
|
872 | 925 | |
873 | 926 | foreach (debug_backtrace() as $step) |
874 | 927 | { |
@@ -887,12 +940,14 @@ discard block |
||
887 | 940 | } |
888 | 941 | |
889 | 942 | // A special case - we want the file and line numbers for debugging. |
890 | - if ($error_type == 'return') |
|
891 | - return array($file, $line); |
|
943 | + if ($error_type == 'return') { |
|
944 | + return array($file, $line); |
|
945 | + } |
|
892 | 946 | |
893 | 947 | // Is always a critical error. |
894 | - if (function_exists('log_error')) |
|
895 | - log_error($log_message, 'critical', $file, $line); |
|
948 | + if (function_exists('log_error')) { |
|
949 | + log_error($log_message, 'critical', $file, $line); |
|
950 | + } |
|
896 | 951 | |
897 | 952 | if (function_exists('fatal_error')) |
898 | 953 | { |
@@ -900,12 +955,12 @@ discard block |
||
900 | 955 | |
901 | 956 | // Cannot continue... |
902 | 957 | exit; |
958 | + } elseif ($error_type) { |
|
959 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
960 | + } else { |
|
961 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
962 | + } |
|
903 | 963 | } |
904 | - elseif ($error_type) |
|
905 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
906 | - else |
|
907 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
908 | -} |
|
909 | 964 | |
910 | 965 | /** |
911 | 966 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -922,10 +977,11 @@ discard block |
||
922 | 977 | '\\' => '\\\\', |
923 | 978 | ); |
924 | 979 | |
925 | - if ($translate_human_wildcards) |
|
926 | - $replacements += array( |
|
980 | + if ($translate_human_wildcards) { |
|
981 | + $replacements += array( |
|
927 | 982 | '*' => '%', |
928 | 983 | ); |
984 | + } |
|
929 | 985 | |
930 | 986 | return strtr($string, $replacements); |
931 | 987 | } |