@@ -18,7 +18,7 @@ |
||
| 18 | 18 | class ApprovePost_Notify_Background extends SMF_BackgroundTask |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | - * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
| 21 | + * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
| 22 | 22 | * @return bool Always returns true |
| 23 | 23 | */ |
| 24 | 24 | public function execute() |
@@ -54,8 +54,9 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | $smcFunc['db_free_result']($request); |
| 56 | 56 | |
| 57 | - if (empty($members)) |
|
| 58 | - return true; |
|
| 57 | + if (empty($members)) { |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | require_once($sourcedir . '/Subs-Notify.php'); |
| 61 | 62 | $members = array_unique($members); |
@@ -103,14 +104,15 @@ discard block |
||
| 103 | 104 | } |
| 104 | 105 | |
| 105 | 106 | // Insert the alerts if any |
| 106 | - if (!empty($alert_rows)) |
|
| 107 | - $smcFunc['db_insert']('', |
|
| 107 | + if (!empty($alert_rows)) { |
|
| 108 | + $smcFunc['db_insert']('', |
|
| 108 | 109 | '{db_prefix}user_alerts', |
| 109 | 110 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 110 | 111 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 111 | 112 | $alert_rows, |
| 112 | 113 | array() |
| 113 | 114 | ); |
| 115 | + } |
|
| 114 | 116 | |
| 115 | 117 | return true; |
| 116 | 118 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Register_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true. |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -43,9 +43,10 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | foreach ($prefs as $member => $pref_option) |
| 45 | 45 | { |
| 46 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 47 | - if ($pref_option['member_register'] & $bitvalue) |
|
| 46 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 47 | + if ($pref_option['member_register'] & $bitvalue) |
|
| 48 | 48 | $notifies[$type][] = $member; |
| 49 | + } |
|
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | // Firstly, anyone who wants alerts. |
@@ -101,8 +102,9 @@ discard block |
||
| 101 | 102 | ); |
| 102 | 103 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 103 | 104 | { |
| 104 | - if (empty($row['lngfile'])) |
|
| 105 | - $row['lngfile'] = $language; |
|
| 105 | + if (empty($row['lngfile'])) { |
|
| 106 | + $row['lngfile'] = $language; |
|
| 107 | + } |
|
| 106 | 108 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 107 | 109 | } |
| 108 | 110 | $smcFunc['db_free_result']($request); |
@@ -126,8 +128,9 @@ discard block |
||
| 126 | 128 | $emaildata = loadEmailTemplate($emailtype, $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 127 | 129 | |
| 128 | 130 | // And do the actual sending... |
| 129 | - foreach ($recipients as $id_member => $email_address) |
|
| 130 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0); |
|
| 131 | + foreach ($recipients as $id_member => $email_address) { |
|
| 132 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0); |
|
| 133 | + } |
|
| 131 | 134 | } |
| 132 | 135 | } |
| 133 | 136 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class MsgReport_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true. |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | 'current_board' => $this->_details['board_id'], |
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 44 | - $members[] = $row['id_member']; |
|
| 43 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 44 | + $members[] = $row['id_member']; |
|
| 45 | + } |
|
| 45 | 46 | $smcFunc['db_free_result']($request); |
| 46 | 47 | |
| 47 | 48 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -58,8 +59,9 @@ discard block |
||
| 58 | 59 | ) |
| 59 | 60 | ); |
| 60 | 61 | |
| 61 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 62 | - $members[] = $row['id_member']; |
|
| 62 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 63 | + $members[] = $row['id_member']; |
|
| 64 | + } |
|
| 63 | 65 | $smcFunc['db_free_result']($request); |
| 64 | 66 | |
| 65 | 67 | // And now weed out the duplicates. |
@@ -81,9 +83,10 @@ discard block |
||
| 81 | 83 | |
| 82 | 84 | foreach ($prefs as $member => $pref_option) |
| 83 | 85 | { |
| 84 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 85 | - if ($pref_option['msg_report'] & $bitvalue) |
|
| 86 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 87 | + if ($pref_option['msg_report'] & $bitvalue) |
|
| 86 | 88 | $notifies[$type][] = $member; |
| 89 | + } |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | // Firstly, anyone who wants alerts. |
@@ -143,8 +146,9 @@ discard block |
||
| 143 | 146 | ); |
| 144 | 147 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 145 | 148 | { |
| 146 | - if (empty($row['lngfile'])) |
|
| 147 | - $row['lngfile'] = $language; |
|
| 149 | + if (empty($row['lngfile'])) { |
|
| 150 | + $row['lngfile'] = $language; |
|
| 151 | + } |
|
| 148 | 152 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 149 | 153 | } |
| 150 | 154 | $smcFunc['db_free_result']($request); |
@@ -177,8 +181,9 @@ discard block |
||
| 177 | 181 | $emaildata = loadEmailTemplate('report_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 178 | 182 | |
| 179 | 183 | // And do the actual sending... |
| 180 | - foreach ($recipients as $id_member => $email_address) |
|
| 181 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'report' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
| 184 | + foreach ($recipients as $id_member => $email_address) { |
|
| 185 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'report' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
| 186 | + } |
|
| 182 | 187 | } |
| 183 | 188 | } |
| 184 | 189 | |
@@ -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 | |
@@ -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 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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'); |
@@ -88,22 +91,25 @@ discard block |
||
| 88 | 91 | $context['page_title'] = $txt['calendar']; |
| 89 | 92 | |
| 90 | 93 | // Ensure a default view is defined |
| 91 | - if (empty($modSettings['calendar_default_view'])) |
|
| 92 | - $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 94 | + if (empty($modSettings['calendar_default_view'])) { |
|
| 95 | + $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | // What view do we want? |
| 95 | - if (isset($_GET['viewweek'])) |
|
| 96 | - $context['calendar_view'] = 'viewweek'; |
|
| 97 | - elseif (isset($_GET['viewmonth'])) |
|
| 98 | - $context['calendar_view'] = 'viewmonth'; |
|
| 99 | - elseif (isset($_GET['viewlist'])) |
|
| 100 | - $context['calendar_view'] = 'viewlist'; |
|
| 101 | - else |
|
| 102 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 99 | + if (isset($_GET['viewweek'])) { |
|
| 100 | + $context['calendar_view'] = 'viewweek'; |
|
| 101 | + } elseif (isset($_GET['viewmonth'])) { |
|
| 102 | + $context['calendar_view'] = 'viewmonth'; |
|
| 103 | + } elseif (isset($_GET['viewlist'])) { |
|
| 104 | + $context['calendar_view'] = 'viewlist'; |
|
| 105 | + } else { |
|
| 106 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // Don't let search engines index the non-default calendar pages |
| 105 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
| 106 | - $context['robot_no_index'] = true; |
|
| 110 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
| 111 | + $context['robot_no_index'] = true; |
|
| 112 | + } |
|
| 107 | 113 | |
| 108 | 114 | // Get the current day of month... |
| 109 | 115 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -164,16 +170,19 @@ discard block |
||
| 164 | 170 | ); |
| 165 | 171 | |
| 166 | 172 | // Make sure the year and month are in valid ranges. |
| 167 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
| 168 | - fatal_lang_error('invalid_month', false); |
|
| 169 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
| 170 | - fatal_lang_error('invalid_year', false); |
|
| 173 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
| 174 | + fatal_lang_error('invalid_month', false); |
|
| 175 | + } |
|
| 176 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
| 177 | + fatal_lang_error('invalid_year', false); |
|
| 178 | + } |
|
| 171 | 179 | // If we have a day clean that too. |
| 172 | 180 | if ($context['calendar_view'] != 'viewmonth') |
| 173 | 181 | { |
| 174 | 182 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
| 175 | - if (!$isValid) |
|
| 176 | - fatal_lang_error('invalid_day', false); |
|
| 183 | + if (!$isValid) { |
|
| 184 | + fatal_lang_error('invalid_day', false); |
|
| 185 | + } |
|
| 177 | 186 | } |
| 178 | 187 | |
| 179 | 188 | // Load all the context information needed to show the calendar grid. |
@@ -195,23 +204,26 @@ discard block |
||
| 195 | 204 | ); |
| 196 | 205 | |
| 197 | 206 | // Load up the main view. |
| 198 | - if ($context['calendar_view'] == 'viewlist') |
|
| 199 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 200 | - elseif ($context['calendar_view'] == 'viewweek') |
|
| 201 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 202 | - else |
|
| 203 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 207 | + if ($context['calendar_view'] == 'viewlist') { |
|
| 208 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 209 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
| 210 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 211 | + } else { |
|
| 212 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 213 | + } |
|
| 204 | 214 | |
| 205 | 215 | // Load up the previous and next months. |
| 206 | 216 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
| 207 | 217 | |
| 208 | 218 | // Only show previous month if it isn't pre-January of the min-year |
| 209 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
| 210 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 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); |
|
| 221 | + } |
|
| 211 | 222 | |
| 212 | 223 | // Only show next month if it isn't post-December of the max-year |
| 213 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
| 214 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 224 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
| 225 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 226 | + } |
|
| 215 | 227 | |
| 216 | 228 | // Basic template stuff. |
| 217 | 229 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -231,8 +243,9 @@ discard block |
||
| 231 | 243 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
| 232 | 244 | |
| 233 | 245 | // Set the page title to mention the month or week, too |
| 234 | - if ($context['calendar_view'] != 'viewlist') |
|
| 235 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 246 | + if ($context['calendar_view'] != 'viewlist') { |
|
| 247 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 248 | + } |
|
| 236 | 249 | |
| 237 | 250 | // Load up the linktree! |
| 238 | 251 | $context['linktree'][] = array( |
@@ -245,17 +258,19 @@ discard block |
||
| 245 | 258 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
| 246 | 259 | ); |
| 247 | 260 | // If applicable, add the current week to the linktree. |
| 248 | - if ($context['calendar_view'] == 'viewweek') |
|
| 249 | - $context['linktree'][] = array( |
|
| 261 | + if ($context['calendar_view'] == 'viewweek') { |
|
| 262 | + $context['linktree'][] = array( |
|
| 250 | 263 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 251 | 264 | 'name' => $context['calendar_grid_main']['week_title'], |
| 252 | 265 | ); |
| 266 | + } |
|
| 253 | 267 | |
| 254 | 268 | // Build the calendar button array. |
| 255 | 269 | $context['calendar_buttons'] = array(); |
| 256 | 270 | |
| 257 | - if ($context['can_post']) |
|
| 258 | - $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']); |
|
| 271 | + if ($context['can_post']) { |
|
| 272 | + $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']); |
|
| 273 | + } |
|
| 259 | 274 | |
| 260 | 275 | // Allow mods to add additional buttons here |
| 261 | 276 | call_integration_hook('integrate_calendar_buttons'); |
@@ -284,14 +299,16 @@ discard block |
||
| 284 | 299 | require_once($sourcedir . '/Subs.php'); |
| 285 | 300 | |
| 286 | 301 | // Cast this for safety... |
| 287 | - if (isset($_REQUEST['eventid'])) |
|
| 288 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 302 | + if (isset($_REQUEST['eventid'])) { |
|
| 303 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 304 | + } |
|
| 289 | 305 | |
| 290 | 306 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 291 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 292 | - $time_string = '%k:%M'; |
|
| 293 | - else |
|
| 294 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 307 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 308 | + $time_string = '%k:%M'; |
|
| 309 | + } else { |
|
| 310 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 311 | + } |
|
| 295 | 312 | |
| 296 | 313 | $js_time_string = str_replace( |
| 297 | 314 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -305,12 +322,14 @@ discard block |
||
| 305 | 322 | checkSession(); |
| 306 | 323 | |
| 307 | 324 | // Validate the post... |
| 308 | - if (!isset($_POST['link_to_board'])) |
|
| 309 | - validateEventPost(); |
|
| 325 | + if (!isset($_POST['link_to_board'])) { |
|
| 326 | + validateEventPost(); |
|
| 327 | + } |
|
| 310 | 328 | |
| 311 | 329 | // If you're not allowed to edit any events, you have to be the poster. |
| 312 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
| 313 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 330 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
| 331 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 332 | + } |
|
| 314 | 333 | |
| 315 | 334 | // New - and directing? |
| 316 | 335 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -333,8 +352,9 @@ discard block |
||
| 333 | 352 | } |
| 334 | 353 | |
| 335 | 354 | // Deleting... |
| 336 | - elseif (isset($_REQUEST['deleteevent'])) |
|
| 337 | - removeEvent($_REQUEST['eventid']); |
|
| 355 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
| 356 | + removeEvent($_REQUEST['eventid']); |
|
| 357 | + } |
|
| 338 | 358 | |
| 339 | 359 | // ... or just update it? |
| 340 | 360 | else |
@@ -357,15 +377,13 @@ discard block |
||
| 357 | 377 | $year = $d['year']; |
| 358 | 378 | $month = $d['month']; |
| 359 | 379 | $day = $d['day']; |
| 360 | - } |
|
| 361 | - elseif (isset($_POST['start_datetime'])) |
|
| 380 | + } elseif (isset($_POST['start_datetime'])) |
|
| 362 | 381 | { |
| 363 | 382 | $d = date_parse($_POST['start_datetime']); |
| 364 | 383 | $year = $d['year']; |
| 365 | 384 | $month = $d['month']; |
| 366 | 385 | $day = $d['day']; |
| 367 | - } |
|
| 368 | - else |
|
| 386 | + } else |
|
| 369 | 387 | { |
| 370 | 388 | $today = getdate(); |
| 371 | 389 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -399,13 +417,13 @@ discard block |
||
| 399 | 417 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
| 400 | 418 | |
| 401 | 419 | $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'])); |
| 402 | - } |
|
| 403 | - else |
|
| 420 | + } else |
|
| 404 | 421 | { |
| 405 | 422 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
| 406 | 423 | |
| 407 | - if ($context['event'] === false) |
|
| 408 | - fatal_lang_error('no_access', false); |
|
| 424 | + if ($context['event'] === false) { |
|
| 425 | + fatal_lang_error('no_access', false); |
|
| 426 | + } |
|
| 409 | 427 | |
| 410 | 428 | // If it has a board, then they should be editing it within the topic. |
| 411 | 429 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -416,10 +434,11 @@ discard block |
||
| 416 | 434 | } |
| 417 | 435 | |
| 418 | 436 | // Make sure the user is allowed to edit this event. |
| 419 | - if ($context['event']['member'] != $user_info['id']) |
|
| 420 | - isAllowedTo('calendar_edit_any'); |
|
| 421 | - elseif (!allowedTo('calendar_edit_any')) |
|
| 422 | - isAllowedTo('calendar_edit_own'); |
|
| 437 | + if ($context['event']['member'] != $user_info['id']) { |
|
| 438 | + isAllowedTo('calendar_edit_any'); |
|
| 439 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
| 440 | + isAllowedTo('calendar_edit_own'); |
|
| 441 | + } |
|
| 423 | 442 | } |
| 424 | 443 | |
| 425 | 444 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -453,8 +472,7 @@ discard block |
||
| 453 | 472 | { |
| 454 | 473 | // You can post new events but can't link them to anything... |
| 455 | 474 | $context['event']['categories'] = array(); |
| 456 | - } |
|
| 457 | - else |
|
| 475 | + } else |
|
| 458 | 476 | { |
| 459 | 477 | // Load the list of boards and categories in the context. |
| 460 | 478 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -541,12 +559,14 @@ discard block |
||
| 541 | 559 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
| 542 | 560 | |
| 543 | 561 | // You can't export if the calendar export feature is off. |
| 544 | - if (empty($modSettings['cal_export'])) |
|
| 545 | - fatal_lang_error('calendar_export_off', false); |
|
| 562 | + if (empty($modSettings['cal_export'])) { |
|
| 563 | + fatal_lang_error('calendar_export_off', false); |
|
| 564 | + } |
|
| 546 | 565 | |
| 547 | 566 | // Goes without saying that this is required. |
| 548 | - if (!isset($_REQUEST['eventid'])) |
|
| 549 | - fatal_lang_error('no_access', false); |
|
| 567 | + if (!isset($_REQUEST['eventid'])) { |
|
| 568 | + fatal_lang_error('no_access', false); |
|
| 569 | + } |
|
| 550 | 570 | |
| 551 | 571 | // This is kinda wanted. |
| 552 | 572 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -554,15 +574,17 @@ discard block |
||
| 554 | 574 | // Load up the event in question and check it exists. |
| 555 | 575 | $event = getEventProperties($_REQUEST['eventid']); |
| 556 | 576 | |
| 557 | - if ($event === false) |
|
| 558 | - fatal_lang_error('no_access', false); |
|
| 577 | + if ($event === false) { |
|
| 578 | + fatal_lang_error('no_access', false); |
|
| 579 | + } |
|
| 559 | 580 | |
| 560 | 581 | // Check the title isn't too long - iCal requires some formatting if so. |
| 561 | 582 | $title = str_split($event['title'], 30); |
| 562 | 583 | foreach ($title as $id => $line) |
| 563 | 584 | { |
| 564 | - if ($id != 0) |
|
| 565 | - $title[$id] = ' ' . $title[$id]; |
|
| 585 | + if ($id != 0) { |
|
| 586 | + $title[$id] = ' ' . $title[$id]; |
|
| 587 | + } |
|
| 566 | 588 | $title[$id] .= "\n"; |
| 567 | 589 | } |
| 568 | 590 | |
@@ -575,8 +597,7 @@ discard block |
||
| 575 | 597 | { |
| 576 | 598 | $datestart = date_format($start_date, 'Ymd\THis'); |
| 577 | 599 | $dateend = date_format($end_date, 'Ymd\THis'); |
| 578 | - } |
|
| 579 | - else |
|
| 600 | + } else |
|
| 580 | 601 | { |
| 581 | 602 | $datestart = date_format($start_date, 'Ymd'); |
| 582 | 603 | |
@@ -597,15 +618,18 @@ discard block |
||
| 597 | 618 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
| 598 | 619 | |
| 599 | 620 | // event has a duration |
| 600 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
| 601 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 621 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
| 622 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 623 | + } |
|
| 602 | 624 | |
| 603 | 625 | // event has changed? advance the sequence for this UID |
| 604 | - if ($event['sequence'] > 0) |
|
| 605 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 626 | + if ($event['sequence'] > 0) { |
|
| 627 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 628 | + } |
|
| 606 | 629 | |
| 607 | - if (!empty($event['location'])) |
|
| 608 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 630 | + if (!empty($event['location'])) { |
|
| 631 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 632 | + } |
|
| 609 | 633 | |
| 610 | 634 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 611 | 635 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -614,23 +638,26 @@ discard block |
||
| 614 | 638 | |
| 615 | 639 | // Send some standard headers. |
| 616 | 640 | ob_end_clean(); |
| 617 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 618 | - @ob_start('ob_gzhandler'); |
|
| 619 | - else |
|
| 620 | - ob_start(); |
|
| 641 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 642 | + @ob_start('ob_gzhandler'); |
|
| 643 | + } else { |
|
| 644 | + ob_start(); |
|
| 645 | + } |
|
| 621 | 646 | |
| 622 | 647 | // Send the file headers |
| 623 | 648 | header('Pragma: '); |
| 624 | 649 | header('Cache-Control: no-cache'); |
| 625 | - if (!isBrowser('gecko')) |
|
| 626 | - header('Content-Transfer-Encoding: binary'); |
|
| 650 | + if (!isBrowser('gecko')) { |
|
| 651 | + header('Content-Transfer-Encoding: binary'); |
|
| 652 | + } |
|
| 627 | 653 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 628 | 654 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
| 629 | 655 | header('Accept-Ranges: bytes'); |
| 630 | 656 | header('Connection: close'); |
| 631 | 657 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 632 | - if (empty($modSettings['enableCompressedOutput'])) |
|
| 633 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 658 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
| 659 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 660 | + } |
|
| 634 | 661 | |
| 635 | 662 | // This is a calendar item! |
| 636 | 663 | header('Content-Type: text/calendar'); |
@@ -669,20 +696,17 @@ discard block |
||
| 669 | 696 | $context['sub_template'] = 'bcd'; |
| 670 | 697 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
| 671 | 698 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true); |
| 672 | - } |
|
| 673 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 699 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 674 | 700 | { |
| 675 | 701 | $context['sub_template'] = 'hms'; |
| 676 | 702 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
| 677 | 703 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true); |
| 678 | - } |
|
| 679 | - elseif ($omfg) |
|
| 704 | + } elseif ($omfg) |
|
| 680 | 705 | { |
| 681 | 706 | $context['sub_template'] = 'omfg'; |
| 682 | 707 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
| 683 | 708 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true); |
| 684 | - } |
|
| 685 | - elseif (isset($_REQUEST['time'])) |
|
| 709 | + } elseif (isset($_REQUEST['time'])) |
|
| 686 | 710 | { |
| 687 | 711 | $context['sub_template'] = 'thetime'; |
| 688 | 712 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -736,12 +760,13 @@ discard block |
||
| 736 | 760 | ), |
| 737 | 761 | ); |
| 738 | 762 | |
| 739 | - foreach ($context['clockicons'] as $t => $vs) |
|
| 740 | - foreach ($vs as $v => $dumb) |
|
| 763 | + foreach ($context['clockicons'] as $t => $vs) { |
|
| 764 | + foreach ($vs as $v => $dumb) |
|
| 741 | 765 | { |
| 742 | 766 | if ($$t >= $v) |
| 743 | 767 | { |
| 744 | 768 | $$t -= $v; |
| 769 | + } |
|
| 745 | 770 | $context['clockicons'][$t][$v] = true; |
| 746 | 771 | } |
| 747 | 772 | } |
@@ -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;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting. |
| 154 | 160 | error_reporting(E_ALL); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
| 237 | 246 | { |
| 238 | 247 | // Get PHP's default timezone, if set |
| 239 | 248 | $ini_tz = ini_get('date.timezone'); |
| 240 | - if (!empty($ini_tz)) |
|
| 241 | - $timezone_id = $ini_tz; |
|
| 242 | - else |
|
| 243 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
| 270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 271 | 281 | while ($entry = $dir->read()) |
| 272 | 282 | { |
| 273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 275 | 286 | } |
| 276 | 287 | $dir->close(); |
| 277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
| 306 | 317 | } |
| 307 | 318 | |
| 308 | 319 | // Override the language file? |
| 309 | - if (isset($_GET['lang_file'])) |
|
| 310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 313 | 325 | |
| 314 | 326 | // Make sure it exists, if it doesn't reset it. |
| 315 | 327 | 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'])) |
@@ -318,8 +330,9 @@ discard block |
||
| 318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 319 | 331 | |
| 320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 323 | 336 | } |
| 324 | 337 | |
| 325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
| 332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 334 | 347 | |
| 335 | - if (empty($sourcedir)) |
|
| 336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // Need this to check whether we need the database password. |
| 339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 340 | - if (!defined('SMF')) |
|
| 341 | - define('SMF', 1); |
|
| 342 | - if (empty($smcFunc)) |
|
| 343 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 344 | 360 | |
| 345 | 361 | $modSettings['disableQueryCheck'] = true; |
| 346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
| 348 | 364 | if (!$db_connection) |
| 349 | 365 | { |
| 350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 353 | 370 | |
| 354 | 371 | $db_options = array('persist' => $db_persist); |
| 355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
| 360 | 377 | if ($db_type == 'mysql') |
| 361 | 378 | { |
| 362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 363 | - } |
|
| 364 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 365 | 381 | { |
| 366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 368 | 384 | } |
| 369 | 385 | } |
| 370 | 386 | |
| 371 | - if (!empty($port)) |
|
| 372 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 373 | 390 | |
| 374 | - if (!$db_connection) |
|
| 375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 376 | 394 | } |
| 377 | 395 | } |
| 378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
| 400 | 418 | // @todo REMOVE THIS!! |
| 401 | 419 | else |
| 402 | 420 | { |
| 403 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 404 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 405 | 424 | } |
| 406 | 425 | // Show the footer. |
| 407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
| 419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 420 | 439 | |
| 421 | 440 | // Done the submission? |
| 422 | - if (isset($_POST['contbutt'])) |
|
| 423 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 424 | 444 | |
| 425 | 445 | // See if we think they have already installed it? |
| 426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
| 428 | 448 | $probably_installed = 0; |
| 429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 430 | 450 | { |
| 431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 432 | - $probably_installed++; |
|
| 433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 434 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 435 | 457 | } |
| 436 | 458 | |
| 437 | - if ($probably_installed == 2) |
|
| 438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 439 | 462 | } |
| 440 | 463 | |
| 441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
| 450 | 473 | $databases[$key]['supported'] = false; |
| 451 | 474 | $notFoundSQLFile = true; |
| 452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 453 | 478 | } |
| 454 | - else |
|
| 455 | - $incontext['supported_databases'][] = $db; |
|
| 456 | 479 | } |
| 457 | 480 | } |
| 458 | 481 | |
| 459 | 482 | // Check the PHP version. |
| 460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 461 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 462 | 486 | // Make sure we have a supported database |
| 463 | - elseif (empty($incontext['supported_databases'])) |
|
| 464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 465 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 466 | - elseif (!function_exists('session_start')) |
|
| 467 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 468 | 494 | // Make sure they uploaded all the files. |
| 469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 470 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 471 | 498 | // Very simple check on the session.save_path for Windows. |
| 472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 474 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 475 | 503 | |
| 476 | 504 | // Since each of the three messages would look the same, anyway... |
| 477 | - if (isset($error)) |
|
| 478 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 479 | 508 | |
| 480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 483 | 513 | |
| 484 | 514 | // Confirm mbstring is loaded... |
| 485 | - if (!extension_loaded('mbstring')) |
|
| 486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 515 | + if (!extension_loaded('mbstring')) { |
|
| 516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Check for https stream support. |
| 489 | 520 | $supported_streams = stream_get_wrappers(); |
| 490 | - if (!in_array('https', $supported_streams)) |
|
| 491 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 521 | + if (!in_array('https', $supported_streams)) { |
|
| 522 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | return false; |
| 494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
| 514 | 546 | 'db_last_error.php', |
| 515 | 547 | ); |
| 516 | 548 | |
| 517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 551 | + } |
|
| 519 | 552 | |
| 520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 556 | + } |
|
| 523 | 557 | |
| 524 | 558 | $failed_files = array(); |
| 525 | 559 | |
@@ -531,20 +565,23 @@ discard block |
||
| 531 | 565 | foreach ($writable_files as $file) |
| 532 | 566 | { |
| 533 | 567 | // Some files won't exist, try to address up front |
| 534 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 535 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 568 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 569 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 570 | + } |
|
| 536 | 571 | // NOW do the writable check... |
| 537 | 572 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 538 | 573 | { |
| 539 | 574 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 540 | 575 | |
| 541 | 576 | // Well, 755 hopefully worked... if not, try 777. |
| 542 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 543 | - $failed_files[] = $file; |
|
| 577 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 578 | + $failed_files[] = $file; |
|
| 579 | + } |
|
| 544 | 580 | } |
| 545 | 581 | } |
| 546 | - foreach ($extra_files as $file) |
|
| 547 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 582 | + foreach ($extra_files as $file) { |
|
| 583 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 584 | + } |
|
| 548 | 585 | } |
| 549 | 586 | // Windows is trickier. Let's try opening for r+... |
| 550 | 587 | else |
@@ -554,30 +591,35 @@ discard block |
||
| 554 | 591 | foreach ($writable_files as $file) |
| 555 | 592 | { |
| 556 | 593 | // Folders can't be opened for write... but the index.php in them can ;) |
| 557 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 558 | - $file .= '/index.php'; |
|
| 594 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 595 | + $file .= '/index.php'; |
|
| 596 | + } |
|
| 559 | 597 | |
| 560 | 598 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 561 | 599 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 562 | 600 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 563 | 601 | |
| 564 | 602 | // Hmm, okay, try just for write in that case... |
| 565 | - if (!is_resource($fp)) |
|
| 566 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 603 | + if (!is_resource($fp)) { |
|
| 604 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 605 | + } |
|
| 567 | 606 | |
| 568 | - if (!is_resource($fp)) |
|
| 569 | - $failed_files[] = $file; |
|
| 607 | + if (!is_resource($fp)) { |
|
| 608 | + $failed_files[] = $file; |
|
| 609 | + } |
|
| 570 | 610 | |
| 571 | 611 | @fclose($fp); |
| 572 | 612 | } |
| 573 | - foreach ($extra_files as $file) |
|
| 574 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 613 | + foreach ($extra_files as $file) { |
|
| 614 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 615 | + } |
|
| 575 | 616 | } |
| 576 | 617 | |
| 577 | 618 | $failure = count($failed_files) >= 1; |
| 578 | 619 | |
| 579 | - if (!isset($_SERVER)) |
|
| 580 | - return !$failure; |
|
| 620 | + if (!isset($_SERVER)) { |
|
| 621 | + return !$failure; |
|
| 622 | + } |
|
| 581 | 623 | |
| 582 | 624 | // Put the list into context. |
| 583 | 625 | $incontext['failed_files'] = $failed_files; |
@@ -625,19 +667,23 @@ discard block |
||
| 625 | 667 | |
| 626 | 668 | if (!isset($ftp) || $ftp->error !== false) |
| 627 | 669 | { |
| 628 | - if (!isset($ftp)) |
|
| 629 | - $ftp = new ftp_connection(null); |
|
| 670 | + if (!isset($ftp)) { |
|
| 671 | + $ftp = new ftp_connection(null); |
|
| 672 | + } |
|
| 630 | 673 | // Save the error so we can mess with listing... |
| 631 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 632 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 674 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 675 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 676 | + } |
|
| 633 | 677 | |
| 634 | 678 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 635 | 679 | |
| 636 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 637 | - $_POST['ftp_path'] = $detect_path; |
|
| 680 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 681 | + $_POST['ftp_path'] = $detect_path; |
|
| 682 | + } |
|
| 638 | 683 | |
| 639 | - if (!isset($_POST['ftp_username'])) |
|
| 640 | - $_POST['ftp_username'] = $username; |
|
| 684 | + if (!isset($_POST['ftp_username'])) { |
|
| 685 | + $_POST['ftp_username'] = $username; |
|
| 686 | + } |
|
| 641 | 687 | |
| 642 | 688 | // Set the username etc, into context. |
| 643 | 689 | $incontext['ftp'] = array( |
@@ -649,8 +695,7 @@ discard block |
||
| 649 | 695 | ); |
| 650 | 696 | |
| 651 | 697 | return false; |
| 652 | - } |
|
| 653 | - else |
|
| 698 | + } else |
|
| 654 | 699 | { |
| 655 | 700 | $_SESSION['installer_temp_ftp'] = array( |
| 656 | 701 | 'server' => $_POST['ftp_server'], |
@@ -664,10 +709,12 @@ discard block |
||
| 664 | 709 | |
| 665 | 710 | foreach ($failed_files as $file) |
| 666 | 711 | { |
| 667 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 668 | - $ftp->chmod($file, 0755); |
|
| 669 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 670 | - $ftp->chmod($file, 0777); |
|
| 712 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 713 | + $ftp->chmod($file, 0755); |
|
| 714 | + } |
|
| 715 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 716 | + $ftp->chmod($file, 0777); |
|
| 717 | + } |
|
| 671 | 718 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 672 | 719 | { |
| 673 | 720 | $failed_files_updated[] = $file; |
@@ -723,15 +770,17 @@ discard block |
||
| 723 | 770 | |
| 724 | 771 | if (!$foundOne) |
| 725 | 772 | { |
| 726 | - if (isset($db['default_host'])) |
|
| 727 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 773 | + if (isset($db['default_host'])) { |
|
| 774 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 775 | + } |
|
| 728 | 776 | if (isset($db['default_user'])) |
| 729 | 777 | { |
| 730 | 778 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 731 | 779 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 732 | 780 | } |
| 733 | - if (isset($db['default_password'])) |
|
| 734 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 781 | + if (isset($db['default_password'])) { |
|
| 782 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 783 | + } |
|
| 735 | 784 | |
| 736 | 785 | // For simplicity and less confusion, leave the port blank by default |
| 737 | 786 | $incontext['db']['port'] = ''; |
@@ -750,10 +799,10 @@ discard block |
||
| 750 | 799 | $incontext['db']['server'] = $_POST['db_server']; |
| 751 | 800 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 752 | 801 | |
| 753 | - if (!empty($_POST['db_port'])) |
|
| 754 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 755 | - } |
|
| 756 | - else |
|
| 802 | + if (!empty($_POST['db_port'])) { |
|
| 803 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 804 | + } |
|
| 805 | + } else |
|
| 757 | 806 | { |
| 758 | 807 | $incontext['db']['prefix'] = 'smf_'; |
| 759 | 808 | } |
@@ -789,10 +838,11 @@ discard block |
||
| 789 | 838 | if (!empty($_POST['db_port'])) |
| 790 | 839 | { |
| 791 | 840 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 792 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 793 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 794 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 795 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 841 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 842 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 843 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 844 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 845 | + } |
|
| 796 | 846 | } |
| 797 | 847 | |
| 798 | 848 | // God I hope it saved! |
@@ -805,8 +855,9 @@ discard block |
||
| 805 | 855 | // Make sure it works. |
| 806 | 856 | require(dirname(__FILE__) . '/Settings.php'); |
| 807 | 857 | |
| 808 | - if (empty($sourcedir)) |
|
| 809 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 858 | + if (empty($sourcedir)) { |
|
| 859 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 860 | + } |
|
| 810 | 861 | |
| 811 | 862 | // Better find the database file! |
| 812 | 863 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -816,18 +867,21 @@ discard block |
||
| 816 | 867 | } |
| 817 | 868 | |
| 818 | 869 | // Now include it for database functions! |
| 819 | - if (!defined('SMF')) |
|
| 820 | - define('SMF', 1); |
|
| 870 | + if (!defined('SMF')) { |
|
| 871 | + define('SMF', 1); |
|
| 872 | + } |
|
| 821 | 873 | |
| 822 | 874 | $modSettings['disableQueryCheck'] = true; |
| 823 | - if (empty($smcFunc)) |
|
| 824 | - $smcFunc = array(); |
|
| 875 | + if (empty($smcFunc)) { |
|
| 876 | + $smcFunc = array(); |
|
| 877 | + } |
|
| 825 | 878 | |
| 826 | 879 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 827 | 880 | |
| 828 | 881 | // What - running PHP4? The shame! |
| 829 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 830 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 882 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 883 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 884 | + } |
|
| 831 | 885 | |
| 832 | 886 | // Attempt a connection. |
| 833 | 887 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -915,12 +969,14 @@ discard block |
||
| 915 | 969 | $incontext['page_title'] = $txt['install_settings']; |
| 916 | 970 | |
| 917 | 971 | // Let's see if we got the database type correct. |
| 918 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 919 | - $db_type = $_POST['db_type']; |
|
| 972 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 973 | + $db_type = $_POST['db_type']; |
|
| 974 | + } |
|
| 920 | 975 | |
| 921 | 976 | // Else we'd better be able to get the connection. |
| 922 | - else |
|
| 923 | - load_database(); |
|
| 977 | + else { |
|
| 978 | + load_database(); |
|
| 979 | + } |
|
| 924 | 980 | |
| 925 | 981 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 926 | 982 | |
@@ -940,12 +996,14 @@ discard block |
||
| 940 | 996 | // Submitting? |
| 941 | 997 | if (isset($_POST['boardurl'])) |
| 942 | 998 | { |
| 943 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 944 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 945 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 946 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 947 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 948 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 999 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1000 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1001 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1002 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1003 | + } |
|
| 1004 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1005 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1006 | + } |
|
| 949 | 1007 | |
| 950 | 1008 | // Save these variables. |
| 951 | 1009 | $vars = array( |
@@ -984,10 +1042,10 @@ discard block |
||
| 984 | 1042 | { |
| 985 | 1043 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 986 | 1044 | return false; |
| 987 | - } |
|
| 988 | - else |
|
| 989 | - // Set the character set here. |
|
| 1045 | + } else { |
|
| 1046 | + // Set the character set here. |
|
| 990 | 1047 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1048 | + } |
|
| 991 | 1049 | } |
| 992 | 1050 | |
| 993 | 1051 | // Good, skip on. |
@@ -1007,8 +1065,9 @@ discard block |
||
| 1007 | 1065 | $incontext['continue'] = 1; |
| 1008 | 1066 | |
| 1009 | 1067 | // Already done? |
| 1010 | - if (isset($_POST['pop_done'])) |
|
| 1011 | - return true; |
|
| 1068 | + if (isset($_POST['pop_done'])) { |
|
| 1069 | + return true; |
|
| 1070 | + } |
|
| 1012 | 1071 | |
| 1013 | 1072 | // Reload settings. |
| 1014 | 1073 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1026,8 +1085,9 @@ discard block |
||
| 1026 | 1085 | $modSettings = array(); |
| 1027 | 1086 | if ($result !== false) |
| 1028 | 1087 | { |
| 1029 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1030 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1088 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1089 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1090 | + } |
|
| 1031 | 1091 | $smcFunc['db_free_result']($result); |
| 1032 | 1092 | |
| 1033 | 1093 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1040,20 +1100,22 @@ discard block |
||
| 1040 | 1100 | $modSettings['disableQueryCheck'] = true; |
| 1041 | 1101 | |
| 1042 | 1102 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1043 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1044 | - $smcFunc['db_query']('', ' |
|
| 1103 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1104 | + $smcFunc['db_query']('', ' |
|
| 1045 | 1105 | SET NAMES {string:utf8}', |
| 1046 | 1106 | array( |
| 1047 | 1107 | 'db_error_skip' => true, |
| 1048 | 1108 | 'utf8' => 'utf8', |
| 1049 | 1109 | ) |
| 1050 | 1110 | ); |
| 1111 | + } |
|
| 1051 | 1112 | |
| 1052 | 1113 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1053 | - if (substr(__DIR__, -1) == '\\') |
|
| 1054 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1055 | - else |
|
| 1056 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1114 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1115 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1116 | + } else { |
|
| 1117 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1118 | + } |
|
| 1057 | 1119 | |
| 1058 | 1120 | $replaces = array( |
| 1059 | 1121 | '{$db_prefix}' => $db_prefix, |
@@ -1070,8 +1132,9 @@ discard block |
||
| 1070 | 1132 | |
| 1071 | 1133 | foreach ($txt as $key => $value) |
| 1072 | 1134 | { |
| 1073 | - if (substr($key, 0, 8) == 'default_') |
|
| 1074 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1135 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1136 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1137 | + } |
|
| 1075 | 1138 | } |
| 1076 | 1139 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1077 | 1140 | |
@@ -1086,8 +1149,9 @@ discard block |
||
| 1086 | 1149 | |
| 1087 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1088 | 1151 | { |
| 1089 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1090 | - $engines[] = $row['Engine']; |
|
| 1152 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1153 | + $engines[] = $row['Engine']; |
|
| 1154 | + } |
|
| 1091 | 1155 | } |
| 1092 | 1156 | |
| 1093 | 1157 | // Done with this now |
@@ -1111,8 +1175,7 @@ discard block |
||
| 1111 | 1175 | $replaces['START TRANSACTION;'] = ''; |
| 1112 | 1176 | $replaces['COMMIT;'] = ''; |
| 1113 | 1177 | } |
| 1114 | - } |
|
| 1115 | - else |
|
| 1178 | + } else |
|
| 1116 | 1179 | { |
| 1117 | 1180 | $has_innodb = false; |
| 1118 | 1181 | } |
@@ -1134,21 +1197,24 @@ discard block |
||
| 1134 | 1197 | foreach ($sql_lines as $count => $line) |
| 1135 | 1198 | { |
| 1136 | 1199 | // No comments allowed! |
| 1137 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1138 | - $current_statement .= "\n" . rtrim($line); |
|
| 1200 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1201 | + $current_statement .= "\n" . rtrim($line); |
|
| 1202 | + } |
|
| 1139 | 1203 | |
| 1140 | 1204 | // Is this the end of the query string? |
| 1141 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1142 | - continue; |
|
| 1205 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1206 | + continue; |
|
| 1207 | + } |
|
| 1143 | 1208 | |
| 1144 | 1209 | // Does this table already exist? If so, don't insert more data into it! |
| 1145 | 1210 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1146 | 1211 | { |
| 1147 | 1212 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1148 | - if (!empty($matches[0])) |
|
| 1149 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1150 | - else |
|
| 1151 | - $incontext['sql_results']['insert_dups']++; |
|
| 1213 | + if (!empty($matches[0])) { |
|
| 1214 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1215 | + } else { |
|
| 1216 | + $incontext['sql_results']['insert_dups']++; |
|
| 1217 | + } |
|
| 1152 | 1218 | |
| 1153 | 1219 | $current_statement = ''; |
| 1154 | 1220 | continue; |
@@ -1157,8 +1223,9 @@ discard block |
||
| 1157 | 1223 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1158 | 1224 | { |
| 1159 | 1225 | // Use the appropriate function based on the DB type |
| 1160 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1161 | - $db_errorno = $db_type . '_errno'; |
|
| 1226 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1227 | + $db_errorno = $db_type . '_errno'; |
|
| 1228 | + } |
|
| 1162 | 1229 | |
| 1163 | 1230 | // Error 1050: Table already exists! |
| 1164 | 1231 | // @todo Needs to be made better! |
@@ -1173,18 +1240,18 @@ discard block |
||
| 1173 | 1240 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1174 | 1241 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1175 | 1242 | } |
| 1176 | - } |
|
| 1177 | - else |
|
| 1243 | + } else |
|
| 1178 | 1244 | { |
| 1179 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1180 | - $incontext['sql_results']['tables']++; |
|
| 1181 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1245 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1246 | + $incontext['sql_results']['tables']++; |
|
| 1247 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1182 | 1248 | { |
| 1183 | 1249 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1184 | - if (!empty($matches[0])) |
|
| 1185 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1186 | - else |
|
| 1187 | - $incontext['sql_results']['inserts']++; |
|
| 1250 | + if (!empty($matches[0])) { |
|
| 1251 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1252 | + } else { |
|
| 1253 | + $incontext['sql_results']['inserts']++; |
|
| 1254 | + } |
|
| 1188 | 1255 | } |
| 1189 | 1256 | } |
| 1190 | 1257 | |
@@ -1197,15 +1264,17 @@ discard block |
||
| 1197 | 1264 | // Sort out the context for the SQL. |
| 1198 | 1265 | foreach ($incontext['sql_results'] as $key => $number) |
| 1199 | 1266 | { |
| 1200 | - if ($number == 0) |
|
| 1201 | - unset($incontext['sql_results'][$key]); |
|
| 1202 | - else |
|
| 1203 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1267 | + if ($number == 0) { |
|
| 1268 | + unset($incontext['sql_results'][$key]); |
|
| 1269 | + } else { |
|
| 1270 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1271 | + } |
|
| 1204 | 1272 | } |
| 1205 | 1273 | |
| 1206 | 1274 | // Make sure UTF will be used globally. |
| 1207 | - 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']))) |
|
| 1208 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1275 | + 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']))) { |
|
| 1276 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1277 | + } |
|
| 1209 | 1278 | |
| 1210 | 1279 | // Maybe we can auto-detect better cookie settings? |
| 1211 | 1280 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1216,16 +1285,20 @@ discard block |
||
| 1216 | 1285 | $globalCookies = false; |
| 1217 | 1286 | |
| 1218 | 1287 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
| 1219 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
| 1220 | - $globalCookies = true; |
|
| 1288 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
| 1289 | + $globalCookies = true; |
|
| 1290 | + } |
|
| 1221 | 1291 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
| 1222 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
| 1223 | - $localCookies = true; |
|
| 1292 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
| 1293 | + $localCookies = true; |
|
| 1294 | + } |
|
| 1224 | 1295 | |
| 1225 | - if ($globalCookies) |
|
| 1226 | - $newSettings[] = array('globalCookies', '1'); |
|
| 1227 | - if ($localCookies) |
|
| 1228 | - $newSettings[] = array('localCookies', '1'); |
|
| 1296 | + if ($globalCookies) { |
|
| 1297 | + $newSettings[] = array('globalCookies', '1'); |
|
| 1298 | + } |
|
| 1299 | + if ($localCookies) { |
|
| 1300 | + $newSettings[] = array('localCookies', '1'); |
|
| 1301 | + } |
|
| 1229 | 1302 | } |
| 1230 | 1303 | |
| 1231 | 1304 | // Are we allowing stat collection? |
@@ -1243,16 +1316,17 @@ discard block |
||
| 1243 | 1316 | fwrite($fp, $out); |
| 1244 | 1317 | |
| 1245 | 1318 | $return_data = ''; |
| 1246 | - while (!feof($fp)) |
|
| 1247 | - $return_data .= fgets($fp, 128); |
|
| 1319 | + while (!feof($fp)) { |
|
| 1320 | + $return_data .= fgets($fp, 128); |
|
| 1321 | + } |
|
| 1248 | 1322 | |
| 1249 | 1323 | fclose($fp); |
| 1250 | 1324 | |
| 1251 | 1325 | // Get the unique site ID. |
| 1252 | 1326 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1253 | 1327 | |
| 1254 | - if (!empty($ID[1])) |
|
| 1255 | - $smcFunc['db_insert']('replace', |
|
| 1328 | + if (!empty($ID[1])) { |
|
| 1329 | + $smcFunc['db_insert']('replace', |
|
| 1256 | 1330 | $db_prefix . 'settings', |
| 1257 | 1331 | array('variable' => 'string', 'value' => 'string'), |
| 1258 | 1332 | array( |
@@ -1261,11 +1335,12 @@ discard block |
||
| 1261 | 1335 | ), |
| 1262 | 1336 | array('variable') |
| 1263 | 1337 | ); |
| 1338 | + } |
|
| 1264 | 1339 | } |
| 1265 | 1340 | } |
| 1266 | 1341 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1267 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1268 | - $smcFunc['db_query']('', ' |
|
| 1342 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1343 | + $smcFunc['db_query']('', ' |
|
| 1269 | 1344 | DELETE FROM {db_prefix}settings |
| 1270 | 1345 | WHERE variable = {string:enable_sm_stats}', |
| 1271 | 1346 | array( |
@@ -1273,20 +1348,23 @@ discard block |
||
| 1273 | 1348 | 'db_error_skip' => true, |
| 1274 | 1349 | ) |
| 1275 | 1350 | ); |
| 1351 | + } |
|
| 1276 | 1352 | |
| 1277 | 1353 | // Are we enabling SSL? |
| 1278 | - if (!empty($_POST['force_ssl'])) |
|
| 1279 | - $newSettings[] = array('force_ssl', 2); |
|
| 1354 | + if (!empty($_POST['force_ssl'])) { |
|
| 1355 | + $newSettings[] = array('force_ssl', 2); |
|
| 1356 | + } |
|
| 1280 | 1357 | |
| 1281 | 1358 | // Setting a timezone is required. |
| 1282 | 1359 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1283 | 1360 | { |
| 1284 | 1361 | // Get PHP's default timezone, if set |
| 1285 | 1362 | $ini_tz = ini_get('date.timezone'); |
| 1286 | - if (!empty($ini_tz)) |
|
| 1287 | - $timezone_id = $ini_tz; |
|
| 1288 | - else |
|
| 1289 | - $timezone_id = ''; |
|
| 1363 | + if (!empty($ini_tz)) { |
|
| 1364 | + $timezone_id = $ini_tz; |
|
| 1365 | + } else { |
|
| 1366 | + $timezone_id = ''; |
|
| 1367 | + } |
|
| 1290 | 1368 | |
| 1291 | 1369 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1292 | 1370 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1295,8 +1373,9 @@ discard block |
||
| 1295 | 1373 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1296 | 1374 | } |
| 1297 | 1375 | |
| 1298 | - if (date_default_timezone_set($timezone_id)) |
|
| 1299 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1376 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1377 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1378 | + } |
|
| 1300 | 1379 | } |
| 1301 | 1380 | |
| 1302 | 1381 | if (!empty($newSettings)) |
@@ -1327,16 +1406,18 @@ discard block |
||
| 1327 | 1406 | } |
| 1328 | 1407 | |
| 1329 | 1408 | // MySQL specific stuff |
| 1330 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1331 | - return false; |
|
| 1409 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1410 | + return false; |
|
| 1411 | + } |
|
| 1332 | 1412 | |
| 1333 | 1413 | // Find database user privileges. |
| 1334 | 1414 | $privs = array(); |
| 1335 | 1415 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1336 | 1416 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1337 | 1417 | { |
| 1338 | - if ($row['Privilege'] == 'Alter') |
|
| 1339 | - $privs[] = $row['Privilege']; |
|
| 1418 | + if ($row['Privilege'] == 'Alter') { |
|
| 1419 | + $privs[] = $row['Privilege']; |
|
| 1420 | + } |
|
| 1340 | 1421 | } |
| 1341 | 1422 | $smcFunc['db_free_result']($get_privs); |
| 1342 | 1423 | |
@@ -1366,8 +1447,9 @@ discard block |
||
| 1366 | 1447 | $incontext['continue'] = 1; |
| 1367 | 1448 | |
| 1368 | 1449 | // Skipping? |
| 1369 | - if (!empty($_POST['skip'])) |
|
| 1370 | - return true; |
|
| 1450 | + if (!empty($_POST['skip'])) { |
|
| 1451 | + return true; |
|
| 1452 | + } |
|
| 1371 | 1453 | |
| 1372 | 1454 | // Need this to check whether we need the database password. |
| 1373 | 1455 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1384,18 +1466,22 @@ discard block |
||
| 1384 | 1466 | // We need this to properly hash the password for Admin |
| 1385 | 1467 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1386 | 1468 | global $sourcedir; |
| 1387 | - if (function_exists('mb_strtolower')) |
|
| 1388 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1469 | + if (function_exists('mb_strtolower')) { |
|
| 1470 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1471 | + } |
|
| 1389 | 1472 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1390 | 1473 | return utf8_strtolower($string); |
| 1391 | 1474 | }; |
| 1392 | 1475 | |
| 1393 | - if (!isset($_POST['username'])) |
|
| 1394 | - $_POST['username'] = ''; |
|
| 1395 | - if (!isset($_POST['email'])) |
|
| 1396 | - $_POST['email'] = ''; |
|
| 1397 | - if (!isset($_POST['server_email'])) |
|
| 1398 | - $_POST['server_email'] = ''; |
|
| 1476 | + if (!isset($_POST['username'])) { |
|
| 1477 | + $_POST['username'] = ''; |
|
| 1478 | + } |
|
| 1479 | + if (!isset($_POST['email'])) { |
|
| 1480 | + $_POST['email'] = ''; |
|
| 1481 | + } |
|
| 1482 | + if (!isset($_POST['server_email'])) { |
|
| 1483 | + $_POST['server_email'] = ''; |
|
| 1484 | + } |
|
| 1399 | 1485 | |
| 1400 | 1486 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1401 | 1487 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1414,8 +1500,9 @@ discard block |
||
| 1414 | 1500 | 'admin_group' => 1, |
| 1415 | 1501 | ) |
| 1416 | 1502 | ); |
| 1417 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1418 | - $incontext['skip'] = 1; |
|
| 1503 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1504 | + $incontext['skip'] = 1; |
|
| 1505 | + } |
|
| 1419 | 1506 | $smcFunc['db_free_result']($request); |
| 1420 | 1507 | |
| 1421 | 1508 | // Trying to create an account? |
@@ -1446,8 +1533,9 @@ discard block |
||
| 1446 | 1533 | } |
| 1447 | 1534 | |
| 1448 | 1535 | // Update the webmaster's email? |
| 1449 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1450 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1536 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1537 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1538 | + } |
|
| 1451 | 1539 | |
| 1452 | 1540 | // Work out whether we're going to have dodgy characters and remove them. |
| 1453 | 1541 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1470,32 +1558,27 @@ discard block |
||
| 1470 | 1558 | $smcFunc['db_free_result']($result); |
| 1471 | 1559 | |
| 1472 | 1560 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1473 | - } |
|
| 1474 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1561 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1475 | 1562 | { |
| 1476 | 1563 | // Try the previous step again. |
| 1477 | 1564 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1478 | 1565 | return false; |
| 1479 | - } |
|
| 1480 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1566 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1481 | 1567 | { |
| 1482 | 1568 | // Try the previous step again. |
| 1483 | 1569 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1484 | 1570 | return false; |
| 1485 | - } |
|
| 1486 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1571 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1487 | 1572 | { |
| 1488 | 1573 | // One step back, this time fill out a proper admin email address. |
| 1489 | 1574 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1490 | 1575 | return false; |
| 1491 | - } |
|
| 1492 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1576 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1493 | 1577 | { |
| 1494 | 1578 | // One step back, this time fill out a proper admin email address. |
| 1495 | 1579 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1496 | 1580 | return false; |
| 1497 | - } |
|
| 1498 | - elseif ($_POST['username'] != '') |
|
| 1581 | + } elseif ($_POST['username'] != '') |
|
| 1499 | 1582 | { |
| 1500 | 1583 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1501 | 1584 | |
@@ -1563,17 +1646,19 @@ discard block |
||
| 1563 | 1646 | reloadSettings(); |
| 1564 | 1647 | |
| 1565 | 1648 | // Bring a warning over. |
| 1566 | - if (!empty($incontext['account_existed'])) |
|
| 1567 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1649 | + if (!empty($incontext['account_existed'])) { |
|
| 1650 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1651 | + } |
|
| 1568 | 1652 | |
| 1569 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1570 | - $smcFunc['db_query']('', ' |
|
| 1653 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1654 | + $smcFunc['db_query']('', ' |
|
| 1571 | 1655 | SET NAMES {string:db_character_set}', |
| 1572 | 1656 | array( |
| 1573 | 1657 | 'db_character_set' => $db_character_set, |
| 1574 | 1658 | 'db_error_skip' => true, |
| 1575 | 1659 | ) |
| 1576 | 1660 | ); |
| 1661 | + } |
|
| 1577 | 1662 | |
| 1578 | 1663 | // As track stats is by default enabled let's add some activity. |
| 1579 | 1664 | $smcFunc['db_insert']('ignore', |
@@ -1594,14 +1679,16 @@ discard block |
||
| 1594 | 1679 | // Only proceed if we can load the data. |
| 1595 | 1680 | if ($request) |
| 1596 | 1681 | { |
| 1597 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1598 | - $modSettings[$row[0]] = $row[1]; |
|
| 1682 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1683 | + $modSettings[$row[0]] = $row[1]; |
|
| 1684 | + } |
|
| 1599 | 1685 | $smcFunc['db_free_result']($request); |
| 1600 | 1686 | } |
| 1601 | 1687 | |
| 1602 | 1688 | // Automatically log them in ;) |
| 1603 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1604 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1689 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1690 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1691 | + } |
|
| 1605 | 1692 | |
| 1606 | 1693 | $result = $smcFunc['db_query']('', ' |
| 1607 | 1694 | SELECT value |
@@ -1612,13 +1699,14 @@ discard block |
||
| 1612 | 1699 | 'db_error_skip' => true, |
| 1613 | 1700 | ) |
| 1614 | 1701 | ); |
| 1615 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1616 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1702 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1703 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1704 | + } |
|
| 1617 | 1705 | $smcFunc['db_free_result']($result); |
| 1618 | 1706 | |
| 1619 | - if (empty($db_sessions)) |
|
| 1620 | - $_SESSION['admin_time'] = time(); |
|
| 1621 | - else |
|
| 1707 | + if (empty($db_sessions)) { |
|
| 1708 | + $_SESSION['admin_time'] = time(); |
|
| 1709 | + } else |
|
| 1622 | 1710 | { |
| 1623 | 1711 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1624 | 1712 | |
@@ -1642,8 +1730,9 @@ discard block |
||
| 1642 | 1730 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1643 | 1731 | function($string){ |
| 1644 | 1732 | global $sourcedir; |
| 1645 | - if (function_exists('mb_strtolower')) |
|
| 1646 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1733 | + if (function_exists('mb_strtolower')) { |
|
| 1734 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1735 | + } |
|
| 1647 | 1736 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1648 | 1737 | return utf8_strtolower($string); |
| 1649 | 1738 | }; |
@@ -1659,8 +1748,9 @@ discard block |
||
| 1659 | 1748 | ) |
| 1660 | 1749 | ); |
| 1661 | 1750 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1662 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1663 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1751 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1752 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1753 | + } |
|
| 1664 | 1754 | $smcFunc['db_free_result']($request); |
| 1665 | 1755 | |
| 1666 | 1756 | // Now is the perfect time to fetch the SM files. |
@@ -1679,8 +1769,9 @@ discard block |
||
| 1679 | 1769 | |
| 1680 | 1770 | // Check if we need some stupid MySQL fix. |
| 1681 | 1771 | $server_version = $smcFunc['db_server_info'](); |
| 1682 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1683 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1772 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1773 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1774 | + } |
|
| 1684 | 1775 | |
| 1685 | 1776 | // Some final context for the template. |
| 1686 | 1777 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1700,8 +1791,9 @@ discard block |
||
| 1700 | 1791 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1701 | 1792 | |
| 1702 | 1793 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1703 | - if (count($settingsArray) == 1) |
|
| 1704 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1794 | + if (count($settingsArray) == 1) { |
|
| 1795 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1796 | + } |
|
| 1705 | 1797 | |
| 1706 | 1798 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1707 | 1799 | { |
@@ -1716,19 +1808,22 @@ discard block |
||
| 1716 | 1808 | continue; |
| 1717 | 1809 | } |
| 1718 | 1810 | |
| 1719 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1720 | - $settingsArray[$i] = ''; |
|
| 1811 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1812 | + $settingsArray[$i] = ''; |
|
| 1813 | + } |
|
| 1721 | 1814 | |
| 1722 | 1815 | // Don't trim or bother with it if it's not a variable. |
| 1723 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1724 | - continue; |
|
| 1816 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1817 | + continue; |
|
| 1818 | + } |
|
| 1725 | 1819 | |
| 1726 | 1820 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1727 | 1821 | |
| 1728 | - foreach ($vars as $var => $val) |
|
| 1729 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1822 | + foreach ($vars as $var => $val) { |
|
| 1823 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1730 | 1824 | { |
| 1731 | 1825 | $comment = strstr($settingsArray[$i], '#'); |
| 1826 | + } |
|
| 1732 | 1827 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1733 | 1828 | unset($vars[$var]); |
| 1734 | 1829 | } |
@@ -1738,36 +1833,41 @@ discard block |
||
| 1738 | 1833 | if (!empty($vars)) |
| 1739 | 1834 | { |
| 1740 | 1835 | $settingsArray[$i++] = ''; |
| 1741 | - foreach ($vars as $var => $val) |
|
| 1742 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1836 | + foreach ($vars as $var => $val) { |
|
| 1837 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1838 | + } |
|
| 1743 | 1839 | } |
| 1744 | 1840 | |
| 1745 | 1841 | // Blank out the file - done to fix a oddity with some servers. |
| 1746 | 1842 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1747 | - if (!$fp) |
|
| 1748 | - return false; |
|
| 1843 | + if (!$fp) { |
|
| 1844 | + return false; |
|
| 1845 | + } |
|
| 1749 | 1846 | fclose($fp); |
| 1750 | 1847 | |
| 1751 | 1848 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1752 | 1849 | |
| 1753 | 1850 | // Gotta have one of these ;) |
| 1754 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1755 | - fwrite($fp, "<?php\n"); |
|
| 1851 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1852 | + fwrite($fp, "<?php\n"); |
|
| 1853 | + } |
|
| 1756 | 1854 | |
| 1757 | 1855 | $lines = count($settingsArray); |
| 1758 | 1856 | for ($i = 0; $i < $lines - 1; $i++) |
| 1759 | 1857 | { |
| 1760 | 1858 | // Don't just write a bunch of blank lines. |
| 1761 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1762 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1859 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1860 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1861 | + } |
|
| 1763 | 1862 | } |
| 1764 | 1863 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1765 | 1864 | fclose($fp); |
| 1766 | 1865 | |
| 1767 | 1866 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1768 | 1867 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1769 | - if (function_exists('opcache_invalidate')) |
|
| 1770 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1868 | + if (function_exists('opcache_invalidate')) { |
|
| 1869 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1870 | + } |
|
| 1771 | 1871 | |
| 1772 | 1872 | return true; |
| 1773 | 1873 | } |
@@ -1792,9 +1892,9 @@ discard block |
||
| 1792 | 1892 | SecFilterScanPOST Off |
| 1793 | 1893 | </IfModule>'; |
| 1794 | 1894 | |
| 1795 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1796 | - return true; |
|
| 1797 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1895 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1896 | + return true; |
|
| 1897 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1798 | 1898 | { |
| 1799 | 1899 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1800 | 1900 | |
@@ -1806,29 +1906,28 @@ discard block |
||
| 1806 | 1906 | fwrite($ht_handle, $htaccess_addition); |
| 1807 | 1907 | fclose($ht_handle); |
| 1808 | 1908 | return true; |
| 1909 | + } else { |
|
| 1910 | + return false; |
|
| 1809 | 1911 | } |
| 1810 | - else |
|
| 1811 | - return false; |
|
| 1912 | + } else { |
|
| 1913 | + return true; |
|
| 1812 | 1914 | } |
| 1813 | - else |
|
| 1814 | - return true; |
|
| 1815 | - } |
|
| 1816 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1817 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1818 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1915 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1916 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1917 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1819 | 1918 | { |
| 1820 | 1919 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1821 | 1920 | { |
| 1822 | 1921 | fwrite($ht_handle, $htaccess_addition); |
| 1823 | 1922 | fclose($ht_handle); |
| 1824 | 1923 | return true; |
| 1924 | + } else { |
|
| 1925 | + return false; |
|
| 1825 | 1926 | } |
| 1826 | - else |
|
| 1927 | + } else { |
|
| 1827 | 1928 | return false; |
| 1828 | 1929 | } |
| 1829 | - else |
|
| 1830 | - return false; |
|
| 1831 | -} |
|
| 1930 | + } |
|
| 1832 | 1931 | |
| 1833 | 1932 | function template_install_above() |
| 1834 | 1933 | { |
@@ -1866,9 +1965,10 @@ discard block |
||
| 1866 | 1965 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1867 | 1966 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1868 | 1967 | |
| 1869 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1870 | - echo ' |
|
| 1968 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 1969 | + echo ' |
|
| 1871 | 1970 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 1971 | + } |
|
| 1872 | 1972 | |
| 1873 | 1973 | echo ' |
| 1874 | 1974 | </select> |
@@ -1888,9 +1988,10 @@ discard block |
||
| 1888 | 1988 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1889 | 1989 | <ul>'; |
| 1890 | 1990 | |
| 1891 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1892 | - echo ' |
|
| 1991 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 1992 | + echo ' |
|
| 1893 | 1993 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 1994 | + } |
|
| 1894 | 1995 | |
| 1895 | 1996 | echo ' |
| 1896 | 1997 | </ul> |
@@ -1915,20 +2016,23 @@ discard block |
||
| 1915 | 2016 | echo ' |
| 1916 | 2017 | <div>'; |
| 1917 | 2018 | |
| 1918 | - if (!empty($incontext['continue'])) |
|
| 1919 | - echo ' |
|
| 2019 | + if (!empty($incontext['continue'])) { |
|
| 2020 | + echo ' |
|
| 1920 | 2021 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 1921 | - if (!empty($incontext['skip'])) |
|
| 1922 | - echo ' |
|
| 2022 | + } |
|
| 2023 | + if (!empty($incontext['skip'])) { |
|
| 2024 | + echo ' |
|
| 1923 | 2025 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 2026 | + } |
|
| 1924 | 2027 | echo ' |
| 1925 | 2028 | </div>'; |
| 1926 | 2029 | } |
| 1927 | 2030 | |
| 1928 | 2031 | // Show the closing form tag and other data only if not in the last step |
| 1929 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1930 | - echo ' |
|
| 2032 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2033 | + echo ' |
|
| 1931 | 2034 | </form>'; |
| 2035 | + } |
|
| 1932 | 2036 | |
| 1933 | 2037 | echo ' |
| 1934 | 2038 | </div> |
@@ -1963,13 +2067,15 @@ discard block |
||
| 1963 | 2067 | </div>'; |
| 1964 | 2068 | |
| 1965 | 2069 | // Show the warnings, or not. |
| 1966 | - if (template_warning_divs()) |
|
| 1967 | - echo ' |
|
| 2070 | + if (template_warning_divs()) { |
|
| 2071 | + echo ' |
|
| 1968 | 2072 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2073 | + } |
|
| 1969 | 2074 | |
| 1970 | 2075 | // Say we want the continue button! |
| 1971 | - if (empty($incontext['error'])) |
|
| 1972 | - $incontext['continue'] = 1; |
|
| 2076 | + if (empty($incontext['error'])) { |
|
| 2077 | + $incontext['continue'] = 1; |
|
| 2078 | + } |
|
| 1973 | 2079 | |
| 1974 | 2080 | // For the latest version stuff. |
| 1975 | 2081 | echo ' |
@@ -2003,8 +2109,8 @@ discard block |
||
| 2003 | 2109 | global $txt, $incontext; |
| 2004 | 2110 | |
| 2005 | 2111 | // Errors are very serious.. |
| 2006 | - if (!empty($incontext['error'])) |
|
| 2007 | - echo ' |
|
| 2112 | + if (!empty($incontext['error'])) { |
|
| 2113 | + echo ' |
|
| 2008 | 2114 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2009 | 2115 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2010 | 2116 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2012,9 +2118,10 @@ discard block |
||
| 2012 | 2118 | ', $incontext['error'], ' |
| 2013 | 2119 | </div> |
| 2014 | 2120 | </div>'; |
| 2121 | + } |
|
| 2015 | 2122 | // A warning message? |
| 2016 | - elseif (!empty($incontext['warning'])) |
|
| 2017 | - echo ' |
|
| 2123 | + elseif (!empty($incontext['warning'])) { |
|
| 2124 | + echo ' |
|
| 2018 | 2125 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2019 | 2126 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2020 | 2127 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2022,6 +2129,7 @@ discard block |
||
| 2022 | 2129 | ', $incontext['warning'], ' |
| 2023 | 2130 | </div> |
| 2024 | 2131 | </div>'; |
| 2132 | + } |
|
| 2025 | 2133 | |
| 2026 | 2134 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2027 | 2135 | } |
@@ -2037,27 +2145,30 @@ discard block |
||
| 2037 | 2145 | <li>', $incontext['failed_files']), '</li> |
| 2038 | 2146 | </ul>'; |
| 2039 | 2147 | |
| 2040 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2041 | - echo ' |
|
| 2148 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2149 | + echo ' |
|
| 2042 | 2150 | <hr> |
| 2043 | 2151 | <p>', $txt['chmod_linux_info'], '</p> |
| 2044 | 2152 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2153 | + } |
|
| 2045 | 2154 | |
| 2046 | 2155 | // This is serious! |
| 2047 | - if (!template_warning_divs()) |
|
| 2048 | - return; |
|
| 2156 | + if (!template_warning_divs()) { |
|
| 2157 | + return; |
|
| 2158 | + } |
|
| 2049 | 2159 | |
| 2050 | 2160 | echo ' |
| 2051 | 2161 | <hr> |
| 2052 | 2162 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2053 | 2163 | |
| 2054 | - if (!empty($incontext['ftp_errors'])) |
|
| 2055 | - echo ' |
|
| 2164 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2165 | + echo ' |
|
| 2056 | 2166 | <div class="error_message"> |
| 2057 | 2167 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2058 | 2168 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2059 | 2169 | </div> |
| 2060 | 2170 | <br>'; |
| 2171 | + } |
|
| 2061 | 2172 | |
| 2062 | 2173 | echo ' |
| 2063 | 2174 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2117,17 +2228,17 @@ discard block |
||
| 2117 | 2228 | <td> |
| 2118 | 2229 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2119 | 2230 | |
| 2120 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2121 | - echo ' |
|
| 2231 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2232 | + echo ' |
|
| 2122 | 2233 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2234 | + } |
|
| 2123 | 2235 | |
| 2124 | 2236 | echo ' |
| 2125 | 2237 | </select> |
| 2126 | 2238 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2127 | 2239 | </td> |
| 2128 | 2240 | </tr>'; |
| 2129 | - } |
|
| 2130 | - else |
|
| 2241 | + } else |
|
| 2131 | 2242 | { |
| 2132 | 2243 | echo ' |
| 2133 | 2244 | <tr style="display: none;"> |
@@ -2319,9 +2430,10 @@ discard block |
||
| 2319 | 2430 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2320 | 2431 | <ul>'; |
| 2321 | 2432 | |
| 2322 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2323 | - echo ' |
|
| 2433 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2434 | + echo ' |
|
| 2324 | 2435 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2436 | + } |
|
| 2325 | 2437 | |
| 2326 | 2438 | echo ' |
| 2327 | 2439 | </ul>'; |
@@ -2382,15 +2494,16 @@ discard block |
||
| 2382 | 2494 | </tr> |
| 2383 | 2495 | </table>'; |
| 2384 | 2496 | |
| 2385 | - if ($incontext['require_db_confirm']) |
|
| 2386 | - echo ' |
|
| 2497 | + if ($incontext['require_db_confirm']) { |
|
| 2498 | + echo ' |
|
| 2387 | 2499 | <h2>', $txt['user_settings_database'], '</h2> |
| 2388 | 2500 | <p>', $txt['user_settings_database_info'], '</p> |
| 2389 | 2501 | |
| 2390 | 2502 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2391 | 2503 | <input type="password" name="password3" size="30" class="input_password" /> |
| 2392 | 2504 | </div>'; |
| 2393 | -} |
|
| 2505 | + } |
|
| 2506 | + } |
|
| 2394 | 2507 | |
| 2395 | 2508 | // Tell them it's done, and to delete. |
| 2396 | 2509 | function template_delete_install() |
@@ -2403,14 +2516,15 @@ discard block |
||
| 2403 | 2516 | template_warning_divs(); |
| 2404 | 2517 | |
| 2405 | 2518 | // Install directory still writable? |
| 2406 | - if ($incontext['dir_still_writable']) |
|
| 2407 | - echo ' |
|
| 2519 | + if ($incontext['dir_still_writable']) { |
|
| 2520 | + echo ' |
|
| 2408 | 2521 | <em>', $txt['still_writable'], '</em><br> |
| 2409 | 2522 | <br>'; |
| 2523 | + } |
|
| 2410 | 2524 | |
| 2411 | 2525 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2412 | - if ($incontext['probably_delete_install']) |
|
| 2413 | - echo ' |
|
| 2526 | + if ($incontext['probably_delete_install']) { |
|
| 2527 | + echo ' |
|
| 2414 | 2528 | <div style="margin: 1ex; font-weight: bold;"> |
| 2415 | 2529 | <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> |
| 2416 | 2530 | </div> |
@@ -2426,6 +2540,7 @@ discard block |
||
| 2426 | 2540 | } |
| 2427 | 2541 | </script> |
| 2428 | 2542 | <br>'; |
| 2543 | + } |
|
| 2429 | 2544 | |
| 2430 | 2545 | echo ' |
| 2431 | 2546 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |