@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | class Update_TLD_Regex extends SMF_BackgroundTask |
20 | 20 | { |
21 | - /** |
|
22 | - * This executes the task. It just calls set_tld_regex() in Subs.php |
|
23 | - * @return bool Always returns true |
|
24 | - */ |
|
21 | + /** |
|
22 | + * This executes the task. It just calls set_tld_regex() in Subs.php |
|
23 | + * @return bool Always returns true |
|
24 | + */ |
|
25 | 25 | public function execute() |
26 | 26 | { |
27 | 27 | global $sourcedir; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | class MemberReportReply_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | 24 | * @return bool Always returns true. |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | 'last_comment' => $this->_details['comment_id'], |
41 | 41 | ) |
42 | 42 | ); |
43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
44 | - $possible_members[] = $row[0]; |
|
43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
44 | + $possible_members[] = $row[0]; |
|
45 | + } |
|
45 | 46 | $smcFunc['db_free_result']($request); |
46 | 47 | |
47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
52 | 53 | } |
53 | - if (empty($possible_members)) |
|
54 | - return true; |
|
54 | + if (empty($possible_members)) { |
|
55 | + return true; |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | { |
74 | 76 | foreach ($alert_bits as $type => $bitvalue) |
75 | 77 | { |
76 | - if ($pref_option['member_report_reply'] & $bitvalue) |
|
77 | - $notifies[$type][] = $member; |
|
78 | + if ($pref_option['member_report_reply'] & $bitvalue) { |
|
79 | + $notifies[$type][] = $member; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | 83 | |
@@ -136,8 +139,9 @@ discard block |
||
136 | 139 | ); |
137 | 140 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
138 | 141 | { |
139 | - if (empty($row['lngfile'])) |
|
140 | - $row['lngfile'] = $language; |
|
142 | + if (empty($row['lngfile'])) { |
|
143 | + $row['lngfile'] = $language; |
|
144 | + } |
|
141 | 145 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
142 | 146 | } |
143 | 147 | $smcFunc['db_free_result']($request); |
@@ -155,8 +159,9 @@ discard block |
||
155 | 159 | $emaildata = loadEmailTemplate('reply_to_user_reports', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
156 | 160 | |
157 | 161 | // And do the actual sending... |
158 | - foreach ($recipients as $id_member => $email_address) |
|
159 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
162 | + foreach ($recipients as $id_member => $email_address) { |
|
163 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
164 | + } |
|
160 | 165 | } |
161 | 166 | } |
162 | 167 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | class ApproveReply_Notify_Background extends SMF_BackgroundTask |
19 | 19 | { |
20 | 20 | /** |
21 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
21 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
22 | 22 | * @return bool Always returns true. |
23 | 23 | */ |
24 | 24 | public function execute() |
@@ -96,14 +96,15 @@ |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | // Insert the alerts if any |
99 | - if (!empty($alert_rows)) |
|
100 | - $smcFunc['db_insert']('', |
|
99 | + if (!empty($alert_rows)) { |
|
100 | + $smcFunc['db_insert']('', |
|
101 | 101 | '{db_prefix}user_alerts', |
102 | 102 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
103 | 103 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
104 | 104 | $alert_rows, |
105 | 105 | array() |
106 | 106 | ); |
107 | + } |
|
107 | 108 | |
108 | 109 | return true; |
109 | 110 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | class GroupReq_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
24 | 24 | * @return bool Always returns true. |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | $moderators = array(); |
40 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
41 | - $moderators[] = $row['id_member']; |
|
40 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
41 | + $moderators[] = $row['id_member']; |
|
42 | + } |
|
42 | 43 | $smcFunc['db_free_result']($request); |
43 | 44 | |
44 | 45 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -59,11 +60,13 @@ discard block |
||
59 | 60 | { |
60 | 61 | if (!empty($prefs[$mod]['request_group'])) |
61 | 62 | { |
62 | - if ($prefs[$mod]['request_group'] & 0x01) |
|
63 | - $data['alert'][] = $mod; |
|
63 | + if ($prefs[$mod]['request_group'] & 0x01) { |
|
64 | + $data['alert'][] = $mod; |
|
65 | + } |
|
64 | 66 | |
65 | - if ($prefs[$mod]['request_group'] & 0x02) |
|
66 | - $data['email'][] = $mod; |
|
67 | + if ($prefs[$mod]['request_group'] & 0x02) { |
|
68 | + $data['email'][] = $mod; |
|
69 | + } |
|
67 | 70 | } |
68 | 71 | } |
69 | 72 |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -46,8 +47,9 @@ discard block |
||
46 | 47 | |
47 | 48 | $supported = function_exists('xcache_get') && function_exists('xcache_set') && ini_get('xcache.var_size') > 0; |
48 | 49 | |
49 | - if ($test) |
|
50 | - return $supported; |
|
50 | + if ($test) { |
|
51 | + return $supported; |
|
52 | + } |
|
51 | 53 | return parent::isSupported() && $supported; |
52 | 54 | } |
53 | 55 | |
@@ -68,10 +70,11 @@ discard block |
||
68 | 70 | { |
69 | 71 | $key = $this->prefix . strtr($key, ':/', '-_'); |
70 | 72 | |
71 | - if ($value === null) |
|
72 | - return xcache_unset($key); |
|
73 | - else |
|
74 | - return xcache_set($key, $value, $ttl); |
|
73 | + if ($value === null) { |
|
74 | + return xcache_unset($key); |
|
75 | + } else { |
|
76 | + return xcache_set($key, $value, $ttl); |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | /** |
@@ -90,10 +93,12 @@ discard block |
||
90 | 93 | } |
91 | 94 | |
92 | 95 | // if passed a type, clear that type out |
93 | - if ($type === '' || $type === 'user') |
|
94 | - xcache_clear_cache(XC_TYPE_VAR, 0); |
|
95 | - if ($type === '' || $type === 'data') |
|
96 | - xcache_clear_cache(XC_TYPE_PHP, 0); |
|
96 | + if ($type === '' || $type === 'user') { |
|
97 | + xcache_clear_cache(XC_TYPE_VAR, 0); |
|
98 | + } |
|
99 | + if ($type === '' || $type === 'data') { |
|
100 | + xcache_clear_cache(XC_TYPE_PHP, 0); |
|
101 | + } |
|
97 | 102 | |
98 | 103 | $this->invalidateCache(); |
99 | 104 | return true; |
@@ -112,8 +117,9 @@ discard block |
||
112 | 117 | // While we could md5 this when saving, this could be tricky to be sure it doesn't get corrupted on additional saves. |
113 | 118 | $config_vars[] = array('xcache_adminpass', $txt['cache_xcache_adminpass'], 'db', 'text', 0); |
114 | 119 | |
115 | - if (!isset($context['settings_post_javascript'])) |
|
116 | - $context['settings_post_javascript'] = ''; |
|
120 | + if (!isset($context['settings_post_javascript'])) { |
|
121 | + $context['settings_post_javascript'] = ''; |
|
122 | + } |
|
117 | 123 | |
118 | 124 | $context['settings_post_javascript'] .= ' |
119 | 125 | $("#cache_accelerator").change(function (e) { |
@@ -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 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @version 2.1 Beta 3 |
17 | 17 | */ |
18 | 18 | |
19 | -if (!defined('SMF')) |
|
19 | +if (!defined('SMF')) { |
|
20 | 20 | die('No direct access...'); |
21 | +} |
|
21 | 22 | |
22 | 23 | |
23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | function sha1_smf($str) |
29 | 30 | { |
30 | 31 | // If we have mhash loaded in, use it instead! |
31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
36 | 38 | |
37 | - for ($i = 0; $i < strlen($str); $i++) |
|
38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
41 | + } |
|
39 | 42 | |
40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
70 | 73 | |
71 | 74 | for ($j = 0; $j < 80; $j++) |
72 | 75 | { |
73 | - if ($j < 16) |
|
74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
75 | - else |
|
76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
76 | + if ($j < 16) { |
|
77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
78 | + } else { |
|
79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
80 | + } |
|
77 | 81 | |
78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
103 | 107 | */ |
104 | 108 | function sha1_ft($t, $b, $c, $d) |
105 | 109 | { |
106 | - if ($t < 20) |
|
107 | - return ($b & $c) | ((~$b) & $d); |
|
108 | - if ($t < 40) |
|
109 | - return $b ^ $c ^ $d; |
|
110 | - if ($t < 60) |
|
111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
110 | + if ($t < 20) { |
|
111 | + return ($b & $c) | ((~$b) & $d); |
|
112 | + } |
|
113 | + if ($t < 40) { |
|
114 | + return $b ^ $c ^ $d; |
|
115 | + } |
|
116 | + if ($t < 60) { |
|
117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
118 | + } |
|
112 | 119 | |
113 | 120 | return $b ^ $c ^ $d; |
114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
132 | 139 | function sha1_rol($num, $cnt) |
133 | 140 | { |
134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
135 | - if ($num & 0x80000000) |
|
136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
137 | - else |
|
138 | - $a = $num >> (32 - $cnt); |
|
142 | + if ($num & 0x80000000) { |
|
143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
144 | + } else { |
|
145 | + $a = $num >> (32 - $cnt); |
|
146 | + } |
|
139 | 147 | |
140 | 148 | return ($num << $cnt) | $a; |
141 | 149 | } |
@@ -240,8 +240,8 @@ |
||
240 | 240 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
241 | 241 | |
242 | 242 | $js_time_string = str_replace( |
243 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
244 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
243 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
244 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
245 | 245 | $time_string |
246 | 246 | ); |
247 | 247 |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
47 | 48 | 'post' => 'CalendarPost', |
48 | 49 | ); |
49 | 50 | |
50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
51 | - return call_helper($subActions[$_GET['sa']]); |
|
51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
52 | + return call_helper($subActions[$_GET['sa']]); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | // You can't do anything if the calendar is off. |
54 | - if (empty($modSettings['cal_enabled'])) |
|
55 | - fatal_lang_error('calendar_off', false); |
|
56 | + if (empty($modSettings['cal_enabled'])) { |
|
57 | + fatal_lang_error('calendar_off', false); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // This is gonna be needed... |
58 | 61 | loadTemplate('Calendar'); |
@@ -80,8 +83,9 @@ discard block |
||
80 | 83 | $_REQUEST['month'] = (int) $_REQUEST['month']; |
81 | 84 | |
82 | 85 | // We want month view. |
83 | - if (empty($_GET['viewmonth'])) |
|
84 | - $_GET['viewmonth'] = true; |
|
86 | + if (empty($_GET['viewmonth'])) { |
|
87 | + $_GET['viewmonth'] = true; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | // And we definitely don't want weekly view. |
87 | 91 | unset ($_GET['viewweek']); |
@@ -98,22 +102,25 @@ discard block |
||
98 | 102 | $context['page_title'] = $txt['calendar']; |
99 | 103 | |
100 | 104 | // Ensure a default view is defined |
101 | - if (empty($modSettings['calendar_default_view'])) |
|
102 | - $modSettings['calendar_default_view'] = 'view_list'; |
|
105 | + if (empty($modSettings['calendar_default_view'])) { |
|
106 | + $modSettings['calendar_default_view'] = 'view_list'; |
|
107 | + } |
|
103 | 108 | |
104 | 109 | // What view do we want? |
105 | - if (isset($_GET['viewweek'])) |
|
106 | - $context['calendar_view'] = 'view_week'; |
|
107 | - elseif (isset($_GET['viewmonth'])) |
|
108 | - $context['calendar_view'] = 'view_month'; |
|
109 | - elseif (isset($_GET['viewlist'])) |
|
110 | - $context['calendar_view'] = 'view_list'; |
|
111 | - else |
|
112 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
110 | + if (isset($_GET['viewweek'])) { |
|
111 | + $context['calendar_view'] = 'view_week'; |
|
112 | + } elseif (isset($_GET['viewmonth'])) { |
|
113 | + $context['calendar_view'] = 'view_month'; |
|
114 | + } elseif (isset($_GET['viewlist'])) { |
|
115 | + $context['calendar_view'] = 'view_list'; |
|
116 | + } else { |
|
117 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
118 | + } |
|
113 | 119 | |
114 | 120 | // Don't let search engines index the non-default calendar pages |
115 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
116 | - $context['robot_no_index'] = true; |
|
121 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
122 | + $context['robot_no_index'] = true; |
|
123 | + } |
|
117 | 124 | |
118 | 125 | // Get the current day of month... |
119 | 126 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -174,16 +181,19 @@ discard block |
||
174 | 181 | ); |
175 | 182 | |
176 | 183 | // Make sure the year and month are in valid ranges. |
177 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
178 | - fatal_lang_error('invalid_month', false); |
|
179 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
180 | - fatal_lang_error('invalid_year', false); |
|
184 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
185 | + fatal_lang_error('invalid_month', false); |
|
186 | + } |
|
187 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
188 | + fatal_lang_error('invalid_year', false); |
|
189 | + } |
|
181 | 190 | // If we have a day clean that too. |
182 | 191 | if ($context['calendar_view'] != 'view_month') |
183 | 192 | { |
184 | 193 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
185 | - if (!$isValid) |
|
186 | - fatal_lang_error('invalid_day', false); |
|
194 | + if (!$isValid) { |
|
195 | + fatal_lang_error('invalid_day', false); |
|
196 | + } |
|
187 | 197 | } |
188 | 198 | |
189 | 199 | // Load all the context information needed to show the calendar grid. |
@@ -205,23 +215,26 @@ discard block |
||
205 | 215 | ); |
206 | 216 | |
207 | 217 | // Load up the main view. |
208 | - if ($context['calendar_view'] == 'view_list') |
|
209 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
210 | - elseif ($context['calendar_view'] == 'view_week') |
|
211 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
212 | - else |
|
213 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
218 | + if ($context['calendar_view'] == 'view_list') { |
|
219 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
220 | + } elseif ($context['calendar_view'] == 'view_week') { |
|
221 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
222 | + } else { |
|
223 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
224 | + } |
|
214 | 225 | |
215 | 226 | // Load up the previous and next months. |
216 | 227 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
217 | 228 | |
218 | 229 | // Only show previous month if it isn't pre-January of the min-year |
219 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
220 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
230 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
231 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
232 | + } |
|
221 | 233 | |
222 | 234 | // Only show next month if it isn't post-December of the max-year |
223 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
224 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
235 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
236 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
237 | + } |
|
225 | 238 | |
226 | 239 | // Basic template stuff. |
227 | 240 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -241,8 +254,9 @@ discard block |
||
241 | 254 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
242 | 255 | |
243 | 256 | // Set the page title to mention the month or week, too |
244 | - if ($context['calendar_view'] != 'view_list') |
|
245 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
257 | + if ($context['calendar_view'] != 'view_list') { |
|
258 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
259 | + } |
|
246 | 260 | |
247 | 261 | // Load up the linktree! |
248 | 262 | $context['linktree'][] = array( |
@@ -255,17 +269,19 @@ discard block |
||
255 | 269 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
256 | 270 | ); |
257 | 271 | // If applicable, add the current week to the linktree. |
258 | - if ($context['calendar_view'] == 'view_week') |
|
259 | - $context['linktree'][] = array( |
|
272 | + if ($context['calendar_view'] == 'view_week') { |
|
273 | + $context['linktree'][] = array( |
|
260 | 274 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
261 | 275 | 'name' => $context['calendar_grid_main']['week_title'], |
262 | 276 | ); |
277 | + } |
|
263 | 278 | |
264 | 279 | // Build the calendar button array. |
265 | 280 | $context['calendar_buttons'] = array(); |
266 | 281 | |
267 | - if ($context['can_post']) |
|
268 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
282 | + if ($context['can_post']) { |
|
283 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
284 | + } |
|
269 | 285 | |
270 | 286 | // Allow mods to add additional buttons here |
271 | 287 | call_integration_hook('integrate_calendar_buttons'); |
@@ -294,14 +310,16 @@ discard block |
||
294 | 310 | require_once($sourcedir . '/Subs.php'); |
295 | 311 | |
296 | 312 | // Cast this for safety... |
297 | - if (isset($_REQUEST['eventid'])) |
|
298 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
313 | + if (isset($_REQUEST['eventid'])) { |
|
314 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
315 | + } |
|
299 | 316 | |
300 | 317 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
301 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
302 | - $time_string = '%k:%M'; |
|
303 | - else |
|
304 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
318 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
319 | + $time_string = '%k:%M'; |
|
320 | + } else { |
|
321 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
322 | + } |
|
305 | 323 | |
306 | 324 | $js_time_string = str_replace( |
307 | 325 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -315,12 +333,14 @@ discard block |
||
315 | 333 | checkSession(); |
316 | 334 | |
317 | 335 | // Validate the post... |
318 | - if (!isset($_POST['link_to_board'])) |
|
319 | - validateEventPost(); |
|
336 | + if (!isset($_POST['link_to_board'])) { |
|
337 | + validateEventPost(); |
|
338 | + } |
|
320 | 339 | |
321 | 340 | // If you're not allowed to edit any events, you have to be the poster. |
322 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
323 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
341 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
342 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
343 | + } |
|
324 | 344 | |
325 | 345 | // New - and directing? |
326 | 346 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -343,8 +363,9 @@ discard block |
||
343 | 363 | } |
344 | 364 | |
345 | 365 | // Deleting... |
346 | - elseif (isset($_REQUEST['deleteevent'])) |
|
347 | - removeEvent($_REQUEST['eventid']); |
|
366 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
367 | + removeEvent($_REQUEST['eventid']); |
|
368 | + } |
|
348 | 369 | |
349 | 370 | // ... or just update it? |
350 | 371 | else |
@@ -366,14 +387,12 @@ discard block |
||
366 | 387 | $d = date_parse($_POST['start_date']); |
367 | 388 | $year = $d['year']; |
368 | 389 | $month = $d['month']; |
369 | - } |
|
370 | - elseif (isset($_POST['start_datetime'])) |
|
390 | + } elseif (isset($_POST['start_datetime'])) |
|
371 | 391 | { |
372 | 392 | $d = date_parse($_POST['start_datetime']); |
373 | 393 | $year = $d['year']; |
374 | 394 | $month = $d['month']; |
375 | - } |
|
376 | - else |
|
395 | + } else |
|
377 | 396 | { |
378 | 397 | $today = getdate(); |
379 | 398 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -406,13 +425,13 @@ discard block |
||
406 | 425 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
407 | 426 | |
408 | 427 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
409 | - } |
|
410 | - else |
|
428 | + } else |
|
411 | 429 | { |
412 | 430 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
413 | 431 | |
414 | - if ($context['event'] === false) |
|
415 | - fatal_lang_error('no_access', false); |
|
432 | + if ($context['event'] === false) { |
|
433 | + fatal_lang_error('no_access', false); |
|
434 | + } |
|
416 | 435 | |
417 | 436 | // If it has a board, then they should be editing it within the topic. |
418 | 437 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -423,10 +442,11 @@ discard block |
||
423 | 442 | } |
424 | 443 | |
425 | 444 | // Make sure the user is allowed to edit this event. |
426 | - if ($context['event']['member'] != $user_info['id']) |
|
427 | - isAllowedTo('calendar_edit_any'); |
|
428 | - elseif (!allowedTo('calendar_edit_any')) |
|
429 | - isAllowedTo('calendar_edit_own'); |
|
445 | + if ($context['event']['member'] != $user_info['id']) { |
|
446 | + isAllowedTo('calendar_edit_any'); |
|
447 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
448 | + isAllowedTo('calendar_edit_own'); |
|
449 | + } |
|
430 | 450 | } |
431 | 451 | |
432 | 452 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -460,8 +480,7 @@ discard block |
||
460 | 480 | { |
461 | 481 | // You can post new events but can't link them to anything... |
462 | 482 | $context['event']['categories'] = array(); |
463 | - } |
|
464 | - else |
|
483 | + } else |
|
465 | 484 | { |
466 | 485 | // Load the list of boards and categories in the context. |
467 | 486 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -548,12 +567,14 @@ discard block |
||
548 | 567 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
549 | 568 | |
550 | 569 | // You can't export if the calendar export feature is off. |
551 | - if (empty($modSettings['cal_export'])) |
|
552 | - fatal_lang_error('calendar_export_off', false); |
|
570 | + if (empty($modSettings['cal_export'])) { |
|
571 | + fatal_lang_error('calendar_export_off', false); |
|
572 | + } |
|
553 | 573 | |
554 | 574 | // Goes without saying that this is required. |
555 | - if (!isset($_REQUEST['eventid'])) |
|
556 | - fatal_lang_error('no_access', false); |
|
575 | + if (!isset($_REQUEST['eventid'])) { |
|
576 | + fatal_lang_error('no_access', false); |
|
577 | + } |
|
557 | 578 | |
558 | 579 | // This is kinda wanted. |
559 | 580 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -561,15 +582,17 @@ discard block |
||
561 | 582 | // Load up the event in question and check it exists. |
562 | 583 | $event = getEventProperties($_REQUEST['eventid']); |
563 | 584 | |
564 | - if ($event === false) |
|
565 | - fatal_lang_error('no_access', false); |
|
585 | + if ($event === false) { |
|
586 | + fatal_lang_error('no_access', false); |
|
587 | + } |
|
566 | 588 | |
567 | 589 | // Check the title isn't too long - iCal requires some formatting if so. |
568 | 590 | $title = str_split($event['title'], 30); |
569 | 591 | foreach ($title as $id => $line) |
570 | 592 | { |
571 | - if ($id != 0) |
|
572 | - $title[$id] = ' ' . $title[$id]; |
|
593 | + if ($id != 0) { |
|
594 | + $title[$id] = ' ' . $title[$id]; |
|
595 | + } |
|
573 | 596 | $title[$id] .= "\n"; |
574 | 597 | } |
575 | 598 | |
@@ -582,8 +605,7 @@ discard block |
||
582 | 605 | { |
583 | 606 | $datestart = date_format($start_date, 'Ymd\THis'); |
584 | 607 | $dateend = date_format($end_date, 'Ymd\THis'); |
585 | - } |
|
586 | - else |
|
608 | + } else |
|
587 | 609 | { |
588 | 610 | $datestart = date_format($start_date, 'Ymd'); |
589 | 611 | |
@@ -604,15 +626,18 @@ discard block |
||
604 | 626 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
605 | 627 | |
606 | 628 | // event has a duration |
607 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
608 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
629 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
630 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
631 | + } |
|
609 | 632 | |
610 | 633 | // event has changed? advance the sequence for this UID |
611 | - if ($event['sequence'] > 0) |
|
612 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
634 | + if ($event['sequence'] > 0) { |
|
635 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
636 | + } |
|
613 | 637 | |
614 | - if (!empty($event['location'])) |
|
615 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
638 | + if (!empty($event['location'])) { |
|
639 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
640 | + } |
|
616 | 641 | |
617 | 642 | $filecontents .= 'SUMMARY:' . implode('', $title); |
618 | 643 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -621,23 +646,26 @@ discard block |
||
621 | 646 | |
622 | 647 | // Send some standard headers. |
623 | 648 | ob_end_clean(); |
624 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
625 | - @ob_start('ob_gzhandler'); |
|
626 | - else |
|
627 | - ob_start(); |
|
649 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
650 | + @ob_start('ob_gzhandler'); |
|
651 | + } else { |
|
652 | + ob_start(); |
|
653 | + } |
|
628 | 654 | |
629 | 655 | // Send the file headers |
630 | 656 | header('Pragma: '); |
631 | 657 | header('Cache-Control: no-cache'); |
632 | - if (!isBrowser('gecko')) |
|
633 | - header('Content-Transfer-Encoding: binary'); |
|
658 | + if (!isBrowser('gecko')) { |
|
659 | + header('Content-Transfer-Encoding: binary'); |
|
660 | + } |
|
634 | 661 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
635 | 662 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
636 | 663 | header('Accept-Ranges: bytes'); |
637 | 664 | header('Connection: close'); |
638 | 665 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
639 | - if (empty($modSettings['enableCompressedOutput'])) |
|
640 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
666 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
667 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
668 | + } |
|
641 | 669 | |
642 | 670 | // This is a calendar item! |
643 | 671 | header('Content-Type: text/calendar'); |
@@ -676,20 +704,17 @@ discard block |
||
676 | 704 | $context['sub_template'] = 'bcd'; |
677 | 705 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
678 | 706 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ==')); |
679 | - } |
|
680 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
707 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
681 | 708 | { |
682 | 709 | $context['sub_template'] = 'hms'; |
683 | 710 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
684 | 711 | $context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); |
685 | - } |
|
686 | - elseif ($omfg) |
|
712 | + } elseif ($omfg) |
|
687 | 713 | { |
688 | 714 | $context['sub_template'] = 'omfg'; |
689 | 715 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
690 | 716 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ==')); |
691 | - } |
|
692 | - elseif (isset($_REQUEST['time'])) |
|
717 | + } elseif (isset($_REQUEST['time'])) |
|
693 | 718 | { |
694 | 719 | $context['sub_template'] = 'thetime'; |
695 | 720 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -749,12 +774,13 @@ discard block |
||
749 | 774 | ), |
750 | 775 | ); |
751 | 776 | |
752 | - foreach ($context['clockicons'] as $t => $vs) |
|
753 | - foreach ($vs as $v => $dumb) |
|
777 | + foreach ($context['clockicons'] as $t => $vs) { |
|
778 | + foreach ($vs as $v => $dumb) |
|
754 | 779 | { |
755 | 780 | if ($$t >= $v) |
756 | 781 | { |
757 | 782 | $$t -= $v; |
783 | + } |
|
758 | 784 | $context['clockicons'][$t][$v] = true; |
759 | 785 | } |
760 | 786 | } |
@@ -1622,8 +1622,7 @@ |
||
1622 | 1622 | updateStats('topic'); |
1623 | 1623 | |
1624 | 1624 | // This function is needed to do the updateStats('subject') call. |
1625 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
1626 | - function($string){ |
|
1625 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
1627 | 1626 | global $sourcedir; |
1628 | 1627 | if (function_exists('mb_strtolower')) |
1629 | 1628 | return mb_strtolower($string, 'UTF-8'); |
@@ -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,8 +148,9 @@ 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 | // Enable error reporting. |
150 | 156 | error_reporting(E_ALL); |
@@ -160,21 +166,23 @@ discard block |
||
160 | 166 | { |
161 | 167 | ob_start(); |
162 | 168 | |
163 | - if (ini_get('session.save_handler') == 'user') |
|
164 | - @ini_set('session.save_handler', 'files'); |
|
165 | - if (function_exists('session_start')) |
|
166 | - @session_start(); |
|
167 | - } |
|
168 | - else |
|
169 | + if (ini_get('session.save_handler') == 'user') { |
|
170 | + @ini_set('session.save_handler', 'files'); |
|
171 | + } |
|
172 | + if (function_exists('session_start')) { |
|
173 | + @session_start(); |
|
174 | + } |
|
175 | + } else |
|
169 | 176 | { |
170 | 177 | ob_start('ob_gzhandler'); |
171 | 178 | |
172 | - if (ini_get('session.save_handler') == 'user') |
|
173 | - @ini_set('session.save_handler', 'files'); |
|
179 | + if (ini_get('session.save_handler') == 'user') { |
|
180 | + @ini_set('session.save_handler', 'files'); |
|
181 | + } |
|
174 | 182 | session_start(); |
175 | 183 | |
176 | - if (!headers_sent()) |
|
177 | - echo '<!DOCTYPE html> |
|
184 | + if (!headers_sent()) { |
|
185 | + echo '<!DOCTYPE html> |
|
178 | 186 | <html> |
179 | 187 | <head> |
180 | 188 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -183,14 +191,16 @@ discard block |
||
183 | 191 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
184 | 192 | </body> |
185 | 193 | </html>'; |
194 | + } |
|
186 | 195 | exit; |
187 | 196 | } |
188 | 197 | |
189 | 198 | // Add slashes, as long as they aren't already being added. |
190 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
191 | - foreach ($_POST as $k => $v) |
|
199 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
200 | + foreach ($_POST as $k => $v) |
|
192 | 201 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
193 | 202 | $_POST[$k] = addslashes($v); |
203 | + } |
|
194 | 204 | |
195 | 205 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
196 | 206 | if (isset($_GET['delete'])) |
@@ -211,8 +221,7 @@ discard block |
||
211 | 221 | $ftp->close(); |
212 | 222 | |
213 | 223 | unset($_SESSION['installer_temp_ftp']); |
214 | - } |
|
215 | - else |
|
224 | + } else |
|
216 | 225 | { |
217 | 226 | @unlink(__FILE__); |
218 | 227 | |
@@ -233,10 +242,11 @@ discard block |
||
233 | 242 | { |
234 | 243 | // Get PHP's default timezone, if set |
235 | 244 | $ini_tz = ini_get('date.timezone'); |
236 | - if (!empty($ini_tz)) |
|
237 | - $timezone_id = $ini_tz; |
|
238 | - else |
|
239 | - $timezone_id = ''; |
|
245 | + if (!empty($ini_tz)) { |
|
246 | + $timezone_id = $ini_tz; |
|
247 | + } else { |
|
248 | + $timezone_id = ''; |
|
249 | + } |
|
240 | 250 | |
241 | 251 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
242 | 252 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -266,8 +276,9 @@ discard block |
||
266 | 276 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
267 | 277 | while ($entry = $dir->read()) |
268 | 278 | { |
269 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
270 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
279 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
280 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
281 | + } |
|
271 | 282 | } |
272 | 283 | $dir->close(); |
273 | 284 | } |
@@ -302,10 +313,11 @@ discard block |
||
302 | 313 | } |
303 | 314 | |
304 | 315 | // Override the language file? |
305 | - if (isset($_GET['lang_file'])) |
|
306 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
307 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
308 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
316 | + if (isset($_GET['lang_file'])) { |
|
317 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
318 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
319 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
320 | + } |
|
309 | 321 | |
310 | 322 | // Make sure it exists, if it doesn't reset it. |
311 | 323 | 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'])) |
@@ -314,8 +326,9 @@ discard block |
||
314 | 326 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
315 | 327 | |
316 | 328 | // If we have english and some other language, use the other language. We Americans hate english :P. |
317 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
318 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
329 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
330 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
331 | + } |
|
319 | 332 | } |
320 | 333 | |
321 | 334 | // And now include the actual language file itself. |
@@ -328,15 +341,18 @@ discard block |
||
328 | 341 | global $db_prefix, $db_connection, $sourcedir; |
329 | 342 | global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist; |
330 | 343 | |
331 | - if (empty($sourcedir)) |
|
332 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
344 | + if (empty($sourcedir)) { |
|
345 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
346 | + } |
|
333 | 347 | |
334 | 348 | // Need this to check whether we need the database password. |
335 | 349 | require(dirname(__FILE__) . '/Settings.php'); |
336 | - if (!defined('SMF')) |
|
337 | - define('SMF', 1); |
|
338 | - if (empty($smcFunc)) |
|
339 | - $smcFunc = array(); |
|
350 | + if (!defined('SMF')) { |
|
351 | + define('SMF', 1); |
|
352 | + } |
|
353 | + if (empty($smcFunc)) { |
|
354 | + $smcFunc = array(); |
|
355 | + } |
|
340 | 356 | |
341 | 357 | $modSettings['disableQueryCheck'] = true; |
342 | 358 | |
@@ -344,8 +360,9 @@ discard block |
||
344 | 360 | if (!$db_connection) |
345 | 361 | { |
346 | 362 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
347 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
348 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
363 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
364 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
365 | + } |
|
349 | 366 | |
350 | 367 | $db_options = array('persist' => $db_persist); |
351 | 368 | $port = ''; |
@@ -356,19 +373,20 @@ discard block |
||
356 | 373 | if ($db_type == 'mysql') |
357 | 374 | { |
358 | 375 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
359 | - } |
|
360 | - elseif ($db_type == 'postgresql') |
|
376 | + } elseif ($db_type == 'postgresql') |
|
361 | 377 | { |
362 | 378 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
363 | 379 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
364 | 380 | } |
365 | 381 | } |
366 | 382 | |
367 | - if (!empty($port)) |
|
368 | - $db_options['port'] = $port; |
|
383 | + if (!empty($port)) { |
|
384 | + $db_options['port'] = $port; |
|
385 | + } |
|
369 | 386 | |
370 | - if (!$db_connection) |
|
371 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
387 | + if (!$db_connection) { |
|
388 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
389 | + } |
|
372 | 390 | } |
373 | 391 | } |
374 | 392 | |
@@ -396,8 +414,9 @@ discard block |
||
396 | 414 | // @todo REMOVE THIS!! |
397 | 415 | else |
398 | 416 | { |
399 | - if (function_exists('doStep' . $_GET['step'])) |
|
400 | - call_user_func('doStep' . $_GET['step']); |
|
417 | + if (function_exists('doStep' . $_GET['step'])) { |
|
418 | + call_user_func('doStep' . $_GET['step']); |
|
419 | + } |
|
401 | 420 | } |
402 | 421 | // Show the footer. |
403 | 422 | template_install_below(); |
@@ -415,8 +434,9 @@ discard block |
||
415 | 434 | $incontext['sub_template'] = 'welcome_message'; |
416 | 435 | |
417 | 436 | // Done the submission? |
418 | - if (isset($_POST['contbutt'])) |
|
419 | - return true; |
|
437 | + if (isset($_POST['contbutt'])) { |
|
438 | + return true; |
|
439 | + } |
|
420 | 440 | |
421 | 441 | // See if we think they have already installed it? |
422 | 442 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -424,14 +444,17 @@ discard block |
||
424 | 444 | $probably_installed = 0; |
425 | 445 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
426 | 446 | { |
427 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
428 | - $probably_installed++; |
|
429 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
430 | - $probably_installed++; |
|
447 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
448 | + $probably_installed++; |
|
449 | + } |
|
450 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
451 | + $probably_installed++; |
|
452 | + } |
|
431 | 453 | } |
432 | 454 | |
433 | - if ($probably_installed == 2) |
|
434 | - $incontext['warning'] = $txt['error_already_installed']; |
|
455 | + if ($probably_installed == 2) { |
|
456 | + $incontext['warning'] = $txt['error_already_installed']; |
|
457 | + } |
|
435 | 458 | } |
436 | 459 | |
437 | 460 | // Is some database support even compiled in? |
@@ -446,36 +469,43 @@ discard block |
||
446 | 469 | $databases[$key]['supported'] = false; |
447 | 470 | $notFoundSQLFile = true; |
448 | 471 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
472 | + } else { |
|
473 | + $incontext['supported_databases'][] = $db; |
|
449 | 474 | } |
450 | - else |
|
451 | - $incontext['supported_databases'][] = $db; |
|
452 | 475 | } |
453 | 476 | } |
454 | 477 | |
455 | 478 | // Check the PHP version. |
456 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
457 | - $error = 'error_php_too_low'; |
|
479 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) { |
|
480 | + $error = 'error_php_too_low'; |
|
481 | + } |
|
458 | 482 | // Make sure we have a supported database |
459 | - elseif (empty($incontext['supported_databases'])) |
|
460 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
483 | + elseif (empty($incontext['supported_databases'])) { |
|
484 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
485 | + } |
|
461 | 486 | // How about session support? Some crazy sysadmin remove it? |
462 | - elseif (!function_exists('session_start')) |
|
463 | - $error = 'error_session_missing'; |
|
487 | + elseif (!function_exists('session_start')) { |
|
488 | + $error = 'error_session_missing'; |
|
489 | + } |
|
464 | 490 | // Make sure they uploaded all the files. |
465 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
466 | - $error = 'error_missing_files'; |
|
491 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
492 | + $error = 'error_missing_files'; |
|
493 | + } |
|
467 | 494 | // Very simple check on the session.save_path for Windows. |
468 | 495 | // @todo Move this down later if they don't use database-driven sessions? |
469 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
470 | - $error = 'error_session_save_path'; |
|
496 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
497 | + $error = 'error_session_save_path'; |
|
498 | + } |
|
471 | 499 | |
472 | 500 | // Since each of the three messages would look the same, anyway... |
473 | - if (isset($error)) |
|
474 | - $incontext['error'] = $txt[$error]; |
|
501 | + if (isset($error)) { |
|
502 | + $incontext['error'] = $txt[$error]; |
|
503 | + } |
|
475 | 504 | |
476 | 505 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
477 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
478 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
506 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
507 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
508 | + } |
|
479 | 509 | |
480 | 510 | return false; |
481 | 511 | } |
@@ -501,12 +531,14 @@ discard block |
||
501 | 531 | 'db_last_error.php', |
502 | 532 | ); |
503 | 533 | |
504 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
505 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
534 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
535 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
536 | + } |
|
506 | 537 | |
507 | 538 | // With mod_security installed, we could attempt to fix it with .htaccess. |
508 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
509 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
539 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
540 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
541 | + } |
|
510 | 542 | |
511 | 543 | $failed_files = array(); |
512 | 544 | |
@@ -522,12 +554,14 @@ discard block |
||
522 | 554 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
523 | 555 | |
524 | 556 | // Well, 755 hopefully worked... if not, try 777. |
525 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
526 | - $failed_files[] = $file; |
|
557 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
558 | + $failed_files[] = $file; |
|
559 | + } |
|
527 | 560 | } |
528 | 561 | } |
529 | - foreach ($extra_files as $file) |
|
530 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
562 | + foreach ($extra_files as $file) { |
|
563 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
564 | + } |
|
531 | 565 | } |
532 | 566 | // Windows is trickier. Let's try opening for r+... |
533 | 567 | else |
@@ -537,30 +571,35 @@ discard block |
||
537 | 571 | foreach ($writable_files as $file) |
538 | 572 | { |
539 | 573 | // Folders can't be opened for write... but the index.php in them can ;) |
540 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
541 | - $file .= '/index.php'; |
|
574 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
575 | + $file .= '/index.php'; |
|
576 | + } |
|
542 | 577 | |
543 | 578 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
544 | 579 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
545 | 580 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
546 | 581 | |
547 | 582 | // Hmm, okay, try just for write in that case... |
548 | - if (!is_resource($fp)) |
|
549 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
583 | + if (!is_resource($fp)) { |
|
584 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
585 | + } |
|
550 | 586 | |
551 | - if (!is_resource($fp)) |
|
552 | - $failed_files[] = $file; |
|
587 | + if (!is_resource($fp)) { |
|
588 | + $failed_files[] = $file; |
|
589 | + } |
|
553 | 590 | |
554 | 591 | @fclose($fp); |
555 | 592 | } |
556 | - foreach ($extra_files as $file) |
|
557 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
593 | + foreach ($extra_files as $file) { |
|
594 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
595 | + } |
|
558 | 596 | } |
559 | 597 | |
560 | 598 | $failure = count($failed_files) >= 1; |
561 | 599 | |
562 | - if (!isset($_SERVER)) |
|
563 | - return !$failure; |
|
600 | + if (!isset($_SERVER)) { |
|
601 | + return !$failure; |
|
602 | + } |
|
564 | 603 | |
565 | 604 | // Put the list into context. |
566 | 605 | $incontext['failed_files'] = $failed_files; |
@@ -608,19 +647,23 @@ discard block |
||
608 | 647 | |
609 | 648 | if (!isset($ftp) || $ftp->error !== false) |
610 | 649 | { |
611 | - if (!isset($ftp)) |
|
612 | - $ftp = new ftp_connection(null); |
|
650 | + if (!isset($ftp)) { |
|
651 | + $ftp = new ftp_connection(null); |
|
652 | + } |
|
613 | 653 | // Save the error so we can mess with listing... |
614 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
615 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
654 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
655 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
656 | + } |
|
616 | 657 | |
617 | 658 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
618 | 659 | |
619 | - if (empty($_POST['ftp_path']) && $found_path) |
|
620 | - $_POST['ftp_path'] = $detect_path; |
|
660 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
661 | + $_POST['ftp_path'] = $detect_path; |
|
662 | + } |
|
621 | 663 | |
622 | - if (!isset($_POST['ftp_username'])) |
|
623 | - $_POST['ftp_username'] = $username; |
|
664 | + if (!isset($_POST['ftp_username'])) { |
|
665 | + $_POST['ftp_username'] = $username; |
|
666 | + } |
|
624 | 667 | |
625 | 668 | // Set the username etc, into context. |
626 | 669 | $incontext['ftp'] = array( |
@@ -632,8 +675,7 @@ discard block |
||
632 | 675 | ); |
633 | 676 | |
634 | 677 | return false; |
635 | - } |
|
636 | - else |
|
678 | + } else |
|
637 | 679 | { |
638 | 680 | $_SESSION['installer_temp_ftp'] = array( |
639 | 681 | 'server' => $_POST['ftp_server'], |
@@ -647,10 +689,12 @@ discard block |
||
647 | 689 | |
648 | 690 | foreach ($failed_files as $file) |
649 | 691 | { |
650 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
651 | - $ftp->chmod($file, 0755); |
|
652 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
653 | - $ftp->chmod($file, 0777); |
|
692 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
693 | + $ftp->chmod($file, 0755); |
|
694 | + } |
|
695 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
696 | + $ftp->chmod($file, 0777); |
|
697 | + } |
|
654 | 698 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
655 | 699 | { |
656 | 700 | $failed_files_updated[] = $file; |
@@ -705,15 +749,17 @@ discard block |
||
705 | 749 | |
706 | 750 | if (!$foundOne) |
707 | 751 | { |
708 | - if (isset($db['default_host'])) |
|
709 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
752 | + if (isset($db['default_host'])) { |
|
753 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
754 | + } |
|
710 | 755 | if (isset($db['default_user'])) |
711 | 756 | { |
712 | 757 | $incontext['db']['user'] = ini_get($db['default_user']); |
713 | 758 | $incontext['db']['name'] = ini_get($db['default_user']); |
714 | 759 | } |
715 | - if (isset($db['default_password'])) |
|
716 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
760 | + if (isset($db['default_password'])) { |
|
761 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
762 | + } |
|
717 | 763 | |
718 | 764 | // For simplicity and less confusion, leave the port blank by default |
719 | 765 | $incontext['db']['port'] = ''; |
@@ -732,10 +778,10 @@ discard block |
||
732 | 778 | $incontext['db']['server'] = $_POST['db_server']; |
733 | 779 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
734 | 780 | |
735 | - if (!empty($_POST['db_port'])) |
|
736 | - $incontext['db']['port'] = $_POST['db_port']; |
|
737 | - } |
|
738 | - else |
|
781 | + if (!empty($_POST['db_port'])) { |
|
782 | + $incontext['db']['port'] = $_POST['db_port']; |
|
783 | + } |
|
784 | + } else |
|
739 | 785 | { |
740 | 786 | $incontext['db']['prefix'] = 'smf_'; |
741 | 787 | } |
@@ -771,10 +817,11 @@ discard block |
||
771 | 817 | if (!empty($_POST['db_port'])) |
772 | 818 | { |
773 | 819 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
774 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
775 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
776 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
777 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
820 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
821 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
822 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
823 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
824 | + } |
|
778 | 825 | } |
779 | 826 | |
780 | 827 | // God I hope it saved! |
@@ -787,8 +834,9 @@ discard block |
||
787 | 834 | // Make sure it works. |
788 | 835 | require(dirname(__FILE__) . '/Settings.php'); |
789 | 836 | |
790 | - if (empty($sourcedir)) |
|
791 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
837 | + if (empty($sourcedir)) { |
|
838 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
839 | + } |
|
792 | 840 | |
793 | 841 | // Better find the database file! |
794 | 842 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -798,18 +846,21 @@ discard block |
||
798 | 846 | } |
799 | 847 | |
800 | 848 | // Now include it for database functions! |
801 | - if (!defined('SMF')) |
|
802 | - define('SMF', 1); |
|
849 | + if (!defined('SMF')) { |
|
850 | + define('SMF', 1); |
|
851 | + } |
|
803 | 852 | |
804 | 853 | $modSettings['disableQueryCheck'] = true; |
805 | - if (empty($smcFunc)) |
|
806 | - $smcFunc = array(); |
|
854 | + if (empty($smcFunc)) { |
|
855 | + $smcFunc = array(); |
|
856 | + } |
|
807 | 857 | |
808 | 858 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
809 | 859 | |
810 | 860 | // What - running PHP4? The shame! |
811 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
812 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
861 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
862 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
863 | + } |
|
813 | 864 | |
814 | 865 | // Attempt a connection. |
815 | 866 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -897,12 +948,14 @@ discard block |
||
897 | 948 | $incontext['page_title'] = $txt['install_settings']; |
898 | 949 | |
899 | 950 | // Let's see if we got the database type correct. |
900 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
901 | - $db_type = $_POST['db_type']; |
|
951 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
952 | + $db_type = $_POST['db_type']; |
|
953 | + } |
|
902 | 954 | |
903 | 955 | // Else we'd better be able to get the connection. |
904 | - else |
|
905 | - load_database(); |
|
956 | + else { |
|
957 | + load_database(); |
|
958 | + } |
|
906 | 959 | |
907 | 960 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
908 | 961 | |
@@ -922,12 +975,14 @@ discard block |
||
922 | 975 | // Submitting? |
923 | 976 | if (isset($_POST['boardurl'])) |
924 | 977 | { |
925 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
926 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
927 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
928 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
929 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
930 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
978 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
979 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
980 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
981 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
982 | + } |
|
983 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
984 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
985 | + } |
|
931 | 986 | |
932 | 987 | // Save these variables. |
933 | 988 | $vars = array( |
@@ -964,10 +1019,10 @@ discard block |
||
964 | 1019 | { |
965 | 1020 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
966 | 1021 | return false; |
967 | - } |
|
968 | - else |
|
969 | - // Set the character set here. |
|
1022 | + } else { |
|
1023 | + // Set the character set here. |
|
970 | 1024 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1025 | + } |
|
971 | 1026 | } |
972 | 1027 | |
973 | 1028 | // Good, skip on. |
@@ -987,8 +1042,9 @@ discard block |
||
987 | 1042 | $incontext['continue'] = 1; |
988 | 1043 | |
989 | 1044 | // Already done? |
990 | - if (isset($_POST['pop_done'])) |
|
991 | - return true; |
|
1045 | + if (isset($_POST['pop_done'])) { |
|
1046 | + return true; |
|
1047 | + } |
|
992 | 1048 | |
993 | 1049 | // Reload settings. |
994 | 1050 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1006,8 +1062,9 @@ discard block |
||
1006 | 1062 | $modSettings = array(); |
1007 | 1063 | if ($result !== false) |
1008 | 1064 | { |
1009 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1010 | - $modSettings[$row['variable']] = $row['value']; |
|
1065 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1066 | + $modSettings[$row['variable']] = $row['value']; |
|
1067 | + } |
|
1011 | 1068 | $smcFunc['db_free_result']($result); |
1012 | 1069 | |
1013 | 1070 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1020,20 +1077,22 @@ discard block |
||
1020 | 1077 | $modSettings['disableQueryCheck'] = true; |
1021 | 1078 | |
1022 | 1079 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1023 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1024 | - $smcFunc['db_query']('', ' |
|
1080 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1081 | + $smcFunc['db_query']('', ' |
|
1025 | 1082 | SET NAMES {string:utf8}', |
1026 | 1083 | array( |
1027 | 1084 | 'db_error_skip' => true, |
1028 | 1085 | 'utf8' => 'utf8', |
1029 | 1086 | ) |
1030 | 1087 | ); |
1088 | + } |
|
1031 | 1089 | |
1032 | 1090 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1033 | - if (substr(__DIR__, -1) == '\\') |
|
1034 | - $attachdir = __DIR__ . 'attachments'; |
|
1035 | - else |
|
1036 | - $attachdir = __DIR__ . '/attachments'; |
|
1091 | + if (substr(__DIR__, -1) == '\\') { |
|
1092 | + $attachdir = __DIR__ . 'attachments'; |
|
1093 | + } else { |
|
1094 | + $attachdir = __DIR__ . '/attachments'; |
|
1095 | + } |
|
1037 | 1096 | |
1038 | 1097 | $replaces = array( |
1039 | 1098 | '{$db_prefix}' => $db_prefix, |
@@ -1050,8 +1109,9 @@ discard block |
||
1050 | 1109 | |
1051 | 1110 | foreach ($txt as $key => $value) |
1052 | 1111 | { |
1053 | - if (substr($key, 0, 8) == 'default_') |
|
1054 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1112 | + if (substr($key, 0, 8) == 'default_') { |
|
1113 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1114 | + } |
|
1055 | 1115 | } |
1056 | 1116 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1057 | 1117 | |
@@ -1066,8 +1126,9 @@ discard block |
||
1066 | 1126 | |
1067 | 1127 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1068 | 1128 | { |
1069 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1070 | - $engines[] = $row['Engine']; |
|
1129 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1130 | + $engines[] = $row['Engine']; |
|
1131 | + } |
|
1071 | 1132 | } |
1072 | 1133 | |
1073 | 1134 | // Done with this now |
@@ -1091,8 +1152,7 @@ discard block |
||
1091 | 1152 | $replaces['START TRANSACTION;'] = ''; |
1092 | 1153 | $replaces['COMMIT;'] = ''; |
1093 | 1154 | } |
1094 | - } |
|
1095 | - else |
|
1155 | + } else |
|
1096 | 1156 | { |
1097 | 1157 | $has_innodb = false; |
1098 | 1158 | } |
@@ -1114,21 +1174,24 @@ discard block |
||
1114 | 1174 | foreach ($sql_lines as $count => $line) |
1115 | 1175 | { |
1116 | 1176 | // No comments allowed! |
1117 | - if (substr(trim($line), 0, 1) != '#') |
|
1118 | - $current_statement .= "\n" . rtrim($line); |
|
1177 | + if (substr(trim($line), 0, 1) != '#') { |
|
1178 | + $current_statement .= "\n" . rtrim($line); |
|
1179 | + } |
|
1119 | 1180 | |
1120 | 1181 | // Is this the end of the query string? |
1121 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1122 | - continue; |
|
1182 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1183 | + continue; |
|
1184 | + } |
|
1123 | 1185 | |
1124 | 1186 | // Does this table already exist? If so, don't insert more data into it! |
1125 | 1187 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1126 | 1188 | { |
1127 | 1189 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1128 | - if (!empty($matches[0])) |
|
1129 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1130 | - else |
|
1131 | - $incontext['sql_results']['insert_dups']++; |
|
1190 | + if (!empty($matches[0])) { |
|
1191 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1192 | + } else { |
|
1193 | + $incontext['sql_results']['insert_dups']++; |
|
1194 | + } |
|
1132 | 1195 | |
1133 | 1196 | $current_statement = ''; |
1134 | 1197 | continue; |
@@ -1137,8 +1200,9 @@ discard block |
||
1137 | 1200 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1138 | 1201 | { |
1139 | 1202 | // Use the appropriate function based on the DB type |
1140 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1141 | - $db_errorno = $db_type . '_errno'; |
|
1203 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1204 | + $db_errorno = $db_type . '_errno'; |
|
1205 | + } |
|
1142 | 1206 | |
1143 | 1207 | // Error 1050: Table already exists! |
1144 | 1208 | // @todo Needs to be made better! |
@@ -1153,18 +1217,18 @@ discard block |
||
1153 | 1217 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1154 | 1218 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1155 | 1219 | } |
1156 | - } |
|
1157 | - else |
|
1220 | + } else |
|
1158 | 1221 | { |
1159 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1160 | - $incontext['sql_results']['tables']++; |
|
1161 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1222 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1223 | + $incontext['sql_results']['tables']++; |
|
1224 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1162 | 1225 | { |
1163 | 1226 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1164 | - if (!empty($matches[0])) |
|
1165 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1166 | - else |
|
1167 | - $incontext['sql_results']['inserts']++; |
|
1227 | + if (!empty($matches[0])) { |
|
1228 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1229 | + } else { |
|
1230 | + $incontext['sql_results']['inserts']++; |
|
1231 | + } |
|
1168 | 1232 | } |
1169 | 1233 | } |
1170 | 1234 | |
@@ -1177,15 +1241,17 @@ discard block |
||
1177 | 1241 | // Sort out the context for the SQL. |
1178 | 1242 | foreach ($incontext['sql_results'] as $key => $number) |
1179 | 1243 | { |
1180 | - if ($number == 0) |
|
1181 | - unset($incontext['sql_results'][$key]); |
|
1182 | - else |
|
1183 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1244 | + if ($number == 0) { |
|
1245 | + unset($incontext['sql_results'][$key]); |
|
1246 | + } else { |
|
1247 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1248 | + } |
|
1184 | 1249 | } |
1185 | 1250 | |
1186 | 1251 | // Make sure UTF will be used globally. |
1187 | - 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']))) |
|
1188 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1252 | + 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']))) { |
|
1253 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1254 | + } |
|
1189 | 1255 | |
1190 | 1256 | // Maybe we can auto-detect better cookie settings? |
1191 | 1257 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1196,16 +1262,20 @@ discard block |
||
1196 | 1262 | $globalCookies = false; |
1197 | 1263 | |
1198 | 1264 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1199 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1200 | - $globalCookies = true; |
|
1265 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1266 | + $globalCookies = true; |
|
1267 | + } |
|
1201 | 1268 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1202 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1203 | - $localCookies = true; |
|
1269 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1270 | + $localCookies = true; |
|
1271 | + } |
|
1204 | 1272 | |
1205 | - if ($globalCookies) |
|
1206 | - $newSettings[] = array('globalCookies', '1'); |
|
1207 | - if ($localCookies) |
|
1208 | - $newSettings[] = array('localCookies', '1'); |
|
1273 | + if ($globalCookies) { |
|
1274 | + $newSettings[] = array('globalCookies', '1'); |
|
1275 | + } |
|
1276 | + if ($localCookies) { |
|
1277 | + $newSettings[] = array('localCookies', '1'); |
|
1278 | + } |
|
1209 | 1279 | } |
1210 | 1280 | |
1211 | 1281 | // Are we allowing stat collection? |
@@ -1221,32 +1291,36 @@ discard block |
||
1221 | 1291 | fwrite($fp, $out); |
1222 | 1292 | |
1223 | 1293 | $return_data = ''; |
1224 | - while (!feof($fp)) |
|
1225 | - $return_data .= fgets($fp, 128); |
|
1294 | + while (!feof($fp)) { |
|
1295 | + $return_data .= fgets($fp, 128); |
|
1296 | + } |
|
1226 | 1297 | |
1227 | 1298 | fclose($fp); |
1228 | 1299 | |
1229 | 1300 | // Get the unique site ID. |
1230 | 1301 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1231 | 1302 | |
1232 | - if (!empty($ID[1])) |
|
1233 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1303 | + if (!empty($ID[1])) { |
|
1304 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1305 | + } |
|
1234 | 1306 | } |
1235 | 1307 | } |
1236 | 1308 | |
1237 | 1309 | // Are we enabling SSL? |
1238 | - if (!empty($_POST['force_ssl'])) |
|
1239 | - $newSettings[] = array('force_ssl', 2); |
|
1310 | + if (!empty($_POST['force_ssl'])) { |
|
1311 | + $newSettings[] = array('force_ssl', 2); |
|
1312 | + } |
|
1240 | 1313 | |
1241 | 1314 | // Setting a timezone is required. |
1242 | 1315 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1243 | 1316 | { |
1244 | 1317 | // Get PHP's default timezone, if set |
1245 | 1318 | $ini_tz = ini_get('date.timezone'); |
1246 | - if (!empty($ini_tz)) |
|
1247 | - $timezone_id = $ini_tz; |
|
1248 | - else |
|
1249 | - $timezone_id = ''; |
|
1319 | + if (!empty($ini_tz)) { |
|
1320 | + $timezone_id = $ini_tz; |
|
1321 | + } else { |
|
1322 | + $timezone_id = ''; |
|
1323 | + } |
|
1250 | 1324 | |
1251 | 1325 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1252 | 1326 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1255,8 +1329,9 @@ discard block |
||
1255 | 1329 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1256 | 1330 | } |
1257 | 1331 | |
1258 | - if (date_default_timezone_set($timezone_id)) |
|
1259 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1332 | + if (date_default_timezone_set($timezone_id)) { |
|
1333 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1334 | + } |
|
1260 | 1335 | } |
1261 | 1336 | |
1262 | 1337 | if (!empty($newSettings)) |
@@ -1287,16 +1362,18 @@ discard block |
||
1287 | 1362 | } |
1288 | 1363 | |
1289 | 1364 | // MySQL specific stuff |
1290 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1291 | - return false; |
|
1365 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1366 | + return false; |
|
1367 | + } |
|
1292 | 1368 | |
1293 | 1369 | // Find database user privileges. |
1294 | 1370 | $privs = array(); |
1295 | 1371 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1296 | 1372 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1297 | 1373 | { |
1298 | - if ($row['Privilege'] == 'Alter') |
|
1299 | - $privs[] = $row['Privilege']; |
|
1374 | + if ($row['Privilege'] == 'Alter') { |
|
1375 | + $privs[] = $row['Privilege']; |
|
1376 | + } |
|
1300 | 1377 | } |
1301 | 1378 | $smcFunc['db_free_result']($get_privs); |
1302 | 1379 | |
@@ -1326,8 +1403,9 @@ discard block |
||
1326 | 1403 | $incontext['continue'] = 1; |
1327 | 1404 | |
1328 | 1405 | // Skipping? |
1329 | - if (!empty($_POST['skip'])) |
|
1330 | - return true; |
|
1406 | + if (!empty($_POST['skip'])) { |
|
1407 | + return true; |
|
1408 | + } |
|
1331 | 1409 | |
1332 | 1410 | // Need this to check whether we need the database password. |
1333 | 1411 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1340,18 +1418,22 @@ discard block |
||
1340 | 1418 | // We need this to properly hash the password for Admin |
1341 | 1419 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1342 | 1420 | global $sourcedir; |
1343 | - if (function_exists('mb_strtolower')) |
|
1344 | - return mb_strtolower($string, 'UTF-8'); |
|
1421 | + if (function_exists('mb_strtolower')) { |
|
1422 | + return mb_strtolower($string, 'UTF-8'); |
|
1423 | + } |
|
1345 | 1424 | require_once($sourcedir . '/Subs-Charset.php'); |
1346 | 1425 | return utf8_strtolower($string); |
1347 | 1426 | }; |
1348 | 1427 | |
1349 | - if (!isset($_POST['username'])) |
|
1350 | - $_POST['username'] = ''; |
|
1351 | - if (!isset($_POST['email'])) |
|
1352 | - $_POST['email'] = ''; |
|
1353 | - if (!isset($_POST['server_email'])) |
|
1354 | - $_POST['server_email'] = ''; |
|
1428 | + if (!isset($_POST['username'])) { |
|
1429 | + $_POST['username'] = ''; |
|
1430 | + } |
|
1431 | + if (!isset($_POST['email'])) { |
|
1432 | + $_POST['email'] = ''; |
|
1433 | + } |
|
1434 | + if (!isset($_POST['server_email'])) { |
|
1435 | + $_POST['server_email'] = ''; |
|
1436 | + } |
|
1355 | 1437 | |
1356 | 1438 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1357 | 1439 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1370,8 +1452,9 @@ discard block |
||
1370 | 1452 | 'admin_group' => 1, |
1371 | 1453 | ) |
1372 | 1454 | ); |
1373 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1374 | - $incontext['skip'] = 1; |
|
1455 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1456 | + $incontext['skip'] = 1; |
|
1457 | + } |
|
1375 | 1458 | $smcFunc['db_free_result']($request); |
1376 | 1459 | |
1377 | 1460 | // Trying to create an account? |
@@ -1402,8 +1485,9 @@ discard block |
||
1402 | 1485 | } |
1403 | 1486 | |
1404 | 1487 | // Update the webmaster's email? |
1405 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1406 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1488 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1489 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1490 | + } |
|
1407 | 1491 | |
1408 | 1492 | // Work out whether we're going to have dodgy characters and remove them. |
1409 | 1493 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1426,32 +1510,27 @@ discard block |
||
1426 | 1510 | $smcFunc['db_free_result']($result); |
1427 | 1511 | |
1428 | 1512 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1429 | - } |
|
1430 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1513 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1431 | 1514 | { |
1432 | 1515 | // Try the previous step again. |
1433 | 1516 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1434 | 1517 | return false; |
1435 | - } |
|
1436 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1518 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1437 | 1519 | { |
1438 | 1520 | // Try the previous step again. |
1439 | 1521 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1440 | 1522 | return false; |
1441 | - } |
|
1442 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1523 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1443 | 1524 | { |
1444 | 1525 | // One step back, this time fill out a proper admin email address. |
1445 | 1526 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1446 | 1527 | return false; |
1447 | - } |
|
1448 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1528 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1449 | 1529 | { |
1450 | 1530 | // One step back, this time fill out a proper admin email address. |
1451 | 1531 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1452 | 1532 | return false; |
1453 | - } |
|
1454 | - elseif ($_POST['username'] != '') |
|
1533 | + } elseif ($_POST['username'] != '') |
|
1455 | 1534 | { |
1456 | 1535 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1457 | 1536 | |
@@ -1517,17 +1596,19 @@ discard block |
||
1517 | 1596 | require_once($sourcedir . '/Subs-Auth.php'); |
1518 | 1597 | |
1519 | 1598 | // Bring a warning over. |
1520 | - if (!empty($incontext['account_existed'])) |
|
1521 | - $incontext['warning'] = $incontext['account_existed']; |
|
1599 | + if (!empty($incontext['account_existed'])) { |
|
1600 | + $incontext['warning'] = $incontext['account_existed']; |
|
1601 | + } |
|
1522 | 1602 | |
1523 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1524 | - $smcFunc['db_query']('', ' |
|
1603 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1604 | + $smcFunc['db_query']('', ' |
|
1525 | 1605 | SET NAMES {string:db_character_set}', |
1526 | 1606 | array( |
1527 | 1607 | 'db_character_set' => $db_character_set, |
1528 | 1608 | 'db_error_skip' => true, |
1529 | 1609 | ) |
1530 | 1610 | ); |
1611 | + } |
|
1531 | 1612 | |
1532 | 1613 | // As track stats is by default enabled let's add some activity. |
1533 | 1614 | $smcFunc['db_insert']('ignore', |
@@ -1548,14 +1629,16 @@ discard block |
||
1548 | 1629 | // Only proceed if we can load the data. |
1549 | 1630 | if ($request) |
1550 | 1631 | { |
1551 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1552 | - $modSettings[$row[0]] = $row[1]; |
|
1632 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1633 | + $modSettings[$row[0]] = $row[1]; |
|
1634 | + } |
|
1553 | 1635 | $smcFunc['db_free_result']($request); |
1554 | 1636 | } |
1555 | 1637 | |
1556 | 1638 | // Automatically log them in ;) |
1557 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1558 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1639 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1640 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1641 | + } |
|
1559 | 1642 | |
1560 | 1643 | $result = $smcFunc['db_query']('', ' |
1561 | 1644 | SELECT value |
@@ -1566,13 +1649,14 @@ discard block |
||
1566 | 1649 | 'db_error_skip' => true, |
1567 | 1650 | ) |
1568 | 1651 | ); |
1569 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1570 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1652 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1653 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1654 | + } |
|
1571 | 1655 | $smcFunc['db_free_result']($result); |
1572 | 1656 | |
1573 | - if (empty($db_sessions)) |
|
1574 | - $_SESSION['admin_time'] = time(); |
|
1575 | - else |
|
1657 | + if (empty($db_sessions)) { |
|
1658 | + $_SESSION['admin_time'] = time(); |
|
1659 | + } else |
|
1576 | 1660 | { |
1577 | 1661 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1578 | 1662 | |
@@ -1596,8 +1680,9 @@ discard block |
||
1596 | 1680 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1597 | 1681 | function($string){ |
1598 | 1682 | global $sourcedir; |
1599 | - if (function_exists('mb_strtolower')) |
|
1600 | - return mb_strtolower($string, 'UTF-8'); |
|
1683 | + if (function_exists('mb_strtolower')) { |
|
1684 | + return mb_strtolower($string, 'UTF-8'); |
|
1685 | + } |
|
1601 | 1686 | require_once($sourcedir . '/Subs-Charset.php'); |
1602 | 1687 | return utf8_strtolower($string); |
1603 | 1688 | }; |
@@ -1613,8 +1698,9 @@ discard block |
||
1613 | 1698 | ) |
1614 | 1699 | ); |
1615 | 1700 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1616 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1617 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1701 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1702 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1703 | + } |
|
1618 | 1704 | $smcFunc['db_free_result']($request); |
1619 | 1705 | |
1620 | 1706 | // Now is the perfect time to fetch the SM files. |
@@ -1633,8 +1719,9 @@ discard block |
||
1633 | 1719 | |
1634 | 1720 | // Check if we need some stupid MySQL fix. |
1635 | 1721 | $server_version = $smcFunc['db_server_info'](); |
1636 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1637 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1722 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1723 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1724 | + } |
|
1638 | 1725 | |
1639 | 1726 | // Some final context for the template. |
1640 | 1727 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1654,8 +1741,9 @@ discard block |
||
1654 | 1741 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1655 | 1742 | |
1656 | 1743 | // @todo Do we just want to read the file in clean, and split it this way always? |
1657 | - if (count($settingsArray) == 1) |
|
1658 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1744 | + if (count($settingsArray) == 1) { |
|
1745 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1746 | + } |
|
1659 | 1747 | |
1660 | 1748 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1661 | 1749 | { |
@@ -1670,19 +1758,22 @@ discard block |
||
1670 | 1758 | continue; |
1671 | 1759 | } |
1672 | 1760 | |
1673 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1674 | - $settingsArray[$i] = ''; |
|
1761 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1762 | + $settingsArray[$i] = ''; |
|
1763 | + } |
|
1675 | 1764 | |
1676 | 1765 | // Don't trim or bother with it if it's not a variable. |
1677 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1678 | - continue; |
|
1766 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1767 | + continue; |
|
1768 | + } |
|
1679 | 1769 | |
1680 | 1770 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1681 | 1771 | |
1682 | - foreach ($vars as $var => $val) |
|
1683 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1772 | + foreach ($vars as $var => $val) { |
|
1773 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1684 | 1774 | { |
1685 | 1775 | $comment = strstr($settingsArray[$i], '#'); |
1776 | + } |
|
1686 | 1777 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1687 | 1778 | unset($vars[$var]); |
1688 | 1779 | } |
@@ -1692,36 +1783,41 @@ discard block |
||
1692 | 1783 | if (!empty($vars)) |
1693 | 1784 | { |
1694 | 1785 | $settingsArray[$i++] = ''; |
1695 | - foreach ($vars as $var => $val) |
|
1696 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1786 | + foreach ($vars as $var => $val) { |
|
1787 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1788 | + } |
|
1697 | 1789 | } |
1698 | 1790 | |
1699 | 1791 | // Blank out the file - done to fix a oddity with some servers. |
1700 | 1792 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1701 | - if (!$fp) |
|
1702 | - return false; |
|
1793 | + if (!$fp) { |
|
1794 | + return false; |
|
1795 | + } |
|
1703 | 1796 | fclose($fp); |
1704 | 1797 | |
1705 | 1798 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1706 | 1799 | |
1707 | 1800 | // Gotta have one of these ;) |
1708 | - if (trim($settingsArray[0]) != '<?php') |
|
1709 | - fwrite($fp, "<?php\n"); |
|
1801 | + if (trim($settingsArray[0]) != '<?php') { |
|
1802 | + fwrite($fp, "<?php\n"); |
|
1803 | + } |
|
1710 | 1804 | |
1711 | 1805 | $lines = count($settingsArray); |
1712 | 1806 | for ($i = 0; $i < $lines - 1; $i++) |
1713 | 1807 | { |
1714 | 1808 | // Don't just write a bunch of blank lines. |
1715 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1716 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1809 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1810 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1811 | + } |
|
1717 | 1812 | } |
1718 | 1813 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1719 | 1814 | fclose($fp); |
1720 | 1815 | |
1721 | 1816 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1722 | 1817 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1723 | - if (function_exists('opcache_invalidate')) |
|
1724 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1818 | + if (function_exists('opcache_invalidate')) { |
|
1819 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1820 | + } |
|
1725 | 1821 | |
1726 | 1822 | return true; |
1727 | 1823 | } |
@@ -1746,9 +1842,9 @@ discard block |
||
1746 | 1842 | SecFilterScanPOST Off |
1747 | 1843 | </IfModule>'; |
1748 | 1844 | |
1749 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1750 | - return true; |
|
1751 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1845 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1846 | + return true; |
|
1847 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1752 | 1848 | { |
1753 | 1849 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1754 | 1850 | |
@@ -1760,29 +1856,28 @@ discard block |
||
1760 | 1856 | fwrite($ht_handle, $htaccess_addition); |
1761 | 1857 | fclose($ht_handle); |
1762 | 1858 | return true; |
1859 | + } else { |
|
1860 | + return false; |
|
1763 | 1861 | } |
1764 | - else |
|
1765 | - return false; |
|
1862 | + } else { |
|
1863 | + return true; |
|
1766 | 1864 | } |
1767 | - else |
|
1768 | - return true; |
|
1769 | - } |
|
1770 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1771 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1772 | - elseif (is_writable(dirname(__FILE__))) |
|
1865 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1866 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1867 | + } elseif (is_writable(dirname(__FILE__))) |
|
1773 | 1868 | { |
1774 | 1869 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1775 | 1870 | { |
1776 | 1871 | fwrite($ht_handle, $htaccess_addition); |
1777 | 1872 | fclose($ht_handle); |
1778 | 1873 | return true; |
1874 | + } else { |
|
1875 | + return false; |
|
1779 | 1876 | } |
1780 | - else |
|
1877 | + } else { |
|
1781 | 1878 | return false; |
1782 | 1879 | } |
1783 | - else |
|
1784 | - return false; |
|
1785 | -} |
|
1880 | + } |
|
1786 | 1881 | |
1787 | 1882 | function template_install_above() |
1788 | 1883 | { |
@@ -1820,9 +1915,10 @@ discard block |
||
1820 | 1915 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1821 | 1916 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1822 | 1917 | |
1823 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1824 | - echo ' |
|
1918 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1919 | + echo ' |
|
1825 | 1920 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1921 | + } |
|
1826 | 1922 | |
1827 | 1923 | echo ' |
1828 | 1924 | </select> |
@@ -1842,9 +1938,10 @@ discard block |
||
1842 | 1938 | <h2>', $txt['upgrade_progress'], '</h2> |
1843 | 1939 | <ul>'; |
1844 | 1940 | |
1845 | - foreach ($incontext['steps'] as $num => $step) |
|
1846 | - echo ' |
|
1941 | + foreach ($incontext['steps'] as $num => $step) { |
|
1942 | + echo ' |
|
1847 | 1943 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
1944 | + } |
|
1848 | 1945 | |
1849 | 1946 | echo ' |
1850 | 1947 | </ul> |
@@ -1869,20 +1966,23 @@ discard block |
||
1869 | 1966 | echo ' |
1870 | 1967 | <div>'; |
1871 | 1968 | |
1872 | - if (!empty($incontext['continue'])) |
|
1873 | - echo ' |
|
1969 | + if (!empty($incontext['continue'])) { |
|
1970 | + echo ' |
|
1874 | 1971 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1875 | - if (!empty($incontext['skip'])) |
|
1876 | - echo ' |
|
1972 | + } |
|
1973 | + if (!empty($incontext['skip'])) { |
|
1974 | + echo ' |
|
1877 | 1975 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1976 | + } |
|
1878 | 1977 | echo ' |
1879 | 1978 | </div>'; |
1880 | 1979 | } |
1881 | 1980 | |
1882 | 1981 | // Show the closing form tag and other data only if not in the last step |
1883 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1884 | - echo ' |
|
1982 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
1983 | + echo ' |
|
1885 | 1984 | </form>'; |
1985 | + } |
|
1886 | 1986 | |
1887 | 1987 | echo ' |
1888 | 1988 | </div> |
@@ -1917,13 +2017,15 @@ discard block |
||
1917 | 2017 | </div>'; |
1918 | 2018 | |
1919 | 2019 | // Show the warnings, or not. |
1920 | - if (template_warning_divs()) |
|
1921 | - echo ' |
|
2020 | + if (template_warning_divs()) { |
|
2021 | + echo ' |
|
1922 | 2022 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2023 | + } |
|
1923 | 2024 | |
1924 | 2025 | // Say we want the continue button! |
1925 | - if (empty($incontext['error'])) |
|
1926 | - $incontext['continue'] = 1; |
|
2026 | + if (empty($incontext['error'])) { |
|
2027 | + $incontext['continue'] = 1; |
|
2028 | + } |
|
1927 | 2029 | |
1928 | 2030 | // For the latest version stuff. |
1929 | 2031 | echo ' |
@@ -1957,8 +2059,8 @@ discard block |
||
1957 | 2059 | global $txt, $incontext; |
1958 | 2060 | |
1959 | 2061 | // Errors are very serious.. |
1960 | - if (!empty($incontext['error'])) |
|
1961 | - echo ' |
|
2062 | + if (!empty($incontext['error'])) { |
|
2063 | + echo ' |
|
1962 | 2064 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1963 | 2065 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1964 | 2066 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1966,9 +2068,10 @@ discard block |
||
1966 | 2068 | ', $incontext['error'], ' |
1967 | 2069 | </div> |
1968 | 2070 | </div>'; |
2071 | + } |
|
1969 | 2072 | // A warning message? |
1970 | - elseif (!empty($incontext['warning'])) |
|
1971 | - echo ' |
|
2073 | + elseif (!empty($incontext['warning'])) { |
|
2074 | + echo ' |
|
1972 | 2075 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1973 | 2076 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1974 | 2077 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1976,6 +2079,7 @@ discard block |
||
1976 | 2079 | ', $incontext['warning'], ' |
1977 | 2080 | </div> |
1978 | 2081 | </div>'; |
2082 | + } |
|
1979 | 2083 | |
1980 | 2084 | return empty($incontext['error']) && empty($incontext['warning']); |
1981 | 2085 | } |
@@ -1991,27 +2095,30 @@ discard block |
||
1991 | 2095 | <li>', $incontext['failed_files']), '</li> |
1992 | 2096 | </ul>'; |
1993 | 2097 | |
1994 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
1995 | - echo ' |
|
2098 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2099 | + echo ' |
|
1996 | 2100 | <hr> |
1997 | 2101 | <p>', $txt['chmod_linux_info'], '</p> |
1998 | 2102 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2103 | + } |
|
1999 | 2104 | |
2000 | 2105 | // This is serious! |
2001 | - if (!template_warning_divs()) |
|
2002 | - return; |
|
2106 | + if (!template_warning_divs()) { |
|
2107 | + return; |
|
2108 | + } |
|
2003 | 2109 | |
2004 | 2110 | echo ' |
2005 | 2111 | <hr> |
2006 | 2112 | <p>', $txt['ftp_setup_info'], '</p>'; |
2007 | 2113 | |
2008 | - if (!empty($incontext['ftp_errors'])) |
|
2009 | - echo ' |
|
2114 | + if (!empty($incontext['ftp_errors'])) { |
|
2115 | + echo ' |
|
2010 | 2116 | <div class="error_message"> |
2011 | 2117 | ', $txt['error_ftp_no_connect'], '<br><br> |
2012 | 2118 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2013 | 2119 | </div> |
2014 | 2120 | <br>'; |
2121 | + } |
|
2015 | 2122 | |
2016 | 2123 | echo ' |
2017 | 2124 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2071,17 +2178,17 @@ discard block |
||
2071 | 2178 | <td> |
2072 | 2179 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2073 | 2180 | |
2074 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2075 | - echo ' |
|
2181 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2182 | + echo ' |
|
2076 | 2183 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2184 | + } |
|
2077 | 2185 | |
2078 | 2186 | echo ' |
2079 | 2187 | </select> |
2080 | 2188 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2081 | 2189 | </td> |
2082 | 2190 | </tr>'; |
2083 | - } |
|
2084 | - else |
|
2191 | + } else |
|
2085 | 2192 | { |
2086 | 2193 | echo ' |
2087 | 2194 | <tr style="display: none;"> |
@@ -2273,9 +2380,10 @@ discard block |
||
2273 | 2380 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2274 | 2381 | <ul>'; |
2275 | 2382 | |
2276 | - foreach ($incontext['failures'] as $line => $fail) |
|
2277 | - echo ' |
|
2383 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2384 | + echo ' |
|
2278 | 2385 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2386 | + } |
|
2279 | 2387 | |
2280 | 2388 | echo ' |
2281 | 2389 | </ul>'; |
@@ -2336,15 +2444,16 @@ discard block |
||
2336 | 2444 | </tr> |
2337 | 2445 | </table>'; |
2338 | 2446 | |
2339 | - if ($incontext['require_db_confirm']) |
|
2340 | - echo ' |
|
2447 | + if ($incontext['require_db_confirm']) { |
|
2448 | + echo ' |
|
2341 | 2449 | <h2>', $txt['user_settings_database'], '</h2> |
2342 | 2450 | <p>', $txt['user_settings_database_info'], '</p> |
2343 | 2451 | |
2344 | 2452 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2345 | 2453 | <input type="password" name="password3" size="30" class="input_password" /> |
2346 | 2454 | </div>'; |
2347 | -} |
|
2455 | + } |
|
2456 | + } |
|
2348 | 2457 | |
2349 | 2458 | // Tell them it's done, and to delete. |
2350 | 2459 | function template_delete_install() |
@@ -2357,14 +2466,15 @@ discard block |
||
2357 | 2466 | template_warning_divs(); |
2358 | 2467 | |
2359 | 2468 | // Install directory still writable? |
2360 | - if ($incontext['dir_still_writable']) |
|
2361 | - echo ' |
|
2469 | + if ($incontext['dir_still_writable']) { |
|
2470 | + echo ' |
|
2362 | 2471 | <em>', $txt['still_writable'], '</em><br> |
2363 | 2472 | <br>'; |
2473 | + } |
|
2364 | 2474 | |
2365 | 2475 | // Don't show the box if it's like 99% sure it won't work :P. |
2366 | - if ($incontext['probably_delete_install']) |
|
2367 | - echo ' |
|
2476 | + if ($incontext['probably_delete_install']) { |
|
2477 | + echo ' |
|
2368 | 2478 | <div style="margin: 1ex; font-weight: bold;"> |
2369 | 2479 | <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> |
2370 | 2480 | </div> |
@@ -2380,6 +2490,7 @@ discard block |
||
2380 | 2490 | } |
2381 | 2491 | </script> |
2382 | 2492 | <br>'; |
2493 | + } |
|
2383 | 2494 | |
2384 | 2495 | echo ' |
2385 | 2496 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |