@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ 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 | * Sets the SMF-style login cookie and session based on the id_member and password passed. |
@@ -47,8 +48,9 @@ discard block |
||
47 | 48 | if (isset($_COOKIE[$cookiename])) |
48 | 49 | { |
49 | 50 | // First check for 2.1 json-format cookie |
50 | - if (preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+,"3":"[^"]+","4":"[^"]+"~', $_COOKIE[$cookiename]) === 1) |
|
51 | - list(,,, $old_domain, $old_path) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
51 | + if (preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+,"3":"[^"]+","4":"[^"]+"~', $_COOKIE[$cookiename]) === 1) { |
|
52 | + list(,,, $old_domain, $old_path) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
54 | 56 | elseif (preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;(i:3;i:\d;)?~', $_COOKIE[$cookiename]) === 1) |
@@ -58,15 +60,17 @@ discard block |
||
58 | 60 | $cookie_state = (empty($modSettings['localCookies']) ? 0 : 1) | (empty($modSettings['globalCookies']) ? 0 : 2); |
59 | 61 | |
60 | 62 | // Maybe we need to temporarily pretend to be using local cookies |
61 | - if ($cookie_state == 0 && $old_state == 1) |
|
62 | - list($old_domain, $old_path) = url_parts(true, false); |
|
63 | - else |
|
64 | - list($old_domain, $old_path) = url_parts($old_state & 1 > 0, $old_state & 2 > 0); |
|
63 | + if ($cookie_state == 0 && $old_state == 1) { |
|
64 | + list($old_domain, $old_path) = url_parts(true, false); |
|
65 | + } else { |
|
66 | + list($old_domain, $old_path) = url_parts($old_state & 1 > 0, $old_state & 2 > 0); |
|
67 | + } |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | // Out with the old, in with the new! |
68 | - if (isset($old_domain) && $old_domain != $cookie_url[0] || isset($old_path) && $old_path != $cookie_url[1]) |
|
69 | - smf_setcookie($cookiename, $smcFunc['json_encode'](array(0, '', 0, $old_domain, $old_path), JSON_FORCE_OBJECT), 1, $old_path, $old_domain); |
|
71 | + if (isset($old_domain) && $old_domain != $cookie_url[0] || isset($old_path) && $old_path != $cookie_url[1]) { |
|
72 | + smf_setcookie($cookiename, $smcFunc['json_encode'](array(0, '', 0, $old_domain, $old_path), JSON_FORCE_OBJECT), 1, $old_path, $old_domain); |
|
73 | + } |
|
70 | 74 | } |
71 | 75 | |
72 | 76 | // Get the data and path to set it on. |
@@ -82,8 +86,9 @@ discard block |
||
82 | 86 | smf_setcookie($cookiename, $data, $expiry_time, $cookie_url[1], $cookie_url[0]); |
83 | 87 | |
84 | 88 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
85 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
86 | - smf_setcookie($cookiename, $data, $expiry_time, $cookie_url[1], ''); |
|
89 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
90 | + smf_setcookie($cookiename, $data, $expiry_time, $cookie_url[1], ''); |
|
91 | + } |
|
87 | 92 | |
88 | 93 | // Any alias URLs? This is mainly for use with frames, etc. |
89 | 94 | if (!empty($modSettings['forum_alias_urls'])) |
@@ -99,8 +104,9 @@ discard block |
||
99 | 104 | |
100 | 105 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
101 | 106 | |
102 | - if ($cookie_url[0] == '') |
|
103 | - $cookie_url[0] = strtok($alias, '/'); |
|
107 | + if ($cookie_url[0] == '') { |
|
108 | + $cookie_url[0] = strtok($alias, '/'); |
|
109 | + } |
|
104 | 110 | |
105 | 111 | $alias_data = $smcFunc['json_decode']($data, true); |
106 | 112 | $alias_data[3] = $cookie_url[0]; |
@@ -159,8 +165,9 @@ discard block |
||
159 | 165 | smf_setcookie($identifier, $data, $expiry_time, $cookie_url[1], $cookie_url[0]); |
160 | 166 | |
161 | 167 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
162 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
163 | - smf_setcookie($identifier, $data, $expiry_time, $cookie_url[1], ''); |
|
168 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
169 | + smf_setcookie($identifier, $data, $expiry_time, $cookie_url[1], ''); |
|
170 | + } |
|
164 | 171 | |
165 | 172 | $_COOKIE[$identifier] = $data; |
166 | 173 | } |
@@ -182,23 +189,28 @@ discard block |
||
182 | 189 | $parsed_url = parse_url($boardurl); |
183 | 190 | |
184 | 191 | // Is local cookies off? |
185 | - if (empty($parsed_url['path']) || !$local) |
|
186 | - $parsed_url['path'] = ''; |
|
192 | + if (empty($parsed_url['path']) || !$local) { |
|
193 | + $parsed_url['path'] = ''; |
|
194 | + } |
|
187 | 195 | |
188 | - if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) |
|
189 | - $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
196 | + if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) { |
|
197 | + $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
198 | + } |
|
190 | 199 | |
191 | 200 | // Globalize cookies across domains (filter out IP-addresses)? |
192 | - elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
193 | - $parsed_url['host'] = '.' . $parts[1]; |
|
201 | + elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
202 | + $parsed_url['host'] = '.' . $parts[1]; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // We shouldn't use a host at all if both options are off. |
196 | - elseif (!$local && !$global) |
|
197 | - $parsed_url['host'] = ''; |
|
206 | + elseif (!$local && !$global) { |
|
207 | + $parsed_url['host'] = ''; |
|
208 | + } |
|
198 | 209 | |
199 | 210 | // The host also shouldn't be set if there aren't any dots in it. |
200 | - elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) |
|
201 | - $parsed_url['host'] = ''; |
|
211 | + elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) { |
|
212 | + $parsed_url['host'] = ''; |
|
213 | + } |
|
202 | 214 | |
203 | 215 | return array($parsed_url['host'], $parsed_url['path'] . '/'); |
204 | 216 | } |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | createToken('login'); |
218 | 230 | |
219 | 231 | // Never redirect to an attachment |
220 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
221 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
232 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
233 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
234 | + } |
|
222 | 235 | |
223 | 236 | $context['sub_template'] = 'kick_guest'; |
224 | 237 | $context['page_title'] = $txt['login']; |
@@ -273,10 +286,12 @@ discard block |
||
273 | 286 | $txt['security_wrong'] = sprintf($txt['security_wrong'], isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $txt['unknown'], $_SERVER['HTTP_USER_AGENT'], $user_info['ip']); |
274 | 287 | log_error($txt['security_wrong'], 'critical'); |
275 | 288 | |
276 | - if (isset($_POST[$type . '_hash_pass'])) |
|
277 | - unset($_POST[$type . '_hash_pass']); |
|
278 | - if (isset($_POST[$type . '_pass'])) |
|
279 | - unset($_POST[$type . '_pass']); |
|
289 | + if (isset($_POST[$type . '_hash_pass'])) { |
|
290 | + unset($_POST[$type . '_hash_pass']); |
|
291 | + } |
|
292 | + if (isset($_POST[$type . '_pass'])) { |
|
293 | + unset($_POST[$type . '_pass']); |
|
294 | + } |
|
280 | 295 | |
281 | 296 | $context['incorrect_password'] = true; |
282 | 297 | } |
@@ -289,15 +304,17 @@ discard block |
||
289 | 304 | |
290 | 305 | // Now go through $_POST. Make sure the session hash is sent. |
291 | 306 | $_POST[$context['session_var']] = $context['session_id']; |
292 | - foreach ($_POST as $k => $v) |
|
293 | - $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
307 | + foreach ($_POST as $k => $v) { |
|
308 | + $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
309 | + } |
|
294 | 310 | |
295 | 311 | // Now we'll use the admin_login sub template of the Login template. |
296 | 312 | $context['sub_template'] = 'admin_login'; |
297 | 313 | |
298 | 314 | // And title the page something like "Login". |
299 | - if (!isset($context['page_title'])) |
|
300 | - $context['page_title'] = $txt['login']; |
|
315 | + if (!isset($context['page_title'])) { |
|
316 | + $context['page_title'] = $txt['login']; |
|
317 | + } |
|
301 | 318 | |
302 | 319 | // The type of action. |
303 | 320 | $context['sessionCheckType'] = $type; |
@@ -320,14 +337,15 @@ discard block |
||
320 | 337 | { |
321 | 338 | global $smcFunc; |
322 | 339 | |
323 | - if (!is_array($v)) |
|
324 | - return ' |
|
340 | + if (!is_array($v)) { |
|
341 | + return ' |
|
325 | 342 | <input type="hidden" name="' . $smcFunc['htmlspecialchars']($k) . '" value="' . strtr($v, array('"' => '"', '<' => '<', '>' => '>')) . '">'; |
326 | - else |
|
343 | + } else |
|
327 | 344 | { |
328 | 345 | $ret = ''; |
329 | - foreach ($v as $k2 => $v2) |
|
330 | - $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
346 | + foreach ($v as $k2 => $v2) { |
|
347 | + $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
348 | + } |
|
331 | 349 | |
332 | 350 | return $ret; |
333 | 351 | } |
@@ -354,18 +372,20 @@ discard block |
||
354 | 372 | foreach ($get as $k => $v) |
355 | 373 | { |
356 | 374 | // Only if it's not already in the $scripturl! |
357 | - if (!isset($temp[$k])) |
|
358 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
375 | + if (!isset($temp[$k])) { |
|
376 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
377 | + } |
|
359 | 378 | // If it changed, put it out there, but with an ampersand. |
360 | - elseif ($temp[$k] != $get[$k]) |
|
361 | - $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
379 | + elseif ($temp[$k] != $get[$k]) { |
|
380 | + $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
381 | + } |
|
362 | 382 | } |
363 | - } |
|
364 | - else |
|
383 | + } else |
|
365 | 384 | { |
366 | 385 | // Add up all the data from $_GET into get_data. |
367 | - foreach ($get as $k => $v) |
|
368 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
386 | + foreach ($get as $k => $v) { |
|
387 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
388 | + } |
|
369 | 389 | } |
370 | 390 | |
371 | 391 | $query_string = substr($query_string, 0, -1); |
@@ -388,8 +408,9 @@ discard block |
||
388 | 408 | global $scripturl, $user_info, $smcFunc; |
389 | 409 | |
390 | 410 | // If it's not already an array, make it one. |
391 | - if (!is_array($names)) |
|
392 | - $names = explode(',', $names); |
|
411 | + if (!is_array($names)) { |
|
412 | + $names = explode(',', $names); |
|
413 | + } |
|
393 | 414 | |
394 | 415 | $maybe_email = false; |
395 | 416 | $names_list = array(); |
@@ -401,10 +422,11 @@ discard block |
||
401 | 422 | $maybe_email |= strpos($name, '@') !== false; |
402 | 423 | |
403 | 424 | // Make it so standard wildcards will work. (* and ?) |
404 | - if ($use_wildcards) |
|
405 | - $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
406 | - else |
|
407 | - $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
425 | + if ($use_wildcards) { |
|
426 | + $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
427 | + } else { |
|
428 | + $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
429 | + } |
|
408 | 430 | |
409 | 431 | $names_list[] = '{string:lookup_name_' . $i . '}'; |
410 | 432 | $where_params['lookup_name_' . $i] = $names[$i]; |
@@ -417,11 +439,12 @@ discard block |
||
417 | 439 | $results = array(); |
418 | 440 | |
419 | 441 | // This ensures you can't search someones email address if you can't see it. |
420 | - if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) |
|
421 | - $email_condition = ' |
|
442 | + if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) { |
|
443 | + $email_condition = ' |
|
422 | 444 | OR (email_address ' . $comparison . ' \'' . implode('\') OR (email_address ' . $comparison . ' \'', $names) . '\')'; |
423 | - else |
|
424 | - $email_condition = ''; |
|
445 | + } else { |
|
446 | + $email_condition = ''; |
|
447 | + } |
|
425 | 448 | |
426 | 449 | // Get the case of the columns right - but only if we need to as things like MySQL will go slow needlessly otherwise. |
427 | 450 | $member_name = $smcFunc['db_case_sensitive'] ? 'LOWER(member_name)' : 'member_name'; |
@@ -480,10 +503,11 @@ discard block |
||
480 | 503 | $context['template_layers'] = array(); |
481 | 504 | $context['sub_template'] = 'find_members'; |
482 | 505 | |
483 | - if (isset($_REQUEST['search'])) |
|
484 | - $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
485 | - else |
|
486 | - $_REQUEST['start'] = 0; |
|
506 | + if (isset($_REQUEST['search'])) { |
|
507 | + $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
508 | + } else { |
|
509 | + $_REQUEST['start'] = 0; |
|
510 | + } |
|
487 | 511 | |
488 | 512 | // Allow the user to pass the input to be added to to the box. |
489 | 513 | $context['input_box_name'] = isset($_REQUEST['input']) && preg_match('~^[\w-]+$~', $_REQUEST['input']) === 1 ? $_REQUEST['input'] : 'to'; |
@@ -524,10 +548,10 @@ discard block |
||
524 | 548 | ); |
525 | 549 | |
526 | 550 | $context['results'] = array_slice($context['results'], $_REQUEST['start'], 7); |
551 | + } else { |
|
552 | + $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
553 | + } |
|
527 | 554 | } |
528 | - else |
|
529 | - $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
530 | -} |
|
531 | 555 | |
532 | 556 | /** |
533 | 557 | * Outputs each member name on its own line. |
@@ -543,8 +567,9 @@ discard block |
||
543 | 567 | $_REQUEST['search'] = trim($smcFunc['strtolower']($_REQUEST['search'])); |
544 | 568 | $_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '&' => '&')); |
545 | 569 | |
546 | - if (function_exists('iconv')) |
|
547 | - header('content-type: text/plain; charset=UTF-8'); |
|
570 | + if (function_exists('iconv')) { |
|
571 | + header('content-type: text/plain; charset=UTF-8'); |
|
572 | + } |
|
548 | 573 | |
549 | 574 | $request = $smcFunc['db_query']('', ' |
550 | 575 | SELECT real_name |
@@ -564,14 +589,16 @@ discard block |
||
564 | 589 | if (function_exists('iconv')) |
565 | 590 | { |
566 | 591 | $utf8 = iconv($txt['lang_character_set'], 'UTF-8', $row['real_name']); |
567 | - if ($utf8) |
|
568 | - $row['real_name'] = $utf8; |
|
592 | + if ($utf8) { |
|
593 | + $row['real_name'] = $utf8; |
|
594 | + } |
|
569 | 595 | } |
570 | 596 | |
571 | 597 | $row['real_name'] = strtr($row['real_name'], array('&' => '&', '<' => '<', '>' => '>', '"' => '"')); |
572 | 598 | |
573 | - if (preg_match('~&#\d+;~', $row['real_name']) != 0) |
|
574 | - $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
599 | + if (preg_match('~&#\d+;~', $row['real_name']) != 0) { |
|
600 | + $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
601 | + } |
|
575 | 602 | |
576 | 603 | echo $row['real_name'], "\n"; |
577 | 604 | } |
@@ -628,9 +655,9 @@ discard block |
||
628 | 655 | |
629 | 656 | // Update the database... |
630 | 657 | updateMemberData($memID, array('member_name' => $user, 'passwd' => $newPassword_sha1)); |
658 | + } else { |
|
659 | + updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
631 | 660 | } |
632 | - else |
|
633 | - updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
634 | 661 | |
635 | 662 | call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword)); |
636 | 663 | |
@@ -661,31 +688,37 @@ discard block |
||
661 | 688 | $errors = array(); |
662 | 689 | |
663 | 690 | // Don't use too long a name. |
664 | - if ($smcFunc['strlen']($username) > 25) |
|
665 | - $errors[] = array('lang', 'error_long_name'); |
|
691 | + if ($smcFunc['strlen']($username) > 25) { |
|
692 | + $errors[] = array('lang', 'error_long_name'); |
|
693 | + } |
|
666 | 694 | |
667 | 695 | // No name?! How can you register with no name? |
668 | - if ($username == '') |
|
669 | - $errors[] = array('lang', 'need_username'); |
|
696 | + if ($username == '') { |
|
697 | + $errors[] = array('lang', 'need_username'); |
|
698 | + } |
|
670 | 699 | |
671 | 700 | // Only these characters are permitted. |
672 | - if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) |
|
673 | - $errors[] = array('lang', 'error_invalid_characters_username'); |
|
701 | + if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) { |
|
702 | + $errors[] = array('lang', 'error_invalid_characters_username'); |
|
703 | + } |
|
674 | 704 | |
675 | - if (stristr($username, $txt['guest_title']) !== false) |
|
676 | - $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
705 | + if (stristr($username, $txt['guest_title']) !== false) { |
|
706 | + $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
707 | + } |
|
677 | 708 | |
678 | 709 | if ($check_reserved_name) |
679 | 710 | { |
680 | 711 | require_once($sourcedir . '/Subs-Members.php'); |
681 | - if (isReservedName($username, $memID, false)) |
|
682 | - $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
712 | + if (isReservedName($username, $memID, false)) { |
|
713 | + $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
714 | + } |
|
683 | 715 | } |
684 | 716 | |
685 | - if ($return_error) |
|
686 | - return $errors; |
|
687 | - elseif (empty($errors)) |
|
688 | - return null; |
|
717 | + if ($return_error) { |
|
718 | + return $errors; |
|
719 | + } elseif (empty($errors)) { |
|
720 | + return null; |
|
721 | + } |
|
689 | 722 | |
690 | 723 | loadLanguage('Errors'); |
691 | 724 | $error = $errors[0]; |
@@ -711,22 +744,26 @@ discard block |
||
711 | 744 | global $modSettings, $smcFunc; |
712 | 745 | |
713 | 746 | // Perform basic requirements first. |
714 | - if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) |
|
715 | - return 'short'; |
|
747 | + if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) { |
|
748 | + return 'short'; |
|
749 | + } |
|
716 | 750 | |
717 | 751 | // Is this enough? |
718 | - if (empty($modSettings['password_strength'])) |
|
719 | - return null; |
|
752 | + if (empty($modSettings['password_strength'])) { |
|
753 | + return null; |
|
754 | + } |
|
720 | 755 | |
721 | 756 | // Otherwise, perform the medium strength test - checking if password appears in the restricted string. |
722 | - if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) |
|
723 | - return 'restricted_words'; |
|
724 | - elseif ($smcFunc['strpos']($password, $username) !== false) |
|
725 | - return 'restricted_words'; |
|
757 | + if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) { |
|
758 | + return 'restricted_words'; |
|
759 | + } elseif ($smcFunc['strpos']($password, $username) !== false) { |
|
760 | + return 'restricted_words'; |
|
761 | + } |
|
726 | 762 | |
727 | 763 | // If just medium, we're done. |
728 | - if ($modSettings['password_strength'] == 1) |
|
729 | - return null; |
|
764 | + if ($modSettings['password_strength'] == 1) { |
|
765 | + return null; |
|
766 | + } |
|
730 | 767 | |
731 | 768 | // Otherwise, hard test next, check for numbers and letters, uppercase too. |
732 | 769 | $good = preg_match('~(\D\d|\d\D)~', $password) != 0; |
@@ -758,14 +795,16 @@ discard block |
||
758 | 795 | ) |
759 | 796 | ); |
760 | 797 | $groups = array(); |
761 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
762 | - $groups[] = $row['id_group']; |
|
798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
799 | + $groups[] = $row['id_group']; |
|
800 | + } |
|
763 | 801 | $smcFunc['db_free_result']($request); |
764 | 802 | |
765 | - if (empty($groups)) |
|
766 | - $group_query = '0=1'; |
|
767 | - else |
|
768 | - $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
803 | + if (empty($groups)) { |
|
804 | + $group_query = '0=1'; |
|
805 | + } else { |
|
806 | + $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
807 | + } |
|
769 | 808 | } |
770 | 809 | |
771 | 810 | // Then, same again, just the boards this time! |
@@ -775,10 +814,11 @@ discard block |
||
775 | 814 | { |
776 | 815 | $boards = boardsAllowedTo('moderate_board', true); |
777 | 816 | |
778 | - if (empty($boards)) |
|
779 | - $board_query = '0=1'; |
|
780 | - else |
|
781 | - $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
817 | + if (empty($boards)) { |
|
818 | + $board_query = '0=1'; |
|
819 | + } else { |
|
820 | + $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
821 | + } |
|
782 | 822 | } |
783 | 823 | |
784 | 824 | // What boards are they the moderator of? |
@@ -793,8 +833,9 @@ discard block |
||
793 | 833 | 'current_member' => $user_info['id'], |
794 | 834 | ) |
795 | 835 | ); |
796 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
797 | - $boards_mod[] = $row['id_board']; |
|
836 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
837 | + $boards_mod[] = $row['id_board']; |
|
838 | + } |
|
798 | 839 | $smcFunc['db_free_result']($request); |
799 | 840 | |
800 | 841 | // Can any of the groups they're in moderate any of the boards? |
@@ -806,8 +847,9 @@ discard block |
||
806 | 847 | 'groups' => $user_info['groups'], |
807 | 848 | ) |
808 | 849 | ); |
809 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
810 | - $boards_mod[] = $row['id_board']; |
|
850 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
851 | + $boards_mod[] = $row['id_board']; |
|
852 | + } |
|
811 | 853 | $smcFunc['db_free_result']($request); |
812 | 854 | |
813 | 855 | // Just in case we've got duplicates here... |
@@ -852,10 +894,12 @@ discard block |
||
852 | 894 | global $modSettings; |
853 | 895 | |
854 | 896 | // In case a customization wants to override the default settings |
855 | - if ($httponly === null) |
|
856 | - $httponly = !empty($modSettings['httponlyCookies']); |
|
857 | - if ($secure === null) |
|
858 | - $secure = !empty($modSettings['secureCookies']); |
|
897 | + if ($httponly === null) { |
|
898 | + $httponly = !empty($modSettings['httponlyCookies']); |
|
899 | + } |
|
900 | + if ($secure === null) { |
|
901 | + $secure = !empty($modSettings['secureCookies']); |
|
902 | + } |
|
859 | 903 | |
860 | 904 | // Intercept cookie? |
861 | 905 | call_integration_hook('integrate_cookie', array($name, $value, $expire, $path, $domain, $secure, $httponly)); |
@@ -875,8 +919,9 @@ discard block |
||
875 | 919 | function hash_password($username, $password, $cost = null) |
876 | 920 | { |
877 | 921 | global $sourcedir, $smcFunc, $modSettings; |
878 | - if (!function_exists('password_hash')) |
|
879 | - require_once($sourcedir . '/Subs-Password.php'); |
|
922 | + if (!function_exists('password_hash')) { |
|
923 | + require_once($sourcedir . '/Subs-Password.php'); |
|
924 | + } |
|
880 | 925 | |
881 | 926 | $cost = empty($cost) ? (empty($modSettings['bcrypt_hash_cost']) ? 10 : $modSettings['bcrypt_hash_cost']) : $cost; |
882 | 927 | |
@@ -908,8 +953,9 @@ discard block |
||
908 | 953 | function hash_verify_password($username, $password, $hash) |
909 | 954 | { |
910 | 955 | global $sourcedir, $smcFunc; |
911 | - if (!function_exists('password_verify')) |
|
912 | - require_once($sourcedir . '/Subs-Password.php'); |
|
956 | + if (!function_exists('password_verify')) { |
|
957 | + require_once($sourcedir . '/Subs-Password.php'); |
|
958 | + } |
|
913 | 959 | |
914 | 960 | return password_verify($smcFunc['strtolower']($username) . $password, $hash); |
915 | 961 | } |
@@ -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', |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | 'db_allow_persistent' => 'smf_db_allow_persistent', |
35 | 36 | ); |
36 | -} |
|
37 | + } |
|
38 | + } |
|
37 | 39 | |
38 | 40 | /** |
39 | 41 | * Backup $table to $backup_table. |
@@ -75,8 +77,9 @@ discard block |
||
75 | 77 | )); |
76 | 78 | |
77 | 79 | // Old school or no school? |
78 | - if ($request) |
|
79 | - return $request; |
|
80 | + if ($request) { |
|
81 | + return $request; |
|
82 | + } |
|
80 | 83 | } |
81 | 84 | |
82 | 85 | // At this point, the quick method failed. |
@@ -100,8 +103,9 @@ discard block |
||
100 | 103 | foreach ($create as $k => $l) |
101 | 104 | { |
102 | 105 | // Get the name of the auto_increment column. |
103 | - if (strpos($l, 'auto_increment')) |
|
104 | - $auto_inc = trim($l); |
|
106 | + if (strpos($l, 'auto_increment')) { |
|
107 | + $auto_inc = trim($l); |
|
108 | + } |
|
105 | 109 | |
106 | 110 | // For the engine type, see if we can work out what it is. |
107 | 111 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -109,30 +113,36 @@ discard block |
||
109 | 113 | // Extract the engine type. |
110 | 114 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
111 | 115 | |
112 | - if (!empty($match[1])) |
|
113 | - $engine = $match[1]; |
|
116 | + if (!empty($match[1])) { |
|
117 | + $engine = $match[1]; |
|
118 | + } |
|
114 | 119 | |
115 | - if (!empty($match[2])) |
|
116 | - $engine = $match[2]; |
|
120 | + if (!empty($match[2])) { |
|
121 | + $engine = $match[2]; |
|
122 | + } |
|
117 | 123 | |
118 | - if (!empty($match[5])) |
|
119 | - $charset = $match[5]; |
|
124 | + if (!empty($match[5])) { |
|
125 | + $charset = $match[5]; |
|
126 | + } |
|
120 | 127 | |
121 | - if (!empty($match[7])) |
|
122 | - $collate = $match[7]; |
|
128 | + if (!empty($match[7])) { |
|
129 | + $collate = $match[7]; |
|
130 | + } |
|
123 | 131 | } |
124 | 132 | |
125 | 133 | // Skip everything but keys... |
126 | - if (strpos($l, 'KEY') === false) |
|
127 | - unset($create[$k]); |
|
134 | + if (strpos($l, 'KEY') === false) { |
|
135 | + unset($create[$k]); |
|
136 | + } |
|
128 | 137 | } |
129 | 138 | |
130 | - if (!empty($create)) |
|
131 | - $create = '( |
|
139 | + if (!empty($create)) { |
|
140 | + $create = '( |
|
132 | 141 | ' . implode(' |
133 | 142 | ', $create) . ')'; |
134 | - else |
|
135 | - $create = ''; |
|
143 | + } else { |
|
144 | + $create = ''; |
|
145 | + } |
|
136 | 146 | |
137 | 147 | $request = $smcFunc['db_query']('', ' |
138 | 148 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -151,8 +161,9 @@ discard block |
||
151 | 161 | |
152 | 162 | if ($auto_inc != '') |
153 | 163 | { |
154 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
155 | - $auto_inc = substr($auto_inc, 0, -1); |
|
164 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
165 | + $auto_inc = substr($auto_inc, 0, -1); |
|
166 | + } |
|
156 | 167 | |
157 | 168 | $smcFunc['db_query']('', ' |
158 | 169 | ALTER TABLE {raw:backup_table} |
@@ -196,8 +207,9 @@ discard block |
||
196 | 207 | 'table' => $table, |
197 | 208 | ) |
198 | 209 | ); |
199 | - if (!$request) |
|
200 | - return -1; |
|
210 | + if (!$request) { |
|
211 | + return -1; |
|
212 | + } |
|
201 | 213 | |
202 | 214 | // How much left? |
203 | 215 | $request = $smcFunc['db_query']('', ' |
@@ -240,8 +252,9 @@ discard block |
||
240 | 252 | ) |
241 | 253 | ); |
242 | 254 | $tables = array(); |
243 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
244 | - $tables[] = $row[0]; |
|
255 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
256 | + $tables[] = $row[0]; |
|
257 | + } |
|
245 | 258 | $smcFunc['db_free_result']($request); |
246 | 259 | |
247 | 260 | return $tables; |
@@ -285,8 +298,9 @@ discard block |
||
285 | 298 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
286 | 299 | { |
287 | 300 | // Make a special case of auto-timestamp. |
288 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
289 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
301 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
302 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
303 | + } |
|
290 | 304 | // Text shouldn't have a default. |
291 | 305 | elseif ($row['Default'] !== null) |
292 | 306 | { |
@@ -321,14 +335,16 @@ discard block |
||
321 | 335 | $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'] . '`'; |
322 | 336 | |
323 | 337 | // Is this the first column in the index? |
324 | - if (empty($indexes[$row['Key_name']])) |
|
325 | - $indexes[$row['Key_name']] = array(); |
|
338 | + if (empty($indexes[$row['Key_name']])) { |
|
339 | + $indexes[$row['Key_name']] = array(); |
|
340 | + } |
|
326 | 341 | |
327 | 342 | // A sub part, like only indexing 15 characters of a varchar. |
328 | - if (!empty($row['Sub_part'])) |
|
329 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
330 | - else |
|
331 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
343 | + if (!empty($row['Sub_part'])) { |
|
344 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
345 | + } else { |
|
346 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
347 | + } |
|
332 | 348 | } |
333 | 349 | $smcFunc['db_free_result']($result); |
334 | 350 | |
@@ -366,8 +382,9 @@ discard block |
||
366 | 382 | { |
367 | 383 | static $ver; |
368 | 384 | |
369 | - if (!empty($ver)) |
|
370 | - return $ver; |
|
385 | + if (!empty($ver)) { |
|
386 | + return $ver; |
|
387 | + } |
|
371 | 388 | |
372 | 389 | global $smcFunc; |
373 | 390 | |
@@ -392,8 +409,9 @@ discard block |
||
392 | 409 | global $smcFunc; |
393 | 410 | static $db_type; |
394 | 411 | |
395 | - if (!empty($db_type)) |
|
396 | - return $db_type; |
|
412 | + if (!empty($db_type)) { |
|
413 | + return $db_type; |
|
414 | + } |
|
397 | 415 | |
398 | 416 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
399 | 417 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -402,13 +420,15 @@ discard block |
||
402 | 420 | // Skip these if we don't have a comment. |
403 | 421 | if (!empty($comment)) |
404 | 422 | { |
405 | - if (stripos($comment, 'percona') !== false) |
|
406 | - return 'Percona'; |
|
407 | - if (stripos($comment, 'mariadb') !== false) |
|
408 | - return 'MariaDB'; |
|
423 | + if (stripos($comment, 'percona') !== false) { |
|
424 | + return 'Percona'; |
|
425 | + } |
|
426 | + if (stripos($comment, 'mariadb') !== false) { |
|
427 | + return 'MariaDB'; |
|
428 | + } |
|
429 | + } else { |
|
430 | + return 'fail'; |
|
409 | 431 | } |
410 | - else |
|
411 | - return 'fail'; |
|
412 | 432 | |
413 | 433 | return 'MySQL'; |
414 | 434 | } |
@@ -421,10 +441,11 @@ discard block |
||
421 | 441 | function smf_db_allow_persistent() |
422 | 442 | { |
423 | 443 | $value = ini_get('mysqli.allow_persistent'); |
424 | - if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') |
|
425 | - return true; |
|
426 | - else |
|
427 | - return false; |
|
428 | -} |
|
444 | + if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') { |
|
445 | + return true; |
|
446 | + } else { |
|
447 | + return false; |
|
448 | + } |
|
449 | + } |
|
429 | 450 | |
430 | 451 | ?> |
431 | 452 | \ 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 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', |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | 'db_allow_persistent' => 'smf_db_allow_persistent', |
35 | 36 | ); |
36 | -} |
|
37 | + } |
|
38 | + } |
|
37 | 39 | |
38 | 40 | /** |
39 | 41 | * Backup $table to $backup_table. |
@@ -49,13 +51,14 @@ discard block |
||
49 | 51 | |
50 | 52 | // Do we need to drop it first? |
51 | 53 | $tables = smf_db_list_tables(false, $backup_table); |
52 | - if (!empty($tables)) |
|
53 | - $smcFunc['db_query']('', ' |
|
54 | + if (!empty($tables)) { |
|
55 | + $smcFunc['db_query']('', ' |
|
54 | 56 | DROP TABLE {raw:backup_table}', |
55 | 57 | array( |
56 | 58 | 'backup_table' => $backup_table, |
57 | 59 | ) |
58 | 60 | ); |
61 | + } |
|
59 | 62 | |
60 | 63 | /** |
61 | 64 | * @todo Should we create backups of sequences as well? |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | ) |
119 | 122 | ); |
120 | 123 | |
121 | - if (!$request) |
|
122 | - return -1; |
|
124 | + if (!$request) { |
|
125 | + return -1; |
|
126 | + } |
|
123 | 127 | |
124 | 128 | $request = $smcFunc['db_query']('', ' |
125 | 129 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -137,11 +141,12 @@ discard block |
||
137 | 141 | $row = $smcFunc['db_fetch_assoc']($request); |
138 | 142 | $smcFunc['db_free_result']($request); |
139 | 143 | |
140 | - if (isset($row['size'])) |
|
141 | - return ($old_size - $row['size']) / 1024; |
|
142 | - else |
|
143 | - return 0; |
|
144 | -} |
|
144 | + if (isset($row['size'])) { |
|
145 | + return ($old_size - $row['size']) / 1024; |
|
146 | + } else { |
|
147 | + return 0; |
|
148 | + } |
|
149 | + } |
|
145 | 150 | |
146 | 151 | /** |
147 | 152 | * This function lists all tables in the database. |
@@ -168,8 +173,9 @@ discard block |
||
168 | 173 | ); |
169 | 174 | |
170 | 175 | $tables = array(); |
171 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
172 | - $tables[] = $row[0]; |
|
176 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
177 | + $tables[] = $row[0]; |
|
178 | + } |
|
173 | 179 | $smcFunc['db_free_result']($request); |
174 | 180 | |
175 | 181 | return $tables; |
@@ -210,12 +216,14 @@ discard block |
||
210 | 216 | ); |
211 | 217 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
212 | 218 | { |
213 | - if ($row['data_type'] == 'character varying') |
|
214 | - $row['data_type'] = 'varchar'; |
|
215 | - elseif ($row['data_type'] == 'character') |
|
216 | - $row['data_type'] = 'char'; |
|
217 | - if ($row['character_maximum_length']) |
|
218 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
219 | + if ($row['data_type'] == 'character varying') { |
|
220 | + $row['data_type'] = 'varchar'; |
|
221 | + } elseif ($row['data_type'] == 'character') { |
|
222 | + $row['data_type'] = 'char'; |
|
223 | + } |
|
224 | + if ($row['character_maximum_length']) { |
|
225 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
226 | + } |
|
219 | 227 | |
220 | 228 | // Make the CREATE for this column. |
221 | 229 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -266,13 +274,14 @@ discard block |
||
266 | 274 | { |
267 | 275 | if ($row['is_primary']) |
268 | 276 | { |
269 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
270 | - continue; |
|
277 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
278 | + continue; |
|
279 | + } |
|
271 | 280 | |
272 | 281 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
282 | + } else { |
|
283 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
273 | 284 | } |
274 | - else |
|
275 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
276 | 285 | } |
277 | 286 | $smcFunc['db_free_result']($result); |
278 | 287 | |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | global $db_connection; |
292 | 301 | static $ver; |
293 | 302 | |
294 | - if(!empty($ver)) |
|
295 | - return $ver; |
|
303 | + if(!empty($ver)) { |
|
304 | + return $ver; |
|
305 | + } |
|
296 | 306 | |
297 | 307 | $ver = pg_version($db_connection)['server']; |
298 | 308 | |
@@ -317,10 +327,11 @@ discard block |
||
317 | 327 | function smf_db_allow_persistent() |
318 | 328 | { |
319 | 329 | $value = ini_get('pgsql.allow_persistent'); |
320 | - if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') |
|
321 | - return true; |
|
322 | - else |
|
323 | - return false; |
|
324 | -} |
|
330 | + if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') { |
|
331 | + return true; |
|
332 | + } else { |
|
333 | + return false; |
|
334 | + } |
|
335 | + } |
|
325 | 336 | |
326 | 337 | ?> |
327 | 338 | \ No newline at end of file |