@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | )); |
75 | 77 | |
76 | 78 | // Old school or no school? |
77 | - if ($request) |
|
78 | - return $request; |
|
79 | + if ($request) { |
|
80 | + return $request; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
99 | 102 | foreach ($create as $k => $l) |
100 | 103 | { |
101 | 104 | // Get the name of the auto_increment column. |
102 | - if (strpos($l, 'auto_increment')) |
|
103 | - $auto_inc = trim($l); |
|
105 | + if (strpos($l, 'auto_increment')) { |
|
106 | + $auto_inc = trim($l); |
|
107 | + } |
|
104 | 108 | |
105 | 109 | // For the engine type, see if we can work out what it is. |
106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
108 | 112 | // Extract the engine type. |
109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
110 | 114 | |
111 | - if (!empty($match[1])) |
|
112 | - $engine = $match[1]; |
|
115 | + if (!empty($match[1])) { |
|
116 | + $engine = $match[1]; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!empty($match[2])) |
|
115 | - $engine = $match[2]; |
|
119 | + if (!empty($match[2])) { |
|
120 | + $engine = $match[2]; |
|
121 | + } |
|
116 | 122 | |
117 | - if (!empty($match[5])) |
|
118 | - $charset = $match[5]; |
|
123 | + if (!empty($match[5])) { |
|
124 | + $charset = $match[5]; |
|
125 | + } |
|
119 | 126 | |
120 | - if (!empty($match[7])) |
|
121 | - $collate = $match[7]; |
|
127 | + if (!empty($match[7])) { |
|
128 | + $collate = $match[7]; |
|
129 | + } |
|
122 | 130 | } |
123 | 131 | |
124 | 132 | // Skip everything but keys... |
125 | - if (strpos($l, 'KEY') === false) |
|
126 | - unset($create[$k]); |
|
133 | + if (strpos($l, 'KEY') === false) { |
|
134 | + unset($create[$k]); |
|
135 | + } |
|
127 | 136 | } |
128 | 137 | |
129 | - if (!empty($create)) |
|
130 | - $create = '( |
|
138 | + if (!empty($create)) { |
|
139 | + $create = '( |
|
131 | 140 | ' . implode(' |
132 | 141 | ', $create) . ')'; |
133 | - else |
|
134 | - $create = ''; |
|
142 | + } else { |
|
143 | + $create = ''; |
|
144 | + } |
|
135 | 145 | |
136 | 146 | $request = $smcFunc['db_query']('', ' |
137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
150 | 160 | |
151 | 161 | if ($auto_inc != '') |
152 | 162 | { |
153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | $smcFunc['db_query']('', ' |
157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
195 | 206 | 'table' => $table, |
196 | 207 | ) |
197 | 208 | ); |
198 | - if (!$request) |
|
199 | - return -1; |
|
209 | + if (!$request) { |
|
210 | + return -1; |
|
211 | + } |
|
200 | 212 | |
201 | 213 | // How much left? |
202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
239 | 251 | ) |
240 | 252 | ); |
241 | 253 | $tables = array(); |
242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
243 | - $tables[] = $row[0]; |
|
254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
255 | + $tables[] = $row[0]; |
|
256 | + } |
|
244 | 257 | $smcFunc['db_free_result']($request); |
245 | 258 | |
246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
285 | 298 | { |
286 | 299 | // Make a special case of auto-timestamp. |
287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
302 | + } |
|
289 | 303 | // Text shouldn't have a default. |
290 | 304 | elseif ($row['Default'] !== null) |
291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
320 | 334 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
321 | 335 | |
322 | 336 | // Is this the first column in the index? |
323 | - if (empty($indexes[$row['Key_name']])) |
|
324 | - $indexes[$row['Key_name']] = array(); |
|
337 | + if (empty($indexes[$row['Key_name']])) { |
|
338 | + $indexes[$row['Key_name']] = array(); |
|
339 | + } |
|
325 | 340 | |
326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
327 | - if (!empty($row['Sub_part'])) |
|
328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
329 | - else |
|
330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
342 | + if (!empty($row['Sub_part'])) { |
|
343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
344 | + } else { |
|
345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
346 | + } |
|
331 | 347 | } |
332 | 348 | $smcFunc['db_free_result']($result); |
333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
365 | 381 | { |
366 | 382 | static $ver; |
367 | 383 | |
368 | - if (!empty($ver)) |
|
369 | - return $ver; |
|
384 | + if (!empty($ver)) { |
|
385 | + return $ver; |
|
386 | + } |
|
370 | 387 | |
371 | 388 | global $smcFunc; |
372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
391 | 408 | global $smcFunc; |
392 | 409 | static $db_type; |
393 | 410 | |
394 | - if (!empty($db_type)) |
|
395 | - return $db_type; |
|
411 | + if (!empty($db_type)) { |
|
412 | + return $db_type; |
|
413 | + } |
|
396 | 414 | |
397 | 415 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
398 | 416 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -401,13 +419,15 @@ discard block |
||
401 | 419 | // Skip these if we don't have a comment. |
402 | 420 | if (!empty($comment)) |
403 | 421 | { |
404 | - if (stripos($comment, 'percona') !== false) |
|
405 | - return 'Percona'; |
|
406 | - if (stripos($comment, 'mariadb') !== false) |
|
407 | - return 'MariaDB'; |
|
422 | + if (stripos($comment, 'percona') !== false) { |
|
423 | + return 'Percona'; |
|
424 | + } |
|
425 | + if (stripos($comment, 'mariadb') !== false) { |
|
426 | + return 'MariaDB'; |
|
427 | + } |
|
428 | + } else { |
|
429 | + return 'fail'; |
|
408 | 430 | } |
409 | - else |
|
410 | - return 'fail'; |
|
411 | 431 | |
412 | 432 | return 'MySQL'; |
413 | 433 | } |
@@ -27,9 +27,10 @@ discard block |
||
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
29 | 29 | |
30 | - if (!isset($context['old_search'])) |
|
31 | - echo ' |
|
30 | + if (!isset($context['old_search'])) { |
|
31 | + echo ' |
|
32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
33 | + } |
|
33 | 34 | echo ' |
34 | 35 | </h3> |
35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
44 | 45 | foreach ($context['columns'] as $key => $column) |
45 | 46 | { |
46 | 47 | // @TODO maybe find something nicer? |
47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
48 | - continue; |
|
48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
49 | + continue; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // This is a selected column, so underline it or some such. |
51 | - if ($column['selected']) |
|
52 | - echo ' |
|
53 | + if ($column['selected']) { |
|
54 | + echo ' |
|
53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
57 | + } |
|
55 | 58 | |
56 | 59 | // This is just some column... show the link and be done with it. |
57 | - else |
|
58 | - echo ' |
|
60 | + else { |
|
61 | + echo ' |
|
59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
60 | 63 | ', $column['link'], '</th>'; |
64 | + } |
|
61 | 65 | } |
62 | 66 | |
63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
77 | 81 | </td> |
78 | 82 | <td class="lefttext">', $member['link'], '</td>'; |
79 | 83 | |
80 | - if (!isset($context['disabled_fields']['website'])) |
|
81 | - echo ' |
|
84 | + if (!isset($context['disabled_fields']['website'])) { |
|
85 | + echo ' |
|
82 | 86 | <td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
87 | + } |
|
83 | 88 | |
84 | 89 | // Group and date. |
85 | 90 | echo ' |
@@ -92,32 +97,35 @@ discard block |
||
92 | 97 | <td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td> |
93 | 98 | <td class="centertext statsbar" style="width: 120px">'; |
94 | 99 | |
95 | - if (!empty($member['post_percent'])) |
|
96 | - echo ' |
|
100 | + if (!empty($member['post_percent'])) { |
|
101 | + echo ' |
|
97 | 102 | <div class="bar" style="width: ', $member['post_percent'] + 4, 'px;"> |
98 | 103 | <div style="width: ', $member['post_percent'], 'px;"></div> |
99 | 104 | </div>'; |
105 | + } |
|
100 | 106 | |
101 | 107 | echo ' |
102 | 108 | </td>'; |
103 | 109 | } |
104 | 110 | |
105 | 111 | // Show custom fields marked to be shown here |
106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
108 | 114 | echo ' |
109 | 115 | <td class="righttext">', $member['options'][$key], '</td>'; |
116 | + } |
|
110 | 117 | |
111 | 118 | echo ' |
112 | 119 | </tr>'; |
113 | 120 | } |
114 | 121 | } |
115 | 122 | // No members? |
116 | - else |
|
117 | - echo ' |
|
123 | + else { |
|
124 | + echo ' |
|
118 | 125 | <tr> |
119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
120 | 127 | </tr>'; |
128 | + } |
|
121 | 129 | |
122 | 130 | echo ' |
123 | 131 | </tbody> |
@@ -130,11 +138,12 @@ discard block |
||
130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
131 | 139 | |
132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
133 | - if (isset($context['old_search'])) |
|
134 | - echo ' |
|
141 | + if (isset($context['old_search'])) { |
|
142 | + echo ' |
|
135 | 143 | <div class="buttonlist floatright"> |
136 | 144 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a> |
137 | 145 | </div>'; |
146 | + } |
|
138 | 147 | echo ' |
139 | 148 | </div> |
140 | 149 | </div><!-- #memberlist -->'; |
@@ -174,12 +183,13 @@ discard block |
||
174 | 183 | <dd> |
175 | 184 | <ul>'; |
176 | 185 | |
177 | - foreach ($context['search_fields'] as $id => $title) |
|
178 | - echo ' |
|
186 | + foreach ($context['search_fields'] as $id => $title) { |
|
187 | + echo ' |
|
179 | 188 | <li> |
180 | 189 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
181 | 190 | <label for="fields-', $id, '">', $title, '</label> |
182 | 191 | </li>'; |
192 | + } |
|
183 | 193 | |
184 | 194 | echo ' |
185 | 195 | </ul> |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -98,23 +102,26 @@ discard block |
||
98 | 102 | if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest']) |
99 | 103 | { |
100 | 104 | // First check for 2.1 json-format cookie in $_COOKIE |
101 | - if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) |
|
102 | - list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
105 | + if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) { |
|
106 | + list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
107 | + } |
|
103 | 108 | |
104 | 109 | // Try checking for 2.1 json-format cookie in $_SESSION |
105 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) |
|
106 | - list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
110 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) { |
|
111 | + list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
112 | + } |
|
107 | 113 | |
108 | 114 | // Next, try checking for 2.0 serialized string cookie in $_COOKIE |
109 | - elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) |
|
110 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
115 | + elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) { |
|
116 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION |
113 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
115 | - |
|
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
120 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) { |
|
121 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
122 | + } else { |
|
123 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 127 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +134,11 @@ discard block |
||
127 | 134 | list ($tfamember, $tfasecret, $exp, $domain, $path, $preserve) = $tfadata; |
128 | 135 | |
129 | 136 | // If we're preserving the cookie, reset it with updated salt |
130 | - if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) |
|
131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
132 | - else |
|
133 | - setTFACookie(-3600, 0, ''); |
|
137 | + if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) { |
|
138 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
139 | + } else { |
|
140 | + setTFACookie(-3600, 0, ''); |
|
141 | + } |
|
134 | 142 | } |
135 | 143 | |
136 | 144 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +149,20 @@ discard block |
||
141 | 149 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
142 | 150 | { |
143 | 151 | // Strike! You're outta there! |
144 | - if ($_GET['member'] != $user_info['id']) |
|
145 | - fatal_lang_error('login_cookie_error', false); |
|
152 | + if ($_GET['member'] != $user_info['id']) { |
|
153 | + fatal_lang_error('login_cookie_error', false); |
|
154 | + } |
|
146 | 155 | |
147 | 156 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
148 | 157 | |
149 | 158 | // Some whitelisting for login_url... |
150 | - if (empty($_SESSION['login_url'])) |
|
151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
159 | + if (empty($_SESSION['login_url'])) { |
|
160 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
161 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
153 | 162 | { |
154 | 163 | unset ($_SESSION['login_url']); |
155 | 164 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
156 | - } |
|
157 | - else |
|
165 | + } else |
|
158 | 166 | { |
159 | 167 | // Best not to clutter the session data too much... |
160 | 168 | $temp = $_SESSION['login_url']; |
@@ -165,8 +173,9 @@ discard block |
||
165 | 173 | } |
166 | 174 | |
167 | 175 | // Beyond this point you are assumed to be a guest trying to login. |
168 | - if (!$user_info['is_guest']) |
|
169 | - redirectexit(); |
|
176 | + if (!$user_info['is_guest']) { |
|
177 | + redirectexit(); |
|
178 | + } |
|
170 | 179 | |
171 | 180 | // Are you guessing with a script? |
172 | 181 | checkSession(); |
@@ -174,18 +183,21 @@ discard block |
||
174 | 183 | spamProtection('login'); |
175 | 184 | |
176 | 185 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
177 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
186 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
187 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
188 | + } |
|
179 | 189 | |
180 | 190 | // Been guessing a lot, haven't we? |
181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
191 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
192 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
193 | + } |
|
183 | 194 | |
184 | 195 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
186 | - $modSettings['cookieTime'] = 3153600; |
|
187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
196 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
197 | + $modSettings['cookieTime'] = 3153600; |
|
198 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
199 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
200 | + } |
|
189 | 201 | |
190 | 202 | loadLanguage('Login'); |
191 | 203 | // Load the template stuff. |
@@ -305,8 +317,9 @@ discard block |
||
305 | 317 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
306 | 318 | |
307 | 319 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
320 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
321 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
322 | + } |
|
310 | 323 | |
311 | 324 | // phpBB3 users new hashing. We now support it as well ;). |
312 | 325 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +339,29 @@ discard block |
||
326 | 339 | // Some common md5 ones. |
327 | 340 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
328 | 341 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
329 | - } |
|
330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
342 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
331 | 343 | { |
332 | 344 | // Maybe they are using a hash from before the password fix. |
333 | 345 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
334 | 346 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
335 | 347 | |
336 | 348 | // BurningBoard3 style of hashing. |
337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
349 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
350 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
351 | + } |
|
339 | 352 | |
340 | 353 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
341 | 354 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
342 | 355 | { |
343 | 356 | // Try iconv first, for no particular reason. |
344 | - if (function_exists('iconv')) |
|
345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
357 | + if (function_exists('iconv')) { |
|
358 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
359 | + } |
|
346 | 360 | |
347 | 361 | // Say it aint so, iconv failed! |
348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
349 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
362 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
363 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
364 | + } |
|
350 | 365 | } |
351 | 366 | } |
352 | 367 | |
@@ -376,8 +391,9 @@ discard block |
||
376 | 391 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
377 | 392 | |
378 | 393 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
380 | - redirectexit('action=reminder'); |
|
394 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
395 | + redirectexit('action=reminder'); |
|
396 | + } |
|
381 | 397 | // We'll give you another chance... |
382 | 398 | else |
383 | 399 | { |
@@ -388,8 +404,7 @@ discard block |
||
388 | 404 | return; |
389 | 405 | } |
390 | 406 | } |
391 | - } |
|
392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
407 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
393 | 408 | { |
394 | 409 | // Let's be sure they weren't a little hacker. |
395 | 410 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +421,9 @@ discard block |
||
406 | 421 | } |
407 | 422 | |
408 | 423 | // Check their activation status. |
409 | - if (!checkActivation()) |
|
410 | - return; |
|
424 | + if (!checkActivation()) { |
|
425 | + return; |
|
426 | + } |
|
411 | 427 | |
412 | 428 | DoLogin(); |
413 | 429 | } |
@@ -419,8 +435,9 @@ discard block |
||
419 | 435 | { |
420 | 436 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
421 | 437 | |
422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
423 | - fatal_lang_error('no_access', false); |
|
438 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
439 | + fatal_lang_error('no_access', false); |
|
440 | + } |
|
424 | 441 | |
425 | 442 | loadLanguage('Profile'); |
426 | 443 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +445,9 @@ discard block |
||
428 | 445 | $member = $context['tfa_member']; |
429 | 446 | |
430 | 447 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
431 | - if (time() - $member['last_login'] < 120) |
|
432 | - fatal_lang_error('tfa_wait', false); |
|
448 | + if (time() - $member['last_login'] < 120) { |
|
449 | + fatal_lang_error('tfa_wait', false); |
|
450 | + } |
|
433 | 451 | |
434 | 452 | $totp = new \TOTP\Auth($member['tfa_secret']); |
435 | 453 | $totp->setRange(1); |
@@ -443,8 +461,9 @@ discard block |
||
443 | 461 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
444 | 462 | { |
445 | 463 | // Check to ensure we're forcing SSL for authentication |
446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
447 | - fatal_lang_error('login_ssl_required'); |
|
464 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
465 | + fatal_lang_error('login_ssl_required'); |
|
466 | + } |
|
448 | 467 | |
449 | 468 | $code = $_POST['tfa_code']; |
450 | 469 | |
@@ -454,20 +473,19 @@ discard block |
||
454 | 473 | |
455 | 474 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
456 | 475 | redirectexit(); |
457 | - } |
|
458 | - else |
|
476 | + } else |
|
459 | 477 | { |
460 | 478 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
461 | 479 | |
462 | 480 | $context['tfa_error'] = true; |
463 | 481 | $context['tfa_value'] = $_POST['tfa_code']; |
464 | 482 | } |
465 | - } |
|
466 | - elseif (!empty($_POST['tfa_backup'])) |
|
483 | + } elseif (!empty($_POST['tfa_backup'])) |
|
467 | 484 | { |
468 | 485 | // Check to ensure we're forcing SSL for authentication |
469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
470 | - fatal_lang_error('login_ssl_required'); |
|
486 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
487 | + fatal_lang_error('login_ssl_required'); |
|
488 | + } |
|
471 | 489 | |
472 | 490 | $backup = $_POST['tfa_backup']; |
473 | 491 | |
@@ -481,8 +499,7 @@ discard block |
||
481 | 499 | )); |
482 | 500 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
483 | 501 | redirectexit('action=profile;area=tfasetup;backup'); |
484 | - } |
|
485 | - else |
|
502 | + } else |
|
486 | 503 | { |
487 | 504 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
488 | 505 | |
@@ -505,8 +522,9 @@ discard block |
||
505 | 522 | { |
506 | 523 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
507 | 524 | |
508 | - if (!isset($context['login_errors'])) |
|
509 | - $context['login_errors'] = array(); |
|
525 | + if (!isset($context['login_errors'])) { |
|
526 | + $context['login_errors'] = array(); |
|
527 | + } |
|
510 | 528 | |
511 | 529 | // What is the true activation status of this account? |
512 | 530 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +536,9 @@ discard block |
||
518 | 536 | return false; |
519 | 537 | } |
520 | 538 | // Awaiting approval still? |
521 | - elseif ($activation_status == 3) |
|
522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
539 | + elseif ($activation_status == 3) { |
|
540 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
541 | + } |
|
523 | 542 | // Awaiting deletion, changed their mind? |
524 | 543 | elseif ($activation_status == 4) |
525 | 544 | { |
@@ -527,8 +546,7 @@ discard block |
||
527 | 546 | { |
528 | 547 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
529 | 548 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
530 | - } |
|
531 | - else |
|
549 | + } else |
|
532 | 550 | { |
533 | 551 | $context['disable_login_hashing'] = true; |
534 | 552 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +586,9 @@ discard block |
||
568 | 586 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
569 | 587 | |
570 | 588 | // Reset the login threshold. |
571 | - if (isset($_SESSION['failed_login'])) |
|
572 | - unset($_SESSION['failed_login']); |
|
589 | + if (isset($_SESSION['failed_login'])) { |
|
590 | + unset($_SESSION['failed_login']); |
|
591 | + } |
|
573 | 592 | |
574 | 593 | $user_info['is_guest'] = false; |
575 | 594 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +610,18 @@ discard block |
||
591 | 610 | 'id_member' => $user_info['id'], |
592 | 611 | ) |
593 | 612 | ); |
594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
595 | - $_SESSION['first_login'] = true; |
|
596 | - else |
|
597 | - unset($_SESSION['first_login']); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
614 | + $_SESSION['first_login'] = true; |
|
615 | + } else { |
|
616 | + unset($_SESSION['first_login']); |
|
617 | + } |
|
598 | 618 | $smcFunc['db_free_result']($request); |
599 | 619 | |
600 | 620 | // You've logged in, haven't you? |
601 | 621 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
602 | - if (empty($user_settings['tfa_secret'])) |
|
603 | - $update['last_login'] = time(); |
|
622 | + if (empty($user_settings['tfa_secret'])) { |
|
623 | + $update['last_login'] = time(); |
|
624 | + } |
|
604 | 625 | updateMemberData($user_info['id'], $update); |
605 | 626 | |
606 | 627 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +635,8 @@ discard block |
||
614 | 635 | $_SESSION['log_time'] = 0; |
615 | 636 | |
616 | 637 | // Log this entry, only if we have it enabled. |
617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
618 | - $smcFunc['db_insert']('insert', |
|
638 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
639 | + $smcFunc['db_insert']('insert', |
|
619 | 640 | '{db_prefix}member_logins', |
620 | 641 | array( |
621 | 642 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +648,15 @@ discard block |
||
627 | 648 | 'id_member', 'time' |
628 | 649 | ) |
629 | 650 | ); |
651 | + } |
|
630 | 652 | |
631 | 653 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
634 | - else |
|
635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
636 | -} |
|
654 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
655 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
656 | + } else { |
|
657 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
658 | + } |
|
659 | + } |
|
637 | 660 | |
638 | 661 | /** |
639 | 662 | * Logs the current user out of their account. |
@@ -649,13 +672,15 @@ discard block |
||
649 | 672 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
650 | 673 | |
651 | 674 | // Make sure they aren't being auto-logged out. |
652 | - if (!$internal) |
|
653 | - checkSession('get'); |
|
675 | + if (!$internal) { |
|
676 | + checkSession('get'); |
|
677 | + } |
|
654 | 678 | |
655 | 679 | require_once($sourcedir . '/Subs-Auth.php'); |
656 | 680 | |
657 | - if (isset($_SESSION['pack_ftp'])) |
|
658 | - $_SESSION['pack_ftp'] = null; |
|
681 | + if (isset($_SESSION['pack_ftp'])) { |
|
682 | + $_SESSION['pack_ftp'] = null; |
|
683 | + } |
|
659 | 684 | |
660 | 685 | // It won't be first login anymore. |
661 | 686 | unset($_SESSION['first_login']); |
@@ -683,8 +708,9 @@ discard block |
||
683 | 708 | |
684 | 709 | // And some other housekeeping while we're at it. |
685 | 710 | $salt = substr(md5(mt_rand()), 0, 4); |
686 | - if (!empty($user_info['id'])) |
|
687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
711 | + if (!empty($user_info['id'])) { |
|
712 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
713 | + } |
|
688 | 714 | |
689 | 715 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
690 | 716 | { |
@@ -693,10 +719,11 @@ discard block |
||
693 | 719 | list ($tfamember, $tfasecret, $exp, $domain, $path, $preserve) = $tfadata; |
694 | 720 | |
695 | 721 | // If we're preserving the cookie, reset it with updated salt |
696 | - if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) |
|
697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
698 | - else |
|
699 | - setTFACookie(-3600, 0, ''); |
|
722 | + if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) { |
|
723 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
724 | + } else { |
|
725 | + setTFACookie(-3600, 0, ''); |
|
726 | + } |
|
700 | 727 | } |
701 | 728 | |
702 | 729 | session_destroy(); |
@@ -704,14 +731,13 @@ discard block |
||
704 | 731 | // Off to the merry board index we go! |
705 | 732 | if ($redirect) |
706 | 733 | { |
707 | - if (empty($_SESSION['logout_url'])) |
|
708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
734 | + if (empty($_SESSION['logout_url'])) { |
|
735 | + redirectexit('', $context['server']['needs_login_fix']); |
|
736 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
710 | 737 | { |
711 | 738 | unset ($_SESSION['logout_url']); |
712 | 739 | redirectexit(); |
713 | - } |
|
714 | - else |
|
740 | + } else |
|
715 | 741 | { |
716 | 742 | $temp = $_SESSION['logout_url']; |
717 | 743 | unset($_SESSION['logout_url']); |
@@ -744,8 +770,9 @@ discard block |
||
744 | 770 | function phpBB3_password_check($passwd, $passwd_hash) |
745 | 771 | { |
746 | 772 | // Too long or too short? |
747 | - if (strlen($passwd_hash) != 34) |
|
748 | - return; |
|
773 | + if (strlen($passwd_hash) != 34) { |
|
774 | + return; |
|
775 | + } |
|
749 | 776 | |
750 | 777 | // Range of characters allowed. |
751 | 778 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +783,9 @@ discard block |
||
756 | 783 | $salt = substr($passwd_hash, 4, 8); |
757 | 784 | |
758 | 785 | $hash = md5($salt . $passwd, true); |
759 | - for (; $count != 0; --$count) |
|
760 | - $hash = md5($hash . $passwd, true); |
|
786 | + for (; $count != 0; --$count) { |
|
787 | + $hash = md5($hash . $passwd, true); |
|
788 | + } |
|
761 | 789 | |
762 | 790 | $output = substr($passwd_hash, 0, 12); |
763 | 791 | $i = 0; |
@@ -766,21 +794,25 @@ discard block |
||
766 | 794 | $value = ord($hash[$i++]); |
767 | 795 | $output .= $range[$value & 0x3f]; |
768 | 796 | |
769 | - if ($i < 16) |
|
770 | - $value |= ord($hash[$i]) << 8; |
|
797 | + if ($i < 16) { |
|
798 | + $value |= ord($hash[$i]) << 8; |
|
799 | + } |
|
771 | 800 | |
772 | 801 | $output .= $range[($value >> 6) & 0x3f]; |
773 | 802 | |
774 | - if ($i++ >= 16) |
|
775 | - break; |
|
803 | + if ($i++ >= 16) { |
|
804 | + break; |
|
805 | + } |
|
776 | 806 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 16; |
|
807 | + if ($i < 16) { |
|
808 | + $value |= ord($hash[$i]) << 16; |
|
809 | + } |
|
779 | 810 | |
780 | 811 | $output .= $range[($value >> 12) & 0x3f]; |
781 | 812 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
813 | + if ($i++ >= 16) { |
|
814 | + break; |
|
815 | + } |
|
784 | 816 | |
785 | 817 | $output .= $range[($value >> 18) & 0x3f]; |
786 | 818 | } |
@@ -812,8 +844,9 @@ discard block |
||
812 | 844 | require_once($sourcedir . '/Subs-Auth.php'); |
813 | 845 | setLoginCookie(-3600, 0); |
814 | 846 | |
815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
816 | - unset($_SESSION['login_' . $cookiename]); |
|
847 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
848 | + unset($_SESSION['login_' . $cookiename]); |
|
849 | + } |
|
817 | 850 | } |
818 | 851 | |
819 | 852 | // We need a member! |
@@ -827,8 +860,9 @@ discard block |
||
827 | 860 | } |
828 | 861 | |
829 | 862 | // Right, have we got a flood value? |
830 | - if ($password_flood_value !== false) |
|
831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
863 | + if ($password_flood_value !== false) { |
|
864 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
865 | + } |
|
832 | 866 | |
833 | 867 | // Timestamp or number of tries invalid? |
834 | 868 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +878,17 @@ discard block |
||
844 | 878 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
845 | 879 | |
846 | 880 | // They are trying too fast, make them wait longer |
847 | - if ($time_stamp < time() - 10) |
|
848 | - $time_stamp = time(); |
|
881 | + if ($time_stamp < time() - 10) { |
|
882 | + $time_stamp = time(); |
|
883 | + } |
|
849 | 884 | } |
850 | 885 | |
851 | 886 | $number_tries++; |
852 | 887 | |
853 | 888 | // Broken the law? |
854 | - if ($number_tries > 5) |
|
855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
889 | + if ($number_tries > 5) { |
|
890 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
891 | + } |
|
856 | 892 | |
857 | 893 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
858 | 894 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -37,9 +37,10 @@ discard block |
||
37 | 37 | echo ' |
38 | 38 | <optgroup label="', $category['name'], '">'; |
39 | 39 | |
40 | - foreach ($category['boards'] as $board) |
|
41 | - echo ' |
|
40 | + foreach ($category['boards'] as $board) { |
|
41 | + echo ' |
|
42 | 42 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=> ' : '', $board['name'], '</option>'; |
43 | + } |
|
43 | 44 | echo ' |
44 | 45 | </optgroup>'; |
45 | 46 | } |
@@ -70,9 +71,10 @@ discard block |
||
70 | 71 | </div><!-- .move_topic --> |
71 | 72 | </div><!-- .windowbg -->'; |
72 | 73 | |
73 | - if ($context['back_to_topic']) |
|
74 | - echo ' |
|
74 | + if ($context['back_to_topic']) { |
|
75 | + echo ' |
|
75 | 76 | <input type="hidden" name="goback" value="1">'; |
77 | + } |
|
76 | 78 | |
77 | 79 | echo ' |
78 | 80 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -125,10 +127,10 @@ discard block |
||
125 | 127 | <option value="86400">', $txt['two_months'], '</option> |
126 | 128 | </select> |
127 | 129 | </dd>'; |
128 | - } |
|
129 | - else |
|
130 | - echo ' |
|
130 | + } else { |
|
131 | + echo ' |
|
131 | 132 | <input type="hidden" name="redirect_expires" value="0">'; |
133 | + } |
|
132 | 134 | |
133 | 135 | echo ' |
134 | 136 | </dl> |
@@ -207,9 +209,10 @@ discard block |
||
207 | 209 | echo ' |
208 | 210 | <optgroup label="', $cat['name'], '">'; |
209 | 211 | |
210 | - foreach ($cat['boards'] as $board) |
|
211 | - echo ' |
|
212 | + foreach ($cat['boards'] as $board) { |
|
213 | + echo ' |
|
212 | 214 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
215 | + } |
|
213 | 216 | |
214 | 217 | echo ' |
215 | 218 | </optgroup>'; |
@@ -220,9 +223,9 @@ discard block |
||
220 | 223 | <input type="submit" value="', $txt['go'], '" class="button"> |
221 | 224 | </form>'; |
222 | 225 | |
226 | + } else { |
|
227 | + echo $txt['target_below']; |
|
223 | 228 | } |
224 | - else |
|
225 | - echo $txt['target_below']; |
|
226 | 229 | |
227 | 230 | echo ' </h4> |
228 | 231 | </div><!-- .title_bar --> |
@@ -240,12 +243,13 @@ discard block |
||
240 | 243 | |
241 | 244 | $merge_button = create_button('merge', 'merge', ''); |
242 | 245 | |
243 | - foreach ($context['topics'] as $topic) |
|
244 | - echo ' |
|
246 | + foreach ($context['topics'] as $topic) { |
|
247 | + echo ' |
|
245 | 248 | <li> |
246 | 249 | <a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a> |
247 | 250 | <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], ' |
248 | 251 | </li>'; |
252 | + } |
|
249 | 253 | |
250 | 254 | echo ' |
251 | 255 | </ul> |
@@ -256,9 +260,10 @@ discard block |
||
256 | 260 | </div>'; |
257 | 261 | } |
258 | 262 | // Just a nice "There aren't any topics" message |
259 | - else |
|
260 | - echo ' |
|
263 | + else { |
|
264 | + echo ' |
|
261 | 265 | <div class="windowbg2">', $txt['topic_alert_none'], '</div>'; |
266 | + } |
|
262 | 267 | |
263 | 268 | echo ' |
264 | 269 | <br> |
@@ -308,8 +313,8 @@ discard block |
||
308 | 313 | </thead> |
309 | 314 | <tbody>'; |
310 | 315 | |
311 | - foreach ($context['topics'] as $topic) |
|
312 | - echo ' |
|
316 | + foreach ($context['topics'] as $topic) { |
|
317 | + echo ' |
|
313 | 318 | <tr class="windowbg"> |
314 | 319 | <td> |
315 | 320 | <input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked> |
@@ -329,6 +334,7 @@ discard block |
||
329 | 334 | <input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked> |
330 | 335 | </td> |
331 | 336 | </tr>'; |
337 | + } |
|
332 | 338 | echo ' |
333 | 339 | </tbody> |
334 | 340 | </table> |
@@ -338,9 +344,10 @@ discard block |
||
338 | 344 | <legend>', $txt['merge_select_subject'], '</legend> |
339 | 345 | <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">'; |
340 | 346 | |
341 | - foreach ($context['topics'] as $topic) |
|
342 | - echo ' |
|
347 | + foreach ($context['topics'] as $topic) { |
|
348 | + echo ' |
|
343 | 349 | <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>'; |
350 | + } |
|
344 | 351 | echo ' |
345 | 352 | <option value="0">', $txt['merge_custom_subject'], ':</option> |
346 | 353 | </select> |
@@ -359,11 +366,12 @@ discard block |
||
359 | 366 | <legend>', $txt['merge_select_target_board'], '</legend> |
360 | 367 | <ul>'; |
361 | 368 | |
362 | - foreach ($context['boards'] as $board) |
|
363 | - echo ' |
|
369 | + foreach ($context['boards'] as $board) { |
|
370 | + echo ' |
|
364 | 371 | <li> |
365 | 372 | <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . ' |
366 | 373 | </li>'; |
374 | + } |
|
367 | 375 | echo ' |
368 | 376 | </ul> |
369 | 377 | </fieldset>'; |
@@ -375,11 +383,12 @@ discard block |
||
375 | 383 | <legend>' . $txt['merge_select_poll'] . '</legend> |
376 | 384 | <ul>'; |
377 | 385 | |
378 | - foreach ($context['polls'] as $poll) |
|
379 | - echo ' |
|
386 | + foreach ($context['polls'] as $poll) { |
|
387 | + echo ' |
|
380 | 388 | <li> |
381 | 389 | <input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>) |
382 | 390 | </li>'; |
391 | + } |
|
383 | 392 | echo ' |
384 | 393 | <li> |
385 | 394 | <input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ') |
@@ -53,14 +53,15 @@ discard block |
||
53 | 53 | foreach ($context['smileys'] as $location => $smileyRows) |
54 | 54 | { |
55 | 55 | $countLocations--; |
56 | - if ($location == 'postform') |
|
57 | - echo ' |
|
56 | + if ($location == 'postform') { |
|
57 | + echo ' |
|
58 | 58 | dropdown: |
59 | 59 | {'; |
60 | - elseif ($location == 'popup') |
|
61 | - echo ' |
|
60 | + } elseif ($location == 'popup') { |
|
61 | + echo ' |
|
62 | 62 | popup: |
63 | 63 | {'; |
64 | + } |
|
64 | 65 | |
65 | 66 | $numRows = count($smileyRows); |
66 | 67 | |
@@ -68,25 +69,27 @@ discard block |
||
68 | 69 | $emptyPlaceholder = 0; |
69 | 70 | foreach ($smileyRows as $smileyRow) |
70 | 71 | { |
71 | - foreach ($smileyRow['smileys'] as $smiley) |
|
72 | - echo ' |
|
72 | + foreach ($smileyRow['smileys'] as $smiley) { |
|
73 | + echo ' |
|
73 | 74 | ', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : ''; |
75 | + } |
|
74 | 76 | |
75 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
76 | - echo ', |
|
77 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
78 | + echo ', |
|
77 | 79 | \'-', $emptyPlaceholder++, '\': \'\','; |
80 | + } |
|
78 | 81 | } |
79 | 82 | echo ' |
80 | 83 | }', $countLocations != 0 ? ',' : ''; |
81 | 84 | } |
82 | 85 | echo ' |
83 | 86 | }'; |
84 | - } |
|
85 | - else |
|
86 | - echo ', |
|
87 | + } else { |
|
88 | + echo ', |
|
87 | 89 | emoticons: |
88 | 90 | {}, |
89 | 91 | emoticonsEnabled:false'; |
92 | + } |
|
90 | 93 | |
91 | 94 | if ($context['show_bbc'] && $bbcContainer !== null) |
92 | 95 | { |
@@ -100,15 +103,16 @@ discard block |
||
100 | 103 | |
101 | 104 | $count_tags--; |
102 | 105 | |
103 | - if (!empty($count_tags)) |
|
104 | - echo '||'; |
|
106 | + if (!empty($count_tags)) { |
|
107 | + echo '||'; |
|
108 | + } |
|
105 | 109 | } |
106 | 110 | |
107 | 111 | echo '",'; |
108 | - } |
|
109 | - else |
|
110 | - echo ', |
|
112 | + } else { |
|
113 | + echo ', |
|
111 | 114 | toolbar: "",'; |
115 | + } |
|
112 | 116 | |
113 | 117 | echo ' |
114 | 118 | }); |
@@ -150,42 +154,47 @@ discard block |
||
150 | 154 | |
151 | 155 | $tempTab = $context['tabindex']; |
152 | 156 | |
153 | - if (!empty($context['drafts_pm_save'])) |
|
154 | - $tempTab++; |
|
155 | - elseif (!empty($context['drafts_save'])) |
|
156 | - $tempTab++; |
|
157 | - elseif ($editor_context['preview_type']) |
|
158 | - $tempTab++; |
|
159 | - elseif ($context['show_spellchecking']) |
|
160 | - $tempTab++; |
|
157 | + if (!empty($context['drafts_pm_save'])) { |
|
158 | + $tempTab++; |
|
159 | + } elseif (!empty($context['drafts_save'])) { |
|
160 | + $tempTab++; |
|
161 | + } elseif ($editor_context['preview_type']) { |
|
162 | + $tempTab++; |
|
163 | + } elseif ($context['show_spellchecking']) { |
|
164 | + $tempTab++; |
|
165 | + } |
|
161 | 166 | |
162 | 167 | $tempTab++; |
163 | 168 | $context['tabindex'] = $tempTab; |
164 | 169 | |
165 | - if (!empty($context['drafts_pm_save'])) |
|
166 | - echo ' |
|
170 | + if (!empty($context['drafts_pm_save'])) { |
|
171 | + echo ' |
|
167 | 172 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
168 | 173 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
174 | + } |
|
169 | 175 | |
170 | - if (!empty($context['drafts_save'])) |
|
171 | - echo ' |
|
176 | + if (!empty($context['drafts_save'])) { |
|
177 | + echo ' |
|
172 | 178 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button"> |
173 | 179 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
180 | + } |
|
174 | 181 | |
175 | - if ($context['show_spellchecking']) |
|
176 | - echo ' |
|
182 | + if ($context['show_spellchecking']) { |
|
183 | + echo ' |
|
177 | 184 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
185 | + } |
|
178 | 186 | |
179 | - if ($editor_context['preview_type']) |
|
180 | - echo ' |
|
187 | + if ($editor_context['preview_type']) { |
|
188 | + echo ' |
|
181 | 189 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button">'; |
190 | + } |
|
182 | 191 | |
183 | 192 | echo ' |
184 | 193 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">'; |
185 | 194 | |
186 | 195 | // Load in the PM autosaver if it's enabled |
187 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
188 | - echo ' |
|
196 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
197 | + echo ' |
|
189 | 198 | <span class="righttext padding" style="display: block"> |
190 | 199 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
191 | 200 | <span id="draft_lastautosave" ></span> |
@@ -203,10 +212,11 @@ discard block |
||
203 | 212 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
204 | 213 | }); |
205 | 214 | </script>'; |
215 | + } |
|
206 | 216 | |
207 | 217 | // Start an instance of the auto saver if its enabled |
208 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
209 | - echo ' |
|
218 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
219 | + echo ' |
|
210 | 220 | <span class="righttext padding" style="display: block"> |
211 | 221 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
212 | 222 | <span id="draft_lastautosave" ></span> |
@@ -223,7 +233,8 @@ discard block |
||
223 | 233 | iFreq: ', $context['drafts_autosave_frequency'], ' |
224 | 234 | }); |
225 | 235 | </script>'; |
226 | -} |
|
236 | + } |
|
237 | + } |
|
227 | 238 | |
228 | 239 | /** |
229 | 240 | * This template displays a verification form |
@@ -240,51 +251,57 @@ discard block |
||
240 | 251 | $verify_context = &$context['controls']['verification'][$verify_id]; |
241 | 252 | |
242 | 253 | // Keep track of where we are. |
243 | - if (empty($verify_context['tracking']) || $reset) |
|
244 | - $verify_context['tracking'] = 0; |
|
254 | + if (empty($verify_context['tracking']) || $reset) { |
|
255 | + $verify_context['tracking'] = 0; |
|
256 | + } |
|
245 | 257 | |
246 | 258 | // How many items are there to display in total. |
247 | 259 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
248 | 260 | |
249 | 261 | // If we've gone too far, stop. |
250 | - if ($verify_context['tracking'] > $total_items) |
|
251 | - return false; |
|
262 | + if ($verify_context['tracking'] > $total_items) { |
|
263 | + return false; |
|
264 | + } |
|
252 | 265 | |
253 | 266 | // Loop through each item to show them. |
254 | 267 | for ($i = 0; $i < $total_items; $i++) |
255 | 268 | { |
256 | 269 | // If we're after a single item only show it if we're in the right place. |
257 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
258 | - continue; |
|
270 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
271 | + continue; |
|
272 | + } |
|
259 | 273 | |
260 | - if ($display_type != 'single') |
|
261 | - echo ' |
|
274 | + if ($display_type != 'single') { |
|
275 | + echo ' |
|
262 | 276 | <div id="verification_control_', $i, '" class="verification_control">'; |
277 | + } |
|
263 | 278 | |
264 | 279 | // Display empty field, but only if we have one, and it's the first time. |
265 | - if ($verify_context['empty_field'] && empty($i)) |
|
266 | - echo ' |
|
280 | + if ($verify_context['empty_field'] && empty($i)) { |
|
281 | + echo ' |
|
267 | 282 | <div class="smalltext vv_special"> |
268 | 283 | ', $txt['visual_verification_hidden'], ': |
269 | 284 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
270 | 285 | </div>'; |
286 | + } |
|
271 | 287 | |
272 | 288 | // Do the actual stuff |
273 | 289 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
274 | 290 | { |
275 | 291 | if ($verify_context['show_visual']) |
276 | 292 | { |
277 | - if ($context['use_graphic_library']) |
|
278 | - echo ' |
|
293 | + if ($context['use_graphic_library']) { |
|
294 | + echo ' |
|
279 | 295 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
280 | - else |
|
281 | - echo ' |
|
296 | + } else { |
|
297 | + echo ' |
|
282 | 298 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
283 | 299 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
284 | 300 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
285 | 301 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
286 | 302 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
287 | 303 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
304 | + } |
|
288 | 305 | |
289 | 306 | echo ' |
290 | 307 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -302,8 +319,7 @@ discard block |
||
302 | 319 | <br> |
303 | 320 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>'; |
304 | 321 | } |
305 | - } |
|
306 | - else |
|
322 | + } else |
|
307 | 323 | { |
308 | 324 | // Where in the question array is this question? |
309 | 325 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -315,21 +331,24 @@ discard block |
||
315 | 331 | </div>'; |
316 | 332 | } |
317 | 333 | |
318 | - if ($display_type != 'single') |
|
319 | - echo ' |
|
334 | + if ($display_type != 'single') { |
|
335 | + echo ' |
|
320 | 336 | </div><!-- #verification_control_[i] -->'; |
337 | + } |
|
321 | 338 | |
322 | 339 | // If we were displaying just one and we did it, break. |
323 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
324 | - break; |
|
340 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
341 | + break; |
|
342 | + } |
|
325 | 343 | } |
326 | 344 | |
327 | 345 | // Assume we found something, always. |
328 | 346 | $verify_context['tracking']++; |
329 | 347 | |
330 | 348 | // Tell something displaying piecemeal to keep going. |
331 | - if ($display_type == 'single') |
|
332 | - return true; |
|
333 | -} |
|
349 | + if ($display_type == 'single') { |
|
350 | + return true; |
|
351 | + } |
|
352 | + } |
|
334 | 353 | |
335 | 354 | ?> |
336 | 355 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
195 | 202 | $context['print_custom_fields'] = array(); |
196 | 203 | |
197 | 204 | // Any custom profile fields? |
198 | - if (!empty($context['custom_fields'])) |
|
199 | - foreach ($context['custom_fields'] as $custom) |
|
205 | + if (!empty($context['custom_fields'])) { |
|
206 | + foreach ($context['custom_fields'] as $custom) |
|
200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
208 | + } |
|
201 | 209 | |
202 | 210 | } |
203 | 211 | |
@@ -245,16 +253,18 @@ discard block |
||
245 | 253 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
246 | 254 | $alerts[$id_alert] = $row; |
247 | 255 | |
248 | - if (!empty($row['sender_id'])) |
|
249 | - $senders[] = $row['sender_id']; |
|
256 | + if (!empty($row['sender_id'])) { |
|
257 | + $senders[] = $row['sender_id']; |
|
258 | + } |
|
250 | 259 | } |
251 | 260 | $smcFunc['db_free_result']($request); |
252 | 261 | |
253 | 262 | if($withSender) |
254 | 263 | { |
255 | 264 | $senders = loadMemberData($senders); |
256 | - foreach ($senders as $member) |
|
257 | - loadMemberContext($member); |
|
265 | + foreach ($senders as $member) { |
|
266 | + loadMemberContext($member); |
|
267 | + } |
|
258 | 268 | } |
259 | 269 | |
260 | 270 | // Now go through and actually make with the text. |
@@ -269,12 +279,15 @@ discard block |
||
269 | 279 | $msgs = array(); |
270 | 280 | foreach ($alerts as $id_alert => $alert) |
271 | 281 | { |
272 | - if (isset($alert['extra']['board'])) |
|
273 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
274 | - if (isset($alert['extra']['topic'])) |
|
275 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
276 | - if ($alert['content_type'] == 'msg') |
|
277 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
282 | + if (isset($alert['extra']['board'])) { |
|
283 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
284 | + } |
|
285 | + if (isset($alert['extra']['topic'])) { |
|
286 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
287 | + } |
|
288 | + if ($alert['content_type'] == 'msg') { |
|
289 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
290 | + } |
|
278 | 291 | } |
279 | 292 | |
280 | 293 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -289,8 +302,9 @@ discard block |
||
289 | 302 | 'boards' => array_keys($boards), |
290 | 303 | ) |
291 | 304 | ); |
292 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
293 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
305 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
306 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
307 | + } |
|
294 | 308 | } |
295 | 309 | if (!empty($topics)) |
296 | 310 | { |
@@ -305,8 +319,9 @@ discard block |
||
305 | 319 | 'topics' => array_keys($topics), |
306 | 320 | ) |
307 | 321 | ); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
324 | + } |
|
310 | 325 | } |
311 | 326 | if (!empty($msgs)) |
312 | 327 | { |
@@ -321,44 +336,51 @@ discard block |
||
321 | 336 | 'msgs' => array_keys($msgs), |
322 | 337 | ) |
323 | 338 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
339 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
340 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
341 | + } |
|
326 | 342 | } |
327 | 343 | |
328 | 344 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
329 | 345 | foreach ($alerts as $id_alert => $alert) |
330 | 346 | { |
331 | - if (!empty($alert['text'])) |
|
332 | - continue; |
|
333 | - if (isset($alert['extra']['board'])) |
|
334 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
347 | + if (!empty($alert['text'])) { |
|
348 | + continue; |
|
349 | + } |
|
350 | + if (isset($alert['extra']['board'])) { |
|
351 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
335 | 352 | { |
336 | 353 | unset($alerts[$id_alert]); |
354 | + } |
|
337 | 355 | continue; |
356 | + } else { |
|
357 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
338 | 358 | } |
339 | - else |
|
340 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
341 | - if (isset($alert['extra']['topic'])) |
|
342 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
359 | + if (isset($alert['extra']['topic'])) { |
|
360 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
343 | 361 | { |
344 | 362 | unset($alerts[$id_alert]); |
363 | + } |
|
345 | 364 | continue; |
365 | + } else { |
|
366 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
346 | 367 | } |
347 | - else |
|
348 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
349 | - if ($alert['content_type'] == 'msg') |
|
350 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
368 | + if ($alert['content_type'] == 'msg') { |
|
369 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
351 | 370 | { |
352 | 371 | unset($alerts[$id_alert]); |
372 | + } |
|
353 | 373 | continue; |
374 | + } else { |
|
375 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
354 | 376 | } |
355 | - else |
|
356 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
357 | - if ($alert['content_type'] == 'profile') |
|
358 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
377 | + if ($alert['content_type'] == 'profile') { |
|
378 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
379 | + } |
|
359 | 380 | |
360 | - if (!empty($memberContext[$alert['sender_id']])) |
|
361 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
381 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
382 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
383 | + } |
|
362 | 384 | |
363 | 385 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
364 | 386 | if (isset($txt[$string])) |
@@ -446,11 +468,11 @@ discard block |
||
446 | 468 | checkSession('request'); |
447 | 469 | |
448 | 470 | // Call it! |
449 | - if ($action == 'remove') |
|
450 | - alert_delete($toMark, $memID); |
|
451 | - |
|
452 | - else |
|
453 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
471 | + if ($action == 'remove') { |
|
472 | + alert_delete($toMark, $memID); |
|
473 | + } else { |
|
474 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
475 | + } |
|
454 | 476 | |
455 | 477 | // Set a nice update message. |
456 | 478 | $_SESSION['update_message'] = true; |
@@ -500,23 +522,27 @@ discard block |
||
500 | 522 | ); |
501 | 523 | |
502 | 524 | // Set the page title |
503 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
504 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
505 | - else |
|
506 | - $context['page_title'] = $txt['showPosts']; |
|
525 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
526 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
527 | + } else { |
|
528 | + $context['page_title'] = $txt['showPosts']; |
|
529 | + } |
|
507 | 530 | |
508 | 531 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
509 | 532 | |
510 | 533 | // Is the load average too high to allow searching just now? |
511 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
512 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
534 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
535 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
536 | + } |
|
513 | 537 | |
514 | 538 | // If we're specifically dealing with attachments use that function! |
515 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
516 | - return showAttachments($memID); |
|
539 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
540 | + return showAttachments($memID); |
|
541 | + } |
|
517 | 542 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
518 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
519 | - return showUnwatched($memID); |
|
543 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
544 | + return showUnwatched($memID); |
|
545 | + } |
|
520 | 546 | |
521 | 547 | // Are we just viewing topics? |
522 | 548 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -539,27 +565,30 @@ discard block |
||
539 | 565 | $smcFunc['db_free_result']($request); |
540 | 566 | |
541 | 567 | // Trying to remove a message that doesn't exist. |
542 | - if (empty($info)) |
|
543 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
568 | + if (empty($info)) { |
|
569 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
570 | + } |
|
544 | 571 | |
545 | 572 | // We can be lazy, since removeMessage() will check the permissions for us. |
546 | 573 | require_once($sourcedir . '/RemoveTopic.php'); |
547 | 574 | removeMessage((int) $_GET['delete']); |
548 | 575 | |
549 | 576 | // Add it to the mod log. |
550 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
551 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
577 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
578 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
579 | + } |
|
552 | 580 | |
553 | 581 | // Back to... where we are now ;). |
554 | 582 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
555 | 583 | } |
556 | 584 | |
557 | 585 | // Default to 10. |
558 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
559 | - $_REQUEST['viewscount'] = '10'; |
|
586 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
587 | + $_REQUEST['viewscount'] = '10'; |
|
588 | + } |
|
560 | 589 | |
561 | - if ($context['is_topics']) |
|
562 | - $request = $smcFunc['db_query']('', ' |
|
590 | + if ($context['is_topics']) { |
|
591 | + $request = $smcFunc['db_query']('', ' |
|
563 | 592 | SELECT COUNT(*) |
564 | 593 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
565 | 594 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -572,8 +601,8 @@ discard block |
||
572 | 601 | 'board' => $board, |
573 | 602 | ) |
574 | 603 | ); |
575 | - else |
|
576 | - $request = $smcFunc['db_query']('', ' |
|
604 | + } else { |
|
605 | + $request = $smcFunc['db_query']('', ' |
|
577 | 606 | SELECT COUNT(*) |
578 | 607 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
579 | 608 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -586,6 +615,7 @@ discard block |
||
586 | 615 | 'board' => $board, |
587 | 616 | ) |
588 | 617 | ); |
618 | + } |
|
589 | 619 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
590 | 620 | $smcFunc['db_free_result']($request); |
591 | 621 | |
@@ -606,10 +636,11 @@ discard block |
||
606 | 636 | |
607 | 637 | $range_limit = ''; |
608 | 638 | |
609 | - if ($context['is_topics']) |
|
610 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
611 | - else |
|
612 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
639 | + if ($context['is_topics']) { |
|
640 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
641 | + } else { |
|
642 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
643 | + } |
|
613 | 644 | |
614 | 645 | $maxIndex = $maxPerPage; |
615 | 646 | |
@@ -635,9 +666,9 @@ discard block |
||
635 | 666 | { |
636 | 667 | $margin *= 5; |
637 | 668 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
669 | + } else { |
|
670 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
638 | 671 | } |
639 | - else |
|
640 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
641 | 672 | } |
642 | 673 | |
643 | 674 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -669,8 +700,7 @@ discard block |
||
669 | 700 | 'max' => $maxIndex, |
670 | 701 | ) |
671 | 702 | ); |
672 | - } |
|
673 | - else |
|
703 | + } else |
|
674 | 704 | { |
675 | 705 | $request = $smcFunc['db_query']('', ' |
676 | 706 | SELECT |
@@ -699,8 +729,9 @@ discard block |
||
699 | 729 | } |
700 | 730 | |
701 | 731 | // Make sure we quit this loop. |
702 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') |
|
703 | - break; |
|
732 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') { |
|
733 | + break; |
|
734 | + } |
|
704 | 735 | $looped = true; |
705 | 736 | $range_limit = ''; |
706 | 737 | } |
@@ -744,19 +775,21 @@ discard block |
||
744 | 775 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
745 | 776 | ); |
746 | 777 | |
747 | - if ($user_info['id'] == $row['id_member_started']) |
|
748 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
778 | + if ($user_info['id'] == $row['id_member_started']) { |
|
779 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
780 | + } |
|
749 | 781 | $board_ids['any'][$row['id_board']][] = $counter; |
750 | 782 | } |
751 | 783 | $smcFunc['db_free_result']($request); |
752 | 784 | |
753 | 785 | // All posts were retrieved in reverse order, get them right again. |
754 | - if ($reverse) |
|
755 | - $context['posts'] = array_reverse($context['posts'], true); |
|
786 | + if ($reverse) { |
|
787 | + $context['posts'] = array_reverse($context['posts'], true); |
|
788 | + } |
|
756 | 789 | |
757 | 790 | // These are all the permissions that are different from board to board.. |
758 | - if ($context['is_topics']) |
|
759 | - $permissions = array( |
|
791 | + if ($context['is_topics']) { |
|
792 | + $permissions = array( |
|
760 | 793 | 'own' => array( |
761 | 794 | 'post_reply_own' => 'can_reply', |
762 | 795 | ), |
@@ -764,8 +797,8 @@ discard block |
||
764 | 797 | 'post_reply_any' => 'can_reply', |
765 | 798 | ) |
766 | 799 | ); |
767 | - else |
|
768 | - $permissions = array( |
|
800 | + } else { |
|
801 | + $permissions = array( |
|
769 | 802 | 'own' => array( |
770 | 803 | 'post_reply_own' => 'can_reply', |
771 | 804 | 'delete_own' => 'can_delete', |
@@ -775,6 +808,7 @@ discard block |
||
775 | 808 | 'delete_any' => 'can_delete', |
776 | 809 | ) |
777 | 810 | ); |
811 | + } |
|
778 | 812 | |
779 | 813 | // For every permission in the own/any lists... |
780 | 814 | foreach ($permissions as $type => $list) |
@@ -785,19 +819,22 @@ discard block |
||
785 | 819 | $boards = boardsAllowedTo($permission); |
786 | 820 | |
787 | 821 | // Hmm, they can do it on all boards, can they? |
788 | - if (!empty($boards) && $boards[0] == 0) |
|
789 | - $boards = array_keys($board_ids[$type]); |
|
822 | + if (!empty($boards) && $boards[0] == 0) { |
|
823 | + $boards = array_keys($board_ids[$type]); |
|
824 | + } |
|
790 | 825 | |
791 | 826 | // Now go through each board they can do the permission on. |
792 | 827 | foreach ($boards as $board_id) |
793 | 828 | { |
794 | 829 | // There aren't any posts displayed from this board. |
795 | - if (!isset($board_ids[$type][$board_id])) |
|
796 | - continue; |
|
830 | + if (!isset($board_ids[$type][$board_id])) { |
|
831 | + continue; |
|
832 | + } |
|
797 | 833 | |
798 | 834 | // Set the permission to true ;). |
799 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
800 | - $context['posts'][$counter][$allowed] = true; |
|
835 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
836 | + $context['posts'][$counter][$allowed] = true; |
|
837 | + } |
|
801 | 838 | } |
802 | 839 | } |
803 | 840 | } |
@@ -828,8 +865,9 @@ discard block |
||
828 | 865 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
829 | 866 | |
830 | 867 | // Make sure we can't actually see anything... |
831 | - if (empty($boardsAllowed)) |
|
832 | - $boardsAllowed = array(-1); |
|
868 | + if (empty($boardsAllowed)) { |
|
869 | + $boardsAllowed = array(-1); |
|
870 | + } |
|
833 | 871 | |
834 | 872 | require_once($sourcedir . '/Subs-List.php'); |
835 | 873 | |
@@ -980,8 +1018,8 @@ discard block |
||
980 | 1018 | ) |
981 | 1019 | ); |
982 | 1020 | $attachments = array(); |
983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
984 | - $attachments[] = array( |
|
1021 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1022 | + $attachments[] = array( |
|
985 | 1023 | 'id' => $row['id_attach'], |
986 | 1024 | 'filename' => $row['filename'], |
987 | 1025 | 'downloads' => $row['downloads'], |
@@ -993,6 +1031,7 @@ discard block |
||
993 | 1031 | 'board_name' => $row['name'], |
994 | 1032 | 'approved' => $row['approved'], |
995 | 1033 | ); |
1034 | + } |
|
996 | 1035 | |
997 | 1036 | $smcFunc['db_free_result']($request); |
998 | 1037 | |
@@ -1047,8 +1086,9 @@ discard block |
||
1047 | 1086 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1048 | 1087 | |
1049 | 1088 | // Only the owner can see the list (if the function is enabled of course) |
1050 | - if ($user_info['id'] != $memID) |
|
1051 | - return; |
|
1089 | + if ($user_info['id'] != $memID) { |
|
1090 | + return; |
|
1091 | + } |
|
1052 | 1092 | |
1053 | 1093 | require_once($sourcedir . '/Subs-List.php'); |
1054 | 1094 | |
@@ -1194,8 +1234,9 @@ discard block |
||
1194 | 1234 | ); |
1195 | 1235 | |
1196 | 1236 | $topics = array(); |
1197 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1198 | - $topics[] = $row['id_topic']; |
|
1237 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1238 | + $topics[] = $row['id_topic']; |
|
1239 | + } |
|
1199 | 1240 | |
1200 | 1241 | $smcFunc['db_free_result']($request); |
1201 | 1242 | |
@@ -1215,8 +1256,9 @@ discard block |
||
1215 | 1256 | 'topics' => $topics, |
1216 | 1257 | ) |
1217 | 1258 | ); |
1218 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1219 | - $topicsInfo[] = $row; |
|
1259 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1260 | + $topicsInfo[] = $row; |
|
1261 | + } |
|
1220 | 1262 | $smcFunc['db_free_result']($request); |
1221 | 1263 | } |
1222 | 1264 | |
@@ -1264,8 +1306,9 @@ discard block |
||
1264 | 1306 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1265 | 1307 | |
1266 | 1308 | // Is the load average too high to allow searching just now? |
1267 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1268 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1309 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1310 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1311 | + } |
|
1269 | 1312 | |
1270 | 1313 | // General user statistics. |
1271 | 1314 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1408,11 +1451,13 @@ discard block |
||
1408 | 1451 | } |
1409 | 1452 | $smcFunc['db_free_result']($result); |
1410 | 1453 | |
1411 | - if ($maxPosts > 0) |
|
1412 | - for ($hour = 0; $hour < 24; $hour++) |
|
1454 | + if ($maxPosts > 0) { |
|
1455 | + for ($hour = 0; |
|
1456 | + } |
|
1457 | + $hour < 24; $hour++) |
|
1413 | 1458 | { |
1414 | - if (!isset($context['posts_by_time'][$hour])) |
|
1415 | - $context['posts_by_time'][$hour] = array( |
|
1459 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1460 | + $context['posts_by_time'][$hour] = array( |
|
1416 | 1461 | 'hour' => $hour, |
1417 | 1462 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1418 | 1463 | 'posts' => 0, |
@@ -1420,7 +1465,7 @@ discard block |
||
1420 | 1465 | 'relative_percent' => 0, |
1421 | 1466 | 'is_last' => $hour == 23, |
1422 | 1467 | ); |
1423 | - else |
|
1468 | + } else |
|
1424 | 1469 | { |
1425 | 1470 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1426 | 1471 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1453,8 +1498,9 @@ discard block |
||
1453 | 1498 | |
1454 | 1499 | foreach ($subActions as $sa => $action) |
1455 | 1500 | { |
1456 | - if (!allowedTo($action[2])) |
|
1457 | - unset($subActions[$sa]); |
|
1501 | + if (!allowedTo($action[2])) { |
|
1502 | + unset($subActions[$sa]); |
|
1503 | + } |
|
1458 | 1504 | } |
1459 | 1505 | |
1460 | 1506 | // Create the tabs for the template. |
@@ -1472,15 +1518,18 @@ discard block |
||
1472 | 1518 | ); |
1473 | 1519 | |
1474 | 1520 | // Moderation must be on to track edits. |
1475 | - if (empty($modSettings['userlog_enabled'])) |
|
1476 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1521 | + if (empty($modSettings['userlog_enabled'])) { |
|
1522 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1523 | + } |
|
1477 | 1524 | |
1478 | 1525 | // Group requests must be active to show it... |
1479 | - if (empty($modSettings['show_group_membership'])) |
|
1480 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1526 | + if (empty($modSettings['show_group_membership'])) { |
|
1527 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1528 | + } |
|
1481 | 1529 | |
1482 | - if (empty($subActions)) |
|
1483 | - fatal_lang_error('no_access', false); |
|
1530 | + if (empty($subActions)) { |
|
1531 | + fatal_lang_error('no_access', false); |
|
1532 | + } |
|
1484 | 1533 | |
1485 | 1534 | $keys = array_keys($subActions); |
1486 | 1535 | $default = array_shift($keys); |
@@ -1493,9 +1542,10 @@ discard block |
||
1493 | 1542 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1494 | 1543 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1495 | 1544 | |
1496 | - if (!empty($call)) |
|
1497 | - call_user_func($call, $memID); |
|
1498 | -} |
|
1545 | + if (!empty($call)) { |
|
1546 | + call_user_func($call, $memID); |
|
1547 | + } |
|
1548 | + } |
|
1499 | 1549 | |
1500 | 1550 | /** |
1501 | 1551 | * Handles tracking a user's activity |
@@ -1511,8 +1561,9 @@ discard block |
||
1511 | 1561 | isAllowedTo('moderate_forum'); |
1512 | 1562 | |
1513 | 1563 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1514 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1515 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1564 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1565 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1566 | + } |
|
1516 | 1567 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1517 | 1568 | |
1518 | 1569 | // Set the options for the list component. |
@@ -1679,8 +1730,9 @@ discard block |
||
1679 | 1730 | ) |
1680 | 1731 | ); |
1681 | 1732 | $message_members = array(); |
1682 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1683 | - $message_members[] = $row['id_member']; |
|
1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1734 | + $message_members[] = $row['id_member']; |
|
1735 | + } |
|
1684 | 1736 | $smcFunc['db_free_result']($request); |
1685 | 1737 | |
1686 | 1738 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1695,8 +1747,9 @@ discard block |
||
1695 | 1747 | 'ip_list' => $ips, |
1696 | 1748 | ) |
1697 | 1749 | ); |
1698 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1699 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1750 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1751 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1752 | + } |
|
1700 | 1753 | $smcFunc['db_free_result']($request); |
1701 | 1754 | } |
1702 | 1755 | |
@@ -1710,8 +1763,9 @@ discard block |
||
1710 | 1763 | 'ip_list' => $ips, |
1711 | 1764 | ) |
1712 | 1765 | ); |
1713 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1714 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1766 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1767 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1768 | + } |
|
1715 | 1769 | $smcFunc['db_free_result']($request); |
1716 | 1770 | } |
1717 | 1771 | } |
@@ -1771,8 +1825,8 @@ discard block |
||
1771 | 1825 | )) |
1772 | 1826 | ); |
1773 | 1827 | $error_messages = array(); |
1774 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1775 | - $error_messages[] = array( |
|
1828 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1829 | + $error_messages[] = array( |
|
1776 | 1830 | 'ip' => inet_dtop($row['ip']), |
1777 | 1831 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1778 | 1832 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1780,6 +1834,7 @@ discard block |
||
1780 | 1834 | 'time' => timeformat($row['log_time']), |
1781 | 1835 | 'timestamp' => forum_time(true, $row['log_time']), |
1782 | 1836 | ); |
1837 | + } |
|
1783 | 1838 | $smcFunc['db_free_result']($request); |
1784 | 1839 | |
1785 | 1840 | return $error_messages; |
@@ -1842,8 +1897,8 @@ discard block |
||
1842 | 1897 | )) |
1843 | 1898 | ); |
1844 | 1899 | $messages = array(); |
1845 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1846 | - $messages[] = array( |
|
1900 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1901 | + $messages[] = array( |
|
1847 | 1902 | 'ip' => inet_dtop($row['poster_ip']), |
1848 | 1903 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1849 | 1904 | 'board' => array( |
@@ -1856,6 +1911,7 @@ discard block |
||
1856 | 1911 | 'time' => timeformat($row['poster_time']), |
1857 | 1912 | 'timestamp' => forum_time(true, $row['poster_time']) |
1858 | 1913 | ); |
1914 | + } |
|
1859 | 1915 | $smcFunc['db_free_result']($request); |
1860 | 1916 | |
1861 | 1917 | return $messages; |
@@ -1882,19 +1938,20 @@ discard block |
||
1882 | 1938 | $context['sub_template'] = 'trackIP'; |
1883 | 1939 | $context['page_title'] = $txt['profile']; |
1884 | 1940 | $context['base_url'] = $scripturl . '?action=trackip'; |
1885 | - } |
|
1886 | - else |
|
1941 | + } else |
|
1887 | 1942 | { |
1888 | 1943 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1889 | 1944 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1890 | 1945 | } |
1891 | 1946 | |
1892 | 1947 | // Searching? |
1893 | - if (isset($_REQUEST['searchip'])) |
|
1894 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1948 | + if (isset($_REQUEST['searchip'])) { |
|
1949 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1950 | + } |
|
1895 | 1951 | |
1896 | - if (isValidIP($context['ip']) === false) |
|
1897 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1952 | + if (isValidIP($context['ip']) === false) { |
|
1953 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1954 | + } |
|
1898 | 1955 | |
1899 | 1956 | //mysql didn't support like search with varbinary |
1900 | 1957 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1902,8 +1959,9 @@ discard block |
||
1902 | 1959 | $ip_var = $context['ip']; |
1903 | 1960 | $ip_string = '= {inet:ip_address}'; |
1904 | 1961 | |
1905 | - if (empty($context['tracking_area'])) |
|
1906 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1962 | + if (empty($context['tracking_area'])) { |
|
1963 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1964 | + } |
|
1907 | 1965 | |
1908 | 1966 | $request = $smcFunc['db_query']('', ' |
1909 | 1967 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1914,8 +1972,9 @@ discard block |
||
1914 | 1972 | ) |
1915 | 1973 | ); |
1916 | 1974 | $context['ips'] = array(); |
1917 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1918 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1975 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1976 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1977 | + } |
|
1919 | 1978 | $smcFunc['db_free_result']($request); |
1920 | 1979 | |
1921 | 1980 | ksort($context['ips']); |
@@ -2144,8 +2203,9 @@ discard block |
||
2144 | 2203 | foreach ($context['whois_servers'] as $whois) |
2145 | 2204 | { |
2146 | 2205 | // Strip off the "decimal point" and anything following... |
2147 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2148 | - $context['auto_whois_server'] = $whois; |
|
2206 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2207 | + $context['auto_whois_server'] = $whois; |
|
2208 | + } |
|
2149 | 2209 | } |
2150 | 2210 | } |
2151 | 2211 | } |
@@ -2162,10 +2222,11 @@ discard block |
||
2162 | 2222 | // Gonna want this for the list. |
2163 | 2223 | require_once($sourcedir . '/Subs-List.php'); |
2164 | 2224 | |
2165 | - if ($memID == 0) |
|
2166 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2167 | - else |
|
2168 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2225 | + if ($memID == 0) { |
|
2226 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2227 | + } else { |
|
2228 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2229 | + } |
|
2169 | 2230 | |
2170 | 2231 | // Start with the user messages. |
2171 | 2232 | $listOptions = array( |
@@ -2275,12 +2336,13 @@ discard block |
||
2275 | 2336 | ) |
2276 | 2337 | ); |
2277 | 2338 | $logins = array(); |
2278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2279 | - $logins[] = array( |
|
2339 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2340 | + $logins[] = array( |
|
2280 | 2341 | 'time' => timeformat($row['time']), |
2281 | 2342 | 'ip' => inet_dtop($row['ip']), |
2282 | 2343 | 'ip2' => inet_dtop($row['ip2']), |
2283 | 2344 | ); |
2345 | + } |
|
2284 | 2346 | $smcFunc['db_free_result']($request); |
2285 | 2347 | |
2286 | 2348 | return $logins; |
@@ -2305,11 +2367,12 @@ discard block |
||
2305 | 2367 | ) |
2306 | 2368 | ); |
2307 | 2369 | $context['custom_field_titles'] = array(); |
2308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2309 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2370 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2371 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2310 | 2372 | 'title' => $row['field_name'], |
2311 | 2373 | 'parse_bbc' => $row['bbc'], |
2312 | 2374 | ); |
2375 | + } |
|
2313 | 2376 | $smcFunc['db_free_result']($request); |
2314 | 2377 | |
2315 | 2378 | // Set the options for the error lists. |
@@ -2448,19 +2511,22 @@ discard block |
||
2448 | 2511 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2449 | 2512 | { |
2450 | 2513 | $extra = $smcFunc['json_decode']($row['extra'], true); |
2451 | - if (!empty($extra['applicator'])) |
|
2452 | - $members[] = $extra['applicator']; |
|
2514 | + if (!empty($extra['applicator'])) { |
|
2515 | + $members[] = $extra['applicator']; |
|
2516 | + } |
|
2453 | 2517 | |
2454 | 2518 | // Work out what the name of the action is. |
2455 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2456 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2457 | - elseif (isset($txt[$row['action']])) |
|
2458 | - $action_text = $txt[$row['action']]; |
|
2519 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2520 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2521 | + } elseif (isset($txt[$row['action']])) { |
|
2522 | + $action_text = $txt[$row['action']]; |
|
2523 | + } |
|
2459 | 2524 | // Custom field? |
2460 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2461 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2462 | - else |
|
2463 | - $action_text = $row['action']; |
|
2525 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2526 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2527 | + } else { |
|
2528 | + $action_text = $row['action']; |
|
2529 | + } |
|
2464 | 2530 | |
2465 | 2531 | // Parse BBC? |
2466 | 2532 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2492,13 +2558,15 @@ discard block |
||
2492 | 2558 | ) |
2493 | 2559 | ); |
2494 | 2560 | $members = array(); |
2495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2496 | - $members[$row['id_member']] = $row['real_name']; |
|
2561 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2562 | + $members[$row['id_member']] = $row['real_name']; |
|
2563 | + } |
|
2497 | 2564 | $smcFunc['db_free_result']($request); |
2498 | 2565 | |
2499 | - foreach ($edits as $key => $value) |
|
2500 | - if (isset($members[$value['id_member']])) |
|
2566 | + foreach ($edits as $key => $value) { |
|
2567 | + if (isset($members[$value['id_member']])) |
|
2501 | 2568 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2569 | + } |
|
2502 | 2570 | } |
2503 | 2571 | |
2504 | 2572 | return $edits; |
@@ -2699,10 +2767,11 @@ discard block |
||
2699 | 2767 | $context['board'] = $board; |
2700 | 2768 | |
2701 | 2769 | // Determine which groups this user is in. |
2702 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2703 | - $curGroups = array(); |
|
2704 | - else |
|
2705 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2770 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2771 | + $curGroups = array(); |
|
2772 | + } else { |
|
2773 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2774 | + } |
|
2706 | 2775 | $curGroups[] = $user_profile[$memID]['id_group']; |
2707 | 2776 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2708 | 2777 | |
@@ -2722,28 +2791,30 @@ discard block |
||
2722 | 2791 | $context['no_access_boards'] = array(); |
2723 | 2792 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2724 | 2793 | { |
2725 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2726 | - $context['no_access_boards'][] = array( |
|
2794 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2795 | + $context['no_access_boards'][] = array( |
|
2727 | 2796 | 'id' => $row['id_board'], |
2728 | 2797 | 'name' => $row['name'], |
2729 | 2798 | 'is_last' => false, |
2730 | 2799 | ); |
2731 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2732 | - $context['boards'][$row['id_board']] = array( |
|
2800 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2801 | + $context['boards'][$row['id_board']] = array( |
|
2733 | 2802 | 'id' => $row['id_board'], |
2734 | 2803 | 'name' => $row['name'], |
2735 | 2804 | 'selected' => $board == $row['id_board'], |
2736 | 2805 | 'profile' => $row['id_profile'], |
2737 | 2806 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2738 | 2807 | ); |
2808 | + } |
|
2739 | 2809 | } |
2740 | 2810 | $smcFunc['db_free_result']($request); |
2741 | 2811 | |
2742 | 2812 | require_once($sourcedir . '/Subs-Boards.php'); |
2743 | 2813 | sortBoards($context['boards']); |
2744 | 2814 | |
2745 | - if (!empty($context['no_access_boards'])) |
|
2746 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2815 | + if (!empty($context['no_access_boards'])) { |
|
2816 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2817 | + } |
|
2747 | 2818 | |
2748 | 2819 | $context['member']['permissions'] = array( |
2749 | 2820 | 'general' => array(), |
@@ -2752,8 +2823,9 @@ discard block |
||
2752 | 2823 | |
2753 | 2824 | // If you're an admin we know you can do everything, we might as well leave. |
2754 | 2825 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2755 | - if ($context['member']['has_all_permissions']) |
|
2756 | - return; |
|
2826 | + if ($context['member']['has_all_permissions']) { |
|
2827 | + return; |
|
2828 | + } |
|
2757 | 2829 | |
2758 | 2830 | $denied = array(); |
2759 | 2831 | |
@@ -2772,21 +2844,24 @@ discard block |
||
2772 | 2844 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2773 | 2845 | { |
2774 | 2846 | // We don't know about this permission, it doesn't exist :P. |
2775 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2776 | - continue; |
|
2847 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2848 | + continue; |
|
2849 | + } |
|
2777 | 2850 | |
2778 | - if (empty($row['add_deny'])) |
|
2779 | - $denied[] = $row['permission']; |
|
2851 | + if (empty($row['add_deny'])) { |
|
2852 | + $denied[] = $row['permission']; |
|
2853 | + } |
|
2780 | 2854 | |
2781 | 2855 | // Permissions that end with _own or _any consist of two parts. |
2782 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2783 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2784 | - else |
|
2785 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2856 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2857 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2858 | + } else { |
|
2859 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2860 | + } |
|
2786 | 2861 | |
2787 | 2862 | // Add this permission if it doesn't exist yet. |
2788 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2789 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2863 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2864 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2790 | 2865 | 'id' => $row['permission'], |
2791 | 2866 | 'groups' => array( |
2792 | 2867 | 'allowed' => array(), |
@@ -2796,6 +2871,7 @@ discard block |
||
2796 | 2871 | 'is_denied' => false, |
2797 | 2872 | 'is_global' => true, |
2798 | 2873 | ); |
2874 | + } |
|
2799 | 2875 | |
2800 | 2876 | // Add the membergroup to either the denied or the allowed groups. |
2801 | 2877 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2829,18 +2905,20 @@ discard block |
||
2829 | 2905 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2830 | 2906 | { |
2831 | 2907 | // We don't know about this permission, it doesn't exist :P. |
2832 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2833 | - continue; |
|
2908 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2909 | + continue; |
|
2910 | + } |
|
2834 | 2911 | |
2835 | 2912 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2836 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2837 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2838 | - else |
|
2839 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2913 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2914 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2915 | + } else { |
|
2916 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2917 | + } |
|
2840 | 2918 | |
2841 | 2919 | // Create the structure for this permission. |
2842 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2843 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2920 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2921 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2844 | 2922 | 'id' => $row['permission'], |
2845 | 2923 | 'groups' => array( |
2846 | 2924 | 'allowed' => array(), |
@@ -2850,6 +2928,7 @@ discard block |
||
2850 | 2928 | 'is_denied' => false, |
2851 | 2929 | 'is_global' => empty($board), |
2852 | 2930 | ); |
2931 | + } |
|
2853 | 2932 | |
2854 | 2933 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2855 | 2934 | |
@@ -2868,8 +2947,9 @@ discard block |
||
2868 | 2947 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2869 | 2948 | |
2870 | 2949 | // Firstly, can we actually even be here? |
2871 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2872 | - fatal_lang_error('no_access', false); |
|
2950 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2951 | + fatal_lang_error('no_access', false); |
|
2952 | + } |
|
2873 | 2953 | |
2874 | 2954 | // Make sure things which are disabled stay disabled. |
2875 | 2955 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2956,9 +3036,10 @@ discard block |
||
2956 | 3036 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2957 | 3037 | ); |
2958 | 3038 | $context['current_level'] = 0; |
2959 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2960 | - if ($context['member']['warning'] >= $limit) |
|
3039 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3040 | + if ($context['member']['warning'] >= $limit) |
|
2961 | 3041 | $context['current_level'] = $limit; |
2962 | -} |
|
3042 | + } |
|
3043 | + } |
|
2963 | 3044 | |
2964 | 3045 | ?> |
2965 | 3046 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); |
56 | - foreach ($reservedTables as $k => $table_name) |
|
57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
57 | + foreach ($reservedTables as $k => $table_name) { |
|
58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | // We in turn may need the extra stuff. |
60 | 62 | db_extend('extra'); |
@@ -107,8 +109,9 @@ discard block |
||
107 | 109 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
108 | 110 | |
109 | 111 | // First - no way do we touch SMF tables. |
110 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
111 | - return false; |
|
112 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
113 | + return false; |
|
114 | + } |
|
112 | 115 | |
113 | 116 | // Log that we'll want to remove this on uninstall. |
114 | 117 | $db_package_log[] = array('remove_table', $table_name); |
@@ -118,9 +121,9 @@ discard block |
||
118 | 121 | if (in_array($full_table_name, $tables)) |
119 | 122 | { |
120 | 123 | // This is a sad day... drop the table? If not, return false (error) by default. |
121 | - if ($if_exists == 'overwrite') |
|
122 | - $smcFunc['db_drop_table']($table_name); |
|
123 | - else if ($if_exists == 'update') |
|
124 | + if ($if_exists == 'overwrite') { |
|
125 | + $smcFunc['db_drop_table']($table_name); |
|
126 | + } else if ($if_exists == 'update') |
|
124 | 127 | { |
125 | 128 | $smcFunc['db_drop_table']($table_name.'_old'); |
126 | 129 | $smcFunc['db_transaction']('begin'); |
@@ -132,47 +135,51 @@ discard block |
||
132 | 135 | ) |
133 | 136 | ); |
134 | 137 | $old_table_exists = true; |
138 | + } else { |
|
139 | + return $if_exists == 'ignore'; |
|
135 | 140 | } |
136 | - else |
|
137 | - return $if_exists == 'ignore'; |
|
138 | 141 | } |
139 | 142 | |
140 | 143 | // If we've got this far - good news - no table exists. We can build our own! |
141 | - if (!$db_trans) |
|
142 | - $smcFunc['db_transaction']('begin'); |
|
144 | + if (!$db_trans) { |
|
145 | + $smcFunc['db_transaction']('begin'); |
|
146 | + } |
|
143 | 147 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
144 | 148 | foreach ($columns as $column) |
145 | 149 | { |
146 | 150 | // If we have an auto increment do it! |
147 | 151 | if (!empty($column['auto'])) |
148 | 152 | { |
149 | - if (!$old_table_exists) |
|
150 | - $smcFunc['db_query']('', ' |
|
153 | + if (!$old_table_exists) { |
|
154 | + $smcFunc['db_query']('', ' |
|
151 | 155 | DROP SEQUENCE IF EXISTS ' . $table_name . '_seq', |
152 | 156 | array( |
153 | 157 | 'security_override' => true, |
154 | 158 | ) |
155 | 159 | ); |
160 | + } |
|
156 | 161 | |
157 | - if (!$old_table_exists) |
|
158 | - $smcFunc['db_query']('', ' |
|
162 | + if (!$old_table_exists) { |
|
163 | + $smcFunc['db_query']('', ' |
|
159 | 164 | CREATE SEQUENCE ' . $table_name . '_seq', |
160 | 165 | array( |
161 | 166 | 'security_override' => true, |
162 | 167 | ) |
163 | 168 | ); |
169 | + } |
|
164 | 170 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
171 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
172 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
173 | + } else { |
|
174 | + $default = ''; |
|
165 | 175 | } |
166 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
167 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
168 | - else |
|
169 | - $default = ''; |
|
170 | 176 | |
171 | 177 | // Sort out the size... |
172 | 178 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
173 | 179 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
174 | - if ($size !== null) |
|
175 | - $type = $type . '(' . $size . ')'; |
|
180 | + if ($size !== null) { |
|
181 | + $type = $type . '(' . $size . ')'; |
|
182 | + } |
|
176 | 183 | |
177 | 184 | // Now just put it together! |
178 | 185 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -185,19 +192,21 @@ discard block |
||
185 | 192 | $columns = implode(',', $index['columns']); |
186 | 193 | |
187 | 194 | // Primary goes in the table... |
188 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
189 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
190 | - else |
|
195 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
196 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
197 | + } else |
|
191 | 198 | { |
192 | - if (empty($index['name'])) |
|
193 | - $index['name'] = implode('_', $index['columns']); |
|
199 | + if (empty($index['name'])) { |
|
200 | + $index['name'] = implode('_', $index['columns']); |
|
201 | + } |
|
194 | 202 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
195 | 203 | } |
196 | 204 | } |
197 | 205 | |
198 | 206 | // No trailing commas! |
199 | - if (substr($table_query, -1) == ',') |
|
200 | - $table_query = substr($table_query, 0, -1); |
|
207 | + if (substr($table_query, -1) == ',') { |
|
208 | + $table_query = substr($table_query, 0, -1); |
|
209 | + } |
|
201 | 210 | |
202 | 211 | $table_query .= ')'; |
203 | 212 | |
@@ -242,18 +251,20 @@ discard block |
||
242 | 251 | } |
243 | 252 | |
244 | 253 | // And the indexes... |
245 | - foreach ($index_queries as $query) |
|
246 | - $smcFunc['db_query']('', $query, |
|
254 | + foreach ($index_queries as $query) { |
|
255 | + $smcFunc['db_query']('', $query, |
|
247 | 256 | array( |
248 | 257 | 'security_override' => true, |
249 | 258 | ) |
250 | 259 | ); |
260 | + } |
|
251 | 261 | |
252 | 262 | // Go, go power rangers! |
253 | 263 | $smcFunc['db_transaction']('commit'); |
254 | 264 | |
255 | - if ($old_table_exists) |
|
256 | - $smcFunc['db_drop_table']($table_name . '_old'); |
|
265 | + if ($old_table_exists) { |
|
266 | + $smcFunc['db_drop_table']($table_name . '_old'); |
|
267 | + } |
|
257 | 268 | |
258 | 269 | return true; |
259 | 270 | } |
@@ -278,8 +289,9 @@ discard block |
||
278 | 289 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
279 | 290 | |
280 | 291 | // God no - dropping one of these = bad. |
281 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
282 | - return false; |
|
292 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
293 | + return false; |
|
294 | + } |
|
283 | 295 | |
284 | 296 | // Does it exist? |
285 | 297 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -337,21 +349,24 @@ discard block |
||
337 | 349 | |
338 | 350 | // Does it exist - if so don't add it again! |
339 | 351 | $columns = $smcFunc['db_list_columns']($table_name, false); |
340 | - foreach ($columns as $column) |
|
341 | - if ($column == $column_info['name']) |
|
352 | + foreach ($columns as $column) { |
|
353 | + if ($column == $column_info['name']) |
|
342 | 354 | { |
343 | 355 | // If we're going to overwrite then use change column. |
344 | 356 | if ($if_exists == 'update') |
345 | 357 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
346 | - else |
|
347 | - return false; |
|
358 | + } |
|
359 | + else { |
|
360 | + return false; |
|
361 | + } |
|
348 | 362 | } |
349 | 363 | |
350 | 364 | // Get the specifics... |
351 | 365 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
352 | 366 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
353 | - if ($size !== null) |
|
354 | - $type = $type . '(' . $size . ')'; |
|
367 | + if ($size !== null) { |
|
368 | + $type = $type . '(' . $size . ')'; |
|
369 | + } |
|
355 | 370 | |
356 | 371 | // Now add the thing! |
357 | 372 | $query = ' |
@@ -366,11 +381,12 @@ discard block |
||
366 | 381 | // If there's more attributes they need to be done via a change on PostgreSQL. |
367 | 382 | unset($column_info['type'], $column_info['size']); |
368 | 383 | |
369 | - if (count($column_info) != 1) |
|
370 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
371 | - else |
|
372 | - return true; |
|
373 | -} |
|
384 | + if (count($column_info) != 1) { |
|
385 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
386 | + } else { |
|
387 | + return true; |
|
388 | + } |
|
389 | + } |
|
374 | 390 | |
375 | 391 | /** |
376 | 392 | * Removes a column. |
@@ -389,8 +405,8 @@ discard block |
||
389 | 405 | |
390 | 406 | // Does it exist? |
391 | 407 | $columns = $smcFunc['db_list_columns']($table_name, true); |
392 | - foreach ($columns as $column) |
|
393 | - if ($column['name'] == $column_name) |
|
408 | + foreach ($columns as $column) { |
|
409 | + if ($column['name'] == $column_name) |
|
394 | 410 | { |
395 | 411 | // If there is an auto we need remove it! |
396 | 412 | if ($column['auto']) |
@@ -400,6 +416,7 @@ discard block |
||
400 | 416 | 'security_override' => true, |
401 | 417 | ) |
402 | 418 | ); |
419 | + } |
|
403 | 420 | |
404 | 421 | $smcFunc['db_query']('', ' |
405 | 422 | ALTER TABLE ' . $table_name . ' |
@@ -433,13 +450,15 @@ discard block |
||
433 | 450 | // Check it does exist! |
434 | 451 | $columns = $smcFunc['db_list_columns']($table_name, true); |
435 | 452 | $old_info = null; |
436 | - foreach ($columns as $column) |
|
437 | - if ($column['name'] == $old_column) |
|
453 | + foreach ($columns as $column) { |
|
454 | + if ($column['name'] == $old_column) |
|
438 | 455 | $old_info = $column; |
456 | + } |
|
439 | 457 | |
440 | 458 | // Nothing? |
441 | - if ($old_info == null) |
|
442 | - return false; |
|
459 | + if ($old_info == null) { |
|
460 | + return false; |
|
461 | + } |
|
443 | 462 | |
444 | 463 | // Now we check each bit individually and ALTER as required. |
445 | 464 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | { |
497 | 516 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
498 | 517 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
499 | - if ($size !== null) |
|
500 | - $type = $type . '(' . $size . ')'; |
|
518 | + if ($size !== null) { |
|
519 | + $type = $type . '(' . $size . ')'; |
|
520 | + } |
|
501 | 521 | |
502 | 522 | // The alter is a pain. |
503 | 523 | $smcFunc['db_transaction']('begin'); |
@@ -598,21 +618,23 @@ discard block |
||
598 | 618 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
599 | 619 | |
600 | 620 | // No columns = no index. |
601 | - if (empty($index_info['columns'])) |
|
602 | - return false; |
|
621 | + if (empty($index_info['columns'])) { |
|
622 | + return false; |
|
623 | + } |
|
603 | 624 | $columns = implode(',', $index_info['columns']); |
604 | 625 | |
605 | 626 | // No name - make it up! |
606 | 627 | if (empty($index_info['name'])) |
607 | 628 | { |
608 | 629 | // No need for primary. |
609 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
610 | - $index_info['name'] = ''; |
|
611 | - else |
|
612 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
630 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
631 | + $index_info['name'] = ''; |
|
632 | + } else { |
|
633 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
634 | + } |
|
635 | + } else { |
|
636 | + $index_info['name'] = $table_name . $index_info['name']; |
|
613 | 637 | } |
614 | - else |
|
615 | - $index_info['name'] = $table_name . $index_info['name']; |
|
616 | 638 | |
617 | 639 | // Log that we are going to want to remove this! |
618 | 640 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -625,10 +647,11 @@ discard block |
||
625 | 647 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
626 | 648 | { |
627 | 649 | // If we want to overwrite simply remove the current one then continue. |
628 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
629 | - return false; |
|
630 | - else |
|
631 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
650 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
651 | + return false; |
|
652 | + } else { |
|
653 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
654 | + } |
|
632 | 655 | } |
633 | 656 | } |
634 | 657 | |
@@ -642,8 +665,7 @@ discard block |
||
642 | 665 | 'security_override' => true, |
643 | 666 | ) |
644 | 667 | ); |
645 | - } |
|
646 | - else |
|
668 | + } else |
|
647 | 669 | { |
648 | 670 | $smcFunc['db_query']('', ' |
649 | 671 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -671,8 +693,9 @@ discard block |
||
671 | 693 | |
672 | 694 | // Better exist! |
673 | 695 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
674 | - if ($index_name != 'primary') |
|
675 | - $index_name = $table_name . '_' . $index_name; |
|
696 | + if ($index_name != 'primary') { |
|
697 | + $index_name = $table_name . '_' . $index_name; |
|
698 | + } |
|
676 | 699 | |
677 | 700 | foreach ($indexes as $index) |
678 | 701 | { |
@@ -736,8 +759,7 @@ discard block |
||
736 | 759 | 'datetime' => 'timestamp without time zone', |
737 | 760 | 'timestamp' => 'timestamp without time zone', |
738 | 761 | ); |
739 | - } |
|
740 | - else |
|
762 | + } else |
|
741 | 763 | { |
742 | 764 | $types = array( |
743 | 765 | 'character varying' => 'varchar', |
@@ -753,14 +775,16 @@ discard block |
||
753 | 775 | // Got it? Change it! |
754 | 776 | if (isset($types[$type_name])) |
755 | 777 | { |
756 | - if ($type_name == 'tinytext') |
|
757 | - $type_size = 255; |
|
778 | + if ($type_name == 'tinytext') { |
|
779 | + $type_size = 255; |
|
780 | + } |
|
758 | 781 | $type_name = $types[$type_name]; |
759 | 782 | } |
760 | 783 | |
761 | 784 | // Only char fields got size |
762 | - if (strpos($type_name, 'char') === false) |
|
763 | - $type_size = null; |
|
785 | + if (strpos($type_name, 'char') === false) { |
|
786 | + $type_size = null; |
|
787 | + } |
|
764 | 788 | |
765 | 789 | |
766 | 790 | return array($type_name, $type_size); |
@@ -816,8 +840,7 @@ discard block |
||
816 | 840 | if (!$detail) |
817 | 841 | { |
818 | 842 | $columns[] = $row['column_name']; |
819 | - } |
|
820 | - else |
|
843 | + } else |
|
821 | 844 | { |
822 | 845 | $auto = false; |
823 | 846 | // What is the default? |
@@ -825,11 +848,11 @@ discard block |
||
825 | 848 | { |
826 | 849 | $default = null; |
827 | 850 | $auto = true; |
851 | + } elseif (trim($row['column_default']) != '') { |
|
852 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
853 | + } else { |
|
854 | + $default = null; |
|
828 | 855 | } |
829 | - elseif (trim($row['column_default']) != '') |
|
830 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
831 | - else |
|
832 | - $default = null; |
|
833 | 856 | |
834 | 857 | // Make the type generic. |
835 | 858 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -880,26 +903,30 @@ discard block |
||
880 | 903 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
881 | 904 | { |
882 | 905 | // Try get the columns that make it up. |
883 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
884 | - continue; |
|
906 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
907 | + continue; |
|
908 | + } |
|
885 | 909 | |
886 | 910 | $columns = explode(',', $matches[1]); |
887 | 911 | |
888 | - if (empty($columns)) |
|
889 | - continue; |
|
912 | + if (empty($columns)) { |
|
913 | + continue; |
|
914 | + } |
|
890 | 915 | |
891 | - foreach ($columns as $k => $v) |
|
892 | - $columns[$k] = trim($v); |
|
916 | + foreach ($columns as $k => $v) { |
|
917 | + $columns[$k] = trim($v); |
|
918 | + } |
|
893 | 919 | |
894 | 920 | // Fix up the name to be consistent cross databases |
895 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
896 | - $row['name'] = 'PRIMARY'; |
|
897 | - else |
|
898 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
921 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
922 | + $row['name'] = 'PRIMARY'; |
|
923 | + } else { |
|
924 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
925 | + } |
|
899 | 926 | |
900 | - if (!$detail) |
|
901 | - $indexes[] = $row['name']; |
|
902 | - else |
|
927 | + if (!$detail) { |
|
928 | + $indexes[] = $row['name']; |
|
929 | + } else |
|
903 | 930 | { |
904 | 931 | $indexes[$row['name']] = array( |
905 | 932 | 'name' => $row['name'], |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Log an error, if the error logging is enabled. |
@@ -41,17 +42,19 @@ discard block |
||
41 | 42 | // are we in a loop? |
42 | 43 | if($error_call > 2) |
43 | 44 | { |
44 | - if (!isset($db_show_debug) || $db_show_debug === false) |
|
45 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
46 | - else |
|
47 | - $backtrace = debug_backtrace(); |
|
45 | + if (!isset($db_show_debug) || $db_show_debug === false) { |
|
46 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
47 | + } else { |
|
48 | + $backtrace = debug_backtrace(); |
|
49 | + } |
|
48 | 50 | var_dump($backtrace); |
49 | 51 | die('Error loop.'); |
50 | 52 | } |
51 | 53 | |
52 | 54 | // Check if error logging is actually on. |
53 | - if (empty($modSettings['enableErrorLogging'])) |
|
54 | - return $error_message; |
|
55 | + if (empty($modSettings['enableErrorLogging'])) { |
|
56 | + return $error_message; |
|
57 | + } |
|
55 | 58 | |
56 | 59 | // Basically, htmlspecialchars it minus &. (for entities!) |
57 | 60 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -59,33 +62,39 @@ discard block |
||
59 | 62 | |
60 | 63 | // Add a file and line to the error message? |
61 | 64 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
62 | - if ($file == null) |
|
63 | - $file = ''; |
|
64 | - else |
|
65 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
65 | + if ($file == null) { |
|
66 | + $file = ''; |
|
67 | + } else { |
|
68 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
66 | 69 | $file = str_replace('\\', '/', $file); |
70 | + } |
|
67 | 71 | |
68 | - if ($line == null) |
|
69 | - $line = 0; |
|
70 | - else |
|
71 | - $line = (int) $line; |
|
72 | + if ($line == null) { |
|
73 | + $line = 0; |
|
74 | + } else { |
|
75 | + $line = (int) $line; |
|
76 | + } |
|
72 | 77 | |
73 | 78 | // Just in case there's no id_member or IP set yet. |
74 | - if (empty($user_info['id'])) |
|
75 | - $user_info['id'] = 0; |
|
76 | - if (empty($user_info['ip'])) |
|
77 | - $user_info['ip'] = ''; |
|
79 | + if (empty($user_info['id'])) { |
|
80 | + $user_info['id'] = 0; |
|
81 | + } |
|
82 | + if (empty($user_info['ip'])) { |
|
83 | + $user_info['ip'] = ''; |
|
84 | + } |
|
78 | 85 | |
79 | 86 | // Find the best query string we can... |
80 | 87 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
81 | 88 | |
82 | 89 | // Don't log the session hash in the url twice, it's a waste. |
83 | - if (!empty($smcFunc['htmlspecialchars'])) |
|
84 | - $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
90 | + if (!empty($smcFunc['htmlspecialchars'])) { |
|
91 | + $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
92 | + } |
|
85 | 93 | |
86 | 94 | // Just so we know what board error messages are from. |
87 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
88 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
95 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
96 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
97 | + } |
|
89 | 98 | |
90 | 99 | // What types of categories do we have? |
91 | 100 | $known_error_types = array( |
@@ -134,9 +143,9 @@ discard block |
||
134 | 143 | |
135 | 144 | list($context['num_errors']) = $smcFunc['db_fetch_row']($query); |
136 | 145 | $smcFunc['db_free_result']($query); |
146 | + } else { |
|
147 | + $context['num_errors']++; |
|
137 | 148 | } |
138 | - else |
|
139 | - $context['num_errors']++; |
|
140 | 149 | } |
141 | 150 | |
142 | 151 | // reset error call |
@@ -158,12 +167,14 @@ discard block |
||
158 | 167 | global $txt; |
159 | 168 | |
160 | 169 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
161 | - if (!empty($status)) |
|
162 | - send_http_status($status); |
|
170 | + if (!empty($status)) { |
|
171 | + send_http_status($status); |
|
172 | + } |
|
163 | 173 | |
164 | 174 | // We don't have $txt yet, but that's okay... |
165 | - if (empty($txt)) |
|
166 | - die($error); |
|
175 | + if (empty($txt)) { |
|
176 | + die($error); |
|
177 | + } |
|
167 | 178 | |
168 | 179 | log_error_online($error, false); |
169 | 180 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -190,8 +201,9 @@ discard block |
||
190 | 201 | static $fatal_error_called = false; |
191 | 202 | |
192 | 203 | // Send the status header - set this to 0 or false if you don't want to send one at all |
193 | - if (!empty($status)) |
|
194 | - send_http_status($status); |
|
204 | + if (!empty($status)) { |
|
205 | + send_http_status($status); |
|
206 | + } |
|
195 | 207 | |
196 | 208 | // Try to load a theme if we don't have one. |
197 | 209 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -201,8 +213,9 @@ discard block |
||
201 | 213 | } |
202 | 214 | |
203 | 215 | // If we have no theme stuff we can't have the language file... |
204 | - if (empty($context['theme_loaded'])) |
|
205 | - die($error); |
|
216 | + if (empty($context['theme_loaded'])) { |
|
217 | + die($error); |
|
218 | + } |
|
206 | 219 | |
207 | 220 | $reload_lang_file = true; |
208 | 221 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -238,8 +251,9 @@ discard block |
||
238 | 251 | global $settings, $modSettings, $db_show_debug; |
239 | 252 | |
240 | 253 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
241 | - if (error_reporting() == 0) |
|
242 | - return; |
|
254 | + if (error_reporting() == 0) { |
|
255 | + return; |
|
256 | + } |
|
243 | 257 | |
244 | 258 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
245 | 259 | { |
@@ -247,19 +261,22 @@ discard block |
||
247 | 261 | $count = count($array); |
248 | 262 | for ($i = 0; $i < $count; $i++) |
249 | 263 | { |
250 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
251 | - continue; |
|
264 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
265 | + continue; |
|
266 | + } |
|
252 | 267 | |
253 | 268 | // This is a bug in PHP, with eval, it seems! |
254 | - if (empty($array[$i]['args'])) |
|
255 | - $i++; |
|
269 | + if (empty($array[$i]['args'])) { |
|
270 | + $i++; |
|
271 | + } |
|
256 | 272 | break; |
257 | 273 | } |
258 | 274 | |
259 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
260 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
261 | - else |
|
262 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
275 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
276 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
277 | + } else { |
|
278 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
279 | + } |
|
263 | 280 | } |
264 | 281 | |
265 | 282 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -268,8 +285,9 @@ discard block |
||
268 | 285 | if ($error_level % 255 != E_ERROR) |
269 | 286 | { |
270 | 287 | $temporary = ob_get_contents(); |
271 | - if (substr($temporary, -2) == '="') |
|
272 | - echo '"'; |
|
288 | + if (substr($temporary, -2) == '="') { |
|
289 | + echo '"'; |
|
290 | + } |
|
273 | 291 | } |
274 | 292 | |
275 | 293 | // Debugging! This should look like a PHP error message. |
@@ -285,23 +303,27 @@ discard block |
||
285 | 303 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
286 | 304 | |
287 | 305 | // Dying on these errors only causes MORE problems (blank pages!) |
288 | - if ($file == 'Unknown') |
|
289 | - return; |
|
306 | + if ($file == 'Unknown') { |
|
307 | + return; |
|
308 | + } |
|
290 | 309 | |
291 | 310 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
292 | - if ($error_level % 255 == E_ERROR) |
|
293 | - obExit(false); |
|
294 | - else |
|
295 | - return; |
|
311 | + if ($error_level % 255 == E_ERROR) { |
|
312 | + obExit(false); |
|
313 | + } else { |
|
314 | + return; |
|
315 | + } |
|
296 | 316 | |
297 | 317 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
298 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
299 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
318 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
319 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
320 | + } |
|
300 | 321 | |
301 | 322 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
302 | - if ($error_level % 255 == E_ERROR) |
|
303 | - die('No direct access...'); |
|
304 | -} |
|
323 | + if ($error_level % 255 == E_ERROR) { |
|
324 | + die('No direct access...'); |
|
325 | + } |
|
326 | + } |
|
305 | 327 | |
306 | 328 | /** |
307 | 329 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -317,24 +339,28 @@ discard block |
||
317 | 339 | |
318 | 340 | // Attempt to prevent a recursive loop. |
319 | 341 | ++$level; |
320 | - if ($level > 1) |
|
321 | - return false; |
|
342 | + if ($level > 1) { |
|
343 | + return false; |
|
344 | + } |
|
322 | 345 | |
323 | 346 | // Maybe they came from dlattach or similar? |
324 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
325 | - loadTheme(); |
|
347 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
348 | + loadTheme(); |
|
349 | + } |
|
326 | 350 | |
327 | 351 | // Don't bother indexing errors mate... |
328 | 352 | $context['robot_no_index'] = true; |
329 | 353 | |
330 | - if (!isset($context['error_title'])) |
|
331 | - $context['error_title'] = $txt['error_occured']; |
|
354 | + if (!isset($context['error_title'])) { |
|
355 | + $context['error_title'] = $txt['error_occured']; |
|
356 | + } |
|
332 | 357 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
333 | 358 | |
334 | 359 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
335 | 360 | |
336 | - if (empty($context['page_title'])) |
|
337 | - $context['page_title'] = $context['error_title']; |
|
361 | + if (empty($context['page_title'])) { |
|
362 | + $context['page_title'] = $context['error_title']; |
|
363 | + } |
|
338 | 364 | |
339 | 365 | loadTemplate('Errors'); |
340 | 366 | $context['sub_template'] = 'fatal_error'; |
@@ -342,23 +368,26 @@ discard block |
||
342 | 368 | // If this is SSI, what do they want us to do? |
343 | 369 | if (SMF == 'SSI') |
344 | 370 | { |
345 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
346 | - $ssi_on_error_method(); |
|
347 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
348 | - loadSubTemplate('fatal_error'); |
|
371 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
372 | + $ssi_on_error_method(); |
|
373 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
374 | + loadSubTemplate('fatal_error'); |
|
375 | + } |
|
349 | 376 | |
350 | 377 | // No layers? |
351 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
352 | - exit; |
|
378 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
379 | + exit; |
|
380 | + } |
|
353 | 381 | } |
354 | 382 | // Alternatively from the cron call? |
355 | 383 | elseif (SMF == 'BACKGROUND') |
356 | 384 | { |
357 | 385 | // We can't rely on even having language files available. |
358 | - if (defined('FROM_CLI') && FROM_CLI) |
|
359 | - echo 'cron error: ', $context['error_message']; |
|
360 | - else |
|
361 | - echo 'An error occurred. More information may be available in your logs.'; |
|
386 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
387 | + echo 'cron error: ', $context['error_message']; |
|
388 | + } else { |
|
389 | + echo 'An error occurred. More information may be available in your logs.'; |
|
390 | + } |
|
362 | 391 | exit; |
363 | 392 | } |
364 | 393 | |
@@ -386,8 +415,8 @@ discard block |
||
386 | 415 | |
387 | 416 | set_fatal_error_headers(); |
388 | 417 | |
389 | - if (!empty($maintenance)) |
|
390 | - echo '<!DOCTYPE html> |
|
418 | + if (!empty($maintenance)) { |
|
419 | + echo '<!DOCTYPE html> |
|
391 | 420 | <html> |
392 | 421 | <head> |
393 | 422 | <meta name="robots" content="noindex"> |
@@ -398,6 +427,7 @@ discard block |
||
398 | 427 | ', $mmessage, ' |
399 | 428 | </body> |
400 | 429 | </html>'; |
430 | + } |
|
401 | 431 | |
402 | 432 | die(); |
403 | 433 | } |
@@ -419,15 +449,17 @@ discard block |
||
419 | 449 | // For our purposes, we're gonna want this on if at all possible. |
420 | 450 | $modSettings['cache_enable'] = '1'; |
421 | 451 | |
422 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
423 | - $db_last_error = max($db_last_error, $temp); |
|
452 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
453 | + $db_last_error = max($db_last_error, $temp); |
|
454 | + } |
|
424 | 455 | |
425 | 456 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
426 | 457 | { |
427 | 458 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
428 | 459 | cache_put_data('db_last_error', time(), 600); |
429 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
430 | - logLastDatabaseError(); |
|
460 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
461 | + logLastDatabaseError(); |
|
462 | + } |
|
431 | 463 | |
432 | 464 | // Language files aren't loaded yet :(. |
433 | 465 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -508,12 +540,14 @@ discard block |
||
508 | 540 | global $smcFunc, $user_info, $modSettings; |
509 | 541 | |
510 | 542 | // Don't bother if Who's Online is disabled. |
511 | - if (empty($modSettings['who_enabled'])) |
|
512 | - return; |
|
543 | + if (empty($modSettings['who_enabled'])) { |
|
544 | + return; |
|
545 | + } |
|
513 | 546 | |
514 | 547 | // Maybe they came from SSI or similar where sessions are not recorded? |
515 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
516 | - return; |
|
548 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
549 | + return; |
|
550 | + } |
|
517 | 551 | |
518 | 552 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); |
519 | 553 | |
@@ -539,8 +573,9 @@ discard block |
||
539 | 573 | $url = $smcFunc['json_decode']($url, true); |
540 | 574 | $url['error'] = $error; |
541 | 575 | |
542 | - if (!empty($sprintf)) |
|
543 | - $url['error_params'] = $sprintf; |
|
576 | + if (!empty($sprintf)) { |
|
577 | + $url['error_params'] = $sprintf; |
|
578 | + } |
|
544 | 579 | |
545 | 580 | $smcFunc['db_query']('', ' |
546 | 581 | UPDATE {db_prefix}log_online |
@@ -571,10 +606,11 @@ discard block |
||
571 | 606 | |
572 | 607 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
573 | 608 | |
574 | - if (!isset($statuses[$code])) |
|
575 | - header($protocol . ' 500 Internal Server Error'); |
|
576 | - else |
|
577 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
578 | -} |
|
609 | + if (!isset($statuses[$code])) { |
|
610 | + header($protocol . ' 500 Internal Server Error'); |
|
611 | + } else { |
|
612 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
613 | + } |
|
614 | + } |
|
579 | 615 | |
580 | 616 | ?> |
581 | 617 | \ No newline at end of file |
@@ -28,15 +28,17 @@ discard block |
||
28 | 28 | <form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">'; |
29 | 29 | |
30 | 30 | // Did they make a mistake last time? |
31 | - if (!empty($context['login_errors'])) |
|
32 | - echo ' |
|
31 | + if (!empty($context['login_errors'])) { |
|
32 | + echo ' |
|
33 | 33 | <div class="errorbox">', implode('<br>', $context['login_errors']), '</div> |
34 | 34 | <br>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | // Or perhaps there's some special description for this time? |
37 | - if (isset($context['description'])) |
|
38 | - echo ' |
|
38 | + if (isset($context['description'])) { |
|
39 | + echo ' |
|
39 | 40 | <div class="information">', $context['description'], '</div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Now just get the basic information - username, password, etc. |
42 | 44 | echo ' |
@@ -61,10 +63,11 @@ discard block |
||
61 | 63 | </dd>'; |
62 | 64 | |
63 | 65 | // If they have deleted their account, give them a chance to change their mind. |
64 | - if (isset($context['login_show_undelete'])) |
|
65 | - echo ' |
|
66 | + if (isset($context['login_show_undelete'])) { |
|
67 | + echo ' |
|
66 | 68 | <dt class="alert">', $txt['undelete_account'], ':</dt> |
67 | 69 | <dd><input type="checkbox" name="undelete"></dd>'; |
70 | + } |
|
68 | 71 | |
69 | 72 | echo ' |
70 | 73 | </dl> |
@@ -82,8 +85,8 @@ discard block |
||
82 | 85 | document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus(); |
83 | 86 | }, 150);'; |
84 | 87 | |
85 | - if (!empty($context['from_ajax'])) |
|
86 | - echo ' |
|
88 | + if (!empty($context['from_ajax'])) { |
|
89 | + echo ' |
|
87 | 90 | form = $("#frmLogin"); |
88 | 91 | form.submit(function(e) { |
89 | 92 | e.preventDefault(); |
@@ -116,16 +119,18 @@ discard block |
||
116 | 119 | |
117 | 120 | return false; |
118 | 121 | });'; |
122 | + } |
|
119 | 123 | |
120 | 124 | echo ' |
121 | 125 | </script> |
122 | 126 | </form>'; |
123 | 127 | |
124 | 128 | // It is a long story as to why we have this when we're clearly not going to use it. |
125 | - if (!empty($context['from_ajax'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['from_ajax'])) { |
|
130 | + echo ' |
|
127 | 131 | <br> |
128 | 132 | <a href="javascript:self.close();"></a>'; |
133 | + } |
|
129 | 134 | |
130 | 135 | echo ' |
131 | 136 | </div><!-- .roundframe --> |
@@ -148,11 +153,12 @@ discard block |
||
148 | 153 | </div> |
149 | 154 | <div class="roundframe noup">'; |
150 | 155 | |
151 | - if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) |
|
152 | - echo ' |
|
156 | + if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) { |
|
157 | + echo ' |
|
153 | 158 | <div class="error"> |
154 | 159 | ', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], ' |
155 | 160 | </div>'; |
161 | + } |
|
156 | 162 | |
157 | 163 | echo ' |
158 | 164 | <form action="', $context['tfa_url'], '" method="post" id="frmTfa"> |
@@ -181,8 +187,8 @@ discard block |
||
181 | 187 | <script> |
182 | 188 | form = $("#frmTfa");'; |
183 | 189 | |
184 | - if (!empty($context['from_ajax'])) |
|
185 | - echo ' |
|
190 | + if (!empty($context['from_ajax'])) { |
|
191 | + echo ' |
|
186 | 192 | form.submit(function(e) { |
187 | 193 | // If we are submitting backup code, let normal workflow follow since it redirects a couple times into a different page |
188 | 194 | if (form.find("input[name=tfa_backup]:first").val().length > 0) |
@@ -201,6 +207,7 @@ discard block |
||
201 | 207 | |
202 | 208 | return false; |
203 | 209 | });'; |
210 | + } |
|
204 | 211 | |
205 | 212 | echo ' |
206 | 213 | form.find("input[name=backup]").click(function(e) { |
@@ -232,10 +239,11 @@ discard block |
||
232 | 239 | <p class="information centertext"> |
233 | 240 | ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>'; |
234 | 241 | |
235 | - if ($context['can_register']) |
|
236 | - echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
237 | - else |
|
238 | - echo $txt['login_below']; |
|
242 | + if ($context['can_register']) { |
|
243 | + echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
244 | + } else { |
|
245 | + echo $txt['login_below']; |
|
246 | + } |
|
239 | 247 | |
240 | 248 | // And now the login information. |
241 | 249 | echo ' |
@@ -335,9 +343,10 @@ discard block |
||
335 | 343 | </div> |
336 | 344 | <div class="roundframe centertext noup">'; |
337 | 345 | |
338 | - if (!empty($context['incorrect_password'])) |
|
339 | - echo ' |
|
346 | + if (!empty($context['incorrect_password'])) { |
|
347 | + echo ' |
|
340 | 348 | <div class="error">', $txt['admin_incorrect_password'], '</div>'; |
349 | + } |
|
341 | 350 | |
342 | 351 | echo ' |
343 | 352 | <strong>', $txt['password'], ':</strong> |
@@ -378,10 +387,11 @@ discard block |
||
378 | 387 | <dl>'; |
379 | 388 | |
380 | 389 | // You didn't even have an ID? |
381 | - if (empty($context['member_id'])) |
|
382 | - echo ' |
|
390 | + if (empty($context['member_id'])) { |
|
391 | + echo ' |
|
383 | 392 | <dt>', $txt['invalid_activation_username'], ':</dt> |
384 | 393 | <dd><input type="text" name="user" size="30"></dd>'; |
394 | + } |
|
385 | 395 | |
386 | 396 | echo ' |
387 | 397 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
@@ -418,13 +428,14 @@ discard block |
||
418 | 428 | <dd><input type="password" name="passwd" size="30"></dd> |
419 | 429 | </dl>'; |
420 | 430 | |
421 | - if ($context['can_activate']) |
|
422 | - echo ' |
|
431 | + if ($context['can_activate']) { |
|
432 | + echo ' |
|
423 | 433 | <p>', $txt['invalid_activation_known'], '</p> |
424 | 434 | <dl> |
425 | 435 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
426 | 436 | <dd><input type="text" name="code" size="30"></dd> |
427 | 437 | </dl>'; |
438 | + } |
|
428 | 439 | |
429 | 440 | echo ' |
430 | 441 | <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button"></p> |